find_bounding_indices

metpy.calc.find_bounding_indices(arr, values, axis, from_below=True)[source]

Find the indices surrounding the values within arr along axis.

Returns a set of above, below, good. Above and below are lists of arrays of indices. These lists are formulated such that they can be used directly to index into a numpy array and get the expected results (no extra slices or ellipsis necessary). good is a boolean array indicating the “columns” that actually had values to bound the desired value(s).

Parameters
  • arr (array-like) – Array to search for values

  • values (array-like) – One or more values to search for in arr

  • axis (int) – Dimension of arr along which to search

  • from_below (bool, optional) – Whether to search from “below” (i.e. low indices to high indices). If False, the search will instead proceed from high indices to low indices. Defaults to True.

Returns

  • above (list of arrays) – List of broadcasted indices to the location above the desired value

  • below (list of arrays) – List of broadcasted indices to the location below the desired value

  • good (array) – Boolean array indicating where the search found proper bounds for the desired value