Bigger next-pass panel with brightness on the ISS view, deploy on push

The map leaves out the polar caps (75° N to 60° S at the same scale) so the
next visible pass gets a 100 px panel: the time in 48 px type, the date, and
height, direction, estimated magnitude and clouds in 24 px. The magnitude is
the brightest moment of the pass by Matson's formula (standard magnitude -1.8).

A Gitea webhook now makes Coolify deploy every push to main, and Coolify
4.5.3 re-reads docker-compose.yml on each deploy, so no buttons are needed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
rickzkmandClaude Opus 5.5 committed 2026-10-29 22:48:19 +01:00
1 parent 0de68bfce0
commit 517f0868db
7 files changed
+136 -27

No files matched your search

+39 -1
View File
@@ -20,6 +20,8 @@ BODIES = (("Měsíc", ephem.Moon), ("Merkur", ephem.Mercury), ("Venuše", ephem.
DARK_SUN_ALT = "-18" # astronomical darkness
VISIBLE_SUN_ALT = -6 # a satellite pass is visible once the sky is at least this dark
TRACK_BACK, TRACK_AHEAD = 40, 95 # minutes of ISS ground track around now
ISS_STD_MAG = -1.8 # brightness at 1000 km and a 90° phase angle; observers quote -1.3 to -1.8
PASS_STEP_S = 10 # how finely a pass is sampled to find its brightest moment
@dataclass(frozen=True)
@@ -45,6 +47,7 @@ class Pass:
az_from: float
az_to: float
visible: bool # the ISS is sunlit while the sky here is dark
mag: float # estimated magnitude at the brightest moment (lower is brighter)
@dataclass(frozen=True)
@@ -154,11 +157,46 @@ def next_visible_pass(tle: Tle, now: datetime, within_hours: float = 72) -> Pass
iss.compute(o)
sun.compute(o)
if not iss.eclipsed and math.degrees(sun.alt) < VISIBLE_SUN_ALT:
return Pass(_local(rise), math.degrees(top_alt), math.degrees(az_rise), math.degrees(az_set), True)
return Pass(_local(rise), math.degrees(top_alt), math.degrees(az_rise), math.degrees(az_set), True,
_brightest(iss, sun, o, rise, set_))
o.date = set_ + ephem.minute
return None
def magnitude(range_km: float, phase: float, std_mag: float = ISS_STD_MAG) -> float:
"""Estimated magnitude of a satellite seen as a diffusely reflecting sphere (Robert Matson's formula).
`phase` is the sun–satellite–observer angle in radians: 0 when fully lit as seen from here, π when only its
unlit side faces us.
"""
lit = max(1e-6, math.sin(phase) + (math.pi - phase) * math.cos(phase))
return std_mag - 15 + 5 * math.log10(range_km) - 2.5 * math.log10(lit)
def _unit(alt: float, az: float) -> tuple[float, float, float]:
return math.cos(alt) * math.sin(az), math.cos(alt) * math.cos(az), math.sin(alt)
def _phase(sat: ephem.EarthSatellite, sun: ephem.Sun) -> float:
"""The sun is so far away that its direction from the satellite is the same as from here."""
cos = -sum(a * b for a, b in zip(_unit(sat.alt, sat.az), _unit(sun.alt, sun.az)))
return math.acos(max(-1.0, min(1.0, cos)))
def _brightest(iss: ephem.EarthSatellite, sun: ephem.Sun, o: ephem.Observer, rise, set_) -> float:
"""The lowest magnitude while the ISS is above the horizon and sunlit."""
best = math.inf
t = rise
while t <= set_:
o.date = t
iss.compute(o)
sun.compute(o)
if iss.alt > 0 and not iss.eclipsed:
best = min(best, magnitude(iss.range / 1000, _phase(iss, sun)))
t += PASS_STEP_S * ephem.second
return best
def subsolar(now: datetime) -> tuple[float, float]:
"""Latitude and longitude where the sun is straight overhead."""
o = ephem.Observer()