Skip to content

Irregular grid - #1213

Merged
riclarsson merged 2 commits into
atmtools:mainfrom
riclarsson:irregular-grid
Dec 2, 2026
Merged

riclarsson merged 2 commits into
atmtools:mainfrom
riclarsson:irregular-grid

Conversation

@riclarsson

Copy link
Copy Markdown
Contributor

AI summary:

Irregular (lat, lon) data for all six fields

Adds field data defined on an irregular set of (lat, lon) positions, for example satellite footprints. All six fields accept it: atmosphere, surface and subsurface, each in a spectral and a non-spectral version.

New types (src/core/geodesy/irregular_spherical_grid.*)

  • IrregularSphericalGrid: a list of (lat, lon) positions. Interpolation weights are the normalised inverse squared angular distance to every position, and a query exactly at a position returns that position's value.
  • IrregularGeodeticData2, IrregularGeodeticData3, IrregularSpectralGeodeticData2, IrregularSpectralGeodeticData3: data on that grid, optionally with frequency and/or altitude grids. They have XML IO, formatting and Python bindings.

The method is meant for queries near the positions, such as tracking footprints. Far from all of them the weights tend towards a plain average.

Integration

Field data Irregular type
SurfaceData IrregularGeodeticData2
AtmData, SubsurfaceData IrregularGeodeticData3
SurfaceSpectralData IrregularSpectralGeodeticData2
AtmSpectralData, SubsurfaceSpectralData IrregularSpectralGeodeticData3
  • Values, flat views and flat weights (Jacobians) are supported, as are data_type, ok(), XML through the data variant, and implicit construction from Python. NLTE level densities from LTE support IrregularGeodeticData3 too.
  • log_interpolation is supported.
  • Altitude and frequency extrapolation flags work as for gridded data. Latitude and longitude flags don't apply, because the irregular grid has no edges, and are set to Nearest.

Fixes and behaviour changes

  • Flat weights outside the grid: in AtmData, SubsurfaceData and SurfaceData, at() and flat_weight() now derive from one extrapolation step. Before, the weights always described linear extrapolation, whatever the flag. Now:

    • Zero gives no weights.
    • Nearest gives the weights at the grid edge.
    • None throws in both.

    This changes Jacobians for retrievals that reach outside a field's grid.

  • SurfaceData precedence: None now takes precedence over Zero, as in the other fields, and the error message changed to match the spectral fields.

  • Empty grids now throw a clear error instead of reading front() of an empty grid.

  • Exhaustive visits: visits over field data use one overload per type, or end in a static_assert naming the last known type. A new variant alternative now fails to compile instead of silently taking a default branch.

Other changes

  • lagrange_type now spells out its requirements and accepts runtime-sized lags (distance_lag_t).
  • gridded_data_t grids must satisfy a new grid_type concept.
  • atm, surface and subsurface link geodesy.
  • doc/arts/dev.doc.rst documents two rules:
    • In the workspace registry, *Name* must name an existing workspace item.
    • Every Python attribute docstring needs one .. :class: line per type it can hold. The check target enforces this; bare ctest doesn't.

Tests

  • tests/core/surf/irregular_fields.py: all six fields against an independent numpy reference. It covers values, log interpolation, flat weights (checked by finite differences in the log case), every altitude/frequency extrapolation mode and an XML round trip.
  • tests/core/atm/field_extrapolation_weights.py: in every extrapolation mode, the flat weights of AtmData, SubsurfaceData and SurfaceData reproduce the value.
  • tests/core/surf/irreg_surface.py: a plotting example on SurfaceData, which checks that the data are reproduced at their positions and that every value stays between their minimum and maximum.
  • ninja check passes, 323/323.

🤖 Generated with Claude Code

@riclarsson
riclarsson merged commit 088defe into atmtools:main Dec 2, 2026
9 checks passed
@riclarsson
riclarsson deleted the irregular-grid branch December 2, 2026 11:35
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