You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Two separate costs make a regional crop of a large SCRIP mesh scale with the whole mesh rather than the crop. The first is fixable in the subsetting code; the second is a reader/representation question and is the harder one.
1. Grid.bounds is computed for every face before any filtering.
subset.bounding_box filters on face_bounds_lon/lat, which come from _populate_face_bounds (uxarray/grid/bounds.py:84-96). That materializes the node coordinate and connectivity arrays with .values regardless of how the grid was opened. Measured, 12-corner SCRIP, crop fixed at ~0.006% of the mesh:
n_face
crop
memory
400,000
26 faces
+0.076 GiB
1,600,000
116 faces
+0.851 GiB
Asking for a smaller box does not help — the index is built before the box is consulted.
2. face_node_connectivity is a lazy graph over the dedup, so any slice replays it.
On the 63 GB CONUS-RRM np4 grid (299,999,162 faces), after open_grid leaves ~119 GiB resident, even a contiguousconn[:30M] kills a 236 GiB worker: computing the connectivity re-reads the 53.6 GiB corner arrays.
The decisive measurement is crop-size independence:
crop
candidates
outcome
Texas
30,914,134
killed on slice
Key West
15,866
killed on slice
A 2000× smaller crop fails identically, so the cost is not the crop.
For contrast, the pg2 twin — same 200 m geometry, 4 corners instead of 12 — subsets in 113 s.
What did you expect to happen?
That a regional crop costs something proportional to the region, and that a mesh which can be opened can also be subset.
Persist connectivity after dedup, so slicing does not replay the graph — addresses (2).
Subset SCRIP at the file level, bypassing global connectivity entirely. grid_center_lat/lon gives candidates and grid_corner_lat/lon settles them exactly; neither needs node dedup. Prototyped outside uxarray against the 63 GB file: Key West returns 8,858 faces in 39 s at 0.47 GiB, verified to return the identical face set to subset.bounding_box on every SCRIP mesh small enough for both to run. The file is chunking=contiguous, so candidate rows are direct seeks.
Do not hold both coordinate representations: node_x/y/z are derivable from node_lon/lat and are ~46% of what survives a subset.
A narrower INT_DTYPE for connectivity would halve another array, but #1658 shows INT_FILL_VALUE does not survive that narrowing — mentioned only to rule it out.
Version
2026.9.0 (and
main)How did you install UXarray?
Source
What happened?
Two separate costs make a regional crop of a large SCRIP mesh scale with the whole mesh rather than the crop. The first is fixable in the subsetting code; the second is a reader/representation question and is the harder one.
1.
Grid.boundsis computed for every face before any filtering.subset.bounding_boxfilters onface_bounds_lon/lat, which come from_populate_face_bounds(uxarray/grid/bounds.py:84-96). That materializes the node coordinate and connectivity arrays with.valuesregardless of how the grid was opened. Measured, 12-corner SCRIP, crop fixed at ~0.006% of the mesh:Asking for a smaller box does not help — the index is built before the box is consulted.
2.
face_node_connectivityis a lazy graph over the dedup, so any slice replays it.On the 63 GB CONUS-RRM np4 grid (299,999,162 faces), after
open_gridleaves ~119 GiB resident, even a contiguousconn[:30M]kills a 236 GiB worker: computing the connectivity re-reads the 53.6 GiB corner arrays.The decisive measurement is crop-size independence:
A 2000× smaller crop fails identically, so the cost is not the crop.
For contrast, the
pg2twin — same 200 m geometry, 4 corners instead of 12 — subsets in 113 s.What did you expect to happen?
That a regional crop costs something proportional to the region, and that a mesh which can be opened can also be subset.
Can you provide a MCVE to reproduce the bug?
Run at 400000 and 1600000: per-face cost stays flat while the crop stays at ~0.006%.
Possible directions
Not prescribing a fix; each is a design call.
grid_center_lat/longives candidates andgrid_corner_lat/lonsettles them exactly; neither needs node dedup. Prototyped outside uxarray against the 63 GB file: Key West returns 8,858 faces in 39 s at 0.47 GiB, verified to return the identical face set tosubset.bounding_boxon every SCRIP mesh small enough for both to run. The file ischunking=contiguous, so candidate rows are direct seeks.node_x/y/zare derivable fromnode_lon/latand are ~46% of what survives a subset.A narrower
INT_DTYPEfor connectivity would halve another array, but #1658 showsINT_FILL_VALUEdoes not survive that narrowing — mentioned only to rule it out.