diff --git a/tests/test_fplan.py b/tests/test_fplan.py index d4c11e6ffb265898fe2cb30378490128be4ea6d1..fad0003e8466c0319c8df730d9dc002eb3dc2a80 100755 --- a/tests/test_fplan.py +++ b/tests/test_fplan.py @@ -25,7 +25,9 @@ def _consistent_locking_beatnotes(instru, fplan=None): # Read fplan file if fplan is None: with File(instru.fplan_file, 'r') as fplanf: - t = np.arange(fplanf.attrs['size']) * fplanf.attrs['dt'] + with File(instru.orbit_file, 'r') as orbitsf: + t0 = orbitsf.attrs['t0'] + t = t0 + np.arange(fplanf.attrs['size']) * fplanf.attrs['dt'] if instru.lock_config == 'N1-12': fplan = { '13': interp1d(t, -fplanf[instru.lock_config]['rfi_12'][:] * 1E6)(instru.physics_t), @@ -217,25 +219,36 @@ def test_keplerian_fplan_1_1(): # Check fplan file with standard lock configs for primary in Instrument.MOSAS: for topology in Instrument.LOCK_TOPOLOGIES: - instru = Instrument(size=100, lock=f'{topology}-{primary}', fplan='tests/keplerian-fplan-1-1.h5') + instru = Instrument( + size=100, + lock=f'{topology}-{primary}', + fplan='tests/keplerian-fplan-1-1.h5', + orbits='tests/keplerian-orbits-1-0-2.h5', # does not match, but okay + ) # Should raise an error for non-standard lock config with pytest.raises(ValueError): - Instrument(size=100, lock='six', fplan='tests/keplerian-fplan-1-1.h5') + Instrument(size=100, lock='six', fplan='tests/keplerian-fplan-1-1.h5', orbits='tests/keplerian-orbits-1-0-2.h5') with pytest.raises(ValueError): lock = {'12': 'cavity', '13': 'cavity', '21': 'distant', '31': 'distant', '23': 'adjacent', '32': 'adjacent'} Instrument(size=100, lock=lock, fplan='tests/keplerian-fplan-1-1.h5') + # Should raise an error without orbit file + with pytest.raises(ValueError): + Instrument(size=100, lock='N1-12', fplan='tests/keplerian-fplan-1-1.h5') + # Check locking beatnotes - instru = Instrument(size=100, lock='N1-12', fplan='tests/keplerian-fplan-1-1.h5') + with File('tests/keplerian-orbits-1-0-2.h5', 'r') as f: + t0 = f.attrs['t0'] + 100 + instru = Instrument(size=100, lock='N1-12', t0=t0, fplan='tests/keplerian-fplan-1-1.h5', orbits='tests/keplerian-orbits-1-0-2.h5') instru.simulate() instru.write(mode='w') assert _consistent_locking_beatnotes(instru) - instru = Instrument(size=100, lock='N1-21', fplan='tests/keplerian-fplan-1-1.h5') + instru = Instrument(size=100, lock='N1-21', t0=t0, fplan='tests/keplerian-fplan-1-1.h5', orbits='tests/keplerian-orbits-1-0-2.h5') instru.simulate() instru.write(mode='w') assert _consistent_locking_beatnotes(instru) - instru = Instrument(size=100, lock='N4-12', fplan='tests/keplerian-fplan-1-1.h5') + instru = Instrument(size=100, lock='N4-12', t0=t0, fplan='tests/keplerian-fplan-1-1.h5', orbits='tests/keplerian-orbits-1-0-2.h5') instru.simulate() instru.write(mode='w') assert _consistent_locking_beatnotes(instru) @@ -246,25 +259,36 @@ def test_esa_trailing_fplan_1_1(): # Check fplan file with standard lock configs for primary in Instrument.MOSAS: for topology in Instrument.LOCK_TOPOLOGIES: - instru = Instrument(size=100, lock=f'{topology}-{primary}', fplan='tests/esa-trailing-fplan-1-1.h5') + instru = Instrument( + size=100, + lock=f'{topology}-{primary}', + fplan='tests/esa-trailing-fplan-1-1.h5', + orbits='tests/esa-orbits-1-0-2.h5', # does not match, but okay + ) # Should raise an error for non-standard lock config with pytest.raises(ValueError): - Instrument(size=100, lock='six', fplan='tests/esa-trailing-fplan-1-1.h5') + Instrument(size=100, lock='six', fplan='tests/esa-trailing-fplan-1-1.h5', orbits='tests/esa-orbits-1-0-2.h5') with pytest.raises(ValueError): lock = {'12': 'cavity', '13': 'cavity', '21': 'distant', '31': 'distant', '23': 'adjacent', '32': 'adjacent'} - Instrument(size=100, lock=lock, fplan='tests/esa-trailing-fplan-1-1.h5') + Instrument(size=100, lock=lock, fplan='tests/esa-trailing-fplan-1-1.h5', orbits='tests/esa-orbits-1-0-2.h5') + + # Should raise an error without orbit file + with pytest.raises(ValueError): + Instrument(size=100, lock='six', fplan='tests/esa-trailing-fplan-1-1.h5') # Check locking beatnotes - instru = Instrument(size=100, lock='N1-12', fplan='tests/esa-trailing-fplan-1-1.h5') + with File('tests/esa-orbits-1-0-2.h5', 'r') as f: + t0 = f.attrs['t0'] + 100 + instru = Instrument(size=100, lock='N1-12', t0=t0, fplan='tests/esa-trailing-fplan-1-1.h5', orbits='tests/esa-orbits-1-0-2.h5') instru.simulate() instru.write(mode='w') assert _consistent_locking_beatnotes(instru) - instru = Instrument(size=100, lock='N1-21', fplan='tests/esa-trailing-fplan-1-1.h5') + instru = Instrument(size=100, lock='N1-21', t0=t0, fplan='tests/esa-trailing-fplan-1-1.h5', orbits='tests/esa-orbits-1-0-2.h5') instru.simulate() instru.write(mode='w') assert _consistent_locking_beatnotes(instru) - instru = Instrument(size=100, lock='N4-12', fplan='tests/esa-trailing-fplan-1-1.h5') + instru = Instrument(size=100, lock='N4-12', t0=t0, fplan='tests/esa-trailing-fplan-1-1.h5', orbits='tests/esa-orbits-1-0-2.h5') instru.simulate() instru.write(mode='w') assert _consistent_locking_beatnotes(instru)