Skip to content

feat(xarray): load reduced Gaussian/HEALPix netCDF grids and add gridspec to xarray field geography - #1241

Merged
sandorkertesz merged 1 commit into
developfrom
feature/xarray-field-grid
Nov 29, 2026
Merged

sandorkertesz merged 1 commit into
developfrom
feature/xarray-field-grid

Conversation

@sandorkertesz

Copy link
Copy Markdown
Collaborator

Description

Description

Improves the geography of fields read from netCDF/xarray, building on earthkit-geo's grid detection.

  • Grid type: removed earthkit-data's XarrayGrid.grid_type override; fields now report earthkit-geo's grid type. Projected grids with only x/y coordinates now give "regular_xy" (or "unstructured") instead of None; to_xarray() still works for them.
  • Reduced Gaussian and HEALPix grids: the xarray reader now uses earthkit-geo's CF reduced Gaussian and HEALPix detection, so variables on these grids (one point-index dimension, no 2-D lat/lon) load as fields instead of being skipped. XarrayGrid is now a thin view over any earthkit-geo grid instead of a subclass.
  • Gridspec: grid_spec(), grid() and unique_grid_id() now work for xarray fields. The gridspec comes from earthkit-geo; it is None when it does not number the values in their stored order (wrapped longitudes, reduced Gaussian sub-areas crossing 0°). The eckit grid is built lazily, once per variable. Latitudes/longitudes still come from the xarray coordinates, so there is no extra cost at load time or when reading coordinates.
  • Shape: the field shape is taken from the grid's dimension names, so 1-D point grids give (npoints,) wherever singleton dimensions sit.
  • Bounding box: BoundingBox no longer hangs on huge or infinite longitudes (loop-free normalisation), and the xarray bounding box uses only valid points.

Tests

  • New long test tests/netcdf/test_netcdf_grid_xr.py: loads all 65 netCDF files from the remote test-data/grids/xr folder (the same files earthkit-geo tests) and checks field count, shape, grid type, lat/lon samples, bounding box and gridspec, with expected values taken from earthkit-geo's tests. Marked long_test, download and cache.
  • New tests for grid types, reduced Gaussian/HEALPix loading, gridspec, singleton dimensions and BoundingBox edge cases.

Contributor Declaration

By opening this pull request, I affirm the following:

  • All authors agree to the Contributor License Agreement.
  • The code follows the project's coding standards.
  • I have performed self-review and added comments where needed.
  • I have added or updated tests to verify that my changes are effective and functional.
  • I have run all existing tests and confirmed they pass.

@sandorkertesz sandorkertesz self-assigned this Nov 29, 2026
@sandorkertesz
sandorkertesz merged commit a930d1c into develop Nov 29, 2026
117 of 119 checks passed
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