Skip to content

mosaic.from_list: read only the window of each file for an unweighted mosaic with bounds - #65

Merged
SmithB merged 1 commit into
mainfrom
from_list_bounded_reads
Oct 18, 2026
Merged

SmithB merged 1 commit into
mainfrom
from_list_bounded_reads

Conversation

@SmithB

@SmithB SmithB commented Oct 18, 2026

Copy link
Copy Markdown
Owner

What

grid.mosaic.from_list(..., bounds=...) already dropped the inputs that fall outside bounds, but then read every remaining input whole (the setup_fields prototype and replace()) and cropped afterwards. With this change, an unweighted (replace) mosaic passes bounds to the readers, so only each file's window is read. The readers select cells with the same >= / <= test as crop(), so the mosaic is unchanged.

A weighted mosaic (pad or feather) still reads its inputs whole, because its weights are measured from each input's own edges and a window would move them.

Why

ATL1415's ATL11_to_ATL15 reads its --ATL14_reference_file this way once per monthly tile, and Antarctic monthly will read up to four sector ATL14s per tile from S3. Measured on the ADE for one 60 km tile of ATL14_GL_0332_100m_006_02.nc on S3 (641 x 641 window):

time peak RSS
before (whole file, then crop) 113-225 s 6.5 GiB
this branch 15.6 s 0.21 GiB

h, h_sigma, x and y are identical (np.array_equal, NaNs equal).

Also fixed

setup_bounds_from_list rebound an in-memory grid to its cropped copy and then could not remove it from the list (ValueError: list.remove(x)) when it fell outside bounds.

Tests

tests/test_mosaic_list.py: bounded replace mosaics equal the crop of whole tiles (2-D and 3-D groups; serial, workers, block_size; local and an in-memory remote), a spy that every data read is inside the window, and a netCDF root-group case like the ATL14 reference read. Full suite: 345 passed, 3 skipped.

🤖 Generated with Claude Code

…le's window

from_list with bounds dropped the inputs outside them, then read every
remaining input WHOLE (setup_fields' prototype and replace()) and cropped
after.  ATL11_to_ATL15 reads its reference ATL14 this way, once per tile:
for one 60 km tile of the GL ATL14 on S3 that was 113-225 s and 6.5 GiB
of memory for a 641 x 641 window; reading the window is 15.6 s and
0.21 GiB, and the mosaic is identical (h, h_sigma, x, y).  The readers'
bounds select cells with the same >= / <= test as crop().  A weighted
mosaic (pad or feather) still reads whole inputs: its weights are measured
from each input's own edges.

Also: setup_bounds_from_list rebound an in-memory grid to its cropped copy
and then could not remove it from the list (ValueError) when it fell
outside bounds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@SmithB
SmithB merged commit 1c23042 into main Oct 18, 2026
2 checks passed
@SmithB
SmithB deleted the from_list_bounded_reads branch October 19, 2026 22:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant