Epic: #31 · Depends on: #33
Background
The heart of the migration. The original loops per (country, time, target), gathers that country's grid cells + the country total, calls the scaling math, and scatters the result back (views_reporting/.../dataset_export.py to_reconciler / reconcile_pg_dataset). We do the same, frames-native and vectorised, on top of the slice-1 leaf reconcile_proportional (PR #30, views_postprocessing/reconciliation/proportional.py).
Work
- Take a cm frame, a pgm frame, and an injected
(time, priogrid_gid) → country_id mapping.
- Use
views_frames.cross_level_align to label each pgm row with its country; group by (time, country_id); for each group gather the cells + the matching country total, call reconcile_proportional, and scatter the result back into a new pgm frame.
- Pure numpy + views-frames; avoid per-row Python loops where vectorisable.
Acceptance criteria
Validation
- Unit tests on the grouping/scatter against hand-computed small cases + S0-fixture slices.
Notes
cross_level_align requires a (time, unit)-keyed mapping. Our geography is time-invariant, so broadcast the static cell→country assignment over the frame's (time, unit) rows (or use cross_level_align_arrays at scale).
Epic: #31 · Depends on: #33
Background
The heart of the migration. The original loops per
(country, time, target), gathers that country's grid cells + the country total, calls the scaling math, and scatters the result back (views_reporting/.../dataset_export.pyto_reconciler/reconcile_pg_dataset). We do the same, frames-native and vectorised, on top of the slice-1 leafreconcile_proportional(PR #30,views_postprocessing/reconciliation/proportional.py).Work
(time, priogrid_gid) → country_idmapping.views_frames.cross_level_alignto label each pgm row with its country; group by(time, country_id); for each group gather the cells + the matching country total, callreconcile_proportional, and scatter the result back into a new pgm frame.Acceptance criteria
Validation
Notes
cross_level_alignrequires a(time, unit)-keyed mapping. Our geography is time-invariant, so broadcast the static cell→country assignment over the frame's(time, unit)rows (or usecross_level_align_arraysat scale).