Skip to content

Commit

Permalink
add waveform downsample
Browse files Browse the repository at this point in the history
  • Loading branch information
yi-fan-wang committed Nov 14, 2024
1 parent 717509d commit 95db2f6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pycbc/inference/models/gated_gaussian_noise.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from pycbc.pnutils import hybrid_meco_frequency
from pycbc.waveform.utils import time_from_frequencyseries
from pycbc.waveform import generator
from pycbc.filter import highpass
from pycbc.filter import highpass, resample_to_delta_t
from .gaussian_noise import (BaseGaussianNoise, create_waveform_generator)
from .base_data import BaseDataModel
from .data_utils import fd_data_from_strain_dict
Expand Down Expand Up @@ -207,6 +207,12 @@ def get_waveforms(self):
h = highpass(
h.to_timeseries(),
frequency=self.highpass_waveforms).to_frequencyseries()
if 'waveform_srate' in self.static_params:
logging.warning("Resampling waveform from %f to %f Hz",
self.static_params['waveform_srate'], self.data[det].sample_rate)
h = resample_to_delta_t(h.to_timeseries(),
1. / self.data[det].sample_rate,
method='ldas').to_frequencyseries()
wfs[det] = h
self._current_wfs = wfs
return self._current_wfs
Expand Down
3 changes: 3 additions & 0 deletions pycbc/inference/models/gaussian_noise.py
Original file line number Diff line number Diff line change
Expand Up @@ -1215,6 +1215,9 @@ def create_waveform_generator(
d.start_time == start_time]):
raise ValueError("data must all have the same delta_t, "
"delta_f, and start_time")
if 'waveform_srate' in static_params:
delta_t = 1. / static_params['waveform_srate']
logging.warning("Overriding delta_t to match waveform_srate")
waveform_generator = generator_class(
generator_function, epoch=start_time,
variable_args=variable_params, detectors=list(data.keys()),
Expand Down

0 comments on commit 95db2f6

Please sign in to comment.