Skip to main content

GitHub Workflow Status Codecov branch Sonar Quality Gate GitHub

Sun Data

Simple module to get the angle of the Sun relative to the Horizon for a given geographic location and datetime. Also allow for the gathering of sunrise and sunset for a given geographical location and datetime, with the option to shift those to general lighting conditions rather than sunset but instead Astro Night, Night for example.

Features

  • Angle of Sun for given location and date time
  • Get modified datetime for location when sun enters different lighting conditions

Installing

Install using pip into your python virtual environment.

pip install sundata

Usage

Before using sundata to get the lighting information you'll require a location latitude and longitude as well a datetime in order to perform the calculation.

To get only the sunrise and sunset for a given date time the following will be enough.

position = Position(51.772938, 0.102310)
a_date = datetime(2023, 2, 13, 12, 00)
data = SunData(position, a_date)
data.calculate_sun_data()
sunrise = data.sunrise
sunset = data.sunset

To get the lighting periods around sunrise and sunset then a LightPeriod needs to be passed into the calculation method.

pos = Position(51.772938, 0.102310)
current_datetime = datetime(2023, 2, 12, 17, 7)
data = SunData(position, current_datetime)
data.calculate_sun_data(LightPeriod.NIGHT)
sunrise = data.sunrise
sunset = data.sunset

Sunset and Sunrise datetimes have now been shifted to the start of Night and end of Night.

Running Tests

Module uses pytest and pytest-cov for coverage. To run the tests

pytest 

To run the tests with coverage

pytest --cov=src

Contributing

Please first raise an issue then fork the repository referencing the issue in commits and raise a Pull Request.

Acknowledgements

License

Licensed under the MIT. Copyright 2023 Night Works. Copy of the license.

A list of the Licenses of the dependencies of the project can be found at the bottom of the Libraries Summary.

Metadata

Release files for sundata 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sundata 1.0.0
File Size Uploaded Provenance Actions
sundata-1.0.0.tar.gz 5.8 kB Without provenance Details for sundata-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sundata 1.0.0
File Interpreter ABI Platform Actions
sundata-1.0.0-py3-none-any.whl Python 3 none any Details for sundata-1.0.0-py3-none-any.whl

Total release size: 11.1 kB

Release files / sundata-1.0.0.tar.gz

Download URL sundata-1.0.0.tar.gz
Size 5.8 kB
Tags Source
SHA-256 checksum
How to use checksums
705df848d58ad5bd2ca33123fe0f62cde31c1fc980a689d2af385864587962df
BLAKE2b-256 checksum
How to use checksums
1b4fbbf470ab4ad5b03bf2ecb62213990c08cf7593f0816b5d87cff9bef6dd54
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release files / sundata-1.0.0-py3-none-any.whl

Download URL sundata-1.0.0-py3-none-any.whl
Size 5.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
40d78536f93725c6ca4bec1ffbfee5ccb200024e2586418fce05e851e2f993ad
BLAKE2b-256 checksum
How to use checksums
de1e431c10aabed573024c4b696b56691766f451ee4af13ba01a29fc754064d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Security for sundata 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page