Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update VIIRS L1b reader to use additional netcdf attributes #2891

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions satpy/readers/viirs_l1b.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Comment on lines +37 to +51
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see a reason for these to be properties on the class. Could you change this to just access self["/attr/endDirection"] (and the others) directly in the get_metadata method?

@property
def start_orbit_number(self):
"""Get start orbit number."""
Expand Down Expand Up @@ -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,
})
Expand Down
6 changes: 6 additions & 0 deletions satpy/tests/reader_tests/test_viirs_l1b.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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."""
Expand Down