cf.isclose

cf.isclose(value, units=None, attr=None, rtol=None, atol=None)[source]

A Query object for an “is close” condition.

New in version 3.15.2.

Parameters
value:

The value to be used in the isclose test. May be any scalar cf.Data object, or else any numerical object that can be operated on with np.isclose.

units: str or Units, optional

The units of value. By default, the same units as the operand being tested are assumed, if applicable. If units is specified and value already has units (such as those attached to a Data object), then the pair of units must be equivalent.

attr: str, optional

Apply the condition to the attribute, or nested attributes, of the operand, rather than the operand itself. Nested attributes are specified by separating them with a .. For example, the “month” attribute of the “bounds” attribute is specified as 'bounds.month'.

rtol: number, optional

The tolerance on relative numerical differences. If None, the default, then the value returned by cf.rtol is used at evaluation time.

atol: number, optional

The tolerance on absolute numerical differences. If None, the default, then the value returned by cf.atol is used at evaluation time.

Returns
Query

The query object.

Examples

>>> q = cf.isclose(9)
>>> q
<CF Query: (isclose 9)>
>>> q.evaluate(9.000001)
False
>>> with cf.configuration(rtol=0.001, atol=0.01):
...     print(q.evaluate(9.000001))
...
True
>>> q.evaluate(9.000001)
False
>>> q = cf.isclose(9, rtol=0.001, atol=0.01)
>>> q
<CF Query: (isclose 9 rtol=0.001 atol=0.01)>
>>> q.evaluate(9.000001)
True
>>> q = cf.isclose(9, atol=0.01)
>>> q
<CF Query: (isclose 9 atol=0.01)>
>>> q.evaluate(9.000001)
True