Created
March 2, 2026 14:32
-
-
Save johnarban/5b255e4685c93202c192ae6353b5099f to your computer and use it in GitHub Desktop.
Get test rise, transit, and set values for the sun on the 2025 march equinox using Skyfield
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
| from skyfield import almanac | |
| from skyfield.api import load, wgs84 | |
| eph = load("de440s.bsp") | |
| ts = load.timescale() | |
| obs = eph["earth"] + wgs84.latlon(0.0, 0.0, elevation_m=0.0) | |
| sun = eph["sun"] | |
| t_utc = ts.utc(2025, 3, 20, 9, 1, 0) | |
| year, month, day, _, _, _ = t_utc.utc | |
| t0 = ts.utc(int(year), int(month), int(day), 0, 0, 0) | |
| t1 = ts.utc(int(year), int(month), int(day) + 1, 0, 0, 0) | |
| # automatically uses the correct horizonDegrees for sun/moon/planets | |
| rise_times, rise_flags = almanac.find_risings(obs, sun, t0, t1) | |
| set_times, set_flags = almanac.find_settings(obs, sun, t0, t1) | |
| transit_times = almanac.find_transits(obs, sun, t0, t1) | |
| # rise = next((t for t, ok in zip(rise_times, rise_flags) if ok), None) | |
| # transit = transit_times[0] if len(transit_times) else None | |
| # set_ = next((t for t, ok in zip(set_times, set_flags) if ok), None) | |
| to_h = lambda t: float(t.utc[3] + t.utc[4] / 60.0 + t.utc[5] / 3600.0) | |
| print({"rise_h": to_h(rise_times[0]), "transit_h": to_h(transit_times[0]), "set_h": to_h(set_times[0])}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment