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:
1 parent
0de68bfce0
commit
517f0868db
7 files changed
+136
-27
No files matched your search
+42
-17
@@ -8,7 +8,7 @@ from PIL import Image, ImageDraw
|
||||
|
||||
import astro
|
||||
import skykit
|
||||
from astro import direction
|
||||
from astro import Pass, direction
|
||||
from poller import Poller
|
||||
from sky_data import CloudHour, Tle, cloud_at
|
||||
from skykit import H, W, hm
|
||||
@@ -20,13 +20,18 @@ MARKER, HOME = (255, 255, 255), (255, 110, 100)
|
||||
LAND_DAY, LAND_NIGHT, SEA_DAY, SEA_NIGHT = (70, 168, 120), (26, 66, 50), (16, 32, 28), (8, 15, 13)
|
||||
PAST, AHEAD = (50, 110, 96), ACCENT
|
||||
STALE_BG = (240, 200, 90)
|
||||
MAP_TOP, MAP_H, DOT = 40, 240, 4
|
||||
CLEAR_SKY, SOME_CLOUD, OVERCAST = (120, 236, 160), (240, 200, 90), (255, 120, 100)
|
||||
# The map leaves out the polar caps (the ISS stays within 51.6° of the equator) to make room for the next pass.
|
||||
LAT_TOP, LAT_BOTTOM = 75, -60
|
||||
MAP_TOP, MAP_H, DOT = 40, 180, 4 # 4/3 px per degree, the same scale as across
|
||||
PANEL_TOP = MAP_TOP + MAP_H
|
||||
GRID_X = (214, 344) # the two columns of height, direction, brightness and clouds
|
||||
LAND_PATH = Path(__file__).parent / "assets" / "world_land.png"
|
||||
EARTH_KM, GM = 6371.0, 398600.4418 # radius, and the gravitational parameter in km³/s²
|
||||
|
||||
|
||||
def map_xy(lat: float, lon: float) -> tuple[float, float]:
|
||||
return (lon + 180) / 360 * W, MAP_TOP + (90 - lat) / 180 * MAP_H
|
||||
return (lon + 180) / 360 * W, MAP_TOP + (LAT_TOP - lat) / (LAT_TOP - LAT_BOTTOM) * MAP_H
|
||||
|
||||
|
||||
def is_day(lat: float, lon: float, subsolar: tuple[float, float]) -> bool:
|
||||
@@ -45,6 +50,27 @@ def _fmt(value: float) -> str:
|
||||
return f"{abs(value):.1f}".replace(".", ",")
|
||||
|
||||
|
||||
def mag_colour(mag: float):
|
||||
"""How inviting a pass of this brightness is, as a colour (like the cloud cover)."""
|
||||
# TODO(owner): pick the thresholds, e.g. CLEAR_SKY for a pass worth going out for.
|
||||
return TEXT
|
||||
|
||||
|
||||
def pass_cells(p: Pass, clouds: tuple[CloudHour, ...]) -> list[tuple[str, str, tuple]]:
|
||||
"""(label, value, colour) for the grid beside the time of the next pass."""
|
||||
pct = cloud_at(clouds, p.start)
|
||||
if pct is None:
|
||||
cloud = ("--", DIM)
|
||||
else:
|
||||
cloud = (f"{pct} %", OVERCAST if pct >= 60 else SOME_CLOUD if pct >= 25 else CLEAR_SKY)
|
||||
return [
|
||||
("VÝŠKA", f"{p.max_alt:.0f}°", TEXT),
|
||||
("SMĚR", f"{direction(p.az_from)} → {direction(p.az_to)}", TEXT),
|
||||
("JASNOST", f"{p.mag:.1f} mag".replace("-", "−").replace(".", ","), mag_colour(p.mag)),
|
||||
("MRAKY", *cloud),
|
||||
]
|
||||
|
||||
|
||||
class IssView:
|
||||
name = "iss"
|
||||
TLE_STALE_AFTER = 3 * 86400.0
|
||||
@@ -114,30 +140,29 @@ class IssView:
|
||||
@staticmethod
|
||||
def _map(d: ImageDraw.ImageDraw, now: datetime) -> None:
|
||||
land = _land().load()
|
||||
skip = round((90 - LAT_TOP) / 180 * _land().height) # rows of the whole-world mask above the map
|
||||
sun = astro.subsolar(now)
|
||||
for gy in range(DOT // 2, MAP_H, DOT):
|
||||
lat = 90 - (gy + 1) / MAP_H * 180
|
||||
lat = LAT_TOP - (gy + 1) / MAP_H * (LAT_TOP - LAT_BOTTOM)
|
||||
for gx in range(DOT // 2, W, DOT):
|
||||
day = is_day(lat, (gx + 1) / W * 360 - 180, sun)
|
||||
if land[gx, gy]:
|
||||
if land[gx, gy + skip]:
|
||||
colour = LAND_DAY if day else LAND_NIGHT
|
||||
else:
|
||||
colour = SEA_DAY if day else SEA_NIGHT
|
||||
d.rectangle((gx, MAP_TOP + gy, gx + 1, MAP_TOP + gy + 1), fill=colour)
|
||||
|
||||
def _next_pass(self, d: ImageDraw.ImageDraw, tle: Tle, now: datetime) -> None:
|
||||
skykit.tracked(d, (14, 298), "DALŠÍ VIDITELNÝ PŘELET", skykit.font(10, 650), ACCENT)
|
||||
y = PANEL_TOP + 20
|
||||
skykit.tracked(d, (14, y), "DALŠÍ VIDITELNÝ PŘELET", skykit.font(12, 650), ACCENT)
|
||||
p = astro.next_visible_pass(tle, now)
|
||||
if p is None:
|
||||
d.text((14, 316), "v příštích 3 dnech žádný", font=skykit.font(15, 700), fill=TEXT, anchor="ls")
|
||||
d.text((14, y + 40), "v příštích 3 dnech žádný", font=skykit.font(24, 700), fill=TEXT, anchor="ls")
|
||||
return
|
||||
d.text((14, 316), f"{skykit.WEEKDAYS[p.start.weekday()]} {p.start.day}. {p.start.month}. v {hm(p.start)} · "
|
||||
f"{p.max_alt:.0f}° · z {direction(p.az_from)} na {direction(p.az_to)}", font=skykit.font(15, 700),
|
||||
fill=TEXT, anchor="ls")
|
||||
pct = cloud_at(self._clouds.value or (), p.start)
|
||||
if pct is not None:
|
||||
label = f"mraky {pct} %"
|
||||
colour = (255, 120, 100) if pct >= 60 else (240, 200, 90) if pct >= 25 else (120, 236, 160)
|
||||
width = d.textlength(label, font=skykit.font(11, 700))
|
||||
d.rounded_rectangle((466 - width - 16, 290, 466, 310), 10, fill=colour)
|
||||
d.text((458, 304), label, font=skykit.font(11, 700), fill=BG, anchor="rs")
|
||||
d.text((12, y + 50), hm(p.start), font=skykit.font(48, 800), fill=TEXT, anchor="ls")
|
||||
d.text((14, y + 74), f"{skykit.WEEKDAYS[p.start.weekday()]} {p.start.day}. {p.start.month}.",
|
||||
font=skykit.font(18, 650), fill=TEXT, anchor="ls")
|
||||
for i, (label, value, colour) in enumerate(pass_cells(p, self._clouds.value or ())):
|
||||
x, top = GRID_X[i % 2], y + i // 2 * 48
|
||||
skykit.tracked(d, (x, top), label, skykit.font(12, 650), DIM)
|
||||
d.text((x, top + 26), value, font=skykit.font(24, 750), fill=colour, anchor="ls")
|
||||
Reference in new issue
Block a user