diff --git a/lisainstrument/instrument.py b/lisainstrument/instrument.py index a97b78f0c9a5dd4d05e95d84e659afffef45b4af..2e4af6f28180cabfef85527337a92ed0bf1801fd 100755 --- a/lisainstrument/instrument.py +++ b/lisainstrument/instrument.py @@ -627,13 +627,20 @@ class Instrument: def init_orbits_file_1_0(self, orbitf): """Initialize orbits from an orbit file version == 1.*.""" - def pprs(mosa): + def pprs_const(mosa): + if self.orbit_dataset == 'tcb/ltt': + return orbitf[f'tcb/l_{mosa}']['tt'][0] + if self.orbit_dataset == 'tps/ppr': + return orbitf[f'tps/l_{mosa}']['ppr'][0] + raise ValueError(f"invalid orbit dataset '{self.orbit_dataset}'") + + def d_pprs(mosa): if self.orbit_dataset == 'tcb/ltt': times = orbitf['tcb']['t'][:] - values = orbitf[f'tcb/l_{mosa}']['tt'] + values = orbitf[f'tcb/l_{mosa}']['d_tt'] elif self.orbit_dataset == 'tps/ppr': times = orbitf['tps']['tau'][:] - values = orbitf[f'tps/l_{mosa}']['ppr'] + values = orbitf[f'tps/l_{mosa}']['d_ppr'] else: raise ValueError(f"invalid orbit dataset '{self.orbit_dataset}'") return InterpolatedUnivariateSpline(times, values, k=5, ext='raise') @@ -656,9 +663,12 @@ class Instrument: 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)) + self.pprs = ForEachMOSA(lambda mosa: \ + pprs_const(mosa) + d_pprs(mosa).antiderivative()(self.physics_t) \ + - d_pprs(mosa).antiderivative()(self.orbit_t0) + ) logger.debug("Interpolating proper pseudo-range derivatives") - self.d_pprs = ForEachMOSA(lambda mosa: pprs(mosa).derivative()(self.physics_t)) + self.d_pprs = ForEachMOSA(lambda mosa: d_pprs(mosa)(self.physics_t)) logger.debug("Interpolating TPSs with respect to TCB") self.tps_wrt_tcb = ForEachSC(lambda sc: tps_wrt_tcb(sc)(self.physics_t_covering_telemetry)) except ValueError as error: @@ -670,7 +680,8 @@ class Instrument: # Prepare common interpolation method times = orbitf.attrs['t0'] + np.arange(orbitf.attrs['size']) * orbitf.attrs['dt'] - interpolate = lambda data, t, nu=0: InterpolatedUnivariateSpline(times, data, ext='raise')(t, nu=nu) + interpolate = lambda data, t: InterpolatedUnivariateSpline(times, data, k=5, ext='raise')(t) + int_interpolate = lambda data, t: InterpolatedUnivariateSpline(times, data, k=5, ext='raise').antiderivative()(t) link_index = {'12': 0, '23': 1, '31': 2, '13': 3, '32': 4, '21': 5} sc_index = {'1': 0, '2': 1, '3': 2} @@ -680,10 +691,17 @@ class Instrument: 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)) + ppr_dataset = orbitf['tcb/ltt'] if self.orbit_dataset == 'tcb/ltt' else orbitf['tps/ppr'] + d_ppr_dataset = orbitf['tcb/d_ltt'] if self.orbit_dataset == 'tcb/ltt' else orbitf['tps/d_ppr'] + self.pprs = ForEachMOSA(lambda mosa: \ + ppr_dataset[0, link_index[mosa]] \ + + int_interpolate(d_ppr_dataset[:, link_index[mosa]], self.physics_t) \ + - int_interpolate(d_ppr_dataset[:, link_index[mosa]], self.orbit_t0) + ) logger.debug("Interpolating proper pseudo-range derivatives") - self.d_pprs = ForEachMOSA(lambda mosa: interpolate(dataset[:, link_index[mosa]], self.physics_t, nu=1)) + self.d_pprs = ForEachMOSA(lambda mosa: \ + interpolate(d_ppr_dataset[:, link_index[mosa]], self.physics_t) + ) except ValueError as error: logger.error("Missing orbit information at \n%s", self.physics_t) raise ValueError("missing orbit information, use longer orbit file or adjust sampling") from error