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

Add unit tests for frequency plan

parent c8fce595
No related branches found
No related tags found
1 merge request!56Resolve "Add frequency plan"
.gitattributes 100644 → 100755
......@@ -2,3 +2,5 @@ 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
tests/keplerian-fplan-1-1.h5 filter=lfs diff=lfs merge=lfs -text
tests/esa-trailing-fplan-1-1.h5 filter=lfs diff=lfs merge=lfs -text
File added
File added
......@@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-
# pylint: disable=missing-module-docstring
import numpy as np
import pytest
from lisainstrument import Instrument
......@@ -48,6 +49,73 @@ def test_esa_trailing_orbits_2_0_dev():
instru = Instrument(size=100, orbits='tests/esa-trailing-orbits-2-0-dev.h5')
instru.simulate()
def test_custom_fplan():
"""Test that we can pass a custom frequency plan."""
# Constant equal fplan
instru = Instrument(size=100, fplan=42.0)
for mosa in instru.MOSAS:
assert instru.fplan[mosa] == 42.0
instru.simulate()
# Constant unequal fplan
fplan = {
'12': 8.1E6, '23': 9.2E6, '31': 10.3E6,
'13': 1.4E6, '32': -11.6E6, '21': -9.5E6,
}
instru = Instrument(size=100, fplan=fplan)
for mosa in instru.MOSAS:
assert instru.fplan[mosa] == fplan[mosa]
instru.simulate()
# Time-varying equal fplan
fplan = np.random.normal(size=(instru.physics_size))
instru = Instrument(size=100, fplan=fplan)
for mosa in instru.MOSAS:
assert instru.fplan[mosa] == pytest.approx(fplan)
instru.simulate()
# Time-varying unequal fplan
fplan = {mosa: np.random.normal(size=(instru.physics_size)) for mosa in instru.MOSAS}
instru = Instrument(size=100, fplan=fplan)
for mosa in instru.MOSAS:
assert instru.fplan[mosa] == pytest.approx(fplan[mosa])
instru.simulate()
def test_keplerian_fplan_1_1():
"""Test that simulations can run with Keplerian fplan v1.1."""
# Check with six lasers locked on cavity
instru = Instrument(size=100, lock='six', fplan='tests/keplerian-fplan-1-1.h5')
for mosa in instru.MOSAS:
assert instru.fplan[mosa] == 0.0
instru.simulate()
# Check standard lock configs
for topology in Instrument.LOCK_TOPOLOGIES:
for primary in Instrument.MOSAS:
instru = Instrument(
size=100, lock=f'{topology}-{primary}', fplan='tests/keplerian-fplan-1-1.h5')
assert instru.fplan[primary] == 0.0
instru.simulate()
# Should raise an error for non-standard lock config
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')
def test_esa_trailing_fplan_1_1():
"""Test that simulations can run with ESA trailing fplan v1.1."""
# Check with six lasers locked on cavity
instru = Instrument(size=100, lock='six', fplan='tests/esa-trailing-fplan-1-1.h5')
for mosa in instru.MOSAS:
assert instru.fplan[mosa] == 0.0
instru.simulate()
# Check standard lock configs
for topology in Instrument.LOCK_TOPOLOGIES:
for primary in Instrument.MOSAS:
instru = Instrument(
size=100, lock=f'{topology}-{primary}', fplan='tests/esa-trailing-fplan-1-1.h5')
assert instru.fplan[primary] == 0.0
instru.simulate()
# Should raise an error for non-standard lock config
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')
def test_locking():
"""Test that simulations can run with various lock configurations."""
# Test six free-running lasers
......
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