Add optional variable-aware regridding#406
Conversation
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (68.4%) is below the target coverage (90.0%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #406 +/- ##
=======================================
- Coverage 74.9% 74.8% -0.1%
=======================================
Files 28 29 +1
Lines 5246 5545 +299
Branches 963 1012 +49
=======================================
+ Hits 3929 4146 +217
- Misses 1092 1152 +60
- Partials 225 247 +22
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
charles-turner-1
left a comment
There was a problem hiding this comment.
Couple minor comments and theres a fair amount of missing coverage but not spotting anything that worries me!
| method: str, | ||
| weight_path: Path, | ||
| ) -> xr.Dataset: | ||
| del method # Method is encoded in the weight file; kept for future validation. |
There was a problem hiding this comment.
This seems kinda weird to me?
| def main(argv: list[str] | None = None) -> None: | ||
| parser = argparse.ArgumentParser( | ||
| description="Create ACCESS-MOPPy cached regridding weights" | ||
| ) | ||
| subparsers = parser.add_subparsers(dest="command", required=True) | ||
| create = subparsers.add_parser("create", help="create xESMF/ESMF weight file") | ||
| create.add_argument( | ||
| "--source-grid", | ||
| required=True, | ||
| help="NetCDF file containing source grid coordinates/bounds", | ||
| ) | ||
| create.add_argument( | ||
| "--target-grid", required=True, help="Target grid name, e.g. cmip7-1x1" | ||
| ) | ||
| create.add_argument("--method", required=True, choices=sorted(REGRID_METHODS)) | ||
| create.add_argument("--output", required=True, help="Output weight NetCDF file") | ||
| args = parser.parse_args(argv) | ||
| if args.command == "create": | ||
| path = create_weights( | ||
| args.source_grid, args.target_grid, args.method, args.output | ||
| ) | ||
| print(f"Created regridding weights: {path}") | ||
|
|
||
|
|
||
| if __name__ == "__main__": |
There was a problem hiding this comment.
I'm not totally sure this is the right place for the entry point? I had a look through some of the other files (base, driver, ocean) and it doesn't look like they have similar ones - is there a cli.py or something?
There was a problem hiding this comment.
This file would probably benefit from docstrings. Nothing looks alarming without it and the functions are generally pretty short but I think it'd make it more readable
Summary
Adds opt-in regridding to the CMORisation pipeline via a new
access_moppy.regridmodule. Native-grid output remains the default; regridding is activated by adding aregrid:block to the batch config.Changes
access_moppy.regrid:RegridConfig/WeightConfigparsing, variable-aware method selection, cached sparse-weight application (no ESMF at runtime), xESMF-based weight generation, built-incmip7-1x1target grid.conservativefor flux/extensive quantities,bilinearfor smooth state fields,nearest_s2dfor masks/categories, vector fields refused with a clear error.ACCESS_ESM_CMORiser, realm CMORisers, and batch templates.moppy-regrid-weightsentry point for pre-generating weight files.grid_label,grid, regularlat/lon+ bounds, removes stale native-gridcell_measures.docs/source/regridding.rst+ example config block.Verification
python3 -m compileall -q src/access_moppy tests/unit/test_regrid.py✅git diff --check✅Known limitations / follow-up
cmip7-1x1target grid; a target-grid registry is planned.