Skip to content

Alternative grid spacing#2331

Draft
bayliffe wants to merge 9 commits intometoppv:masterfrom
bayliffe:alternative_grid_spacing
Draft

Alternative grid spacing#2331
bayliffe wants to merge 9 commits intometoppv:masterfrom
bayliffe:alternative_grid_spacing

Conversation

@bayliffe
Copy link
Copy Markdown
Contributor

An alternative implementation that avoids the global variables and keeps the values where they are used. Uses None as default in most interfaces to avoid the need for the globals, and then sets the value in calculate_input_grid_spacing if it receives None.

I've not modified any of your tests as they all pass with this set of changes.

rachaelesler and others added 9 commits March 12, 2026 11:42
This feature allows users of the `regrid` CLI to supply a relative
tolerance for grid spacing checks, e.g.,

```
improver regrid <cubes> --rtol-grid-spacing=4.0e-3
```

Previously, this relative tolerance was hard-coded into a function.
The change in this commit enables users to use the `regrid` CLI with
grids that have minor discrepancies in latitude/longitude spacing.

The new `--rtol-grid-spacing` argument is only used for certain regrid
modes ("nearest-2", "nearest-with-mask-2","bilinear-2", and
"bilinear-with-mask-2").

The new `--rtol-grid-spacing` argument is optional and it takes a
default value. The default value is the hard-coded value that existed
previously. This means that existing systems that uses the `regrid` CLI
will not be affected by this change.

This changeset includes:

* Add `--rtol-grid-spacing` argument to `regrid` CLI
* Update the classes `RegridLandSea` and `RegridWithLandSeaMask` to
have a new attribute, `rtol_grid_spacing`
* Update the `calculate_input_grid_spacing()` function in
`improver/regrid/grid.py` with a new argument, `rtol`, which is the
relative tolerance that will be used when calculating grid spacing.
* Use constants for default grid spacing rtols (rather than magic
numbers)
* Update `calculate_grid_spacing()` function in
`improver/utilities/spatial.py` with more input validation
* Unit and acceptance tests for all of the above

Closes metoppv#2307
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.

2 participants