diff --git a/pyrtlib/tests/test_utils.py b/pyrtlib/tests/test_utils.py index 21639d46..5878d368 100644 --- a/pyrtlib/tests/test_utils.py +++ b/pyrtlib/tests/test_utils.py @@ -1,11 +1,11 @@ from unittest import TestCase - +import pytest import numpy as np from numpy.testing import assert_allclose, assert_almost_equal, assert_equal from pyrtlib.absorption_model import H2OAbsModel from pyrtlib.climatology import AtmosphericProfiles as atmp from pyrtlib.utils import (ppmv2gkg, mr2rh, gas_mass, height_to_pressure, pressure_to_height, constants, - to_kelvin, to_celsius, get_frequencies_sat, eswat_goffgratch, satvap, satmix, + to_kelvin, to_celsius, get_frequencies_sat, get_frequencies, eswat_goffgratch, satvap, satmix, import_lineshape, atmospheric_tickness, mr2rho, mr2e, esice_goffgratch, rho2mr) z, p, d, t, md = atmp.gl_atm(atmp.TROPICAL) @@ -188,6 +188,19 @@ def test_get_frequencies_sat(self): 186.71, 188.21, 189.41, 191.71]) assert_almost_equal(frequencies, get_frequencies_sat('MWI'), decimal=4) + + with pytest.raises(Exception): + frq = get_frequencies_sat('MMWI') + + def test_get_frequencies(self): + frequencies = np.array([22.235, 23.035, 23.835, 26.235, 30.000, 51.250, 52.280, 53.850, 54.940, + 56.660, 57.290, 58.800]) + + assert_almost_equal(frequencies, get_frequencies('ARM'), decimal=4) + + with pytest.raises(Exception): + frq = get_frequencies('mARM') + def test_eswat_goffgratch(self): eswat = eswat_goffgratch(273.25) diff --git a/pyrtlib/utils.py b/pyrtlib/utils.py index 587afadc..dd1a15b0 100644 --- a/pyrtlib/utils.py +++ b/pyrtlib/utils.py @@ -911,7 +911,7 @@ def get_frequencies(instrument: Optional[str] = 'hat') -> List: } try: - return frequencies[instrument.lower()] + return np.array(frequencies[instrument.lower()]) except KeyError: raise ValueError(f"Invalid instrument name. Available instruments are: {list(frequencies.keys())}") @@ -971,6 +971,8 @@ def get_frequencies_sat(instrument: str) -> np.ndarray: cf165 = 165.5 cf53 = 57.290344 cf57 = 57.290344 + + instrument = instrument.upper() if instrument == 'SAPHIR': freq = np.array([cf-11, cf-6.8, cf-4.2, cf-2.8, cf-1.1, cf-0.2,