Skip to content

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

Open
gaoflow wants to merge 1 commit into
xarray-contrib:mainfrom
gaoflow:fix-645-romsds-missing-standard-names
Open

Add standard names to romsds so decode_vertical_coords works as documented#650
gaoflow wants to merge 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

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>
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.

1 participant