diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 7b5f80c..9574729 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -38,7 +38,12 @@ jobs:
shell: bash -l {0}
run: cmake --build build --config $BUILD_TYPE
- - name: Test
+ - name: Run Unit Tests
working-directory: ${{runner.workspace}}/daylight/build
shell: bash -l {0}
run: ctest --output-on-failure -C $BUILD_TYPE
+
+ - name: Run Doctests
+ working-directory: ${{runner.workspace}}/daylight
+ shell: bash -l {0}
+ run: cmake --build build --config $BUILD_TYPE --target pydoctest
diff --git a/README.md b/README.md
index 19bb388..7b21901 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,11 @@
-
-
-daylight
-========
+
+
+
+
+
+
+
+
daylight or libdaylight is a library which enables you to answer daylight related questions like:
@@ -28,7 +32,7 @@ $ pip install git+https://github.com/adonmo/daylight
The examples directory contains a real world usage of this library at [Adonmo](https://www.adonmo.com) - for its season and location independent brightness control mechanism: [Click here](/examples/adonmo-daylight-brightness-control.ipynb) to read it.
-
+
# Usage (Python)
diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt
index e725e3f..f22a35b 100644
--- a/docs/CMakeLists.txt
+++ b/docs/CMakeLists.txt
@@ -4,3 +4,10 @@ add_custom_target(
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
)
add_dependencies(pydocs daylight)
+
+add_custom_target(
+ pydoctest
+ ${CMAKE_COMMAND} -E env PYTHONPATH="${CMAKE_SOURCE_DIR}:${CMAKE_SOURCE_DIR}/build/pybind:${PYTHONATH}" make doctest
+ WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
+)
+add_dependencies(pydoctest daylight)
diff --git a/docs/index.rst b/docs/index.rst
index 49e8408..2b8b8e5 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -1,6 +1,20 @@
+.. role:: raw-html(raw)
+ :format: html
+
+:raw-html:`
`
+
+.. image:: ../static/logo.png
+ :width: 300px
+ :align: center
+ :alt: daylight logo
+
+:raw-html:`
`
+:raw-html:`
`
+
Welcome to daylight's documentation
===================================
+
.. toctree::
:maxdepth: 1
:caption: Contents:
@@ -14,8 +28,10 @@ daylight or libdaylight is a library which enables you to answer daylight relate
- Irradiance - How bright is it outside, given a particular time and location?
- What is the time of sunrise/solarnoon/sunset, given a particular time and location?
-Installation
-------------
+For basic usage via Python or C APIs, check `README `_ on our GitHub repository.
+
+Installation (Python)
+---------------------
.. code-block:: bash
diff --git a/pybind/pybind.cpp b/pybind/pybind.cpp
index 5a64cc2..6e9b043 100644
--- a/pybind/pybind.cpp
+++ b/pybind/pybind.cpp
@@ -26,11 +26,13 @@ PYBIND11_MODULE(daylight, m) {
.def("irradiance",
py::vectorize((double (Sunclock::*)(time_t)) & Sunclock::irradiance),
R"pbdoc(
- Calculates the irradiance level for given date.
+ Calculates the irradiance level for given datetime.
+
+ This is a vectorized function.
Parameters
----------
- date : int
+ datetime : int or array_like
unix timestamp (in UTC, seconds)
Examples
@@ -39,17 +41,21 @@ PYBIND11_MODULE(daylight, m) {
>>> sun = daylight.Sunclock(17.3859, 78.4867, 5.5)
>>> sun.irradiance(1590050435)
0.882753920406182
+ >>> sun.irradiance([1590010200, 1590024600])
+ array([-0.56570521, 0.28650605])
)pbdoc",
- py::arg("date"))
+ py::arg("datetime"))
.def("sunrise",
py::vectorize((time_t(Sunclock::*)(time_t)) & Sunclock::sunrise),
R"pbdoc(
Calculates the sunrise time for given date.
+ This is a vectorized function.
+
Parameters
----------
- date : int
+ date : int or array_like
unix timestamp (in UTC, seconds)
Examples
@@ -58,6 +64,8 @@ PYBIND11_MODULE(daylight, m) {
>>> sun = daylight.Sunclock(17.3859, 78.4867, 5.5)
>>> sun.sunrise(1589999400)
1590019961
+ >>> sun.sunrise([1590010200, 1590024600])
+ array([1590019959, 1590019957])
)pbdoc",
py::arg("date"))
@@ -66,9 +74,11 @@ PYBIND11_MODULE(daylight, m) {
R"pbdoc(
Calculates the solar noon time for given date.
+ This is a vectorized function.
+
Parameters
----------
- date : int
+ date : int or array_like
unix timestamp (in UTC, seconds)
Examples
@@ -77,6 +87,8 @@ PYBIND11_MODULE(daylight, m) {
>>> sun = daylight.Sunclock(17.3859, 78.4867, 5.5)
>>> sun.solar_noon(1589999400)
1590043354
+ >>> sun.solar_noon([1590010200, 1590024600])
+ array([1590043355, 1590043355])
)pbdoc",
py::arg("date"))
@@ -85,9 +97,11 @@ PYBIND11_MODULE(daylight, m) {
R"pbdoc(
Calculates the sunset time for given date.
+ This is a vectorized function.
+
Parameters
----------
- date : int
+ date : int or array_like
unix timestamp (in UTC, seconds)
Examples
@@ -96,6 +110,8 @@ PYBIND11_MODULE(daylight, m) {
>>> sun = daylight.Sunclock(17.3859, 78.4867, 5.5)
>>> sun.sunset(1589999400)
1590066748
+ >>> sun.sunset([1590010200, 1590024600])
+ array([1590066751, 1590066754])
)pbdoc",
py::arg("date"));
}
diff --git a/examples/adonmo-daylight-brightness-control.png b/static/adonmo-daylight-brightness-control.png
similarity index 100%
rename from examples/adonmo-daylight-brightness-control.png
rename to static/adonmo-daylight-brightness-control.png
diff --git a/static/logo.png b/static/logo.png
new file mode 100644
index 0000000..ecd6570
Binary files /dev/null and b/static/logo.png differ