pyfvcom2.lanczos module

class pyfvcom2.lanczos.LanczosFilter(dt: float = 1, cutoff: float = None, samples: int = 100, passtype: str = 'low')[source]

Bases: object

Lanczos low- or high-pass filter.

Creates a filter object with fixed parameters. Call filter() to apply it to a 1-D time series.

Parameters:
  • dt (float, optional) – Sampling interval in minutes. Defaults to 1.

  • cutoff (float, optional) – Cutoff period in minutes. Defaults to half the Nyquist period.

  • samples (int, optional) – Number of samples (window length). Defaults to 100.

  • passtype (str, optional) – 'low' for low-pass (default) or 'high' for high-pass.

Notes

Python reimplementation of the MATLAB lanczosfilter.m function: https://mathworks.com/matlabcentral/fileexchange/14041

NaN values are replaced by the time-series mean before filtering.

References

Emery, W. J. and R. E. Thomson. “Data Analysis Methods in Physical Oceanography”. Elsevier, 2nd ed., 2004, pp. 533-539.

filter(x: ndarray) ndarray[source]

Apply the filter to a 1-D time series.

Parameters:

x (np.ndarray) – 1-D time series values.

Returns:

y – Filtered time series, same length as x.

Return type:

np.ndarray

pyfvcom2.lanczos.lanczos(x: ndarray, dt: float = 1, cutoff: float = None, samples: int = 100, passtype: str = 'low')[source]

Apply a Lanczos low- or high-pass filter to a 1-D time series.

Parameters:
  • x (np.ndarray) – 1-D time series values.

  • dt (float, optional) – Sampling interval in minutes. Defaults to 1.

  • cutoff (float, optional) – Cutoff period in minutes. Defaults to half the Nyquist period.

  • samples (int, optional) – Number of samples (window length). Defaults to 100.

  • passtype (str, optional) – 'low' for low-pass (default) or 'high' for high-pass.

Returns:

  • y (np.ndarray) – Filtered time series.

  • coef (np.ndarray) – Cosine window coefficients.

  • window (np.ndarray) – Frequency-domain window.

  • Cx (np.ndarray) – Complex Fourier transform of x (half-spectrum).

  • Ff (np.ndarray) – Fourier frequencies from 0 to the Nyquist frequency.

Notes

Python reimplementation of the MATLAB lanczosfilter.m function: https://mathworks.com/matlabcentral/fileexchange/14041

NaN values are replaced by the time-series mean before filtering.

References

Emery, W. J. and R. E. Thomson. “Data Analysis Methods in Physical Oceanography”. Elsevier, 2nd ed., 2004, pp. 533-539.