diff --git a/lisainstrument/instrument.py b/lisainstrument/instrument.py index 27786fead1287b41490f5a3208db36a5c061ce7b..052f026a4d5d75cb9c8cd526f4ac4927353f4e4b 100755 --- a/lisainstrument/instrument.py +++ b/lisainstrument/instrument.py @@ -236,6 +236,11 @@ class Instrument: np.arange(self.physics_size + self.initial_telemetry_physics_size, dtype=np.float64) * self.physics_dt self.physics_et_withinitial = self.physics_t_withinitial - self.t0 + # Orbits, gravitational waves, glitches + self.init_orbits(orbits, orbit_dataset) + self.init_gws(gws) + self.init_glitches(glitches) + # Instrument topology self.central_freq = float(central_freq) self.init_lock(lock) @@ -382,11 +387,6 @@ class Instrument: else: self.mosa_angles = ForEachMOSA(mosa_angles) - # Orbits, gravitational waves, glitches - self.init_orbits(orbits, orbit_dataset) - self.init_gws(gws) - self.init_glitches(glitches) - # Interpolation and antialiasing filter self.init_interpolation(interpolation) self.init_aafilter(aafilter) @@ -534,7 +534,7 @@ class Instrument: # Switch between various fplan file standards if version in SpecifierSet('== 1.1.*', True): logger.debug("Interpolating locking beatnote frequencies with piecewise linear functions") - times = self.t0 + np.arange(fplanf.attrs['size']) * fplanf.attrs['dt'] + times = self.orbit_t0 + np.arange(fplanf.attrs['size']) * fplanf.attrs['dt'] interpolate = lambda x: InterpolatedUnivariateSpline(times, x, k=1, ext='raise')(self.physics_t) lock_beatnotes = {} # Go through all MOSAs and pick locking beatnotes @@ -571,6 +571,7 @@ class Instrument: if orbits == 'static': logger.info("Using default set of static proper pseudo-ranges") self.orbit_file = None + self.orbit_t0 = self.t0 self.pprs = ForEachMOSA({ # Default PPRs based on first samples of Keplerian orbits (v2.0.dev) '12': 8.33242295, '23': 8.30282196, '31': 8.33242298, @@ -599,6 +600,7 @@ class Instrument: else: logger.info("Using user-provided proper pseudo-ranges and derivatives") self.orbit_file = None + self.orbit_t0 = self.t0 self.pprs = ForEachMOSA(orbits) self.d_pprs = self.pprs.transformed(lambda _, x: 0 if np.isscalar(x) else np.gradient(x, self.physics_dt) @@ -641,6 +643,13 @@ class Instrument: raise ValueError(f"invalid orbit dataset '{self.orbit_dataset}'") try: + logger.debug("Reading orbit's t0") + if self.orbit_dataset == 'tcb/ltt': + self.orbit_t0 = orbitf['tcb']['t'][0] + elif self.orbit_dataset == 'tps/ppr': + self.orbit_t0 = orbitf['tps']['tau'][0] + else: + raise ValueError(f"invalid orbit dataset '{self.orbit_dataset}'") logger.debug("Interpolating proper pseudo-ranges") self.pprs = ForEachMOSA(lambda mosa: pprs(mosa)(self.physics_t)) logger.debug("Interpolating proper pseudo-range derivatives") @@ -663,6 +672,8 @@ class Instrument: # Interpolate necessary orbital quantities, # show a helpful error message if orbit file is too short try: + logger.debug("Reading orbit's t0") + self.orbit_t0 = orbitf.attrs['t0'] logger.debug("Interpolating proper pseudo-ranges") dataset = orbitf['tcb/ltt'] if self.orbit_dataset == 'tcb/ltt' else orbitf['tps/ppr'] self.pprs = ForEachMOSA(lambda mosa: interpolate(dataset[:, link_index[mosa]], self.physics_t)) @@ -1783,7 +1794,7 @@ class Instrument: 'sc_jitter_phi_asds', 'sc_jitter_eta_asds', 'sc_jitter_theta_asds', 'mosa_jitter_phi_asds', 'dws_asds', 'mosa_angles', - 'orbit_file', 'orbit_dataset', + 'orbit_file', 'orbit_dataset', 'orbit_t0', 'gw_file', 'gw_group', 'glitch_file', 'interpolation_order',