PlasmaCalcs.tools.xarray_tools.xarray_indexing.xarray_min_coord_where
- PlasmaCalcs.tools.xarray_tools.xarray_indexing.xarray_min_coord_where(array, coord, where, *, promote_dims_if_needed=True)
- return (array of) minimum value(s) of coord, where condition is True.
- array: xarray.DataArray
- array to find minimum value in.
- coord: str
- coord whose minimum value will appear in the result.Must correspond with a single dimension of array.
- where: xarray.DataArray or callable
- locations at which to consider values of coord.callable –> use where=where(array)(will promote coord to dim first, if coord not dim yet.)
- promote_dims_if_needed: bool
- whether to promote non-dimension coords to dimensions.if False, raise DimensionKeyError if any relevant coord is not already a dimension.
Example:xarray_min_coord_where(growth, ‘E’, lambda arr: arr>0)# returns the minimum value(s) of E across all regions where growth>0.# (result has no ‘E’ dim, but does retain any other dims from array.)Compare to xarray_cmin(growth.where(growth>0), ‘E’),which tells the value of E at the location of minimum growth (where growth>0)(but not necessarily the minimum E across all regions with growth>0).