text stringlengths 0 251 |
|---|
palette = {} |
def normalize_panel( |
panel: dict[str, object], |
palette: dict[str, object], |
) -> dict[str, object]: |
panel_palette = panel.get("palette", {}) |
if not isinstance(panel_palette, dict): |
panel_palette = {} |
effective_palette = { |
**palette, |
**panel_palette, |
} |
axis_labels = panel.get("axis_labels", {}) |
if not isinstance(axis_labels, dict): |
axis_labels = {} |
normalized = { |
"title": panel.get("title"), |
"x_label": panel.get( |
"x_label", |
panel.get("x_axis_label", axis_labels.get("x")), |
), |
"y_label": panel.get( |
"y_label", |
panel.get("y_axis_label", axis_labels.get("y")), |
), |
"event_id": panel.get("event_id"), |
} |
scales = panel.get( |
"axis_scales", |
panel.get("scales", {}), |
) |
if not isinstance(scales, dict): |
scales = {} |
normalized["x_scale"] = panel.get("x_scale", scales.get("x")) |
normalized["y_scale"] = panel.get("y_scale", scales.get("y")) |
limits = panel.get( |
"axis_limits", |
panel.get("limits", {}), |
) |
if not isinstance(limits, dict): |
limits = {} |
normalized["x_limits"] = panel.get("x_limits", limits.get("x")) |
normalized["y_limits"] = panel.get("y_limits", limits.get("y")) |
bounds = panel.get( |
"pixel_bounds_top_left", |
panel.get( |
"pixel_bounds_top_left_origin", |
panel.get("pixel_bounds"), |
), |
) |
if isinstance(bounds, dict): |
left = bounds.get("left") |
top = bounds.get("top") |
right = bounds.get("right") |
bottom = bounds.get("bottom") |
if right is None and left is not None: |
right = float(left) + float(bounds.get("width")) |
if bottom is None and top is not None: |
bottom = float(top) + float(bounds.get("height")) |
bounds = [left, top, right, bottom] |
normalized["pixel_bounds_top_left"] = bounds |
submitted_series = panel.get("series") |
if submitted_series is None: |
event_id = panel.get("event_id") |
if { |
"precursor", |
"primary", |
"quiet", |
"bow_shock", |
} <= set(effective_palette): |
submitted_series = { |
"precursor": { |
"event_id": "precursor", |
"x_field": "energy_kev", |
"y_field": "transient_mean", |
}, |
"primary": { |
"event_id": "primary", |
"x_field": "energy_kev", |
"y_field": "transient_mean", |
}, |
"quiet": { |
"x_field": "energy_kev", |
"y_field": "quiet_mean", |
}, |
"bow_shock": { |
"x_field": "energy_kev", |
"y_field": "bow_shock_mean", |
}, |
} |
elif ( |
event_id in EVENT_IDS |
and {"low_energy", "high_energy"} |
<= set(effective_palette) |
): |
submitted_series = { |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.