suncasa.utils.signal_utils
Functions
|
|
|
smooth the data using a window with requested size. |
|
|
|
|
|
|
|
|
|
Apply a Butterworth bandpass filter to a given dataset and optionally plot the frequency response and filtered data. |
|
|
|
calculate the error in time lag using equation (3) in Gaskell & Peterson 1987 |
|
Module Contents
- suncasa.utils.signal_utils.normalize(y, ymax=None, ymin=None, center=None, yerr=None, symgamma=None)[source]
- Parameters:
y
ymax
ymin
center – option —- None, zero, 0, mean
symgamma
- Returns:
- suncasa.utils.signal_utils.smooth(x, window_len=11, window='hanning', mode='same')[source]
smooth the data using a window with requested size.
This method is based on the convolution of a scaled window with the signal. The signal is prepared by introducing reflected copies of the signal (with the window size) in both ends so that transient parts are minimized in the begining and end part of the output signal.
- input:
x: the input signal window_len: the dimension of the smoothing window; should be an odd integer window: the type of window from ‘flat’, ‘hanning’, ‘hamming’, ‘bartlett’, ‘blackman’
flat window will produce a moving average smoothing.
- output:
the smoothed signal
example:
t=linspace(-2,2,0.1) x=sin(t)+randn(len(t))*0.1 y=smooth(x)
see also:
numpy.hanning, numpy.hamming, numpy.bartlett, numpy.blackman, numpy.convolve scipy.signal.lfilter
TODO: the window parameter could be the window itself if an array instead of a string NOTE: length(output) != length(input), to correct this: return y[(window_len/2-1):-(window_len/2)] instead of just y.
- suncasa.utils.signal_utils.low_pass_filter(t, data, fs=1.0 / 4, cutoff=1.0 / 60, order=6, showplot=False)[source]
- suncasa.utils.signal_utils.bandpass_filter(t, data, fs=1.0 / 4, cutoff=1.0 / 60, order=6, showplot=False)[source]
Apply a Butterworth bandpass filter to a given dataset and optionally plot the frequency response and filtered data.
- Parameters:
t (array_like) – Time array corresponding to the data points.
data (array_like) – Data array to be filtered.
fs (float, optional) – Sampling frequency of the data in Hz, defaults to 0.25 Hz (1/4 Hz).
cutoff (tuple, optional) – Cutoff frequencies of the filter in Hz. It should be a tuple with (low, high) values, defaults to approximately 0.0167 Hz (1/60 Hz).
order (int, optional) – Order of the Butterworth filter, defaults to 6.
showplot (bool, optional) – If True, plots the frequency response and the original plus filtered data, defaults to False.
- Raises:
ValueError – Raises an exception if the ‘cutoff’ parameter does not meet the expected tuple format.
- Returns:
The filtered data array.
- Return type:
ndarray
- suncasa.utils.signal_utils.c_correlateX(a, v, returnx=False, returnav=False, s=0, xran=None, coarse=False, interp='spl')[source]
- Parameters:
a
v – a and v can be a dict in following format {‘x’:[],’y’:[]}. The length of a and v can be different.
returnx
- Returns: