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

Add writing measurement files to tests

parent 89cd9f40
No related branches found
No related tags found
1 merge request!128Resolve "Bug when writing a measurement file with no GW file input"
...@@ -92,12 +92,15 @@ def test_static_fplan(): ...@@ -92,12 +92,15 @@ def test_static_fplan():
# Check locking beatnotes # Check locking beatnotes
instru = Instrument(size=100, lock='N1-12', fplan='static') instru = Instrument(size=100, lock='N1-12', fplan='static')
instru.simulate() instru.simulate()
instru.write(mode='w')
assert _consistent_locking_beatnotes(instru, static) assert _consistent_locking_beatnotes(instru, static)
instru = Instrument(size=100, lock='N1-21', fplan='static') instru = Instrument(size=100, lock='N1-21', fplan='static')
instru.simulate() instru.simulate()
instru.write(mode='w')
assert _consistent_locking_beatnotes(instru, static) assert _consistent_locking_beatnotes(instru, static)
instru = Instrument(size=100, lock='N4-12', fplan='static') instru = Instrument(size=100, lock='N4-12', fplan='static')
instru.simulate() instru.simulate()
instru.write(mode='w')
assert _consistent_locking_beatnotes(instru, static) assert _consistent_locking_beatnotes(instru, static)
def test_static_fplan_valid_with_all_lock_configs(): def test_static_fplan_valid_with_all_lock_configs():
...@@ -112,6 +115,7 @@ def test_static_fplan_valid_with_all_lock_configs(): ...@@ -112,6 +115,7 @@ def test_static_fplan_valid_with_all_lock_configs():
instru = Instrument(size=100, lock=f'{topology}-{primary}', fplan='static') instru = Instrument(size=100, lock=f'{topology}-{primary}', fplan='static')
instru.disable_all_noises() instru.disable_all_noises()
instru.simulate() instru.simulate()
instru.write(mode='w')
for mosa in instru.MOSAS: for mosa in instru.MOSAS:
assert np.all(5E6 <= np.abs(instru.isi_carriers[mosa])) assert np.all(5E6 <= np.abs(instru.isi_carriers[mosa]))
...@@ -146,12 +150,15 @@ def test_constant_unequal_fplan(): ...@@ -146,12 +150,15 @@ def test_constant_unequal_fplan():
# Check locking beatnotes # Check locking beatnotes
instru = Instrument(size=100, lock='N1-12', fplan=fplan) instru = Instrument(size=100, lock='N1-12', fplan=fplan)
instru.simulate() instru.simulate()
instru.write(mode='w')
assert _consistent_locking_beatnotes(instru, fplan) assert _consistent_locking_beatnotes(instru, fplan)
instru = Instrument(size=100, lock='N1-21', fplan=fplan) instru = Instrument(size=100, lock='N1-21', fplan=fplan)
instru.simulate() instru.simulate()
instru.write(mode='w')
assert _consistent_locking_beatnotes(instru, fplan) assert _consistent_locking_beatnotes(instru, fplan)
instru = Instrument(size=100, lock='N4-12', fplan=fplan) instru = Instrument(size=100, lock='N4-12', fplan=fplan)
instru.simulate() instru.simulate()
instru.write(mode='w')
assert _consistent_locking_beatnotes(instru, fplan) assert _consistent_locking_beatnotes(instru, fplan)
def test_varying_equal_fplan(): def test_varying_equal_fplan():
...@@ -167,12 +174,15 @@ def test_varying_equal_fplan(): ...@@ -167,12 +174,15 @@ def test_varying_equal_fplan():
fplan = {mosa: fplan for mosa in Instrument.MOSAS} fplan = {mosa: fplan for mosa in Instrument.MOSAS}
instru = Instrument(size=100, lock='N1-12', fplan=fplan) instru = Instrument(size=100, lock='N1-12', fplan=fplan)
instru.simulate() instru.simulate()
instru.write(mode='w')
assert _consistent_locking_beatnotes(instru, fplan) assert _consistent_locking_beatnotes(instru, fplan)
instru = Instrument(size=100, lock='N1-21', fplan=fplan) instru = Instrument(size=100, lock='N1-21', fplan=fplan)
instru.simulate() instru.simulate()
instru.write(mode='w')
assert _consistent_locking_beatnotes(instru, fplan) assert _consistent_locking_beatnotes(instru, fplan)
instru = Instrument(size=100, lock='N4-12', fplan=fplan) instru = Instrument(size=100, lock='N4-12', fplan=fplan)
instru.simulate() instru.simulate()
instru.write(mode='w')
assert _consistent_locking_beatnotes(instru, fplan) assert _consistent_locking_beatnotes(instru, fplan)
def test_varying_unequal_fplan(): def test_varying_unequal_fplan():
...@@ -190,12 +200,15 @@ def test_varying_unequal_fplan(): ...@@ -190,12 +200,15 @@ def test_varying_unequal_fplan():
# Check locking beatnotes # Check locking beatnotes
instru = Instrument(size=100, lock='N1-12', fplan=fplan) instru = Instrument(size=100, lock='N1-12', fplan=fplan)
instru.simulate() instru.simulate()
instru.write(mode='w')
assert _consistent_locking_beatnotes(instru, fplan) assert _consistent_locking_beatnotes(instru, fplan)
instru = Instrument(size=100, lock='N1-21', fplan=fplan) instru = Instrument(size=100, lock='N1-21', fplan=fplan)
instru.simulate() instru.simulate()
instru.write(mode='w')
assert _consistent_locking_beatnotes(instru, fplan) assert _consistent_locking_beatnotes(instru, fplan)
instru = Instrument(size=100, lock='N4-12', fplan=fplan) instru = Instrument(size=100, lock='N4-12', fplan=fplan)
instru.simulate() instru.simulate()
instru.write(mode='w')
assert _consistent_locking_beatnotes(instru, fplan) assert _consistent_locking_beatnotes(instru, fplan)
def test_keplerian_fplan_1_1(): def test_keplerian_fplan_1_1():
...@@ -216,12 +229,15 @@ def test_keplerian_fplan_1_1(): ...@@ -216,12 +229,15 @@ def test_keplerian_fplan_1_1():
# Check locking beatnotes # Check locking beatnotes
instru = Instrument(size=100, lock='N1-12', fplan='tests/keplerian-fplan-1-1.h5') instru = Instrument(size=100, lock='N1-12', fplan='tests/keplerian-fplan-1-1.h5')
instru.simulate() instru.simulate()
instru.write(mode='w')
assert _consistent_locking_beatnotes(instru) 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', fplan='tests/keplerian-fplan-1-1.h5')
instru.simulate() instru.simulate()
instru.write(mode='w')
assert _consistent_locking_beatnotes(instru) 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', fplan='tests/keplerian-fplan-1-1.h5')
instru.simulate() instru.simulate()
instru.write(mode='w')
assert _consistent_locking_beatnotes(instru) assert _consistent_locking_beatnotes(instru)
def test_esa_trailing_fplan_1_1(): def test_esa_trailing_fplan_1_1():
...@@ -242,12 +258,15 @@ def test_esa_trailing_fplan_1_1(): ...@@ -242,12 +258,15 @@ def test_esa_trailing_fplan_1_1():
# Check locking beatnotes # Check locking beatnotes
instru = Instrument(size=100, lock='N1-12', fplan='tests/esa-trailing-fplan-1-1.h5') instru = Instrument(size=100, lock='N1-12', fplan='tests/esa-trailing-fplan-1-1.h5')
instru.simulate() instru.simulate()
instru.write(mode='w')
assert _consistent_locking_beatnotes(instru) 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', fplan='tests/esa-trailing-fplan-1-1.h5')
instru.simulate() instru.simulate()
instru.write(mode='w')
assert _consistent_locking_beatnotes(instru) 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', fplan='tests/esa-trailing-fplan-1-1.h5')
instru.simulate() instru.simulate()
instru.write(mode='w')
assert _consistent_locking_beatnotes(instru) assert _consistent_locking_beatnotes(instru)
def test_offset_freqs(): def test_offset_freqs():
...@@ -257,6 +276,7 @@ def test_offset_freqs(): ...@@ -257,6 +276,7 @@ def test_offset_freqs():
instru = Instrument(size=100, lock='six', offset_freqs='default') instru = Instrument(size=100, lock='six', offset_freqs='default')
instru.disable_all_noises() instru.disable_all_noises()
instru.simulate() instru.simulate()
instru.write(mode='w')
for mosa in instru.MOSAS: for mosa in instru.MOSAS:
assert np.all(5E6 <= np.abs(instru.isi_carriers[mosa])) assert np.all(5E6 <= np.abs(instru.isi_carriers[mosa]))
assert np.all(5E6 <= np.abs(instru.isi_usbs[mosa])) assert np.all(5E6 <= np.abs(instru.isi_usbs[mosa]))
...@@ -274,15 +294,18 @@ def test_offset_freqs(): ...@@ -274,15 +294,18 @@ def test_offset_freqs():
} }
instru = Instrument(size=100, lock='six', offset_freqs=offset_freqs) instru = Instrument(size=100, lock='six', offset_freqs=offset_freqs)
instru.simulate() instru.simulate()
instru.write(mode='w')
for mosa in instru.MOSAS: for mosa in instru.MOSAS:
assert instru.local_carrier_offsets[mosa] == offset_freqs[mosa] assert instru.local_carrier_offsets[mosa] == offset_freqs[mosa]
# Check that frequency offsets are only set on unlocked lasers # Check that frequency offsets are only set on unlocked lasers
instru = Instrument(size=100, lock='N1-12', offset_freqs=offset_freqs) instru = Instrument(size=100, lock='N1-12', offset_freqs=offset_freqs)
instru.simulate()
instru.disable_all_noises() instru.disable_all_noises()
instru.simulate()
instru.write(mode='w')
assert instru.local_carrier_offsets['12'] == offset_freqs['12'] assert instru.local_carrier_offsets['12'] == offset_freqs['12']
instru = Instrument(size=100, lock='N1-23', offset_freqs=offset_freqs) instru = Instrument(size=100, lock='N1-23', offset_freqs=offset_freqs)
instru.simulate()
instru.disable_all_noises() instru.disable_all_noises()
instru.simulate()
instru.write(mode='w')
assert instru.local_carrier_offsets['23'] == offset_freqs['23'] assert instru.local_carrier_offsets['23'] == offset_freqs['23']
...@@ -21,6 +21,7 @@ def test_no_glitches(): ...@@ -21,6 +21,7 @@ def test_no_glitches():
assert instru.glitch_lasers[mosa] == 0 assert instru.glitch_lasers[mosa] == 0
instru.simulate() instru.simulate()
instru.write(mode='w')
for mosa in instru.MOSAS: for mosa in instru.MOSAS:
assert instru.local_carrier_fluctuations[mosa] == approx(0) assert instru.local_carrier_fluctuations[mosa] == approx(0)
...@@ -72,6 +73,7 @@ def test_glitch_file_1_0(): ...@@ -72,6 +73,7 @@ def test_glitch_file_1_0():
assert instru.glitch_lasers[mosa] == 0 assert instru.glitch_lasers[mosa] == 0
instru.simulate() instru.simulate()
instru.write(mode='w')
for mosa in instru.MOSAS: for mosa in instru.MOSAS:
...@@ -147,6 +149,7 @@ def test_glitch_file_1_1(): ...@@ -147,6 +149,7 @@ def test_glitch_file_1_1():
assert instru.glitch_lasers[mosa] == 0 assert instru.glitch_lasers[mosa] == 0
instru.simulate() instru.simulate()
instru.write(mode='w')
for mosa in instru.MOSAS: for mosa in instru.MOSAS:
......
...@@ -19,6 +19,7 @@ def test_no_gws(): ...@@ -19,6 +19,7 @@ def test_no_gws():
assert instru.gws[mosa] == 0 assert instru.gws[mosa] == 0
instru.simulate() instru.simulate()
instru.write(mode='w')
for mosa in instru.MOSAS: for mosa in instru.MOSAS:
assert instru.distant_carrier_fluctuations[mosa] == approx(0) assert instru.distant_carrier_fluctuations[mosa] == approx(0)
...@@ -44,6 +45,7 @@ def test_dict_of_gws(): ...@@ -44,6 +45,7 @@ def test_dict_of_gws():
assert np.all(instru.gws[mosa] == responses[mosa]) assert np.all(instru.gws[mosa] == responses[mosa])
instru.simulate() instru.simulate()
instru.write(mode='w')
for mosa in instru.MOSAS: for mosa in instru.MOSAS:
assert approx(instru.distant_carrier_fluctuations[mosa]) == \ assert approx(instru.distant_carrier_fluctuations[mosa]) == \
...@@ -99,6 +101,7 @@ def test_gw_file_1_1(): ...@@ -99,6 +101,7 @@ def test_gw_file_1_1():
assert instru.gws[mosa] == approx(gwf[f'tcb/l_{mosa}'][:]) assert instru.gws[mosa] == approx(gwf[f'tcb/l_{mosa}'][:])
instru.simulate() instru.simulate()
instru.write(mode='w')
for mosa in instru.MOSAS: for mosa in instru.MOSAS:
assert approx(instru.distant_carrier_fluctuations[mosa]) == \ assert approx(instru.distant_carrier_fluctuations[mosa]) == \
...@@ -127,6 +130,7 @@ def test_gw_file_1_1(): ...@@ -127,6 +130,7 @@ def test_gw_file_1_1():
assert instru.gws[mosa] == approx(gwf[f'tcb/l_{mosa}'][:]) assert instru.gws[mosa] == approx(gwf[f'tcb/l_{mosa}'][:])
instru.simulate() instru.simulate()
instru.write(mode='w')
for mosa in instru.MOSAS: for mosa in instru.MOSAS:
assert approx(instru.distant_carrier_fluctuations[mosa]) == \ assert approx(instru.distant_carrier_fluctuations[mosa]) == \
...@@ -182,6 +186,7 @@ def test_gw_file_2_0_dev(): ...@@ -182,6 +186,7 @@ def test_gw_file_2_0_dev():
assert instru.gws[mosa] == approx(gwf['tcb/y'][:, imosa]) assert instru.gws[mosa] == approx(gwf['tcb/y'][:, imosa])
instru.simulate() instru.simulate()
instru.write(mode='w')
for imosa, mosa in enumerate(instru.MOSAS): for imosa, mosa in enumerate(instru.MOSAS):
assert approx(instru.distant_carrier_fluctuations[mosa]) == \ assert approx(instru.distant_carrier_fluctuations[mosa]) == \
...@@ -210,6 +215,7 @@ def test_gw_file_2_0_dev(): ...@@ -210,6 +215,7 @@ def test_gw_file_2_0_dev():
assert instru.gws[mosa] == approx(gwf['tcb/y'][:, imosa]) assert instru.gws[mosa] == approx(gwf['tcb/y'][:, imosa])
instru.simulate() instru.simulate()
instru.write(mode='w')
for imosa, mosa in enumerate(instru.MOSAS): for imosa, mosa in enumerate(instru.MOSAS):
assert approx(instru.distant_carrier_fluctuations[mosa]) == \ assert approx(instru.distant_carrier_fluctuations[mosa]) == \
......
...@@ -15,6 +15,6 @@ def test_write(): ...@@ -15,6 +15,6 @@ def test_write():
"""Test that simulations can run and be written.""" """Test that simulations can run and be written."""
hexagon = Hexagon() hexagon = Hexagon()
hexagon.simulate() hexagon.simulate()
hexagon.write('test.h5', mode='w') hexagon.write('measurements.h5', mode='w')
assert os.path.isfile('test.h5') assert os.path.isfile('measurements.h5')
...@@ -10,16 +10,19 @@ def test_run(): ...@@ -10,16 +10,19 @@ def test_run():
"""Test that simulations can run.""" """Test that simulations can run."""
instru = Instrument(size=100) instru = Instrument(size=100)
instru.simulate() instru.simulate()
instru.write(mode='w')
def test_run_no_aafilter(): def test_run_no_aafilter():
"""Test that simulations can run with no filter.""" """Test that simulations can run with no filter."""
instru = Instrument(size=100, aafilter=None) instru = Instrument(size=100, aafilter=None)
instru.simulate() instru.simulate()
instru.write(mode='w')
def test_run_no_upsampling(): def test_run_no_upsampling():
"""Test that simulations can run with no filter.""" """Test that simulations can run with no filter."""
instru = Instrument(size=100, physics_upsampling=1, aafilter=None) instru = Instrument(size=100, physics_upsampling=1, aafilter=None)
instru.simulate() instru.simulate()
instru.write(mode='w')
def test_no_orbit_file(): def test_no_orbit_file():
"""Test that simulations fail with an invalid orbit file.""" """Test that simulations fail with an invalid orbit file."""
...@@ -32,30 +35,38 @@ def test_keplerian_orbits_1_0_2(): ...@@ -32,30 +35,38 @@ def test_keplerian_orbits_1_0_2():
"""Test that simulations can run with Keplerian orbit files v1.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 = Instrument(size=100, orbits='tests/keplerian-orbits-1-0-2.h5')
instru.simulate() instru.simulate()
instru.write(mode='w')
def test_esa_orbits_1_0_2(): def test_esa_orbits_1_0_2():
"""Test that simulations can run with ESA orbit files v1.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 = Instrument(size=100, orbits='tests/esa-orbits-1-0-2.h5')
instru.simulate() instru.simulate()
instru.write(mode='w')
def test_keplerian_orbits_2_0(): def test_keplerian_orbits_2_0():
"""Test that simulations can run with Keplerian orbit files v2.0.""" """Test that simulations can run with Keplerian orbit files v2.0."""
instru = Instrument(size=100, orbits='tests/keplerian-orbits-2-0.h5') instru = Instrument(size=100, orbits='tests/keplerian-orbits-2-0.h5')
instru.simulate() instru.simulate()
instru.write(mode='w')
def test_esa_trailing_orbits_2_0(): def test_esa_trailing_orbits_2_0():
"""Test that simulations can run with ESA trailing orbit files v2.0.""" """Test that simulations can run with ESA trailing orbit files v2.0."""
instru = Instrument(size=100, orbits='tests/esa-trailing-orbits-2-0.h5') instru = Instrument(size=100, orbits='tests/esa-trailing-orbits-2-0.h5')
instru.simulate() instru.simulate()
instru.write(mode='w')
def test_locking(): def test_locking():
"""Test that simulations can run with various lock configurations.""" """Test that simulations can run with various lock configurations."""
# Test six free-running lasers # Test six free-running lasers
Instrument(size=100, lock='six').simulate() instru = Instrument(size=100, lock='six')
instru.simulate()
instru.write(mode='w')
# Test non-swap configurations # Test non-swap configurations
for i in range(1, 6): for i in range(1, 6):
for primary in ['12', '23', '31', '13', '32', '21']: for primary in ['12', '23', '31', '13', '32', '21']:
Instrument(size=100, lock=f'N{i}-{primary}').simulate() instru = Instrument(size=100, lock=f'N{i}-{primary}')
instru.simulate()
instru.write(mode='w')
# Test that any other raises an error # Test that any other raises an error
with pytest.raises(ValueError): with pytest.raises(ValueError):
Instrument(size=100, lock='whatever') Instrument(size=100, lock='whatever')
......
...@@ -21,6 +21,7 @@ def test_no_prn_ambiguity(): ...@@ -21,6 +21,7 @@ def test_no_prn_ambiguity():
instru.disable_clock_noises() instru.disable_clock_noises()
instru.disable_ranging_noises() instru.disable_ranging_noises()
instru.simulate() instru.simulate()
instru.write(mode='w')
for mosa in instru.MOSAS: for mosa in instru.MOSAS:
assert instru.mprs[mosa][50:] == approx(pprs[mosa]) assert instru.mprs[mosa][50:] == approx(pprs[mosa])
...@@ -41,6 +42,7 @@ def test_prn_ambiguity_with_static_orbits(): ...@@ -41,6 +42,7 @@ def test_prn_ambiguity_with_static_orbits():
instru.disable_clock_noises() instru.disable_clock_noises()
instru.disable_ranging_noises() instru.disable_ranging_noises()
instru.simulate() instru.simulate()
instru.write(mode='w')
for mosa in instru.MOSAS: for mosa in instru.MOSAS:
assert instru.mprs[mosa][50:] == approx(pprs[mosa] % (300E3 / c)) assert instru.mprs[mosa][50:] == approx(pprs[mosa] % (300E3 / c))
...@@ -49,6 +51,7 @@ def test_prn_ambiguity_with_static_orbits(): ...@@ -49,6 +51,7 @@ def test_prn_ambiguity_with_static_orbits():
instru.disable_clock_noises() instru.disable_clock_noises()
instru.disable_ranging_noises() instru.disable_ranging_noises()
instru.simulate() instru.simulate()
instru.write(mode='w')
for mosa in instru.MOSAS: for mosa in instru.MOSAS:
assert instru.mprs[mosa][50:] == approx(pprs[mosa] % (100E3 / c)) assert instru.mprs[mosa][50:] == approx(pprs[mosa] % (100E3 / c))
...@@ -64,6 +67,7 @@ def test_prn_ambiguity_with_esa_orbits(): ...@@ -64,6 +67,7 @@ def test_prn_ambiguity_with_esa_orbits():
instru.disable_clock_noises() instru.disable_clock_noises()
instru.disable_ranging_noises() instru.disable_ranging_noises()
instru.simulate() instru.simulate()
instru.write(mode='w')
for mosa in instru.MOSAS: for mosa in instru.MOSAS:
assert np.all(instru.mprs[mosa][50:] <= 300E3 / c) assert np.all(instru.mprs[mosa][50:] <= 300E3 / c)
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