Skip to content
Snippets Groups Projects
Commit ce977617 authored by Jean-Baptiste Bayle's avatar Jean-Baptiste Bayle
Browse files

Fix the fplan unit tests

parent 526db172
No related branches found
No related tags found
No related merge requests found
Pipeline #276580 failed
This commit is part of merge request !167. Comments created here will be created in the context of that merge request.
......@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment