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

A Query object for a “cell contains” condition.

New in version 3.0.0.


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 the already value has units (such as a Data object`), then they 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'.


The query object.


>>>  cf.contains(30, 'degrees_east')
<CF Query: (contains <CF Data: 30 degrees_east>)>
>>>  cf.contains(cf.Data(10, 'km'))
<CF Query: (contains <CF Data: 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]