Skip to content

Instantly share code, notes, and snippets.

@jj1bdx
Last active December 16, 2024 12:31
Show Gist options
  • Save jj1bdx/a274b20fc213cdf056e3a7fbc0556e45 to your computer and use it in GitHub Desktop.
Save jj1bdx/a274b20fc213cdf056e3a7fbc0556e45 to your computer and use it in GitHub Desktop.
Sunrise/Sunset time calculation code for Grid Locator PM95TP
#!/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())
@jj1bdx
Copy link
Author

jj1bdx commented Dec 8, 2024

Reference:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment