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

Add file pattern for NWCSAF input file names to 'grib' reader #1212

Merged
merged 2 commits into from May 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions satpy/etc/readers/grib.yaml
Expand Up @@ -17,6 +17,9 @@ file_types:
# S-OSI_-NOR_-MULT-AHLDLI_FIELD-201805011200Z.grb.gz
- '{stem}.grb'
- '{stem}.grb2'
# NWCSAF input file name format:
# S_NWC_NWP_2017-03-14T00:00:00Z_002.grib
- 'S_NWC_NWP_{start_time:%Y-%m-%dT%H:%M:%S}Z_{forecast_time:3d}.grib'
# grib_ncep:
# file_reader: !!python/name:satpy.readers.grib.GRIBFileHandler
# file_patterns:
Expand Down
15 changes: 15 additions & 0 deletions satpy/tests/reader_tests/test_grib.py
Expand Up @@ -178,6 +178,21 @@ def test_init(self, pg):
# make sure we have some files
self.assertTrue(r.file_handlers)

def test_file_pattern(self):
"""Test matching of file patterns."""
from satpy.readers import load_reader

filenames = [
"quinoa.grb",
"tempeh.grb2",
"tofu.grib2",
"falafel.grib",
"S_NWC_NWP_1900-01-01T00:00:00Z_999.grib"]

r = load_reader(self.reader_configs)
files = r.select_files_from_pathnames(filenames)
self.assertEqual(len(files), 4)

@mock.patch('satpy.readers.grib.pygrib')
def test_load_all(self, pg):
"""Test loading all test datasets"""
Expand Down