scallops.xr.apply_data_array

scallops.xr.apply_data_array(array, dims, func, missing_dims='ignore', **kwargs)

Apply a function to all combinations of the values for the given dimensions.

Parameters:
  • array (DataArray) – The data array

  • dims (list[str]) – List of dimensions to apply the function over

  • func (Callable[[DataArray, Any], ndarray | DataArray]) – Function to apply

  • missing_dims (Literal['ignore', 'error']) – Whether to ignore or raise error for missing dims

  • kwargs (Any) – Keyword arguments to pass to func

Returns:

DataArray containing the same dimensions as the input array

Example:
apply_data_array(
    image,
    ["c", "t"],
    lambda x: skimage.exposure.rescale_intensity(
        x, in_range=tuple(x.quantile([0, 0.95]).values)
    ),
)
Return type:

DataArray