require_unit#
- muse.utils.require_unit(ds, name, label, *, coord_only=False, convertible_to=None)#
Validate that
ds[name]exists and carries a usableastropyunit.- 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) – WhenTrue, requirenameto be a coordinate rather than any variable, by defaultFalse.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: