xarray.Dataset.argo.groupby_pressure_bins

xarray.Dataset.argo.groupby_pressure_bins

Dataset.argo.groupby_pressure_bins(bins: list, axis: str = 'PRES', right: bool = False, select: str = 'deep', squeeze: bool = True, merge: bool = True)

Group measurements by pressure bins

This method can be used to subsample and align an irregular dataset (pressure not being similar in all profiles) on a set of pressure bins. The output dataset could then be used to perform statistics along the N_PROF dimension because N_LEVELS will corresponds to similar pressure bins, while avoiding to interpolate data.

Parameters
  • bins (list or np.array,) – Array of bins. It has to be 1-dimensional and monotonic. Bins of data are localised using values from options axis (default: PRES) and right (default: False), see below.

  • axis (str, default: PRES) – The dataset variable to use as pressure axis. This could be PRES or PRES_ADJUSTED

  • right (bool, default: False) – Indicating whether the bin intervals include the right or the left bin edge. Default behavior is (right==False) indicating that the interval does not include the right edge. The left bin end is open in this case, i.e., bins[i-1] <= x < bins[i] is the default behavior for monotonically increasing bins. Note the merge option is intended to work only for the default right=False.

  • select ({'deep','shallow','middle','random','min','max','mean','median'}, default: 'deep') –

    The value selection method for bins.

    This selection can be based on values at the pressure axis level with: deep (default), shallow, middle, random. For instance, select='deep' will lead to the value returned for a bin to be taken at the deepest pressure level in the bin.

    Or this selection can be based on statistics of measurements in a bin. Stats available are: min, max, mean, median. For instance select='mean' will lead to the value returned for a bin to be the mean of all measurements in the bin.

  • squeeze (bool, default: True) – Squeeze from the output bin levels without measurements.

  • merge (bool, default: True) – Optimize the output bins axis size by merging levels with/without data. The pressure bins axis is modified accordingly. This means that the return STD_PRES_BINS axis has not necessarily the same size as the input bins.

Return type

xarray.Dataset

See also

numpy.digitize, argopy.utilities.groupby_remap