indexes
- indexes(fs, values)
Finds the index of the values at each gridpoint of
fs
in thevalues
array.- Parameters
fs (
Fieldset
) – input fieldsetvalues (ndarray) – the values to find the index for
- Return type
Indexes are zero-based and will always have a minimum value of zero and a maximum value equal to the index of the last element of
values
. A value lying between two values invalues
will use the index of the nearest value; if equidistant, then the higher value is used.values
must be sorted in ascending order.- Example
Let us suppose that our input fieldset contains these values:
10 18 30 40 f = 15 25 35 45 8 4 20 11
then the following call:
import metview as mv import numpy as np g = mv.indexes(f, np.array([5, 10, 15, 20, 25, 30])
produces this GRIB, with values equal to the input values’ positions in the input array:
1 3 5 5 g = 2 4 5 5 1 0 3 1