Skip to content

fix(convert): MITgcm netCDF C-grid xgcm axes and coords for #2484#2555

Open
amit221 wants to merge 2 commits intoParcels-code:mainfrom
amit221:fix/issue-2484
Open

fix(convert): MITgcm netCDF C-grid xgcm axes and coords for #2484#2555
amit221 wants to merge 2 commits intoParcels-code:mainfrom
amit221:fix/issue-2484

Conversation

@amit221
Copy link

@amit221 amit221 commented Mar 24, 2026

Summary

This fixes convert.mitgcm_to_sgrid for MITgcm netCDF circulation-model data where velocity fields use C-grid staggered dimensions Xp1 / Yp1 (instead of XC / YC). Previously, FieldSet.from_sgrid_conventions failed with ValueError: Dimension "Xp1" has no axis attribute because those dims were not wired to the xgcm X/Y axes after conversion.

Changes:

  • Emit SGRID face_dimensions that map Xp1 / Yp1 onto the xgcm X/Y axes when present (with LOW padding so lon / lat stay on the non-center positions expected by XGrid). Fall back to the existing XC / YC + HIGH padding behavior when Xp1 / Yp1 are absent.
  • Accept either Zl or depth in the coords subset (for workflows that rename cell-center Z to depth); map depth to axis Z in _MITGCM_AXIS_VARNAMES.
  • Run _maybe_convert_time_from_float_to_timedelta for MITgcm output, consistent with croco_to_sgrid.
  • Add regression test test_convert_mitgcm_netcdf_circulation_model_to_fieldset mirroring the issue snippet.

How to test

From the repo root, with the test pixi environment (see contributing docs):

pixi run -e test tests -- tests/test_convert.py::test_convert_mitgcm_netcdf_circulation_model_to_fieldset

Optionally run the full convert tests:

pixi run -e test tests -- tests/test_convert.py

Fixes #2484

…ode#2484

- Emit SGRID face_dimensions that map Xp1/Yp1 onto the xgcm X/Y axes when
  present (LOW padding keeps lon/lat on non-center positions for XGrid).
- Accept Zl or depth in coords; set axis Z on depth when used.
- Convert float model time to timedelta like croco_to_sgrid.

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

convert.mitgcm_to_sgrid breaks on datasets_circulation_models["ds_MITgcm_netcdf"]

1 participant