cf.Field.indices

Field.indices(**kwargs)[source]

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 domain 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 reinterpreted as indices to the field’s data array. By default, indices equivalent to Ellipsis are returned.

Coordinates are identified by their exact identity or by their dimension’s identifier in the field’s domain.

A keyword value is a condition which is evaluated by checking where the coordinate’s data array is equals to it. 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 cf.Comparison object cf.eq(x).

Returns :

out : tuple

Examples

>>> f.indices(lat=0.0, lon=0.0)
(slice(0, 1, 1), slice(0, 1, 1))
>>> f.indices(lon=cf.lt(0.0), lon=cf.set([0, 3.75]))
(slice(0, 32, 1), slice(0, 2, 1))
>>> f.indices(lon=cf.lt(0.0), lon=cf.set([0, 356.25]))
(slice(0, 32, 1), slice(0, 96, 96))
>>> f.indices(lon=cf.lt(0.0), lon=cf.set([0, 3.75, 356.25]))
(slice(0, 32, 1), [0, 1, 95])

Previous topic

cf.Field.identity

Next topic

cf.Field.insert_data

This Page