require_unit#

muse.utils.require_unit(ds, name, label, *, coord_only=False, convertible_to=None)#

Validate that ds[name] exists and carries a usable astropy unit.

Parameters:
  • ds (Dataset) – Dataset to inspect.

  • name (str) – Variable or coordinate name to look up.

  • label (str) – Human-readable name used in error messages (e.g. "raster.vdem" or "x coordinate").

  • coord_only (bool) – When True, require name to be a coordinate rather than any variable, by default False.

  • convertible_to (astropy.units.Unit, optional) – When given, also require the unit to be convertible to this unit.

Returns:

The parsed unit of ds[name].

Return type:

astropy.units.Unit