diff --git a/gwinc/noise/quantum.py b/gwinc/noise/quantum.py index 946ff50a3504c7e779a5f7ae7bbd2c4701313809..700dfcfb0455ec43c3789244b46ab4abc818a2e0 100644 --- a/gwinc/noise/quantum.py +++ b/gwinc/noise/quantum.py @@ -33,14 +33,16 @@ def getSqzParams(ifo): params = Struct() if 'Squeezer' not in ifo: - sqzType = None + sqzType = 'None' + elif ifo.Squeezer.AmplitudedB == 0: + sqzType = 'None' else: sqzType = ifo.Squeezer.get('Type', 'Freq Independent') params.sqzType = sqzType # extract squeezer parameters - if sqzType is None: + if sqzType == 'None': params.SQZ_DB = 0 params.ANTISQZ_DB = 0 params.alpha = 0 diff --git a/test/noises/test_quantum.py b/test/noises/test_quantum.py new file mode 100644 index 0000000000000000000000000000000000000000..a5f4a360553beb3246f93f3cbddd0dfc89298005 --- /dev/null +++ b/test/noises/test_quantum.py @@ -0,0 +1,46 @@ +""" +Unit tests for quantum noise +""" +import gwinc +from gwinc.noise.quantum import getSqzParams +from copy import deepcopy +import pytest + + +@pytest.mark.logic +@pytest.mark.fast +def test_no_squeezer_type(): + """Test that the appropriate options result in no squeezer + """ + def assert_no_squeezer(params): + assert params.sqzType == 'None' + assert params.SQZ_DB == 0 + assert params.ANTISQZ_DB == 0 + assert params.lambda_in == 0 + assert params.etaRMS == 0 + + budget = gwinc.load_budget('Aplus') + ifo1 = deepcopy(budget.ifo) + ifo2 = deepcopy(budget.ifo) + ifo3 = deepcopy(budget.ifo) + + # there should be no squeezer if + # the squeezer struct is missing + del ifo1.Squeezer + # or the squeezing amplitude is 0 + ifo2.Squeezer.AmplitudedB = 0 + # or the squeezer type is 'None' + ifo3.Squeezer.Type = 'None' + + assert_no_squeezer(getSqzParams(ifo1)) + assert_no_squeezer(getSqzParams(ifo2)) + assert_no_squeezer(getSqzParams(ifo2)) + + +@pytest.mark.logic +@pytest.mark.fast +@pytest.mark.skip(reason='Needs to be implemented') +def test_lo_params(): + """Test the logic for the various LO options + """ + pass