Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
mraspaud committed Mar 18, 2024
1 parent f0c238c commit 0bc8a42
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
20 changes: 13 additions & 7 deletions satpy/readers/avhrr_l1b_gaclac.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,20 +100,16 @@ def __init__(self, filename, filename_info, filetype_info, # noqa: D417
self.platform_id = filename_info["platform_id"]

if len(self.platform_id) == 3:
self.reader_kwargs["eosip_header"] = True
self.reader_kwargs["header_datetime"] = datetime(2000, 1, 1)

if self.platform_id in ["NK", "NL", "NM", "NN", "NP",
"N15", "N16", "N17", "N18", "N19",
"M1", "M2", "M3",
"MOB", "MOA", "MOC"]:
if self._is_avhrr3():
if filename_info.get("transfer_mode") == "GHRR":
self.reader_class = GACKLMReader
else:
self.reader_class = LACKLMReader
self.chn_dict = AVHRR3_CHANNEL_NAMES
self.sensor = "avhrr-3"
elif self.platform_id in ["NC", "NE", "NF", "NG", "NH", "ND", "NJ",
"N07", "N08", "N09", "N10", "N11", "N12", "N14"]:
elif self._is_avhrr2():
if filename_info.get("transfer_mode") == "GHRR":
self.reader_class = GACPODReader
else:
Expand All @@ -129,6 +125,16 @@ def __init__(self, filename, filename_info, filetype_info, # noqa: D417
self.sensor = "avhrr"
self.filename_info = filename_info

def _is_avhrr2(self):
return self.platform_id in ["NC", "NE", "NF", "NG", "NH", "ND", "NJ",
"N07", "N08", "N09", "N10", "N11", "N12", "N14"]

def _is_avhrr3(self):
return self.platform_id in ["NK", "NL", "NM", "NN", "NP",
"N15", "N16", "N17", "N18", "N19",
"M1", "M2", "M3",
"MOB", "MOA", "MOC"]

def read_raw_data(self):
"""Create a pygac reader and read raw data from the file."""
if self.reader is None:
Expand Down
2 changes: 1 addition & 1 deletion satpy/tests/reader_tests/test_avhrr_l1b_gaclac.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def test_init_eosip(self):
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
assert fh.reader_kwargs["header_datetime"] > datetime.date(1994, 11, 15)

def test_read_raw_data(self):
"""Test raw data reading."""
Expand Down

0 comments on commit 0bc8a42

Please sign in to comment.