xoa.plot.get_label

Contents

xoa.plot.get_label#

xoa.plot.get_label(da, units=True, pretty=True)[source]#

Get a label like "Long name [units]" for a data array

Missing attributes are completed from the current meta specs with xoa.meta.MetaSpecs.fill_attrs().

Parameters:
  • da (xarray.DataArray)

  • units (bool) – Add the units between brackets.

  • pretty (bool) – Write the units in a nicer way, like °C instead of degrees_celsius and m s⁻¹ instead of m s-1, and skip the unit 1 of dimensionless numbers.

Returns:

str

Example

In [1]: da = xr.DataArray([1.], dims="x", name="temp")

In [2]: get_label(da)
Out[2]: 'Sea water in situ temperature [°C]'

In [3]: get_label(da, units=False)
Out[3]: 'Sea water in situ temperature'