cf.Field.indices

Field.indices(**kwargs)

Return the indices to the data array which correspond to coordinate values.

Any index for a dimension of the data array for which no coordinates are specified is returned as a full slice (i.e. slice(None)).

Size 1 coordinates for dimensions of the space which are not spanned by the data array may be specified, but no corresponding index will be returned.

Parameters :
kwargs : optional

Keyword names identify coordinates; and keyword values specify the coordinate values which are to be interpreted as indices to the field’s data array.

A keyword name identifies a coordinate by either its standard_name property, its identity attribute or its identifier in the field’s space, in that order of precedence.

A keyword value is a condition, or sequence of conditions, which is evaluated by finding where the coordinate’s data array equals each condition. The locations where the conditions are satisfied are interpreted as indices to the field’s data array. If a condition is a scalar, x, then this is equivalent to the Comparison object cf.eq(x).

Returns :

out : tuple

Examples

>>> f.slice(lat=0.0, lon=0.0)
<CF Field: air_temperature(12, 1, 1)
>>> f.slice(lon=cf.lt(0.0), lon=[0, 2.8125])
<CF Field: air_temperature(12, 32, 2)
>>> f.slice(lon=[0, 1])
ValueError: 'longitude' coordinate doesn't contain the value 1
>>> f.slice(lon=1)
ValueError: No indices found for 'longitude' coordinate

Previous topic

cf.Field.identity

Next topic

cf.Field.match

This Page