MHRN-Space / src /playground /visualize /session_dashboard.py
ThomasHeisig's picture
Sync GitHub main e8a04aea24121d15707238534e635cf0ceee8eaf (part 8)
250836c verified
Raw History Blame Contribute Delete
1.01 kB
"""Compact data contract for custom playground dashboards."""
from __future__ import annotations
from collections.abc import Mapping
from .raster import raster_series
from .rate import population_rate_series
from .topology_2d import project_2d
from .topology_5d_projection import project_5d
def dashboard_payload(result: Mapping[str, object]) -> dict[str, object]:
topology = result.get("topology", {})
coordinates = (
topology.get("coordinates", []) if isinstance(topology, Mapping) else []
)
dimensions = (
int(topology.get("dimensions", 0)) if isinstance(topology, Mapping) else 0
)
projection = (
project_5d(coordinates, components=2)
if dimensions >= 4
else project_2d(coordinates)
)
return {
"manifest": result.get("manifest"),
"metrics": result.get("metrics"),
"raster": raster_series(result),
"population_rate_hz": population_rate_series(result),
"topology_projection": projection,
}