scippneutron.chopper.filtering.find_plateaus#

scippneutron.chopper.filtering.find_plateaus(data, *, atol, min_n_points, plateau_dim='plateau')[source]#

Find regions where the input data is approximately constant.

Plateaus are found by collecting streaks of points where the derivative of the input is less than the tolerance. Variances are ignored for this comparison.

Warning

This function technically does not search for plateaus, but regions with small derivative. This means that if there is a slope smaller than the noise in the input data, that sloped region may be falsely identified as a plateau. find_plateaus attempts to catch such a case and raise a RuntimeError, but you should always inspect the result!

Parameters:
  • data (DataArray) – Data to search for plateaus in. Must be 1-dimensional.

  • atol (Variable) – Absolute tolerance for the derivative.

  • min_n_points (int | Variable) – Only return plateaus that have at least this many points.

  • plateau_dim (str, default: 'plateau') – Name for the plateau-dimension in the output.

Returns:

DataArray – A 1d binned data array where each bin holds the data points for one plateau.

See also

scippneutron.chopper.filtering.collapse_plateaus

Combine plateau bins into dense data.