cf.contain

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

Return a cf.Query object for cells of a variable for containing a value.

If cells are not defined then return a cf.Query object for a variable for being equal to a value, i.e. this case is equivalent to cf.eq.

New in version 1.0.

Parameters:
value :

The value which a variable is to be compared with.

units : str or cf.Units, optional

The units of each element of values. By default, the same units as the variable being tested are assumed, if applicable.

attr : str, optional

Return a query object for a variable’s attr attribute.

Returns:
out : cf.Query

The query object.

Examples:
>>>  cf.contain(30, 'degrees_east')
<CF Query: (contain <CF Data: 30 degrees_east>)>
>>>  cf.contain(cf.Data(10, 'km'))
<CF Query: (contain <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.contain(100) == c).array
[False True False False]
>>> print (cf.contain(9999) == c).array
[False False False False]

Previous topic

cf.equivalent

Next topic

cf.eq

This Page