xarray_at_min_of
- PlasmaCalcs.tools.xarray_tools.xarray_indexing.xarray_at_min_of(array, of, dim=None, *, promote_dims_if_needed=True)
return array values at locations of minimum
of. Roughly: array.isel(of.argmin([dim])).But, here is nicer, in a few ways:(1) here doesn’t require array to have all dims in dim.E.g., if array has dims ‘x’, ‘kmod’, andofhas dims ‘kmod’, ‘kang’,and dim=[‘kmod’, ‘kang’], it will be handled in the intuitive way. Roughly:amin = of.argmin([‘kmod’, ‘kang’])result = array.isel(kmod=amin[‘kmod’])(2) here allows All-NaN slice inof.all-nan slices inofwill be filled with nan values in result.E.g., if dims=[‘d0’, ‘d1’],ofhas dims [‘d0’, ‘d1’, ‘nmul’, ‘fluid’],and of.isnull().all([‘d0’, ‘d1’]) when nmul index == 4 or 5, and fluid index == 2,then result.isel(nmul=[4,5], fluid=2) will be filled with nan values.array: xarray.DataArray or xarray.Datasetarray to get result values from.of: xarray.DataArrayarray to find minimum values in.dim: None, str, or list of strdim(s) along which to find the minimum values ofof.Takes the “simultaneous” minimum along all these dims, as per argmin(dims)None –> use of.dims.(if dim is a list with len==0, return array, unchanged.)promote_dims_if_needed: boolwhether to promote non-dimension coords to dimensions.if False, raise DimensionKeyError if any relevant coord is not already a dimension.