Skip to main content

Simple module to get the angle of the Sun relative to the Horizon for a given geographic location and datetime.

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sundata-1.0.0.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

sundata-1.0.0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file sundata-1.0.0.tar.gz.

File metadata

  • Download URL: sundata-1.0.0.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for sundata-1.0.0.tar.gz
Algorithm Hash digest
SHA256 705df848d58ad5bd2ca33123fe0f62cde31c1fc980a689d2af385864587962df
MD5 425f44f221cba841eed99c8287a0d64d
BLAKE2b-256 1b4fbbf470ab4ad5b03bf2ecb62213990c08cf7593f0816b5d87cff9bef6dd54

See more details on using hashes here.

File details

Details for the file sundata-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: sundata-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for sundata-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 40d78536f93725c6ca4bec1ffbfee5ccb200024e2586418fce05e851e2f993ad
MD5 a3ac13a983db52ce6ca4f1afd3558aa7
BLAKE2b-256 de1e431c10aabed573024c4b696b56691766f451ee4af13ba01a29fc754064d5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page