Skip to content

Commit

Permalink
Add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
mraspaud committed Mar 18, 2024
1 parent 64dd108 commit f0c238c
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions satpy/tests/reader_tests/test_avhrr_l1b_gaclac.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import xarray as xr

GAC_PATTERN = '{creation_site:3s}.{transfer_mode:4s}.{platform_id:2s}.D{start_time:%y%j.S%H%M}.E{end_time:%H%M}.B{orbit_number:05d}{end_orbit_last_digits:02d}.{station:2s}' # noqa
EOSIP_PATTERN = '{platform_id:3s}_RPRO_AVH_L1B_1P_{start_time:%Y%m%dT%H%M%S}_{end_time:%Y%m%dT%H%M%S}_{orbit_number:06d}/image.l1b' # noqa

GAC_POD_FILENAMES = ["NSS.GHRR.NA.D79184.S1150.E1337.B0008384.WI",
"NSS.GHRR.NA.D79184.S2350.E0137.B0008384.WI",
Expand Down Expand Up @@ -68,6 +69,8 @@
"NSS.FRAC.M2.D12153.S1729.E1910.B2915354.SV",
"NSS.LHRR.NP.D16306.S1803.E1814.B3985555.WI"]

LAC_EOSIP_FILENAMES = ["N06_RPRO_AVH_L1B_1P_20061206T010808_20061206T012223_007961/image.l1b"]


@mock.patch("satpy.readers.avhrr_l1b_gaclac.GACLACFile.__init__", return_value=None)
def _get_fh_mocked(init_mock, **attrs):
Expand Down Expand Up @@ -138,6 +141,12 @@ def _get_fh(self, filename="NSS.GHRR.NG.D88002.S0614.E0807.B0670506.WI",
filename_info = parse(GAC_PATTERN, filename)
return self.GACLACFile(filename, filename_info, {}, **kwargs)

def _get_eosip_fh(self, filename, **kwargs):
"""Create a file handler."""
from trollsift import parse
filename_info = parse(EOSIP_PATTERN, filename)
return self.GACLACFile(filename, filename_info, {}, **kwargs)

def test_init(self):
"""Test GACLACFile initialization."""
from pygac.gac_klm import GACKLMReader
Expand All @@ -161,6 +170,28 @@ def test_init(self):
assert fh.start_time < fh.end_time
assert fh.reader_class is reader_cls


def test_init_eosip(self):
"""Test GACLACFile initialization."""
from pygac.lac_pod import LACPODReader

kwargs = {"start_line": 1,
"end_line": 2,
"strip_invalid_coords": True,
"interpolate_coords": True,
"adjust_clock_drift": True,
"tle_dir": "tle_dir",
"tle_name": "tle_name",
"tle_thresh": 123,
"calibration": "calibration"}
for filenames, reader_cls in zip([LAC_EOSIP_FILENAMES],
[LACPODReader]):
for filename in filenames:
fh = self._get_eosip_fh(filename, **kwargs)
assert fh.start_time < fh.end_time
assert fh.reader_class is reader_cls
assert fh.reader_kwargs["eosip_header"] is True

def test_read_raw_data(self):
"""Test raw data reading."""
fh = _get_fh_mocked(reader=None,
Expand Down

0 comments on commit f0c238c

Please sign in to comment.