Create data array indices based on domain metadata.
If metadata values are specified for an axis then a full slice (slice(None)) is assumed for that axis.
Values for size 1 axes which are not spanned by the field’s data array may be specified, but only indices for axes which span the field’s data array will be returned.
The coordinate value conditions may be given in any order.
Parameters: |
|
---|---|
Returns: | out : tuple |
Examples: |
These examples use the following field, which includes a dimension coordinate object with no identity (ncvar:model_level_number) and which has a data array which doesn’t span all of the domain axes:
>>> print f
eastward_wind field summary
---------------------------
Data : eastward_wind(time(3), air_pressure(5), grid_latitude(110), grid_longitude(106)) m s-1
Cell methods : time: mean
Axes : time(3) = [1979-05-01 12:00:00, ..., 1979-05-03 12:00:00] gregorian
: air_pressure(5) = [850.0, ..., 50.0] hPa
: grid_longitude(106) = [-20.54, ..., 25.66] degrees
: grid_latitude(110) = [23.32, ..., -24.64] degrees
Aux coords : latitude(grid_latitude(110), grid_longitude(106)) = [[67.12, ..., 22.89]] degrees_N
: longitude(grid_latitude(110), grid_longitude(106)) = [[-45.98, ..., 35.29]] degrees_E
Coord refs : <CF CoordinateReference: rotated_latitude_longitude>
>>> f.indices(lat=23.32, lon=-20.54)
(slice(0, 3, 1), slice(0, 5, 1), slice(0, 1, 1), slice(0, 1, 1))
>>> f.indices(grid_lat=slice(50, 2, -2), grid_lon=[0, 1, 3, 90])
(slice(0, 3, 1), slice(0, 5, 1), slice(50, 2, -2), [0, 1, 3, 90])
>>> f.indices('exact', grid_latitude=slice(50, 2, -2), grid_longitude=[0, 1, 3, 90])
(slice(0, 3, 1), slice(0, 5, 1), slice(50, 2, -2), [0, 1, 3, 90])
>>> f.indices(grid_lon=cf.wi(0, 10, 'degrees'), air_pressure=850)
(slice(0, 3, 1), slice(0, 1, 1), slice(0, 110, 1), slice(47, 70, 1))
>>> f.indices(grid_lon=cf.wi(0, 10), air_pressure=cf.eq(85000, 'Pa')
(slice(0, 3, 1), slice(0, 1, 1), slice(0, 110, 1), slice(47, 70, 1))
>>> f.indices(grid_long=cf.gt(0, attr='lower_bounds'))
(slice(0, 3, 1), slice(0, 5, 1), slice(0, 110, 1), slice(48, 106, 1))