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 hashes)

Uploaded Source

Built Distribution

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

Uploaded Python 3

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