Skip to content

Read NetCDF basemaps without materializing every grid cell - #67

Open
crvernon wants to merge 1 commit into
v3/perf-serial-passesfrom
v3/netcdf-reader-memory
Open

crvernon wants to merge 1 commit into
v3/perf-serial-passesfrom
v3/netcdf-reader-memory

Conversation

@crvernon

Copy link
Copy Markdown
Member

Stacked PR — part of the Demeter v3.0.0 upgrade. Base: v3/perf-serial-passes. Review and merge in order, bottom of the stack first.

Plan items: 2.2

Benchmark: Exact frame equality. Memory 4.2 → 1.4 GB on a 12M-cell grid.

Commits

Read NetCDF basemaps without materializing every grid cell

_read_observed_netcdf built ds.to_dataframe() over every lat x lon
cell and every variable before dropping missing cells.
_valid_cells_frame builds the same frame, with the same rows, order,
index, columns, and dtypes, by masking valid cells one variable at a
time. It falls back to the original expression for layouts it does not
handle.

On a 3,000 x 4,000 grid with 20 variables and 30% valid cells it
allocates 1.4 GB instead of 4.2 GB and runs in 0.18 s instead of 0.51 s.
It returns an exactly equal frame for the bundled global basemap and
for a grid with reversed dimension order, float32 values, and NaNs that
differ by variable (new test).

The NetCDF and CSV parity test passes. The CSV path is unchanged.

🤖 Generated with Claude Code

_read_observed_netcdf built ds.to_dataframe() over every lat x lon
cell and every variable before dropping missing cells.
_valid_cells_frame builds the same frame, with the same rows, order,
index, columns, and dtypes, by masking valid cells one variable at a
time. It falls back to the original expression for layouts it does not
handle.

On a 3,000 x 4,000 grid with 20 variables and 30% valid cells it
allocates 1.4 GB instead of 4.2 GB and runs in 0.18 s instead of 0.51 s.
It returns an exactly equal frame for the bundled global basemap and
for a grid with reversed dimension order, float32 values, and NaNs that
differ by variable (new test).

The NetCDF and CSV parity test passes. The CSV path is unchanged.

Co-Authored-By: Claude <noreply@anthropic.com>

This branch has not been deployed

No deployments
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