diff --git a/.gitattributes b/.gitattributes index b2f061eb81180bb5e253702f814b337c576ddbdb..5ba79e1336fb7442cdb5f44c6acd150621148302 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,4 @@ -tests/keplerian-orbits.h5 filter=lfs diff=lfs merge=lfs -text +tests/keplerian-orbits-1-0-2.h5 filter=lfs diff=lfs merge=lfs -text +tests/esa-orbits-1-0-2.h5 filter=lfs diff=lfs merge=lfs -text +tests/keplerian-orbits-2-0-dev.h5 filter=lfs diff=lfs merge=lfs -text +tests/esa-trailing-orbits-2-0-dev.h5 filter=lfs diff=lfs merge=lfs -text diff --git a/lisainstrument/instrument.py b/lisainstrument/instrument.py index 570814d8d49a48db285b8bb92ccbd9111e7cc1b8..1062db019c1f58802a8099bd4abb1acd737119f0 100644 --- a/lisainstrument/instrument.py +++ b/lisainstrument/instrument.py @@ -180,9 +180,6 @@ class Instrument: with File(orbits, 'r') as orbitf: version = Version(orbitf.attrs['version']) logger.debug("Using orbit file version %s", version) - # Warn for orbit file development version - if version.is_devrelease: - logger.warning("You are using an orbit file in a development version") # Switch between various orbit file standards if version in SpecifierSet('== 1.*', True): self.t0 = float(orbitf.attrs['t0' if orbit_dataset == 'tcb/ltt' else 'tau0']) @@ -208,9 +205,6 @@ class Instrument: with File(orbits, 'r') as orbitf: version = Version(orbitf.attrs['version']) logger.debug("Using orbit file version %s", version) - # Warn for orbit file development version - if version.is_devrelease: - logger.warning("You are using an orbit file in a development version") # Switch between various orbit file standards if version in SpecifierSet('== 1.*', True): self.telemetry_t0 = float(orbitf.attrs['t0']) @@ -593,23 +587,24 @@ class Instrument: # Prepare common interpolation method times = orbitf.attrs['t0'] + np.arange(orbitf.attrs['size']) * orbitf.attrs['dt'] interpolate = lambda data, t: InterpolatedUnivariateSpline(times, data, ext='raise')(t) - index = {'12': 0, '23': 1, '31': 2, '13': 3, '32': 4, '21': 5} + link_index = {'12': 0, '23': 1, '31': 2, '13': 3, '32': 4, '21': 5} + sc_index = {'1': 0, '2': 1, '3': 2} # Interpolate necessary orbital quantities, # show a helpful error message if orbit file is too short try: 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[:, index[mosa]], self.physics_t)) + self.pprs = ForEachMOSA(lambda mosa: interpolate(dataset[:, link_index[mosa]], self.physics_t)) logger.debug("Interpolating proper pseudo-range derivatives") dataset = orbitf['tcb/d_ltt'] if self.orbit_dataset == 'tcb/ltt' else orbitf['tps/d_ppr'] - self.d_pprs = ForEachMOSA(lambda mosa: interpolate(dataset[:, index[mosa]], self.physics_t)) + self.d_pprs = ForEachMOSA(lambda mosa: interpolate(dataset[:, link_index[mosa]], self.physics_t)) logger.debug("Interpolating proper time deviation from TCB") if self.orbit_dataset == 'tcb/ltt': self.tps_proper_time_deviations = ForEachSC(lambda sc: 0) else: dataset = orbitf['tcb/delta_tau'] - self.tps_proper_time_deviations = ForEachSC(lambda sc: interpolate(dataset[:, sc - 1], self.physics_t)) + self.tps_proper_time_deviations = ForEachSC(lambda sc: interpolate(dataset[:, sc_index[sc]], 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 @@ -1552,9 +1547,11 @@ class Instrument: logger.debug("Solving iteratively (tolerance=%s s, maxiter=%s)", self.clockinv_tolerance, self.clockinv_maxiter) - niter = 0 + # Drop samples at the edges to compute error + edge = min(100, len(timer_deviations) // 2 - 1) error = 0 - edge = 100 # drop samples at the edges to check convergence + + niter = 0 next_inverse = timer_deviations while not niter or error > self.clockinv_tolerance: if niter >= self.clockinv_maxiter: diff --git a/tests/esa-orbits-1-0-2.h5 b/tests/esa-orbits-1-0-2.h5 new file mode 100644 index 0000000000000000000000000000000000000000..c32b92eb0bdd47cd6c23a56e5a8697d35eb68a05 --- /dev/null +++ b/tests/esa-orbits-1-0-2.h5 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:61398e1cd210a15adac3fdab6fd2e3227eff562a2bbc53387379d0fb1d118943 +size 9518728 diff --git a/tests/esa-trailing-orbits-2-0-dev.h5 b/tests/esa-trailing-orbits-2-0-dev.h5 new file mode 100644 index 0000000000000000000000000000000000000000..9f276362dc2a9ae23f590e9fb65b06793322f41f --- /dev/null +++ b/tests/esa-trailing-orbits-2-0-dev.h5 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:75456add2be5eeede5ad4461e2ae3030f52a829018fb5e07a77188c7e121b310 +size 1212152 diff --git a/tests/keplerian-orbits-1-0-2.h5 b/tests/keplerian-orbits-1-0-2.h5 new file mode 100644 index 0000000000000000000000000000000000000000..4cdd2f8e663b2a43c907af96122c2d8b5dfbc350 --- /dev/null +++ b/tests/keplerian-orbits-1-0-2.h5 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:880c96961c2bae1e41e0d58488e2295d2e0458664ff3ad66e5f025d3e4fa3a88 +size 2516632 diff --git a/tests/keplerian-orbits.h5 b/tests/keplerian-orbits-2-0-dev.h5 similarity index 100% rename from tests/keplerian-orbits.h5 rename to tests/keplerian-orbits-2-0-dev.h5 diff --git a/tests/test_instrument.py b/tests/test_instrument.py index ab0af1e3a5ca99d4f72f468f448b7b3a4ff4b676..54adb731c58fedd3dcdf3855f0bd5df966c53c42 100644 --- a/tests/test_instrument.py +++ b/tests/test_instrument.py @@ -16,12 +16,38 @@ def test_run_no_aafilter(): instru = Instrument(size=100, aafilter=None) instru.simulate() -@pytest.mark.skip(reason="do not know why this fails") def test_run_no_upsampling(): """Test that simulations can run with no filter.""" instru = Instrument(size=100, physics_upsampling=1, aafilter=None) instru.simulate() +def test_no_orbit_file(): + """Test that simulations fail with an invalid orbit file.""" + with pytest.raises(FileNotFoundError): + Instrument(size=100, orbits='tests/nonexistent-orbits.h5') + with pytest.raises(FileNotFoundError): + Instrument(size=100, t0=0, orbits='tests/nonexistent-orbits.h5') + +def test_keplerian_orbits_1_0_2(): + """Test that simulations can run with Keplerian orbit files v1.0.2.""" + instru = Instrument(size=100, orbits='tests/keplerian-orbits-1-0-2.h5') + instru.simulate() + +def test_esa_orbits_1_0_2(): + """Test that simulations can run with ESA orbit files v1.0.2.""" + instru = Instrument(size=100, orbits='tests/esa-orbits-1-0-2.h5') + instru.simulate() + +def test_keplerian_orbits_2_0_dev(): + """Test that simulations can run with Keplerian orbit files v2.0.dev.""" + instru = Instrument(size=100, orbits='tests/keplerian-orbits-2-0-dev.h5') + instru.simulate() + +def test_esa_trailing_orbits_2_0_dev(): + """Test that simulations can run with ESA trailing orbit files v2.0.dev.""" + instru = Instrument(size=100, orbits='tests/esa-trailing-orbits-2-0-dev.h5') + instru.simulate() + def test_locking(): """Test that simulations can run with various lock configurations.""" # Test six free-running lasers