Erweitere Baryzentrum-Übergangstabelle

This commit is contained in:
2026-08-30 20:14:49 +02:00
parent 09dc6198ac
commit 0427e3cf2c
2 changed files with 115 additions and 1 deletions
+91 -1
View File
@@ -5,6 +5,7 @@ session_start();
require_once __DIR__ . '/python_api.php';
$result = runPythonApi('barycenter', ['20', '365', '24']);
$eventsResult = runPythonApi('barycenter', ['20', '24', '100']);
require __DIR__ . '/header.php';
@@ -179,6 +180,46 @@ input[type=range].bc-slider {
color: var(--gold);
border: 1px solid var(--border);
}
.bc-events-card {
margin-top: 1.5rem;
}
.bc-events-table-wrap {
overflow-x: auto;
}
.bc-events-table {
width: 100%;
border-collapse: collapse;
font-size: 0.88rem;
}
.bc-events-table th,
.bc-events-table td {
padding: 0.65rem 0.75rem;
border-bottom: 1px solid var(--border);
text-align: left;
}
.bc-events-table th {
color: var(--text-dim);
font-size: 0.75rem;
letter-spacing: 0.05em;
text-transform: uppercase;
}
.bc-events-table tr:last-child td {
border-bottom: 0;
}
.bc-event-enters td {
background: rgba(79,195,216,0.10);
}
.bc-event-enters td:last-child {
color: var(--cyan);
font-weight: 600;
}
.bc-event-leaves td {
background: rgba(201,168,76,0.10);
}
.bc-event-leaves td:last-child {
color: var(--gold);
font-weight: 600;
}
</style>
<?php if (!$result['ok']): ?>
@@ -191,6 +232,7 @@ input[type=range].bc-slider {
$projDistSR = $cur['proj_dist_solar_radii'];
$inside = $cur['inside_sun'];
$contributions = $result['data']['contributions'];
$thresholdEvents = $eventsResult['ok'] ? ($eventsResult['data']['threshold_events'] ?? []) : [];
?>
<div class="bc-stats-row">
@@ -305,6 +347,38 @@ input[type=range].bc-slider {
</div>
</div>
<div class="card bc-events-card">
<h2>Übertritte an der Sonnenoberfläche</h2>
<p style="font-size:0.88rem;color:var(--text-dim);line-height:1.6;margin-bottom:0.9rem">
20 Jahre vor heute bis 100 Jahre danach, bezogen auf die XY-Projektion.
</p>
<div class="bc-events-table-wrap">
<table class="bc-events-table">
<thead>
<tr>
<th>Datum (UTC)</th>
<th>Ereignis</th>
</tr>
</thead>
<tbody>
<?php if ($thresholdEvents === []): ?>
<tr><td colspan="2">Im gewählten Zeitraum gibt es keine Übertritte.</td></tr>
<?php else: ?>
<?php foreach ($thresholdEvents as $event):
$eventDate = new DateTimeImmutable($event['date_utc']);
$movesInside = ($event['state'] ?? '') === 'inside';
?>
<tr class="<?= $movesInside ? 'bc-event-enters' : 'bc-event-leaves' ?>">
<td><?= $eventDate->format('d.m.Y') ?></td>
<td><?= $movesInside ? 'Baryzentrum betritt die Sonne' : 'Baryzentrum verlässt die Sonne' ?></td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
<script>
(function () {
const SERIES = <?= json_encode($result['data']['series'], JSON_UNESCAPED_UNICODE) ?>;
@@ -341,6 +415,14 @@ input[type=range].bc-slider {
return y + '-' + String(m).padStart(2, '0');
}
function formatCanvasDate(dateValue) {
const date = formatDate(dateValue);
const parts = date.split('-');
return parts.length === 3
? parts[2] + '.' + parts[1] + '.' + parts[0]
: date;
}
function resize() {
const wrap = document.getElementById('bc-canvas-wrap');
const size = wrap.clientWidth;
@@ -464,6 +546,14 @@ input[type=range].bc-slider {
ctx.fillStyle = 'rgba(255,255,255,0.65)';
ctx.textAlign = 'left';
ctx.fillText(pCur.dp.toFixed(3) + ' R☉', px + 8, py - 6);
// Datum der aktuell dargestellten Position unten links in der Grafik.
const canvasDate = formatCanvasDate(DATES[end]);
ctx.font = '600 13px sans-serif';
ctx.fillStyle = 'rgba(0,0,0,0.45)';
ctx.fillRect(10, H - 29, ctx.measureText(canvasDate).width + 16, 20);
ctx.fillStyle = 'rgba(255,255,255,0.9)';
ctx.fillText(canvasDate, 18, H - 15);
}
function updateLabel() {
@@ -519,7 +609,7 @@ input[type=range].bc-slider {
}
let last = null;
const msPerStep = 30; // ~33 fps, 1 step per frame
const msPerStep = 1000 / 24; // 24 Bilder pro Sekunde
function step(ts) {
if (!animPlaying) return;
if (last === null || ts - last >= msPerStep) {
+24
View File
@@ -5801,8 +5801,11 @@ def action_barycenter(args: list[str]) -> dict:
days_per_step = 365.25 / steps_per_year
start_jd = now_time.tt - years_back * 365.25
series = []
threshold_events = []
max_dist_au = 0.0
max_proj_dist_au = 0.0
previous_time_tt = None
previous_inside = None
for i in range(total_steps + 1):
t = astronomy.Time(start_jd + i * days_per_step)
s = astronomy.BaryState(astronomy.Body.Sun, t)
@@ -5813,6 +5816,26 @@ def action_barycenter(args: list[str]) -> dict:
max_dist_au = d
if dp > max_proj_dist_au:
max_proj_dist_au = dp
inside_sun = dp <= _SUN_RADIUS_AU
if previous_time_tt is not None and inside_sun != previous_inside:
left_tt = previous_time_tt
right_tt = t.tt
for _ in range(24):
middle_tt = (left_tt + right_tt) / 2
middle_sun = astronomy.BaryState(astronomy.Body.Sun, astronomy.Time(middle_tt))
middle_inside = math.hypot(-middle_sun.x, -middle_sun.y) <= _SUN_RADIUS_AU
if middle_inside == previous_inside:
left_tt = middle_tt
else:
right_tt = middle_tt
event_dt = datetime(2000, 1, 1, 12, tzinfo=timezone.utc) + timedelta(days=(left_tt + right_tt) / 2)
threshold_events.append({
"date_utc": event_dt.strftime("%Y-%m-%dT%H:%M:%SZ"),
"state": "inside" if inside_sun else "outside",
})
previous_time_tt = t.tt
previous_inside = inside_sun
dt_utc = datetime(2000, 1, 1, 12, tzinfo=timezone.utc) + timedelta(days=t.tt - 0.0)
# Epoche J2000.0 = 2000-01-01 12:00 TT ≈ UTC (Differenz <1 min hier vernachlässigt)
series.append({
@@ -5889,6 +5912,7 @@ def action_barycenter(args: list[str]) -> dict:
},
"series": series,
"series_dates": series_dates,
"threshold_events": threshold_events,
"now_index": now_index,
"max_dist_solar_radii": round(max_dist_au / _SUN_RADIUS_AU, 3),
"max_proj_dist_solar_radii": round(max_proj_dist_au / _SUN_RADIUS_AU, 3),