cf.Query.set_condition_units

Query.set_condition_units(units)[source]

Set units of condition values in-place.

New in version 3.13.1.

Parameters

units: str or Units

The units to be set on all condition values.

Returns

None

Examples

>>> q = cf.lt(9)
>>> q
<CF Query: (lt 9)>
>>> q.set_condition_units('km')
>>> q
<CF Query: (lt 9 km)>
>>> q.set_condition_units('seconds')
    ...
ValueError: Units <Units: seconds> are not equivalent to query condition units <Units: m>
>>> q = cf.lt(9, units='m')
>>> q
<CF Query: (lt 9 m)>
>>> q.set_condition_units('km')
>>> q
<CF Query: (lt 0.009 km)>
>>> q = cf.lt(9)
>>> r = cf.ge(3000, units='m')
>>> s = q & r
>>> s
<CF Query: [(lt 9) & (ge 3000 m)]>
>>> s.set_condition_units('km')
>>> s
<CF Query: [(lt 9 km) & (ge 3 km)]>
>>> q
<CF Query: (lt 9)>
>>> r
<CF Query: (ge 3000 m)>