cf.CellMeasure.override_units

CellMeasure.override_units(*args, **kwargs)[source]

Override the units.

The new units need not be equivalent to the original ones, and the data array elements will not be changed to reflect the new units. Therefore, this method should only be used when it is known that the data array values are correct but the units have incorrectly encoded.

Not to be confused with changing to equivalent units with the to_units method or the Units, units, or calendar attributes. These approaches also convert the data to have the new units.

See also

override_calendar, to_units, units, Units,`calendar`

Parameters:
units: str or Units

The new units for the data array.

inplace: bool, optional

If True then do the operation in-place and return None.

i: deprecated at version 3.0.0

Use the inplace parameter instead.

Returns:
CellMeasure or None

The construct with data converted to the new units, or None if the operation was in-place.

Examples

>>> f.Units
<Units: hPa>
>>> f.datum(0)
100000.0
>>> f.override_units('km', inplace=True)
>>> f.Units
<Units: km>
>>> f.datum(0)
100000.0
>>> f.override_units(Units('watts'), inplace=True)
>>> f.Units
<Units: watts>
>>> f.datum(0)
100000.0