Warning

You are reading the documentation related to the development version. Go here if you are looking for the documentation of the stable release.

spectrochempy.smooth

smooth(dataset, size=5, window='avg', **kwargs)[source]

Smooth the data using a window with requested size.

This method is based on the convolution of a scaled kernel window with the signal.

Parameters
  • dataset (NDDataset or array-like of shape (n_observations , n_features)) – Input data, where n_observations is the number of observations and n_features is the number of features.

  • size (positiveoddinteger, optional, default: 5) – The size of the filter window.size must be a positive odd integer.

  • window (str, optional, default:’flat’) – The type of window from ‘flat’ or ‘avg’, ‘han’ or ‘hanning’, ‘hamming’, ‘bartlett’, ‘blackman’. avg window will produce a moving average smoothing.

  • **kwargs (keyword parameters, optional) – See Other Parameters.

Returns

NDDataset – Smoothed data.

Other Parameters
  • dim (int or str, optional, default: -1,) – Dimension along which the method is applied. By default, the method is applied to the last dimension. If dim is specified as an integer it is equivalent to the usual axis numpy parameter.

  • mode (any value of [ 'mirror' , 'constant' , 'nearest' , 'wrap' , 'interp' ], optional, default: 'interp') – The type of extension to use for the padded signal to which the filter is applied.

    • When mode is ‘constant’, the padding value is given by cval.

    • When the ‘interp’ mode is selected (the default), no extension is used. Instead, a polynomial of degree order is fit to the last size values of the edges, and this polynomial is used to evaluate the last window_length // 2 output values.

    • When mode is ‘nearest’, the last size values are repeated.

    • When mode is ‘mirror’, the padding is created by reflecting the signal about the end of the signal.

    • When mode is ‘wrap’, the signal is wrapped around on itself to create the padding.

    See scipy.signal.savgol_filter for more details on ‘mirror’, ‘constant’, ‘wrap’, and ‘nearest’.

  • cval (float, optional, default: 0.0) – Value to fill past the edges of the input if mode is ‘constant’.

  • log_level (any of ["INFO", "DEBUG", "WARNING", "ERROR"], optional, default: "WARNING") – The log level at startup. It can be changed later on using the set_log_level method or by changing the log_level attribute.

See also

Filter

Define and apply filters/smoothers using various algorithms.

savgol

Savitzky-Golay filter.

savgol_filter

Alias of savgol

whittaker

Whittaker-Eilers filter.