Skip to content

Commit

Permalink
changed t0 to kwarg in init
Browse files Browse the repository at this point in the history
  • Loading branch information
acorreia61201 committed Jul 12, 2024
1 parent 90daee5 commit da48da3
Showing 1 changed file with 13 additions and 48 deletions.
61 changes: 13 additions & 48 deletions pycbc/detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ class LISA_detector(object):
"""
LISA-like GW detector. Applies detector response from FastLISAResponse.
"""
def __init__(self, detector='LISA', reference_time=None, orbits=ESAOrbits(), use_gpu=False):
def __init__(self, detector='LISA', reference_time=None, orbits=ESAOrbits(), use_gpu=False, t0=10000.):
"""
Parameters
----------
Expand All @@ -680,6 +680,11 @@ def __init__(self, detector='LISA', reference_time=None, orbits=ESAOrbits(), use
use_gpu : bool (optional)
Specify whether to run class on GPU support via CuPy. Default False.
t0 : float (optional)
Time length (in seconds) to cut from start and end of TDI observables. By
default, TDI channels will have erroneous noise at edges that will be cut
according to this argument. Default 10000 s.
"""
# initialize detector; for now we only accept LISA
assert (detector=='LISA'), 'Currently only supports LISA detector'
Expand All @@ -693,15 +698,17 @@ def __init__(self, detector='LISA', reference_time=None, orbits=ESAOrbits(), use
# specify and cache the start time and orbital time series
if reference_time is None:
reference_time = self.orbits.t_base[0]
self.com_ref_time = reference_time
self.ref_time = reference_time
self.sample_times = None

# cache the FLR instance along with dt and n
self.dt = None
self.n = None
self.pad_idx = None
self.response_init = None
self.t0 = 10000.

if t0 is None:
self.t0 = 10000.

# initialize whether to use gpu; FLR has handles if this cannot be done
self.use_gpu = use_gpu
Expand All @@ -710,9 +717,6 @@ def apply_polarization(self, hp, hc, polarization):
"""
Apply polarization rotation matrix.
.. math::
\bmatrix{}
Parameters
----------
hp : array
Expand All @@ -736,44 +740,6 @@ def apply_polarization(self, hp, hc, polarization):
hc_ssb = hp*sphi + hc*cphi

return hp_ssb, hc_ssb

def time_delay_from_ssb(self, orbits, reference_time):
"""
Calculate the time delay from the SSB frame to the LISA COM frame.
Parameters
----------
orbits: lisatools.detector.Orbits
The orbital information of the satellites.
reference_time: float
The time in seconds in the SSB frame.
Returns
-------
float
The additive time delay factor between the SSB and LISA COM frame
at the given time.
"""
C_SI = constants.c.value

# configure orbits if not already
try:
orbits.t
except ValueError:
orbits.configure(linear_interp_setup=True)

# get positions of spacecraft at reference time
sc_x = []
for i in [1, 2, 3]:
sc_x.append(orbits.get_pos(reference_time, i))

# average sc positions to get COM position
com_vec = sum(sc_x)/len(sc_x)
com_dist = sum(com_vec*com_vec)**0.5

# time delay from SSB to LISA COM is distance/c
return com_dist/C_SI

def get_links(self, hp, hc, lamb, beta, polarization=0, reference_time=None,
use_gpu=None, tdi=2):
Expand Down Expand Up @@ -826,10 +792,9 @@ def get_links(self, hp, hc, lamb, beta, polarization=0, reference_time=None,

# set waveform start time and cache time series
if reference_time is not None:
frame_delay = self.time_delay_from_ssb(self.orbits, reference_time)
self.com_ref_time = reference_time + frame_delay
hp.start_time = self.com_ref_time
hc.start_time = self.com_ref_time
self.ref_time = reference_time
hp.start_time = self.ref_time
hc.start_time = self.ref_time
self.sample_times = hp.sample_times.numpy()

# rescale the orbital time series to match waveform
Expand Down

0 comments on commit da48da3

Please sign in to comment.