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 additional ACSPO reader file patterns #1824

Merged
merged 1 commit into from Sep 17, 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
2 changes: 1 addition & 1 deletion satpy/etc/readers/acspo.yaml
Expand Up @@ -8,7 +8,7 @@ reader:
file_types:
acspo_sst:
file_reader: !!python/name:satpy.readers.acspo.ACSPOFileHandler
file_patterns: ['{start_time:%Y%m%d%H%M%S}-{rdac:4s}-L2P_GHRSST-SSTskin-{sensor_id}-ACSPO_V{version}-v{gds_version}-fv{file_version}.nc']
file_patterns: ['{start_time:%Y%m%d%H%M%S}-{rdac:4s}-L2P_GHRSST-{dataset_name}-{sensor_id}-ACSPO_V{version}-v{gds_version}-fv{file_version}.nc']

datasets:
longitude:
Expand Down
30 changes: 18 additions & 12 deletions satpy/tests/reader_tests/test_acspo.py
Expand Up @@ -22,8 +22,8 @@
import numpy as np
from satpy.tests.reader_tests.test_netcdf_utils import FakeNetCDF4FileHandler
from satpy.tests.utils import convert_file_content_to_data_array
import unittest
from unittest import mock
import pytest

DEFAULT_FILE_DTYPE = np.uint16
DEFAULT_FILE_SHAPE = (10, 300)
Expand All @@ -44,6 +44,7 @@ def get_test_content(self, filename, filename_info, filetype_info):
dt = filename_info.get('start_time', datetime(2016, 1, 1, 12, 0, 0))
sat, inst = {
'VIIRS_NPP': ('NPP', 'VIIRS'),
'VIIRS_N20': ('N20', 'VIIRS'),
}[filename_info['sensor_id']]

file_content = {
Expand Down Expand Up @@ -96,12 +97,12 @@ def get_test_content(self, filename, filename_info, filetype_info):
return file_content


class TestACSPOReader(unittest.TestCase):
class TestACSPOReader:
"""Test ACSPO Reader."""

yaml_file = "acspo.yaml"

def setUp(self):
def setup_method(self):
"""Wrap NetCDF4 file handler with our own fake handler."""
from satpy._config import config_search_paths
from satpy.readers.acspo import ACSPOFileHandler
Expand All @@ -111,21 +112,26 @@ def setUp(self):
self.fake_handler = self.p.start()
self.p.is_local = True

def tearDown(self):
def teardown_method(self):
"""Stop wrapping the NetCDF4 file handler."""
self.p.stop()

def test_init(self):
@pytest.mark.parametrize(
("filename",),
[
["20170401174600-STAR-L2P_GHRSST-SSTskin-VIIRS_NPP-ACSPO_V2.40-v02.0-fv01.0.nc"],
["20210916161708-STAR-L2P_GHRSST-SSTsubskin-VIIRS_N20-ACSPO_V2.80-v02.0-fv01.0.nc"],
]
)
def test_init(self, filename):
"""Test basic init with no extra parameters."""
from satpy.readers import load_reader
r = load_reader(self.reader_configs)
loadables = r.select_files_from_pathnames([
'20170401174600-STAR-L2P_GHRSST-SSTskin-VIIRS_NPP-ACSPO_V2.40-v02.0-fv01.0.nc',
])
self.assertEqual(len(loadables), 1)
loadables = r.select_files_from_pathnames([filename])
assert len(loadables) == 1
r.create_filehandlers(loadables)
# make sure we have some files
self.assertTrue(r.file_handlers)
assert r.file_handlers

def test_load_every_dataset(self):
"""Test loading all datasets."""
Expand All @@ -139,6 +145,6 @@ def test_load_every_dataset(self):
'satellite_zenith_angle',
'sea_ice_fraction',
'wind_speed'])
self.assertEqual(len(datasets), 4)
assert len(datasets) == 4
for d in datasets.values():
self.assertTupleEqual(d.shape, DEFAULT_FILE_SHAPE)
assert d.shape == DEFAULT_FILE_SHAPE