cf.FieldList.override_units

FieldList.override_units(units, i=False)

For each field, 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 setting cf.Field.units or cf.Field.Units attributes to units which are equivalent to the original units.

Examples 1:
>>> g = f.override_units('m')
Parameters:
units : str or cf.Units

The new units for the data array.

i : bool, optional

If True then update the field list in place. By default a new field list is created. In either case, a field list is returned.

Returns:

out : cf.FieldList

Examples 2:
>>> f[0].Units
<CF Units: hPa>
>>> f[0].datum(0)
100000.0
>>> f.override_units('km')
>>> f[0].Units
<CF Units: km>
>>> f[0].datum(0)
100000.0
>>> f.override_units(cf.Units('watts'))
>>> f[0].Units
<CF Units: watts>
>>> f[0].datum(0)
100000.0