Elongation von Veuns und Merkur drin
This commit is contained in:
@@ -62,6 +62,7 @@ $planetConjunctions = [];
|
||||
$eclipseEvents = [];
|
||||
$moonApsisEvents = [];
|
||||
$sunApsisEvents = [];
|
||||
$innerPlanetElongationEvents = [];
|
||||
$moonOccultations = [];
|
||||
$seasonChanges = [];
|
||||
$monthEventList = [];
|
||||
@@ -404,6 +405,23 @@ if (is_array($sunApsisDecoded) && ($sunApsisDecoded['ok'] ?? false)) {
|
||||
$sunApsisEvents = is_array($sunApsisDecoded['events'] ?? null) ? $sunApsisDecoded['events'] : [];
|
||||
}
|
||||
|
||||
$elongationOutput = [];
|
||||
$elongationExitCode = 0;
|
||||
$elongationArgs = [
|
||||
$pythonScriptPath,
|
||||
'inner_planet_elongations_for_month',
|
||||
(string) $selectedYear,
|
||||
(string) $selectedMonth,
|
||||
$chartTimezone,
|
||||
];
|
||||
$elongationCommand = $pythonExecutable . ' ' . implode(' ', array_map('escapeshellarg', $elongationArgs)) . ' 2>&1';
|
||||
exec($elongationCommand, $elongationOutput, $elongationExitCode);
|
||||
$elongationRaw = trim(implode("\n", $elongationOutput));
|
||||
$elongationDecoded = json_decode($elongationRaw, true);
|
||||
if (is_array($elongationDecoded) && ($elongationDecoded['ok'] ?? false)) {
|
||||
$innerPlanetElongationEvents = is_array($elongationDecoded['events'] ?? null) ? $elongationDecoded['events'] : [];
|
||||
}
|
||||
|
||||
$moonPlanetOutput = [];
|
||||
$moonPlanetExitCode = 0;
|
||||
$moonPlanetArgs = [
|
||||
@@ -597,6 +615,31 @@ foreach ($sunApsisEvents as $sunApsisEvent) {
|
||||
];
|
||||
}
|
||||
|
||||
foreach ($innerPlanetElongationEvents as $elongationEvent) {
|
||||
if (!is_array($elongationEvent)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$elongationPlanet = (string) ($elongationEvent['planet_label'] ?? 'Planet');
|
||||
$elongationKind = (string) ($elongationEvent['kind'] ?? '');
|
||||
$elongationText = isset($elongationEvent['elongation_deg'])
|
||||
? number_format((float) $elongationEvent['elongation_deg'], 2, ',', '') . ' Grad'
|
||||
: '';
|
||||
$elongationLabel = $elongationKind === 'western'
|
||||
? $elongationPlanet . ' größte westliche Elongation'
|
||||
: ($elongationKind === 'eastern'
|
||||
? $elongationPlanet . ' größte östliche Elongation'
|
||||
: (string) ($elongationEvent['label'] ?? 'Elongation'));
|
||||
|
||||
$monthEventList[] = [
|
||||
'event' => trim($elongationLabel . ($elongationText !== '' ? ' (' . $elongationText . ')' : '')),
|
||||
'date' => (string) ($elongationEvent['local_date'] ?? ''),
|
||||
'time' => (string) ($elongationEvent['local_time'] ?? ''),
|
||||
'local_iso' => (string) ($elongationEvent['local_iso'] ?? ''),
|
||||
'type' => 'planet_elongation',
|
||||
];
|
||||
}
|
||||
|
||||
foreach ($moonPlanetApproaches as $approachEvent) {
|
||||
if (!is_array($approachEvent)) {
|
||||
continue;
|
||||
|
||||
Binary file not shown.
+83
-2
@@ -1154,6 +1154,82 @@ def action_sun_apsides_for_month(args: list[str]) -> dict:
|
||||
}
|
||||
|
||||
|
||||
def action_inner_planet_elongations_for_month(args: list[str]) -> dict:
|
||||
if len(args) != 3:
|
||||
fail(
|
||||
"Aktion inner_planet_elongations_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))
|
||||
|
||||
planet_defs = [
|
||||
("Merkur", astronomy.Body.Mercury, "mercury"),
|
||||
("Venus", astronomy.Body.Venus, "venus"),
|
||||
]
|
||||
|
||||
events: list[dict] = []
|
||||
for label, body, key in planet_defs:
|
||||
event = astronomy.SearchMaxElongation(body, 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:
|
||||
visibility_label = "westliche" if event.visibility == astronomy.Visibility.Morning else "oestliche"
|
||||
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",
|
||||
"elongation_deg": float(event.elongation),
|
||||
"ecliptic_separation_deg": float(event.ecliptic_separation),
|
||||
"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.SearchMaxElongation(body, event.time.AddDays(1.0))
|
||||
|
||||
events.sort(key=lambda item: item["local_iso"])
|
||||
|
||||
return {
|
||||
"ok": True,
|
||||
"action": "inner_planet_elongations_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(
|
||||
@@ -2210,7 +2286,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", "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", "moon_star_occultations_for_month"]})
|
||||
|
||||
action = sys.argv[1]
|
||||
args = sys.argv[2:]
|
||||
@@ -2280,12 +2356,17 @@ def main() -> None:
|
||||
print(json.dumps(result, ensure_ascii=False))
|
||||
return
|
||||
|
||||
if action == "inner_planet_elongations_for_month":
|
||||
result = action_inner_planet_elongations_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", "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", "moon_star_occultations_for_month"]})
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user