Skip to content

Commit

Permalink
[bug fixes] fix for codecov
Browse files Browse the repository at this point in the history
  • Loading branch information
whitetuft committed May 22, 2024
1 parent 9dc46b2 commit 1cdfb3f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
17 changes: 15 additions & 2 deletions pyrtlib/tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion pyrtlib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())}")

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 1cdfb3f

Please sign in to comment.