Skip to content

Commit

Permalink
Refactor FakeNetCDF4FileHandler2.get_test_content for viirs_l1b tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mraspaud committed Nov 23, 2021
1 parent 0c54531 commit e351e8f
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions satpy/tests/reader_tests/test_viirs_l1b.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ def get_test_content(self, filename, filename_info, filetype_info):
'/attr/instrument': 'viirs',
'/attr/platform': 'Suomi-NPP',
}
self._fill_contents_with_default_data(file_content, file_type)

self._set_dataset_specific_metadata(file_content)

convert_file_content_to_data_array(file_content)
return file_content

@staticmethod
def _fill_contents_with_default_data(file_content, file_type):
"""Fill file contents with default data."""
if file_type.startswith('vgeo'):
file_content['/attr/OrbitNumber'] = file_content.pop('/attr/orbit_number')
file_content['geolocation_data/latitude'] = DEFAULT_LAT_DATA
Expand Down Expand Up @@ -110,6 +120,9 @@ def get_test_content(self, filename, filename_info, filetype_info):
file_content['observation_data/DNB_observations'] = DEFAULT_FILE_DATA
file_content['observation_data/DNB_observations/attr/units'] = 'Watts/cm^2/steradian'

@staticmethod
def _set_dataset_specific_metadata(file_content):
"""Set dataset-specific metadata."""
for k in list(file_content.keys()):
if not k.startswith('observation_data') and not k.startswith('geolocation_data'):
continue
Expand Down Expand Up @@ -138,9 +151,6 @@ def get_test_content(self, filename, filename_info, filetype_info):
file_content[k + '/attr/scale_factor'] = 1.1
file_content[k + '/attr/add_offset'] = 0.1

convert_file_content_to_data_array(file_content)
return file_content


class TestVIIRSL1BReader(unittest.TestCase):
"""Test VIIRS L1B Reader."""
Expand Down

0 comments on commit e351e8f

Please sign in to comment.