Last active
December 16, 2024 12:31
-
-
Save jj1bdx/a274b20fc213cdf056e3a7fbc0556e45 to your computer and use it in GitHub Desktop.
Sunrise/Sunset time calculation code for Grid Locator PM95TP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from skyfield import api, almanac | |
load = api.Loader('~/.skyfield-data') | |
ts = load.timescale() | |
planets = load('de421.bsp') | |
pm95tp = api.Topos(latitude = '35.645 N', | |
longitude = '139.623 E', | |
elevation_m = 45.0) | |
fmt = "%d-%b-%Y %H%MUTC" | |
if __name__ == '__main__': | |
now = ts.now() | |
now_1day = ts.tai_jd(now.tai + 1.0) | |
pm95tp_st, pm95tp_sf = almanac.find_discrete(now, now_1day, | |
almanac.sunrise_sunset(planets, pm95tp)) | |
pm95tp_ss = zip(pm95tp_st, pm95tp_sf) | |
print("In Grid PM95tp, Setagaya City, Tokyo, Japan:") | |
for time, rise_set in pm95tp_ss: | |
if rise_set: | |
mode = "sunrise:" | |
else: | |
mode = "sunset: " | |
print("next", mode, time.utc_iso()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Reference: