filter_and_resample(ndarray time, ndarray data, double filter_window,
double new_sample_int, first_sample=None)
Filters and resamples a time signal with a running average in a given
time intervall +/-filter_window/2. The filter has a PHASE SHIFT for a
UN-equally sampled signal. Accepts masked arrays but not
"structured arrays" or "recarrays".
- Parameters:
time - the times of the timeseries
data - the data of the timeseries
filter_window - filter time interval
new_sample_int - the new sampling interval (in units of time)
first_sample - the time of the first sample in the resampled signal. If None
(default) it is (approximatly) set to time[0]+filter_window
- Returns: list of np.array
- Returns [new_time, new_data]
Note:
1) ignores any masks in the time variable. 2) will not work if it
finds no values within filter window
To Do:
Correct above point 2) (as well in helper_fns.py)
>>> tim = np.linspace(-3,90,1000); data = tim**2
>>> filter_window = 30; new_sample_int = 30
>>> filter_and_resample(tim, data, filter_window, new_sample_int)
(array([ -0., 30., 60., 90.]), array([ 62.98183318, 975.90237234, 3678.22848073, 6826.19355542]))
>>> data = np.ma.MaskedArray(data)
>>> filter_and_resample(tim, data, filter_window, new_sample_int)
(array([ -0., 30., 60., 90.]), array([ 62.98183318, 975.90237234, 3678.22848073, 6826.19355542]))
>>> data[1:10] = np.ma.masked
>>> filter_and_resample(tim, data, filter_window, new_sample_int)
(array([ -0., 30., 60., 90.]), array([ 65.73049119, 975.90237234, 3678.22848073, 6826.19355542]))
|