Skip to content

Commit

Permalink
add padding (for signals that taper to zero); more cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
acorreia61201 committed Sep 3, 2024
1 parent 3b99cd3 commit c1123ff
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions pycbc/detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ def __init__(self, detector='LISA', reference_time=None, orbits=None, use_gpu=Fa
self.n = None
self.pad_idx = None
self.response_init = None

if t0 is None:
self.t0 = 10000.
else:
Expand Down Expand Up @@ -795,9 +795,20 @@ def get_links(self, hp, hc, lamb, beta, polarization=0, reference_time=None,
# get dt from waveform data
dt = hp.delta_t
self.dt = dt

# index corresponding to time length t0
self.pad_idx = int(self.t0/self.dt)

# set waveform start time and cache time series
# pad the data with zeros
### this assumes that the signal naturally tapers to zero
### this will not work with e.g. GBs or sinusoids
### i.g. we should be tapering to prevent discontinuities
hp.prepend_zeros(self.pad_idx)
hp.append_zeros(self.pad_idx)
hc.prepend_zeros(self.pad_idx)
hc.append_zeros(self.pad_idx)

# set waveform start time and cache time samples
if reference_time is not None:
self.ref_time = reference_time
hp.start_time = self.ref_time
Expand All @@ -815,7 +826,7 @@ def get_links(self, hp, hc, lamb, beta, polarization=0, reference_time=None,
hc = hc.numpy()
wf = hp + 1j*hc

# get n from waveform data
# save length of wf
n = len(wf)
self.n = n

Expand Down Expand Up @@ -862,7 +873,7 @@ def get_links(self, hp, hc, lamb, beta, polarization=0, reference_time=None,
return wf_proj

def project_wave(self, hp, hc, lamb, beta, polarization, reference_time=None, tdi=2,
tdi_chan='AET', tdi_orbits=None, use_gpu=None, remove_garbage=False):
tdi_chan='AET', tdi_orbits=None, use_gpu=None, remove_garbage=True):
"""
Evaluate the TDI observables.
Expand Down Expand Up @@ -904,9 +915,9 @@ def project_wave(self, hp, hc, lamb, beta, polarization, reference_time=None, td
remove_garbage : bool, str (optional)
Flag whether to remove gaps in TDI from start and end. If True,
edge data will be cut from TDI channels. If 'zero', edge data
will be zeroed. If False, TDI channels will not be modified.
Default True.
time length t0 worth of edge data will be cut from TDI channels.
If 'zero', time length t0 worth of edge data will be zeroed. If
False, TDI channels will not be modified. Default True.
Returns
-------
Expand All @@ -918,8 +929,9 @@ def project_wave(self, hp, hc, lamb, beta, polarization, reference_time=None, td
use_gpu = self.use_gpu

# generate the Doppler time series
self.get_links(hp, hc, lamb, beta, polarization=polarization, reference_time=reference_time,
use_gpu=use_gpu, tdi=tdi)
self.get_links(hp, hc, lamb, beta, polarization=polarization,
reference_time=reference_time, use_gpu=use_gpu,
tdi=tdi)

# set TDI channels
if tdi_chan in ['XYZ', 'AET', 'AE']:
Expand Down

0 comments on commit c1123ff

Please sign in to comment.