-
Notifications
You must be signed in to change notification settings - Fork 307
Add a reader for NWC SAF GEO HRW data #3070
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
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3070 +/- ##
========================================
Coverage 96.14% 96.15%
========================================
Files 383 385 +2
Lines 55798 56021 +223
========================================
+ Hits 53649 53867 +218
- Misses 2149 2154 +5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
I reduced the number of data rows that were written to the test data. With the original |
I'll have a look at adding a kwarg to merge the different channel observations, so the user could do something like scn = Scene(reader="nwcsaf-geo", filenames=filenames, reader_kwargs={"merge_channels": True})
scn.load(["wind_speed", "wind_from_direction"]) instead of loading each of the channels ( |
Also some documentation added. |
Pull Request Test Coverage Report for Build 13971092899Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
FILETYPE_INFO = {"file_type": "nc_nwcsaf_geo_hrw"} | ||
|
||
|
||
@pytest.fixture |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pytest.fixture | |
@pytest.fixture(scope="module") |
Unless I misunderstand the fixture, this should make it so it is only created once for all of this module's tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with the scope, but this will break tmp_path
, you need to use tmp_path_factory
instead https://docs.pytest.org/en/stable/how-to/tmp_path.html#the-tmp-path-factory-fixture
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adjusted in ba584f3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a suggestion or two, but I really don't think I should have final say on this as I have no experience with nwcsaf readers. I'm marking my review as approve even though I requested a few things. Not doing my suggestions does not mean this file handler is broken or that it can't be merged, but it isn't as good as it could be 😉
with suppress(OSError): | ||
self.h5f.close() | ||
|
||
def available_datasets(self, configured_datasets=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The configured_datasets
are not "forwarded on" as suggested in the base file handler:
satpy/satpy/readers/file_handlers.py
Lines 256 to 263 in f915074
for is_avail, ds_info in (configured_datasets or []): | |
if is_avail is not None: | |
# some other file handler said it has this dataset | |
# we don't know any more information than the previous | |
# file handler so let's yield early | |
yield is_avail, ds_info | |
continue | |
yield self.file_type_matches(ds_info["file_type"]), ds_info |
Without this users will not be able to statically define datasets in the YAML.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So what to change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple of small things, but otherwise LGTM
satpy/readers/nwcsaf_hrw_nc.py
Outdated
scn = Scene(reader="nwcsaf-geo", filenames=[filename]) | ||
pprint.pprint(scn.available_dataset_names()) | ||
|
||
This print all the available datasets. The truncated output of this is:: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This print all the available datasets. The truncated output of this is:: | |
This prints all the available datasets. The truncated output of this is:: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 6e690d9
FILETYPE_INFO = {"file_type": "nc_nwcsaf_geo_hrw"} | ||
|
||
|
||
@pytest.fixture |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with the scope, but this will break tmp_path
, you need to use tmp_path_factory
instead https://docs.pytest.org/en/stable/how-to/tmp_path.html#the-tmp-path-factory-fixture
except ValueError: | ||
logger.warning("Reading %s is not supported.", dataset_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have thought this raises a KeyError...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It raises ValueError
when the data are there but the compound datatype is unreadable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This PR adds a reader for the High Resolution Winds data from NWC SAF GEO.
The data structure is very complex, and due to the unsupported compound data type can't be opened with
xr.open_dataset()
. Because there are 259 datasets, I've made the dataset definitions dynamic instead of putting them into the reader YAML. The code is in a separate file because the internal structure is completely different to the other NWC SAF GEO products (see the linked issue).By default the file handler reads the datasets separately for each imaging channel. That is, the datasets are named
wind_vis06_air_pressure
,wind_hrvis_wind_speed
, and so on. The prefix is the name of the channel within the files.The user can also supply
reader_kwargs={"merge_channels": True}
to collect all the data together. In this case the datasets are named without the prefix, such asair_pressure
,wind_speed
, etc.