Kleinigkeiten und codierung
This commit is contained in:
+47
-47
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
#!/usr/bin/env python3
|
||||
import base64
|
||||
import json
|
||||
import math
|
||||
@@ -41,7 +41,7 @@ def fail(message: str, *, extra: dict | None = None, code: int = 1) -> None:
|
||||
payload = {"ok": False, "error": message}
|
||||
if extra:
|
||||
payload.update(extra)
|
||||
print(json.dumps(payload, ensure_ascii=False))
|
||||
print(json.dumps(payload, ensure_ascii=True))
|
||||
raise SystemExit(code)
|
||||
|
||||
|
||||
@@ -161,8 +161,8 @@ def action_sun_moon_rise_set(args: list[str]) -> dict:
|
||||
return None
|
||||
return result
|
||||
|
||||
# Morgens: Sonne steigt auf → Direction.Rise (Höhe wird größer)
|
||||
# Abends: Sonne sinkt ab → Direction.Set (Höhe wird kleiner)
|
||||
# Morgens: Sonne steigt auf -> Direction.Rise (Hoehe wird groesser)
|
||||
# Abends: Sonne sinkt ab -> Direction.Set (Hoehe wird kleiner)
|
||||
astro_dawn = search_altitude(astronomy.Direction.Rise, -18.0)
|
||||
nautical_dawn = search_altitude(astronomy.Direction.Rise, -12.0)
|
||||
civil_dawn = search_altitude(astronomy.Direction.Rise, -6.0)
|
||||
@@ -735,15 +735,15 @@ def action_planet_constellation_changes_for_month(args: list[str]) -> dict:
|
||||
"Taurus": "Stier",
|
||||
"Gemini": "Zwillinge",
|
||||
"Cancer": "Krebs",
|
||||
"Leo": "Loewe",
|
||||
"Leo": "Löwe",
|
||||
"Virgo": "Jungfrau",
|
||||
"Libra": "Waage",
|
||||
"Scorpius": "Skorpion",
|
||||
"Sagittarius": "Schuetze",
|
||||
"Sagittarius": "Schütze",
|
||||
"Capricornus": "Steinbock",
|
||||
"Aquarius": "Wassermann",
|
||||
"Pisces": "Fische",
|
||||
"Ophiuchus": "Schlangentraeger",
|
||||
"Ophiuchus": "Schlangenträger",
|
||||
"Cetus": "Walfisch",
|
||||
}
|
||||
|
||||
@@ -2307,12 +2307,12 @@ def action_inner_planet_elongations_for_month(args: list[str]) -> dict:
|
||||
break
|
||||
|
||||
if local_dt >= local_start:
|
||||
visibility_label = "westliche" if event.visibility == astronomy.Visibility.Morning else "oestliche"
|
||||
visibility_label = "westliche" if event.visibility == astronomy.Visibility.Morning else "östliche"
|
||||
events.append({
|
||||
"planet_key": key,
|
||||
"planet_label": label,
|
||||
"kind": "western" if event.visibility == astronomy.Visibility.Morning else "eastern",
|
||||
"label": f"{label} groesste {visibility_label} Elongation",
|
||||
"label": f"{label} größte {visibility_label} Elongation",
|
||||
"elongation_deg": float(event.elongation),
|
||||
"ecliptic_separation_deg": float(event.ecliptic_separation),
|
||||
"utc_iso": dt_utc.isoformat().replace("+00:00", "Z"),
|
||||
@@ -2381,7 +2381,7 @@ def action_venus_peak_magnitude_for_month(args: list[str]) -> dict:
|
||||
"planet_key": "venus",
|
||||
"planet_label": "Venus",
|
||||
"kind": "peak_magnitude",
|
||||
"label": "Venus in groesster Helligkeit",
|
||||
"label": "Venus in größter Helligkeit",
|
||||
"mag": float(event.mag),
|
||||
"utc_iso": dt_utc.isoformat().replace("+00:00", "Z"),
|
||||
"local_iso": local_dt.isoformat(),
|
||||
@@ -2590,13 +2590,13 @@ def action_outer_planet_stations_for_month(args: list[str]) -> dict:
|
||||
rate_after = planet_longitude_rate_deg_per_day(body, station_time_utc + timedelta(days=3))
|
||||
if rate_before > 0 and rate_after < 0:
|
||||
kind = "retrograde"
|
||||
text = "stationaer, dann ruecklaeufig"
|
||||
text = "stationär, dann rückläufig"
|
||||
elif rate_before < 0 and rate_after > 0:
|
||||
kind = "prograde"
|
||||
text = "stationaer, dann rechtlaeufig"
|
||||
text = "stationär, dann rechtläufig"
|
||||
else:
|
||||
kind = "stationary"
|
||||
text = "stationaer"
|
||||
text = "stationär"
|
||||
|
||||
if not any(
|
||||
item["planet_key"] == key and abs(datetime.fromisoformat(item["local_iso"]).timestamp() - local_dt.timestamp()) < 3600
|
||||
@@ -2847,10 +2847,10 @@ def action_jupiter_moons_one_side_for_month(args: list[str]) -> dict:
|
||||
|
||||
def direction_text_from_kinds(raw_kind: str | None, east_west_kind: str | None) -> str:
|
||||
if east_west_kind == "east":
|
||||
return "oestlich"
|
||||
return "östlich"
|
||||
if east_west_kind == "west":
|
||||
return "westlich"
|
||||
return "westlich" if raw_kind == "left" else "oestlich"
|
||||
return "westlich" if raw_kind == "left" else "östlich"
|
||||
|
||||
events: list[dict] = []
|
||||
current = utc_start
|
||||
@@ -3596,7 +3596,7 @@ def action_moon_star_occultations(args: list[str]) -> dict:
|
||||
}
|
||||
|
||||
|
||||
# ── satellite_passes ──────────────────────────────────────────────────────────
|
||||
# ── satellite_passes ──────────────────────────────────────────────────────────
|
||||
|
||||
import math as _math
|
||||
|
||||
@@ -3723,14 +3723,14 @@ def _apparent_magnitude(std_mag, rcs, rcs_size, r_eci, sun_eci_km, obs_ecef_km,
|
||||
if range_km < 1:
|
||||
return None
|
||||
|
||||
# Phase angle (sun → sat → observer)
|
||||
# Phase angle (sun → sat → observer)
|
||||
sx, sy, sz = sun_eci_km
|
||||
ox = -rx + obs_ecef_km[0] # obs ECI ≈ ECEF for this approximation
|
||||
ox = -rx + obs_ecef_km[0] # obs ECI ≈ ECEF for this approximation
|
||||
oy = -ry + obs_ecef_km[1]
|
||||
oz = -rz + obs_ecef_km[2]
|
||||
# to-sun from sat
|
||||
ts_x, ts_y, ts_z = sx - rx, sy - ry, sz - rz
|
||||
to_x, to_y, to_z = -rx, -ry, -rz # observer ≈ Earth center approx
|
||||
to_x, to_y, to_z = -rx, -ry, -rz # observer ≈ Earth center approx
|
||||
ts_len = _math.sqrt(ts_x*ts_x + ts_y*ts_y + ts_z*ts_z)
|
||||
to_len = _math.sqrt(to_x*to_x + to_y*to_y + to_z*to_z)
|
||||
if ts_len < 1 or to_len < 1:
|
||||
@@ -3840,7 +3840,7 @@ def action_satellite_passes(args: list[str]) -> dict:
|
||||
color = COLORS[idx % len(COLORS)]
|
||||
passes = []
|
||||
|
||||
# ── Phase 1: coarse scan to find pass windows ──
|
||||
# ── Phase 1: coarse scan to find pass windows ──
|
||||
current = window_start
|
||||
prev_el = None
|
||||
in_pass = False
|
||||
@@ -3894,7 +3894,7 @@ def action_satellite_passes(args: list[str]) -> dict:
|
||||
_, los_az_v, _ = _ecef_to_altaz(r_ecef3, obs_ecef, lat_rad, lon_rad)
|
||||
los_az = los_az_v
|
||||
|
||||
# ── Phase 2: fine trajectory (5s steps) ──
|
||||
# ── Phase 2: fine trajectory (5s steps) ──
|
||||
path = []
|
||||
shadow_entry = None
|
||||
t = aos_time
|
||||
@@ -4014,132 +4014,132 @@ def main() -> None:
|
||||
|
||||
if action == "sun_moon_rise_set":
|
||||
result = action_sun_moon_rise_set(args)
|
||||
print(json.dumps(result, ensure_ascii=False))
|
||||
print(json.dumps(result, ensure_ascii=True))
|
||||
return
|
||||
|
||||
if action == "moon_star_occultations":
|
||||
result = action_moon_star_occultations(args)
|
||||
print(json.dumps(result, ensure_ascii=False))
|
||||
print(json.dumps(result, ensure_ascii=True))
|
||||
return
|
||||
|
||||
if action == "season_changes_for_month":
|
||||
result = action_season_changes_for_month(args)
|
||||
print(json.dumps(result, ensure_ascii=False))
|
||||
print(json.dumps(result, ensure_ascii=True))
|
||||
return
|
||||
|
||||
if action == "time_changes_for_month":
|
||||
result = action_time_changes_for_month(args)
|
||||
print(json.dumps(result, ensure_ascii=False))
|
||||
print(json.dumps(result, ensure_ascii=True))
|
||||
return
|
||||
|
||||
if action == "moon_phase_details":
|
||||
result = action_moon_phase_details(args)
|
||||
print(json.dumps(result, ensure_ascii=False))
|
||||
print(json.dumps(result, ensure_ascii=True))
|
||||
return
|
||||
|
||||
if action == "satellite_passes":
|
||||
result = action_satellite_passes(args)
|
||||
print(json.dumps(result, ensure_ascii=False))
|
||||
print(json.dumps(result, ensure_ascii=True))
|
||||
return
|
||||
|
||||
if action == "planet_rise_set":
|
||||
result = action_planet_rise_set(args)
|
||||
print(json.dumps(result, ensure_ascii=False))
|
||||
print(json.dumps(result, ensure_ascii=True))
|
||||
return
|
||||
|
||||
if action == "month_sky_context":
|
||||
result = action_month_sky_context(args)
|
||||
print(json.dumps(result, ensure_ascii=False))
|
||||
print(json.dumps(result, ensure_ascii=True))
|
||||
return
|
||||
|
||||
if action == "moon_phases_for_month":
|
||||
result = action_moon_phases_for_month(args)
|
||||
print(json.dumps(result, ensure_ascii=False))
|
||||
print(json.dumps(result, ensure_ascii=True))
|
||||
return
|
||||
|
||||
if action == "golden_handle_for_month":
|
||||
result = action_golden_handle_for_month(args)
|
||||
print(json.dumps(result, ensure_ascii=False))
|
||||
print(json.dumps(result, ensure_ascii=True))
|
||||
return
|
||||
|
||||
if action == "moon_planet_approaches":
|
||||
result = action_moon_planet_approaches(args)
|
||||
print(json.dumps(result, ensure_ascii=False))
|
||||
print(json.dumps(result, ensure_ascii=True))
|
||||
return
|
||||
|
||||
if action == "moon_deep_sky_approaches_for_month":
|
||||
result = action_moon_deep_sky_approaches_for_month(args)
|
||||
print(json.dumps(result, ensure_ascii=False))
|
||||
print(json.dumps(result, ensure_ascii=True))
|
||||
return
|
||||
|
||||
if action == "planet_bright_star_approaches_for_month":
|
||||
result = action_planet_bright_star_approaches_for_month(args)
|
||||
print(json.dumps(result, ensure_ascii=False))
|
||||
print(json.dumps(result, ensure_ascii=True))
|
||||
return
|
||||
|
||||
if action == "planet_conjunctions_for_month":
|
||||
result = action_planet_conjunctions_for_month(args)
|
||||
print(json.dumps(result, ensure_ascii=False))
|
||||
print(json.dumps(result, ensure_ascii=True))
|
||||
return
|
||||
|
||||
if action == "eclipses_for_month":
|
||||
result = action_eclipses_for_month(args)
|
||||
print(json.dumps(result, ensure_ascii=False))
|
||||
print(json.dumps(result, ensure_ascii=True))
|
||||
return
|
||||
|
||||
if action == "moon_apsides_for_month":
|
||||
result = action_moon_apsides_for_month(args)
|
||||
print(json.dumps(result, ensure_ascii=False))
|
||||
print(json.dumps(result, ensure_ascii=True))
|
||||
return
|
||||
|
||||
if action == "sun_apsides_for_month":
|
||||
result = action_sun_apsides_for_month(args)
|
||||
print(json.dumps(result, ensure_ascii=False))
|
||||
print(json.dumps(result, ensure_ascii=True))
|
||||
return
|
||||
|
||||
if action == "inner_planet_elongations_for_month":
|
||||
result = action_inner_planet_elongations_for_month(args)
|
||||
print(json.dumps(result, ensure_ascii=False))
|
||||
print(json.dumps(result, ensure_ascii=True))
|
||||
return
|
||||
|
||||
if action == "venus_peak_magnitude_for_month":
|
||||
result = action_venus_peak_magnitude_for_month(args)
|
||||
print(json.dumps(result, ensure_ascii=False))
|
||||
print(json.dumps(result, ensure_ascii=True))
|
||||
return
|
||||
|
||||
if action == "outer_planet_events_for_month":
|
||||
result = action_outer_planet_events_for_month(args)
|
||||
print(json.dumps(result, ensure_ascii=False))
|
||||
print(json.dumps(result, ensure_ascii=True))
|
||||
return
|
||||
|
||||
if action == "outer_planet_stations_for_month":
|
||||
result = action_outer_planet_stations_for_month(args)
|
||||
print(json.dumps(result, ensure_ascii=False))
|
||||
print(json.dumps(result, ensure_ascii=True))
|
||||
return
|
||||
|
||||
if action == "jupiter_moons_one_side_for_month":
|
||||
result = action_jupiter_moons_one_side_for_month(args)
|
||||
print(json.dumps(result, ensure_ascii=False))
|
||||
print(json.dumps(result, ensure_ascii=True))
|
||||
return
|
||||
|
||||
if action == "mercury_good_visibility_for_month":
|
||||
result = action_mercury_good_visibility_for_month(args)
|
||||
print(json.dumps(result, ensure_ascii=False))
|
||||
print(json.dumps(result, ensure_ascii=True))
|
||||
return
|
||||
|
||||
if action == "planet_parades_for_month":
|
||||
result = action_planet_parades_for_month(args)
|
||||
print(json.dumps(result, ensure_ascii=False))
|
||||
print(json.dumps(result, ensure_ascii=True))
|
||||
return
|
||||
|
||||
if action == "planet_constellation_changes_for_month":
|
||||
result = action_planet_constellation_changes_for_month(args)
|
||||
print(json.dumps(result, ensure_ascii=False))
|
||||
print(json.dumps(result, ensure_ascii=True))
|
||||
return
|
||||
|
||||
if action == "moon_star_occultations_for_month":
|
||||
result = action_moon_star_occultations_for_month(args)
|
||||
print(json.dumps(result, ensure_ascii=False))
|
||||
print(json.dumps(result, ensure_ascii=True))
|
||||
return
|
||||
|
||||
fail("Unbekannte Aktion.", extra={"action": action, "available_actions": ["sun_moon_rise_set", "moon_star_occultations", "moon_phase_details", "satellite_passes", "planet_rise_set", "month_sky_context", "moon_phases_for_month", "golden_handle_for_month", "season_changes_for_month", "time_changes_for_month", "moon_planet_approaches", "moon_deep_sky_approaches_for_month", "planet_bright_star_approaches_for_month", "planet_conjunctions_for_month", "eclipses_for_month", "moon_apsides_for_month", "sun_apsides_for_month", "inner_planet_elongations_for_month", "venus_peak_magnitude_for_month", "outer_planet_events_for_month", "outer_planet_stations_for_month", "jupiter_moons_one_side_for_month", "mercury_good_visibility_for_month", "planet_parades_for_month", "planet_constellation_changes_for_month", "moon_star_occultations_for_month"]})
|
||||
|
||||
Reference in New Issue
Block a user