Skip to content

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

@knutfrode

Description

@knutfrode

Hi,

I am not able to get decode_vertical_coords to work, and it also fails in the documentation:
https://cf-xarray.readthedocs.io/en/stable/parametricz.html#decoding-parametric-coordinates

>>> from cf_xarray.datasets import romsds
>>> romsds.cf.decode_vertical_coords(outnames={'s_rho': 'z_rho'})  # adds new z_rho variable

Traceback (most recent call last):
  File "<python-input-0>", line 2, in <module>
    romsds.cf.decode_vertical_coords(outnames={'s_rho': 'z_rho'})  # adds new z_rho variable
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/knutfd/micromamba/envs/opendrift/lib/python3.13/site-packages/cf_xarray/accessor.py", line 3110, in decode_vertical_coords
    ds.coords[zname] = transform.from_terms(terms).decode()
                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/knutfd/micromamba/envs/opendrift/lib/python3.13/site-packages/cf_xarray/parametric.py", line 636, in decode
    return z.assign_attrs(standard_name=self.computed_standard_name)
                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/knutfd/micromamba/envs/opendrift/lib/python3.13/site-packages/cf_xarray/parametric.py", line 641, in computed_standard_name
    return _derive_ocean_stdname(eta=self.eta.attrs, depth=self.depth.attrs)
  File "/home/knutfd/micromamba/envs/opendrift/lib/python3.13/site-packages/cf_xarray/parametric.py", line 81, in _derive_ocean_stdname
    raise ValueError(
        f"The standard name for the {x!r} variable is not available."
    ) from None
ValueError: The standard name for the 'depth' variable is not available.

Is something missing in the dataset or in the code?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions