cf.contains

cf.contains(value, units=None)[source]

A Query object for a “cell contains” condition.

New in version 3.0.0.

Parameters
value:

The query condition’s value.

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.

Returns
Query

The query object.

Examples

>>> q = cf.contains(8)
>>> q
<CF Query: [lower_bounds(le 8) & upper_bounds(ge 8)]>
>>> q.value
8
>>> q = cf.contains(30, 'degrees_east')
>>> q
<CF Query: [lower_bounds(le 30 degrees_east) & upper_bounds(ge 30 degrees_east)]>
>>> q.value
<CF Data(): 30 degrees_east>
>>> cf.contains(cf.Data(10, 'km'))
<CF Query: [lower_bounds(le 10 km) & upper_bounds(ge 10 km)]>
>>> c
<CF DimensionCoordinate: longitude(4) degrees_east>
>>> print(c.bounds.array)
[[  0   90]
 [ 90  180]
 [180  270]
 [270  360]]
>>> print((cf.contains(100) == c).array)
[False True False False]
>>> print((cf.contains(9999) == c).array)
[False False False False]