From 280ebd6406663f1eb2e8e49527f07a1474ece5bb Mon Sep 17 00:00:00 2001 From: Simon Proud Date: Thu, 29 Aug 2024 11:46:25 +0200 Subject: [PATCH] Update VIIRS L1b reader to use additional netcdf attributes --- satpy/readers/viirs_l1b.py | 18 ++++++++++++++++++ satpy/tests/reader_tests/test_viirs_l1b.py | 6 ++++++ 2 files changed, 24 insertions(+) diff --git a/satpy/readers/viirs_l1b.py b/satpy/readers/viirs_l1b.py index 7dd3079dbb..c0433b38a3 100644 --- a/satpy/readers/viirs_l1b.py +++ b/satpy/readers/viirs_l1b.py @@ -34,6 +34,21 @@ def _parse_datetime(self, datestr): """Parse datetime.""" return dt.datetime.strptime(datestr, "%Y-%m-%dT%H:%M:%S.000Z") + @property + def day_night_flag(self): + """Get the day/night flag.""" + return self["/attr/DayNightFlag"] + + @property + def start_direction(self): + """Get the swath start direction flag.""" + return self["/attr/startDirection"] + + @property + def end_direction(self): + """Get the swath end direction flag.""" + return self["/attr/endDirection"] + @property def start_orbit_number(self): """Get start orbit number.""" @@ -188,6 +203,9 @@ def get_metadata(self, dataset_id, ds_info): "file_units": file_units, "platform_name": self.platform_name, "sensor": self.sensor_name, + "day_night": self.day_night_flag, + "start_direction": self.start_direction, + "end_direction": self.end_direction, "start_orbit": self.start_orbit_number, "end_orbit": self.end_orbit_number, }) diff --git a/satpy/tests/reader_tests/test_viirs_l1b.py b/satpy/tests/reader_tests/test_viirs_l1b.py index b2a5c4b476..c8a5468fc7 100644 --- a/satpy/tests/reader_tests/test_viirs_l1b.py +++ b/satpy/tests/reader_tests/test_viirs_l1b.py @@ -65,6 +65,9 @@ def get_test_content(self, filename, filename_info, filetype_info): "/attr/orbit_number": 26384, "/attr/instrument": "VIIRS", "/attr/platform": "Suomi-NPP", + "/attr/DayNightFlag": "Day", + "/attr/startDirection": "Descending", + "/attr/endDirection": "Ascending", } self._fill_contents_with_default_data(file_content, file_type) self._set_dataset_specific_metadata(file_content) @@ -271,6 +274,9 @@ def test_load_every_m_band_rad(self): assert v.attrs["area"].lons.attrs["rows_per_scan"] == 2 assert v.attrs["area"].lats.attrs["rows_per_scan"] == 2 assert v.attrs["sensor"] == "viirs" + assert v.attrs["day_night"] == "Day" + assert v.attrs["start_direction"] == "Descending" + assert v.attrs["end_direction"] == "Ascending" def test_load_i_band_angles(self): """Test loading all M bands as radiances."""