environmentaltools.common.smooth_1d

environmentaltools.common.smooth_1d(data: ndarray, window_length: int = None, poly_order: int = 3) ndarray[source]

Apply Savitzky-Golay filter for 1D data smoothing.

Uses the Savitzky-Golay filter to smooth 1D data by fitting successive sub-sets of adjacent data points with a low-degree polynomial.

Parameters:
  • data (np.ndarray) – 1D array of data values to smooth.

  • window_length (int, optional) – Length of the filter window (number of coefficients). Must be a positive odd integer. If None, defaults to len(data)/51. Defaults to None.

  • poly_order (int, optional) – Order of the polynomial used to fit the samples. Must be less than window_length. Defaults to 3.

Returns:

Smoothed data array with the same length as input data.

Return type:

np.ndarray