Bugfixes
This commit is contained in:
@@ -63,6 +63,7 @@ $eclipseEvents = [];
|
||||
$moonApsisEvents = [];
|
||||
$sunApsisEvents = [];
|
||||
$innerPlanetElongationEvents = [];
|
||||
$venusPeakMagnitudeEvents = [];
|
||||
$outerPlanetEvents = [];
|
||||
$outerPlanetStationEvents = [];
|
||||
$moonOccultations = [];
|
||||
@@ -424,6 +425,23 @@ if (is_array($elongationDecoded) && ($elongationDecoded['ok'] ?? false)) {
|
||||
$innerPlanetElongationEvents = is_array($elongationDecoded['events'] ?? null) ? $elongationDecoded['events'] : [];
|
||||
}
|
||||
|
||||
$venusPeakMagnitudeOutput = [];
|
||||
$venusPeakMagnitudeExitCode = 0;
|
||||
$venusPeakMagnitudeArgs = [
|
||||
$pythonScriptPath,
|
||||
'venus_peak_magnitude_for_month',
|
||||
(string) $selectedYear,
|
||||
(string) $selectedMonth,
|
||||
$chartTimezone,
|
||||
];
|
||||
$venusPeakMagnitudeCommand = $pythonExecutable . ' ' . implode(' ', array_map('escapeshellarg', $venusPeakMagnitudeArgs)) . ' 2>&1';
|
||||
exec($venusPeakMagnitudeCommand, $venusPeakMagnitudeOutput, $venusPeakMagnitudeExitCode);
|
||||
$venusPeakMagnitudeRaw = trim(implode("\n", $venusPeakMagnitudeOutput));
|
||||
$venusPeakMagnitudeDecoded = json_decode($venusPeakMagnitudeRaw, true);
|
||||
if (is_array($venusPeakMagnitudeDecoded) && ($venusPeakMagnitudeDecoded['ok'] ?? false)) {
|
||||
$venusPeakMagnitudeEvents = is_array($venusPeakMagnitudeDecoded['events'] ?? null) ? $venusPeakMagnitudeDecoded['events'] : [];
|
||||
}
|
||||
|
||||
$outerPlanetOutput = [];
|
||||
$outerPlanetExitCode = 0;
|
||||
$outerPlanetArgs = [
|
||||
@@ -676,6 +694,24 @@ foreach ($innerPlanetElongationEvents as $elongationEvent) {
|
||||
];
|
||||
}
|
||||
|
||||
foreach ($venusPeakMagnitudeEvents as $venusPeakMagnitudeEvent) {
|
||||
if (!is_array($venusPeakMagnitudeEvent)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$magnitudeText = isset($venusPeakMagnitudeEvent['mag'])
|
||||
? number_format((float) $venusPeakMagnitudeEvent['mag'], 1, ',', '') . ' mag'
|
||||
: '';
|
||||
|
||||
$monthEventList[] = [
|
||||
'event' => trim('Venus in groesster Helligkeit' . ($magnitudeText !== '' ? ' (' . $magnitudeText . ')' : '')),
|
||||
'date' => (string) ($venusPeakMagnitudeEvent['local_date'] ?? ''),
|
||||
'time' => (string) ($venusPeakMagnitudeEvent['local_time'] ?? ''),
|
||||
'local_iso' => (string) ($venusPeakMagnitudeEvent['local_iso'] ?? ''),
|
||||
'type' => 'venus_peak_magnitude',
|
||||
];
|
||||
}
|
||||
|
||||
foreach ($outerPlanetEvents as $outerPlanetEvent) {
|
||||
if (!is_array($outerPlanetEvent)) {
|
||||
continue;
|
||||
|
||||
+77
-4
@@ -750,8 +750,6 @@ def action_planet_conjunctions_for_month(args: list[str]) -> dict:
|
||||
coarse_threshold = max_sep_deg + 1.0
|
||||
|
||||
planet_defs = [
|
||||
("Merkur", astronomy.Body.Mercury, "mercury"),
|
||||
("Venus", astronomy.Body.Venus, "venus"),
|
||||
("Mars", astronomy.Body.Mars, "mars"),
|
||||
("Jupiter", astronomy.Body.Jupiter, "jupiter"),
|
||||
("Saturn", astronomy.Body.Saturn, "saturn"),
|
||||
@@ -1230,6 +1228,74 @@ def action_inner_planet_elongations_for_month(args: list[str]) -> dict:
|
||||
}
|
||||
|
||||
|
||||
def action_venus_peak_magnitude_for_month(args: list[str]) -> dict:
|
||||
if len(args) != 3:
|
||||
fail(
|
||||
"Aktion venus_peak_magnitude_for_month erwartet 3 Argumente: year month timezone",
|
||||
extra={"argv": args},
|
||||
)
|
||||
|
||||
try:
|
||||
year = int(args[0])
|
||||
month = int(args[1])
|
||||
except ValueError as exc:
|
||||
fail("Jahr oder Monat sind ungueltig.", extra={"details": str(exc), "argv": args})
|
||||
|
||||
if month < 1 or month > 12:
|
||||
fail("Monat muss zwischen 1 und 12 liegen.", extra={"month": month})
|
||||
|
||||
timezone_name = args[2]
|
||||
try:
|
||||
tz = ZoneInfo(timezone_name)
|
||||
except Exception as exc:
|
||||
fail("Zeitzone ist ungueltig oder auf dem Server nicht verfuegbar.", extra={"details": str(exc)})
|
||||
|
||||
local_start = datetime(year, month, 1, 0, 0, 0, tzinfo=tz)
|
||||
if month == 12:
|
||||
local_end = datetime(year + 1, 1, 1, 0, 0, 0, tzinfo=tz)
|
||||
else:
|
||||
local_end = datetime(year, month + 1, 1, 0, 0, 0, tzinfo=tz)
|
||||
|
||||
utc_start = local_start.astimezone(timezone.utc)
|
||||
scan_start = dt_to_time(utc_start - timedelta(days=80))
|
||||
|
||||
events: list[dict] = []
|
||||
event = astronomy.SearchPeakMagnitude(astronomy.Body.Venus, scan_start)
|
||||
while event is not None:
|
||||
dt_utc = time_to_datetime(event.time)
|
||||
local_dt = dt_utc.astimezone(tz)
|
||||
if local_dt >= local_end:
|
||||
break
|
||||
|
||||
if local_dt >= local_start:
|
||||
events.append({
|
||||
"planet_key": "venus",
|
||||
"planet_label": "Venus",
|
||||
"kind": "peak_magnitude",
|
||||
"label": "Venus in groesster Helligkeit",
|
||||
"mag": float(event.mag),
|
||||
"utc_iso": dt_utc.isoformat().replace("+00:00", "Z"),
|
||||
"local_iso": local_dt.isoformat(),
|
||||
"local_date": local_dt.strftime("%d.%m.%Y"),
|
||||
"local_time": local_dt.strftime("%H:%M"),
|
||||
})
|
||||
|
||||
event = astronomy.SearchPeakMagnitude(astronomy.Body.Venus, event.time.AddDays(30.0))
|
||||
|
||||
events.sort(key=lambda item: item["local_iso"])
|
||||
|
||||
return {
|
||||
"ok": True,
|
||||
"action": "venus_peak_magnitude_for_month",
|
||||
"selected": {
|
||||
"year": year,
|
||||
"month": month,
|
||||
"timezone": timezone_name,
|
||||
},
|
||||
"events": events,
|
||||
}
|
||||
|
||||
|
||||
def action_outer_planet_events_for_month(args: list[str]) -> dict:
|
||||
if len(args) != 3:
|
||||
fail(
|
||||
@@ -1389,6 +1455,8 @@ def action_outer_planet_stations_for_month(args: list[str]) -> dict:
|
||||
scan_step = timedelta(hours=12)
|
||||
|
||||
planet_defs = [
|
||||
("Merkur", astronomy.Body.Mercury, "mercury"),
|
||||
("Venus", astronomy.Body.Venus, "venus"),
|
||||
("Mars", astronomy.Body.Mars, "mars"),
|
||||
("Jupiter", astronomy.Body.Jupiter, "jupiter"),
|
||||
("Saturn", astronomy.Body.Saturn, "saturn"),
|
||||
@@ -2510,7 +2578,7 @@ def action_satellite_passes(args: list[str]) -> dict:
|
||||
|
||||
def main() -> None:
|
||||
if len(sys.argv) < 2:
|
||||
fail("Es wurde keine Aktion uebergeben.", extra={"available_actions": ["sun_moon_rise_set", "moon_star_occultations", "moon_phase_details", "satellite_passes", "planet_rise_set", "month_sky_context", "moon_phases_for_month", "season_changes_for_month", "moon_planet_approaches", "planet_conjunctions_for_month", "eclipses_for_month", "moon_apsides_for_month", "sun_apsides_for_month", "inner_planet_elongations_for_month", "outer_planet_events_for_month", "outer_planet_stations_for_month", "moon_star_occultations_for_month"]})
|
||||
fail("Es wurde keine Aktion uebergeben.", extra={"available_actions": ["sun_moon_rise_set", "moon_star_occultations", "moon_phase_details", "satellite_passes", "planet_rise_set", "month_sky_context", "moon_phases_for_month", "season_changes_for_month", "moon_planet_approaches", "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", "moon_star_occultations_for_month"]})
|
||||
|
||||
action = sys.argv[1]
|
||||
args = sys.argv[2:]
|
||||
@@ -2585,6 +2653,11 @@ def main() -> None:
|
||||
print(json.dumps(result, ensure_ascii=False))
|
||||
return
|
||||
|
||||
if action == "venus_peak_magnitude_for_month":
|
||||
result = action_venus_peak_magnitude_for_month(args)
|
||||
print(json.dumps(result, ensure_ascii=False))
|
||||
return
|
||||
|
||||
if action == "outer_planet_events_for_month":
|
||||
result = action_outer_planet_events_for_month(args)
|
||||
print(json.dumps(result, ensure_ascii=False))
|
||||
@@ -2600,7 +2673,7 @@ def main() -> None:
|
||||
print(json.dumps(result, ensure_ascii=False))
|
||||
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", "season_changes_for_month", "moon_planet_approaches", "planet_conjunctions_for_month", "eclipses_for_month", "moon_apsides_for_month", "sun_apsides_for_month", "inner_planet_elongations_for_month", "outer_planet_events_for_month", "outer_planet_stations_for_month", "moon_star_occultations_for_month"]})
|
||||
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", "season_changes_for_month", "moon_planet_approaches", "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", "moon_star_occultations_for_month"]})
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user