Skip to content

Add standard names to romsds so decode_vertical_coords works as documented#650

Merged
dcherian merged 1 commit into
xarray-contrib:mainfrom
gaoflow:fix-645-romsds-missing-standard-names
Jun 19, 2026
Merged

Add standard names to romsds so decode_vertical_coords works as documented#650
dcherian merged 1 commit into
xarray-contrib:mainfrom
gaoflow:fix-645-romsds-missing-standard-names

Conversation

@gaoflow

@gaoflow gaoflow commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Fixes #645.

Problem

decode_vertical_coords raises on the bundled romsds dataset, including in the documented example:

from cf_xarray.datasets import romsds
romsds.cf.decode_vertical_coords(outnames={"s_rho": "z_rho"})
# ValueError: The standard name for the 'depth' variable is not available.

romsds.s_rho declares formula_terms = "... eta: zeta depth: h ...", but the bundled h (depth) and zeta (eta) coordinates carry no standard_name. _derive_ocean_stdname needs those to look up the computed standard name, so it fails. Tellingly, the existing test_decode_vertical_coords worked around this by assigning the two standard_names inline before calling decode_vertical_coords — i.e. the bundled dataset was incomplete.

Fix

Give the bundled romsds h and zeta the standard names they need (sea_floor_depth_below_geopotential_datum and sea_surface_height_above_geopotential_datum — the same values the test was setting inline), so the dataset works as documented out of the box.

The now-redundant inline assignments are dropped from test_decode_vertical_coords, so the test exercises the bundled dataset directly and will catch a regression of this kind. decode_vertical_coords now yields z_rho with the computed standard name height_above_geopotential_datum.

Testing

test_parametric.py and test_accessor.py pass (205 passed, 24 skipped). The decode test fails without this change (the original ValueError) and passes with it. ruff check and ruff format are clean.


This change was prepared by an AI agent under my direction; I reviewed and verified it.

The bundled romsds dataset's depth (h) and eta (zeta) variables had no
standard_name, so decode_vertical_coords could not derive the computed
standard name and raised 'The standard name for the depth variable is not
available' - including in the documented example. Add the standard names
(matching what the existing test set inline) so the dataset is usable as
documented, and drop the now-redundant inline assignments from the test.

Fixes xarray-contrib#645.

Signed-off-by: gaoflow <gaobing1230@gmail.com>
@dcherian dcherian enabled auto-merge (squash) June 19, 2026 14:17
@dcherian dcherian merged commit 01b3ad2 into xarray-contrib:main Jun 19, 2026
11 checks passed
@codecov

codecov Bot commented Jun 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.10%. Comparing base (a9cebee) to head (3ee86d2).
⚠️ Report is 124 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #650      +/-   ##
==========================================
+ Coverage   85.78%   87.10%   +1.32%     
==========================================
  Files          13       16       +3     
  Lines        2364     3320     +956     
  Branches      183      309     +126     
==========================================
+ Hits         2028     2892     +864     
- Misses        303      381      +78     
- Partials       33       47      +14     
Flag Coverage Δ
mypy 46.23% <ø> (+7.69%) ⬆️
unittests 92.61% <ø> (-1.38%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

docode_vertical_coords : The standard name for the 'depth' variable is not available.

2 participants