Specifying sampling_frequency when reading frame files is not effective
The reason is that the gwpy.TimeSeries.resample
does not modify the original object.
Problem:
When reading strain_data
from a frame file, the sampling_frequency
option is not effective.
In other words, the sampling frequency of the strain data read from this command is still 4096 Hz:
ifo.set_strain_data_from_frame_file('L-L1_GWOSC_4KHZ_R1.gwf', channel='L1:GWOSC-4KHZ_R1_STRAIN', sampling_frequency=2048)
Cause:
In gw.utils.read_frame_file
, the resampling is implemented as such:
if loaded:
if resample and (strain.sample_rate.value != resample):
strain.resample(resample)
return strain
However, the resample
method does not modify the object in place, e.g.
from copy import copy
ts = TimeSeries.read(frame_file) # A 16k frame file
ts_copy = copy(ts)
ts.dt == ts_copy.dt
# True (as expected)
ts.resample(2048)
ts.dt == ts_copy.dt
# True (still true, since the object is not modified)
Suggested fix:
Return the resampled object directly.
if loaded:
if resample and (strain.sample_rate.value != resample):
return strain.resample(resample)
Edited by Samson Leong