Opposition und Konjunktion eingebaut
This commit is contained in:
@@ -63,6 +63,7 @@ $eclipseEvents = [];
|
||||
$moonApsisEvents = [];
|
||||
$sunApsisEvents = [];
|
||||
$innerPlanetElongationEvents = [];
|
||||
$outerPlanetEvents = [];
|
||||
$moonOccultations = [];
|
||||
$seasonChanges = [];
|
||||
$monthEventList = [];
|
||||
@@ -422,6 +423,23 @@ if (is_array($elongationDecoded) && ($elongationDecoded['ok'] ?? false)) {
|
||||
$innerPlanetElongationEvents = is_array($elongationDecoded['events'] ?? null) ? $elongationDecoded['events'] : [];
|
||||
}
|
||||
|
||||
$outerPlanetOutput = [];
|
||||
$outerPlanetExitCode = 0;
|
||||
$outerPlanetArgs = [
|
||||
$pythonScriptPath,
|
||||
'outer_planet_events_for_month',
|
||||
(string) $selectedYear,
|
||||
(string) $selectedMonth,
|
||||
$chartTimezone,
|
||||
];
|
||||
$outerPlanetCommand = $pythonExecutable . ' ' . implode(' ', array_map('escapeshellarg', $outerPlanetArgs)) . ' 2>&1';
|
||||
exec($outerPlanetCommand, $outerPlanetOutput, $outerPlanetExitCode);
|
||||
$outerPlanetRaw = trim(implode("\n", $outerPlanetOutput));
|
||||
$outerPlanetDecoded = json_decode($outerPlanetRaw, true);
|
||||
if (is_array($outerPlanetDecoded) && ($outerPlanetDecoded['ok'] ?? false)) {
|
||||
$outerPlanetEvents = is_array($outerPlanetDecoded['events'] ?? null) ? $outerPlanetDecoded['events'] : [];
|
||||
}
|
||||
|
||||
$moonPlanetOutput = [];
|
||||
$moonPlanetExitCode = 0;
|
||||
$moonPlanetArgs = [
|
||||
@@ -640,6 +658,20 @@ foreach ($innerPlanetElongationEvents as $elongationEvent) {
|
||||
];
|
||||
}
|
||||
|
||||
foreach ($outerPlanetEvents as $outerPlanetEvent) {
|
||||
if (!is_array($outerPlanetEvent)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$monthEventList[] = [
|
||||
'event' => (string) ($outerPlanetEvent['label'] ?? 'Planetenereignis'),
|
||||
'date' => (string) ($outerPlanetEvent['local_date'] ?? ''),
|
||||
'time' => (string) ($outerPlanetEvent['local_time'] ?? ''),
|
||||
'local_iso' => (string) ($outerPlanetEvent['local_iso'] ?? ''),
|
||||
'type' => 'outer_planet_event',
|
||||
];
|
||||
}
|
||||
|
||||
foreach ($moonPlanetApproaches as $approachEvent) {
|
||||
if (!is_array($approachEvent)) {
|
||||
continue;
|
||||
|
||||
Binary file not shown.
+85
-2
@@ -1230,6 +1230,84 @@ def action_inner_planet_elongations_for_month(args: list[str]) -> dict:
|
||||
}
|
||||
|
||||
|
||||
def action_outer_planet_events_for_month(args: list[str]) -> dict:
|
||||
if len(args) != 3:
|
||||
fail(
|
||||
"Aktion outer_planet_events_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=450))
|
||||
|
||||
planet_defs = [
|
||||
("Mars", astronomy.Body.Mars, "mars"),
|
||||
("Jupiter", astronomy.Body.Jupiter, "jupiter"),
|
||||
("Saturn", astronomy.Body.Saturn, "saturn"),
|
||||
("Uranus", astronomy.Body.Uranus, "uranus"),
|
||||
("Neptun", astronomy.Body.Neptune, "neptune"),
|
||||
]
|
||||
|
||||
events: list[dict] = []
|
||||
for label, body, key in planet_defs:
|
||||
for event_kind, target_lon, event_label in [
|
||||
("opposition", 0.0, "Opposition"),
|
||||
("conjunction", 180.0, "Konjunktion"),
|
||||
]:
|
||||
event_time = astronomy.SearchRelativeLongitude(body, target_lon, scan_start)
|
||||
while True:
|
||||
event_dt_utc = time_to_datetime(event_time)
|
||||
local_dt = event_dt_utc.astimezone(tz)
|
||||
if local_dt >= local_end:
|
||||
break
|
||||
if local_dt >= local_start:
|
||||
events.append({
|
||||
"planet_key": key,
|
||||
"planet_label": label,
|
||||
"kind": event_kind,
|
||||
"label": f"{label} in {event_label}",
|
||||
"utc_iso": event_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_time = astronomy.SearchRelativeLongitude(body, target_lon, event_time.AddDays(10.0))
|
||||
|
||||
events.sort(key=lambda item: item["local_iso"])
|
||||
|
||||
return {
|
||||
"ok": True,
|
||||
"action": "outer_planet_events_for_month",
|
||||
"selected": {
|
||||
"year": year,
|
||||
"month": month,
|
||||
"timezone": timezone_name,
|
||||
},
|
||||
"events": events,
|
||||
}
|
||||
|
||||
|
||||
def action_moon_star_occultations_for_month(args: list[str]) -> dict:
|
||||
if len(args) != 7:
|
||||
fail(
|
||||
@@ -2286,7 +2364,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", "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", "outer_planet_events_for_month", "moon_star_occultations_for_month"]})
|
||||
|
||||
action = sys.argv[1]
|
||||
args = sys.argv[2:]
|
||||
@@ -2361,12 +2439,17 @@ def main() -> None:
|
||||
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))
|
||||
return
|
||||
|
||||
if action == "moon_star_occultations_for_month":
|
||||
result = action_moon_star_occultations_for_month(args)
|
||||
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", "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", "outer_planet_events_for_month", "moon_star_occultations_for_month"]})
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user