Repository navigation
feat(xarray): input transforms, chunked GridSpec.predict, and a surface-temperature infilling example - #808
thomaspinder wants to merge 4 commits into
Conversation
from_xarray takes transforms (Standardise, UnitSphere, Cyclic) that turn the named inputs into the columns of X. The GridSpec keeps them, fitted on the training cells, and applies them to every new grid. GridSpec.predict gives the predictive mean and variance on a grid in chunks of fixed size, compiled once, and keeps a Dask-backed grid lazy. Dask is a dev dependency for the lazy-grid test only. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The example now reads a netCDF file of the 2024 NCEP-NCAR Reanalysis 1 temperature anomaly, which is complete, removes cells, and scores the GP infill against the truth. Random removal gives a global mean whose interval holds the truth; value-dependent removal shows the bias of a GP when data are missing not at random. The pull script records how the 44 KB file was made, so docs builds stay offline. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
📖 Docs preview: https://pr-808--endearing-crepe-c2d5fe.netlify.app Smoke render — the expensive notebooks run with reduced budgets, so |
Working with Gridded Data (examples/xarray_workflow, same URL) is the synthetic introduction to gpjax.xarray again, now under Getting started. It uses Standardise and GridSpec.predict, and shows UnitSphere and Cyclic. Infilling Global Surface Temperature (examples/infilling_surface_temperature) holds the reanalysis study, under Applied modelling. It also drops an empty markdown cell at the top of the notebook. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@claude-pr-review |
|
Claude finished @thomaspinder's task in 25s —— View job PR ReviewThis PR adds input transforms ( In-scope
Out-of-scope
I checked these points and found no problem: |
| _encode(name, block.ravel(), self.time_origins) | ||
| for name, block in zip(self.inputs, blocks, strict=True) | ||
| ] | ||
| input_matrix = np.stack(columns, axis=1) |
There was a problem hiding this comment.
P2 For an eager (non-Dask) grid, the whole grid is one block. This line builds the full (M, D) raw input matrix, and _encode then builds a second full copy. Only the predict_fn call is chunked. The docstring says "the memory use does not grow with the size of the grid". That is true only for Dask grids. Change the docstring to say this, for example: "Memory for predict_fn is bounded by chunk_size. For eager input, the (M, D) input matrix is still held in memory. Use Dask-backed input to bound it too." The PR description makes the same claim.
Summary
Input transforms and chunked prediction for
gpjax.xarray. The xarray introduction moves to Getting started, and a new applied example infills a real, complete reanalysis field.UnitSpheremaps lat/lon to 3D points on the unit sphere, so a stationary kernel uses the chord distance. This removes the seam at the antimeridian and the distortion at the poles.Standardisefits on the kept training cells only.Cyclicencodes periodic inputs, for example the seasonal cycle.daskis added to the dev group only, for the lazy-grid test.Evidence
Before: no transforms, and prediction needed the full
(M, D)input matrix and the full distribution in memory.After:
uv run poe test: 3256 passed, 1 skipped. The 23 new tests intests/test_xarray.pyinclude:predict == to_xarray(fn(inputs_for(grid)))forchunk_sizein {1, 5, 12, 100}, and on a fitted posteriorpredict_fnis not called) until.compute(), and then matches the eager resultUnitSphere: unit-norm rows, lon 0 ≡ 360, and all longitudes at a pole give one pointuv run poe lintanduv run poe docstringspass. A fresh docs-ci build (sphinx-build -E -W) passes with 0 warnings.Infilling Global Surface Temperature results (fit on 5°, scored on the 2.5° truth, 2024 global mean truth 0.64 K):
Merge Danger
Door: two-way
The change only adds to the public API: new classes, a new keyword with a default, and new methods.
GridSpecgets a new last field with a default, so the existing constructor calls still work.Blast Radius: small
gpjax.xarraysee the new API.examples/xarray_workflowkeeps its URL and its synthetic content, with the new API. The page moves from Applied modelling to Getting started, and the new applied page has a new URL.🤖 Generated with Claude Code