cf.Data.override_units

Data.override_units(units)[source]

Override the data array units in place.

Not to be confused with setting the Units attribute to units which are equivalent to the original units. This is different because in this case 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.

Parameters :
units : str or Units

The new units for the data array.

Returns :

None

Examples

>>> d.Units
<CF Units: hPa>
>>> d.first_datum
1012.0
>>> d.override_units('km')
>>> d.Units
<CF Units: km>
>>> d.first_datum
1012.0
>>> d.override_units(cf.Units('watts'))
>>> d.Units
<CF Units: watts>
>>> d.first_datum
1012.0

Previous topic

cf.Data.new_dimension_identifier

Next topic

cf.Data.save_to_disk

This Page