3from astropy
import units
as u
4from gwpy.timeseries
import TimeSeries
6from scipy.signal
import butter, sosfiltfilt
12 High-pass a time series
16 time_series : `TimeSeries`
17 GwPy TimeSeries object
19 Sampling value of time series
21 Minimum frequency
for high-
pass
23 Attenuation value at low-freq cut-off
25 Order of butterworth filter
37 w1 = np.tan(np.pi * fmin * dt)
38 wc = w1 * (1.0 / a1**0.5 - 1)**(1.0/(2.0*N))
39 fc = fs * np.arctan(wc) / np.pi
42 sos = butter(N, fc, btype=
'highpass', output=
'sos', fs=fs)
43 output = sosfiltfilt(sos, time_series)
45 output = TimeSeries(output, t0=time_series.epoch, dt=time_series.dt)
52 Stage 1 of time-series conditioning - add taper and high-
pass the time-series
57 GwPy TimeSeries object
59 GwPy TimeSeries object
61 Sampling value of time series
63 Initial extra time
for conditioning
65 Minimum frequency
for high-
pass
71 Ntaper = np.round(t_extra/dt)
72 taper_array = np.arange(Ntaper)
73 w = 0.5 - 0.5*np.cos(taper_array*np.pi/Ntaper)
74 w_ones = np.ones(len(hp))
75 w_ones[:int(Ntaper)] *= w
84 np.trim_zeros(hp, trim=
'b')
85 np.trim_zeros(hc, trim=
'b')
92 Stage 2 of time-series conditioning - taper end of waveform based off maximum frequency
97 GwPy TimeSeries object
99 GwPy TimeSeries object
101 Sampling value of time series
103 Minimum frequency for high-
pass
105 Minimum frequency
for high-
pass
111 min_taper_samples = 4.
112 if len(hp)<2*min_taper_samples:
113 warnings.warn(
"Current waveform has less than %i samples: No Final tapering will be applied"%(2*min_taper_samples))
119 ntaper = int(np.round(1./(fmax*dt)))
120 ntaper = np.max([ntaper, min_taper_samples])
123 taper_array = np.arange(1, ntaper)
124 w = 0.5 - 0.5*np.cos(taper_array*np.pi/ntaper)
126 w_ones = np.ones(Nsize)
127 w_ones[int(Nsize-ntaper+1):] *= w[::-1]
133 ntaper = np.round(1./(fmin*dt))
134 ntaper = np.max([ntaper, min_taper_samples])
137 taper_array = np.arange(ntaper)
138 w = 0.5 - 0.5*np.cos(taper_array*np.pi/ntaper)
139 w_ones = np.ones(Nsize)
140 w_ones[:int(ntaper)] *= w
148 Resize a given gwpy TimeSeries which has a given length and starts at a point specified by start_id. If start_id
149 is negative, the timeseries will be padded on the left
with that amount.
154 TimeSeries that needs to be resized
157 If positive, index at which TimeSeries will now start
from. If negative, TimeSeries will be zero padded
with
158 that length on the left.
161 Final length of output array. This will be done by clippling the end of the TimeSeries,
if new_length
is
162 larger than len(hp[start_id:]); otherwise zero_pad on right
167 Resized gwpy.TimeSeries object.
176 zeros = np.zeros(int(abs(start_id)))
177 hp = np.concatenate([zeros, hp])
179 hp = hp[int(start_id):]
183 end_id = int(len(hp) - new_length)
185 zeros = np.zeros(int(abs(end_id)))
186 hp = np.concatenate([hp, zeros])
191 times_new = np.arange(0, new_length)*dt*u.s
192 times_new = times_new - times_new[np.argmax(hp)]
194 hp_out.times = times_new
def resize_gwpy_timeseries(hp, start_id, new_length)
Resize a given gwpy TimeSeries which has a given length and starts at a point specified by start_id.
def high_pass_time_series(time_series, dt, fmin, attenuation, N)
High-pass a time series.
def time_array_condition_stage1(hp, hc, dt, t_extra, fmin)
Stage 1 of time-series conditioning - add taper and high-pass the time-series.
def time_array_condition_stage2(hp, hc, dt, fmin, fmax)
Stage 2 of time-series conditioning - taper end of waveform based off maximum frequency.