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

Fix file pattern matching in SEVIRI Native reader #1609

Merged
merged 2 commits into from Mar 22, 2021
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
6 changes: 3 additions & 3 deletions satpy/etc/readers/seviri_l1b_native.yaml
Expand Up @@ -13,9 +13,9 @@ reader:
file_types:
native_msg:
file_reader: !!python/name:satpy.readers.seviri_l1b_native.NativeMSGFileHandler
file_patterns: ['{satid:4s}-{instr:4s}-MSG{product_level:2d}-0100-NA-{end_time:%Y%m%d%H%M%S.%f}000Z-{processing_time:%Y%m%d%H%M%S}-{order_id:s}.nat',
'{satid:4s}-{instr:4s}-MSG{product_level:2d}-0100-NA-{end_time:%Y%m%d%H%M%S.%f}000Z-{order_id:s}.nat',
'{satid:4s}-{instr:4s}-MSG{product_level:2d}-0100-NA-{end_time:%Y%m%d%H%M%S.%f}000Z'
file_patterns: ['{satid:4s}-{instr:4s}-MSG{product_level:2d}-{base_algorithm_version:4s}-NA-{end_time:%Y%m%d%H%M%S.%f}000Z-{processing_time:%Y%m%d%H%M%S}-{order_id:s}.nat',
'{satid:4s}-{instr:4s}-MSG{product_level:2d}-{base_algorithm_version:4s}-NA-{end_time:%Y%m%d%H%M%S.%f}000Z-{order_id:s}.nat',
'{satid:4s}-{instr:4s}-MSG{product_level:2d}-{base_algorithm_version:4s}-NA-{end_time:%Y%m%d%H%M%S.%f}000Z'
]
# Note: the end_time value in the SEVIRI native filenames is officially called Nominal Image Time (SNIT field in
# the 15_MAIN_PRODUCT_HEADER) marking the time where the product is defined to be valid. This time always matches
Expand Down
30 changes: 30 additions & 0 deletions satpy/tests/reader_tests/test_seviri_l1b_native.py
Expand Up @@ -17,6 +17,7 @@
# satpy. If not, see <http://www.gnu.org/licenses/>.
"""Unittesting the Native SEVIRI reader."""

import os
import unittest
from unittest import mock

Expand Down Expand Up @@ -1101,3 +1102,32 @@ def test_padder_fes_hrv(self):
"""Test padder for FES HRV data."""
calculated, expected = self.prepare_padder(TEST_PADDER_FES_HRV)
np.testing.assert_array_equal(calculated, expected)


class TestNativeMSGFilenames:
"""Test identification of Native format filenames."""

@pytest.fixture
def reader(self):
"""Return reader for SEVIRI Native format."""
from satpy._config import config_search_paths
from satpy.readers import load_reader

reader_configs = config_search_paths(
os.path.join("readers", "seviri_l1b_native.yaml"))
reader = load_reader(reader_configs)
return reader

def test_file_pattern(self, reader):
"""Test file pattern matching."""
filenames = [
# Valid
"MSG2-SEVI-MSG15-0100-NA-20080219094242.289000000Z",
"MSG2-SEVI-MSG15-0201-NA-20080219094242.289000000Z",
"MSG2-SEVI-MSG15-0301-NA-20080219094242.289000000Z-123456.nat",
"MSG2-SEVI-MSG15-0401-NA-20080219094242.289000000Z-20201231181545-123456.nat",
# Invalid
"MSG2-SEVI-MSG15-010-NA-20080219094242.289000000Z",
]
files = reader.select_files_from_pathnames(filenames)
assert len(files) == 4