Skip to content

Commit

Permalink
Add additional ACSPO reader file patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
djhoese committed Sep 16, 2021
1 parent bc23a0d commit 4d2b1e5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
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

0 comments on commit 4d2b1e5

Please sign in to comment.