Simple sunset and sunrise time calculation python library
Project description
SunTime
Simple sunset and sunrise time calculation python library forked from pypi suntime library.
Usage
You can use the library to get UTC and local time sunrise and sunset times typing:
from suntime import Sun, DegreesOffset, SunTimeException
MADRID_LAT = 40.416775
MADRID_LON = -3.703790
madrid_sun = Sun(MADRID_LAT, MADRID_LON)
# Get today's sunrise and sunset in UTC
sunrise_madrid = madrid_sun.get_sunrise_time()
today_ss = sun.get_sunset_time()
today_sr = sun.get_local_sunset_time()
print('Today at Madrid the sun raised at {} and get down at {} UTC'.
format(today_sr.strftime('%H:%M'), today_ss.strftime('%H:%M')))
# On a special date in your machine's local time zone
abd = datetime.date(2014, 10, 3)
abd_sr = sun.get_local_sunrise_time(abd)
abd_ss = sun.get_local_sunset_time(abd)
print('On {} the sun at Madrid raised at {} and get down at {}.'.
format(abd, abd_sr.strftime('%H:%M'), abd_ss.strftime('%H:%M')))
# offsets
horizon = madrid_sun.get_local_sunset_time(
degrees_offset=DegreesOffset.horizon.value) # 0
civil = madrid_sun.get_local_sunset_time(
degrees_offset=DegreesOffset.civil.value) # 6
nautical = madrid_sun.get_local_sunset_time(
degrees_offset=DegreesOffset.nautilcal.value) # 12
astronomical = madrid_sun.get_local_sunset_time(
degrees_offset=DegreesOffset.astronomical.value) # 18
References
- library improvement: Dusk dawn calculation
- Forked from suntime
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
dt-suntime-1.0.0.tar.gz
(7.0 kB
view hashes)
Built Distribution
Close
Hashes for dt_suntime-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64fd3a8c080fd3b9d4cc69ed4091f7b4e8e7f353b584b3cf9439ceb31aa4c1d5 |
|
MD5 | 98a1b6248f29c0f1645c9094ea42a607 |
|
BLAKE2b-256 | 628baf981121f65eaf375e7dbd76381c890f4908ae4e9074aa3c271806ee3740 |