def test_load_all_i_radiances(self): """Load all I band radiances.""" from satpy.readers import load_reader from satpy.tests.utils import make_dsq r = load_reader(self.reader_configs) loadables = r.select_files_from_pathnames([ 'SVI01_npp_d20120225_t1801245_e1802487_b01708_c20120226002130255476_noaa_ops.h5', 'SVI02_npp_d20120225_t1801245_e1802487_b01708_c20120226002130255476_noaa_ops.h5', 'SVI03_npp_d20120225_t1801245_e1802487_b01708_c20120226002130255476_noaa_ops.h5', 'SVI04_npp_d20120225_t1801245_e1802487_b01708_c20120226002130255476_noaa_ops.h5', 'SVI05_npp_d20120225_t1801245_e1802487_b01708_c20120226002130255476_noaa_ops.h5', 'GITCO_npp_d20120225_t1801245_e1802487_b01708_c20120226002130255476_noaa_ops.h5', ]) r.create_filehandlers(loadables) ds = r.load([ make_dsq(name='I01', calibration='radiance'), make_dsq(name='I02', calibration='radiance'), make_dsq(name='I03', calibration='radiance'), make_dsq(name='I04', calibration='radiance'), make_dsq(name='I05', calibration='radiance'), ]) self.assertEqual(len(ds), 5) for d in ds.values(): self.assertTrue(np.issubdtype(d.dtype, np.float32)) self.assertEqual(d.attrs['calibration'], 'radiance') self.assertEqual(d.attrs['units'], 'W m-2 um-1 sr-1') self.assertEqual(d.attrs['rows_per_scan'], 32) self.assertIn('area', d.attrs) self.assertIsNotNone(d.attrs['area'])
def test_fy4a_1km_resolutions(self): """Test loading data when only 1km resolutions are available.""" from satpy.tests.utils import make_dsq from satpy.readers import load_reader from satpy.dataset.data_dict import get_key filenames = [ 'FY4A-_AGRI--_N_REGC_1047E_L1-_FDI-_MULT_NOM_20190603003000_20190603003416_1000M_V0001.HDF', ] reader = load_reader(self.reader_configs) files = reader.select_files_from_pathnames(filenames) self.assertEqual(1, len(files)) reader.create_filehandlers(files) # Make sure we have some files self.assertTrue(reader.file_handlers) # Verify that the resolution is only 1km available_datasets = reader.available_dataset_ids band_names = ['C' + '%02d' % ch for ch in np.linspace(1, 3, 3)] for band_name in band_names: for resolution in [500, 2000, 4000]: ds_q = make_dsq(name=band_name, resolution=resolution) with pytest.raises(KeyError): res = get_key(ds_q, available_datasets, num_results=0, best=False) ds_q = make_dsq(name=band_name, resolution=1000) res = get_key(ds_q, available_datasets, num_results=0, best=False) self.assertEqual(2, len(res)) res = reader.load(band_names) self.assertEqual(3, len(res)) expected = { 1: np.array([[2.01, 2.02, 2.03, 2.04, 2.05], [2.06, 2.07, 2.08, 2.09, 2.1]]), 2: np.array([[4.03, 4.06, 4.09, 4.12, 4.15], [4.18, 4.21, 4.24, 4.27, 4.3]]), 3: np.array([[6.05, 6.1, 6.15, 6.2, 6.25], [6.3, 6.35, 6.4, 6.45, 6.5]]) } for index, band_name in enumerate(band_names): self.assertEqual(1, res[band_name].attrs['sensor'].islower()) self.assertEqual((2, 5), res[band_name].shape) self.assertEqual('reflectance', res[band_name].attrs['calibration']) self.assertEqual('%', res[band_name].attrs['units']) self.assertTrue( np.allclose(res[band_name].values, expected[index + 1], equal_nan=True))
def test_fy4a_2km_resolutions(self): """Test loading data when only 2km resolutions are available.""" from satpy.tests.utils import make_dsq from satpy.readers import load_reader, get_key filenames = [ 'FY4A-_AGRI--_N_REGC_1047E_L1-_FDI-_MULT_NOM_20190603003000_20190603003416_2000M_V0001.HDF', ] reader = load_reader(self.reader_configs) files = reader.select_files_from_pathnames(filenames) self.assertEqual(1, len(files)) reader.create_filehandlers(files) # Make sure we have some files self.assertTrue(reader.file_handlers) # Verify that the resolution is only 2km available_datasets = reader.available_dataset_ids band_names = ['C' + '%02d' % ch for ch in np.linspace(1, 7, 7)] for band_name in band_names: for resolution in [500, 1000, 4000]: ds_q = make_dsq(name=band_name, resolution=resolution) with pytest.raises(KeyError): res = get_key(ds_q, available_datasets, num_results=0, best=False) ds_q = make_dsq(name=band_name, resolution=2000) res = get_key(ds_q, available_datasets, num_results=0, best=False) if band_name < 'C07': self.assertEqual(2, len(res)) else: self.assertEqual(3, len(res)) res = reader.load(band_names) self.assertEqual(7, len(res)) expected = { 1: np.array([[2.01, 2.02, 2.03, 2.04, 2.05], [2.06, 2.07, 2.08, 2.09, 2.1]]), 2: np.array([[4.03, 4.06, 4.09, 4.12, 4.15], [4.18, 4.21, 4.24, 4.27, 4.3]]), 3: np.array([[6.05, 6.1, 6.15, 6.2, 6.25], [6.3, 6.35, 6.4, 6.45, 6.5]]), 4: np.array([[8.07, 8.14, 8.21, 8.28, 8.35], [8.42, 8.49, 8.56, 8.63, 8.7]]), 5: np.array([[10.09, 10.18, 10.27, 10.36, 10.45], [10.54, 10.63, 10.72, 10.81, 10.9]]), 6: np.array([[12.11, 12.22, 12.33, 12.44, 12.55], [12.66, 12.77, 12.88, 12.99, 13.1]]), 7: np.array([[0.2, 0.3, 0.4, 0.5, 0.6], [0.7, 0.8, 0.9, 1., np.nan]]) } for index, band_name in enumerate(band_names): self.assertEqual((2, 5), res[band_name].shape) if band_name < 'C07': self.assertEqual('reflectance', res[band_name].attrs['calibration']) else: self.assertEqual('brightness_temperature', res[band_name].attrs['calibration']) if band_name < 'C07': self.assertEqual('%', res[band_name].attrs['units']) else: self.assertEqual('K', res[band_name].attrs['units']) self.assertTrue(np.allclose(res[band_name].values, expected[index + 1], equal_nan=True))
def test_reflectance_corrector_different_chunks(self, tmpdir, url, dem_mock_cm, dem_sds): """Test that the modifier works with different chunk sizes for inputs. The modifier uses dask's "map_blocks". If the input chunks aren't the same an error is raised. """ from satpy.modifiers._crefl import ReflectanceCorrector from satpy.tests.utils import make_dsq ref_cor = ReflectanceCorrector( optional_prerequisites=[ make_dsq(name='satellite_azimuth_angle'), make_dsq(name='satellite_zenith_angle'), make_dsq(name='solar_azimuth_angle'), make_dsq(name='solar_zenith_angle') ], name='I01', prerequisites=[], wavelength=(0.6, 0.64, 0.68), resolution=371, calibration='reflectance', modifiers=('sunz_corrected_iband', 'rayleigh_corrected_crefl_iband'), sensor='viirs', url=url, dem_sds=dem_sds, ) area, data = self.data_area_ref_corrector() c01 = _make_viirs_xarray(data, area, 'I01', 'toa_bidirectional_reflectance', wavelength=(0.6, 0.64, 0.68), units='%', calibration='reflectance') c02 = _make_viirs_xarray(data, area, 'satellite_azimuth_angle', 'sensor_azimuth_angle') c02.data = c02.data.rechunk((1, -1)) c03 = _make_viirs_xarray(data, area, 'satellite_zenith_angle', 'sensor_zenith_angle') c04 = _make_viirs_xarray(data, area, 'solar_azimuth_angle', 'solar_azimuth_angle') c05 = _make_viirs_xarray(data, area, 'solar_zenith_angle', 'solar_zenith_angle') with dem_mock_cm(tmpdir, url): res = ref_cor([c01], [c02, c03, c04, c05]) # make sure it can actually compute res.compute()
def test_id_filtering(self): """Check did filtering.""" dq = DataQuery(modifiers=tuple(), name='cheese_shops') did = DataID(self.default_id_keys_config, name='cheese_shops') did2 = DataID(self.default_id_keys_config, name='ni') res = dq.filter_dataids([did2, did]) assert len(res) == 1 assert res[0] == did dataid_container = [ DataID(self.default_id_keys_config, name='ds1', resolution=250, calibration='reflectance', modifiers=tuple()) ] dq = DataQuery(wavelength=0.22, modifiers=tuple()) assert len(dq.filter_dataids(dataid_container)) == 0 dataid_container = [ DataID(minimal_default_keys_config, name='natural_color') ] dq = DataQuery(name='natural_color', resolution=250) assert len(dq.filter_dataids(dataid_container)) == 1 dq = make_dsq(wavelength=0.22, modifiers=('mod1', )) did = make_cid(name='static_image') assert len(dq.filter_dataids([did])) == 0
def test_fy4a_counts_calib(self): """Test loading data at counts calibration.""" from satpy.tests.utils import make_dsq from satpy.readers import load_reader filenames = [ 'FY4A-_AGRI--_N_REGC_1047E_L1-_FDI-_MULT_NOM_20190603003000_20190603003416_0500M_V0001.HDF', 'FY4A-_AGRI--_N_REGC_1047E_L1-_FDI-_MULT_NOM_20190603003000_20190603003416_1000M_V0001.HDF', 'FY4A-_AGRI--_N_REGC_1047E_L1-_FDI-_MULT_NOM_20190603003000_20190603003416_2000M_V0001.HDF', 'FY4A-_AGRI--_N_REGC_1047E_L1-_FDI-_MULT_NOM_20190603003000_20190603003416_4000M_V0001.HDF', ] reader = load_reader(self.reader_configs) files = reader.select_files_from_pathnames(filenames) self.assertEqual(4, len(files)) reader.create_filehandlers(files) # Make sure we have some files self.assertTrue(reader.file_handlers) ds_ids = [] band_names = ['C' + '%02d' % ch for ch in np.linspace(1, 14, 14)] for band_name in band_names: ds_ids.append(make_dsq(name=band_name, calibration='counts')) res = reader.load(ds_ids) self.assertEqual(14, len(res)) for band_name in band_names: self.assertEqual((2, 5), res[band_name].shape) self.assertEqual('counts', res[band_name].attrs['calibration']) self.assertEqual(res[band_name].dtype, np.uint16) self.assertEqual('1', res[band_name].attrs['units'])
def test_fy4a_500m_resolutions(self): """Test loading data when only 500m resolutions are available.""" from satpy.tests.utils import make_dsq from satpy.readers import load_reader from satpy.dataset.data_dict import get_key filenames = [ 'FY4A-_AGRI--_N_REGC_1047E_L1-_FDI-_MULT_NOM_20190603003000_20190603003416_0500M_V0001.HDF', ] reader = load_reader(self.reader_configs) files = reader.select_files_from_pathnames(filenames) self.assertEqual(1, len(files)) reader.create_filehandlers(files) # Make sure we have some files self.assertTrue(reader.file_handlers) # Verify that the resolution is only 500m available_datasets = reader.available_dataset_ids band_names = ['C' + '%02d' % ch for ch in np.linspace(2, 2, 1)] for band_name in band_names: for resolution in [1000, 2000, 4000]: ds_q = make_dsq(name=band_name, resolution=resolution) with pytest.raises(KeyError): res = get_key(ds_q, available_datasets, num_results=0, best=False) ds_q = make_dsq(name=band_name, resolution=500) res = get_key(ds_q, available_datasets, num_results=0, best=False) self.assertEqual(2, len(res)) res = reader.load(band_names) self.assertEqual(1, len(res)) expected = np.array([[2.01, 2.02, 2.03, 2.04, 2.05], [2.06, 2.07, 2.08, 2.09, 2.1]]) for band_name in band_names: self.assertEqual((2, 5), res[band_name].shape) self.assertEqual('reflectance', res[band_name].attrs['calibration']) self.assertEqual('%', res[band_name].attrs['units']) self.assertTrue( np.allclose(res[band_name].values, expected, equal_nan=True))
def test_fy4a_geo(self): """Test loading data for angles.""" from satpy.tests.utils import make_dsq reader = self._create_reader_for_resolutions('GEO') band_name = 'solar_azimuth_angle' ds_ids = [make_dsq(name=band_name)] res = reader.load(ds_ids) assert len(res) == 1 assert res[band_name].shape == (2, 5) assert res[band_name].dtype == np.float32
def _check_keys_for_dsq(available_datasets, resolution_to_test): from satpy.dataset.data_dict import get_key from satpy.tests.utils import make_dsq band_names = CHANNELS_BY_RESOLUTION[resolution_to_test] for band_name in band_names: ds_q = make_dsq(name=band_name, resolution=resolution_to_test) res = get_key(ds_q, available_datasets, num_results=0, best=False) if band_name < 'C07': assert len(res) == 2 else: assert len(res) == 3
def test_getitem(self): """Test DatasetDict getitem with different arguments.""" from satpy.tests.utils import make_dsq d = self.test_dict # access by name self.assertEqual(d["test"], "1") # access by exact wavelength self.assertEqual(d[1.5], "2") # access by near wavelength self.assertEqual(d[1.55], "2") # access by near wavelength of another dataset self.assertEqual(d[1.65], "3") # access by name with multiple levels self.assertEqual(d['test6'], '6_100') self.assertEqual(d[make_dsq(wavelength=1.5)], "2") self.assertEqual(d[make_dsq(wavelength=0.5, resolution=1000)], "1") self.assertEqual(d[make_dsq(wavelength=0.5, resolution=500)], "1h") self.assertEqual(d[make_dsq(name='test6', level=100)], '6_100') self.assertEqual(d[make_dsq(name='test6', level=200)], '6_200') # higher resolution is returned self.assertEqual(d[0.5], "1h") self.assertEqual(d['test4'], '4refl') self.assertEqual(d[make_dataid(name='test4', calibration='radiance')], '4rad') self.assertRaises(KeyError, d.getitem, '1h') # test with full tuple self.assertEqual( d[make_dsq(name='test', wavelength=(0, 0.5, 1), resolution=1000)], "1")
def _assert_which_channels_are_loaded(available_datasets, band_names, resolution_to_test): from satpy.dataset.data_dict import get_key from satpy.tests.utils import make_dsq other_resolutions = RESOLUTION_LIST.copy() other_resolutions.remove(resolution_to_test) for band_name in band_names: for resolution in other_resolutions: ds_q = make_dsq(name=band_name, resolution=resolution) with pytest.raises(KeyError): _ = get_key(ds_q, available_datasets, num_results=0, best=False) ds_q = make_dsq(name=band_name, resolution=resolution_to_test) res = get_key(ds_q, available_datasets, num_results=0, best=False) if band_name < 'C07': assert len(res) == 2 else: assert len(res) == 3
def test_fy4a_counts_calibration(self): """Test loading data at counts calibration.""" from satpy.tests.utils import make_dsq reader = self._create_reader_for_resolutions(*RESOLUTION_LIST) ds_ids = [] band_names = CHANNELS_BY_RESOLUTION[4000] for band_name in band_names: ds_ids.append(make_dsq(name=band_name, calibration='counts')) res = reader.load(ds_ids) assert len(res) == 14 for band_name in band_names: assert res[band_name].shape == (2, 5) assert res[band_name].attrs['calibration'] == "counts" assert res[band_name].dtype == np.uint16 assert res[band_name].attrs['units'] == "1"
def test_reflectance_corrector_modis(self): """Test ReflectanceCorrector modifier with MODIS data.""" from satpy.modifiers._crefl import ReflectanceCorrector from satpy.tests.utils import make_dsq sataa_did = make_dsq(name='satellite_azimuth_angle') satza_did = make_dsq(name='satellite_zenith_angle') solaa_did = make_dsq(name='solar_azimuth_angle') solza_did = make_dsq(name='solar_zenith_angle') ref_cor = ReflectanceCorrector(optional_prerequisites=[ sataa_did, satza_did, solaa_did, solza_did ], name='1', prerequisites=[], wavelength=(0.62, 0.645, 0.67), resolution=250, calibration='reflectance', modifiers=('sunz_corrected', 'rayleigh_corrected_crefl'), sensor='modis') assert ref_cor.attrs['modifiers'] == ('sunz_corrected', 'rayleigh_corrected_crefl') assert ref_cor.attrs['calibration'] == 'reflectance' assert ref_cor.attrs['wavelength'] == (0.62, 0.645, 0.67) assert ref_cor.attrs['name'] == '1' assert ref_cor.attrs['resolution'] == 250 assert ref_cor.attrs['sensor'] == 'modis' assert ref_cor.attrs['prerequisites'] == [] assert ref_cor.attrs['optional_prerequisites'] == [ make_dsq(name='satellite_azimuth_angle'), make_dsq(name='satellite_zenith_angle'), make_dsq(name='solar_azimuth_angle'), make_dsq(name='solar_zenith_angle') ] area, dnb = self.data_area_ref_corrector() def make_xarray(name, calibration, wavelength=None, modifiers=None, resolution=1000): return xr.DataArray(dnb, dims=('y', 'x'), attrs={ 'wavelength': wavelength, 'level': None, 'modifiers': modifiers, 'calibration': calibration, 'resolution': resolution, 'name': name, 'coordinates': ['longitude', 'latitude'], 'platform_name': 'EOS-Aqua', 'polarization': None, 'sensor': 'modis', 'units': '%', 'start_time': datetime(2012, 8, 13, 18, 46, 1, 439838), 'end_time': datetime(2012, 8, 13, 18, 57, 47, 746296), 'area': area, 'ancillary_variables': [] }) c01 = make_xarray('1', 'reflectance', wavelength=(0.62, 0.645, 0.67), modifiers='sunz_corrected', resolution=500) c02 = make_xarray('satellite_azimuth_angle', None) c03 = make_xarray('satellite_zenith_angle', None) c04 = make_xarray('solar_azimuth_angle', None) c05 = make_xarray('solar_zenith_angle', None) res = ref_cor([c01], [c02, c03, c04, c05]) assert isinstance(res, xr.DataArray) assert isinstance(res.data, da.Array) assert res.attrs['wavelength'] == (0.62, 0.645, 0.67) assert res.attrs['modifiers'] == ( 'sunz_corrected', 'rayleigh_corrected_crefl', ) assert res.attrs['calibration'] == 'reflectance' assert res.attrs['resolution'] == 500 assert res.attrs['name'] == '1' assert res.attrs['platform_name'] == 'EOS-Aqua' assert res.attrs['sensor'] == 'modis' assert res.attrs['units'] == '%' assert res.attrs['start_time'] == datetime(2012, 8, 13, 18, 46, 1, 439838) assert res.attrs['end_time'] == datetime(2012, 8, 13, 18, 57, 47, 746296) assert res.attrs['area'] == area assert res.attrs['ancillary_variables'] == [] data = res.values assert abs(np.mean(data) - 52.09372623964498) < 1e-6 assert data.shape == (3, 5) unique = np.unique(data) np.testing.assert_allclose(unique, [25.43670075, 52.93221561, 77.91226236])
def test_reflectance_corrector_viirs(self, tmpdir, url, dem_mock_cm, dem_sds): """Test ReflectanceCorrector modifier with VIIRS data.""" from satpy.modifiers._crefl import ReflectanceCorrector from satpy.tests.utils import make_dsq ref_cor = ReflectanceCorrector( optional_prerequisites=[ make_dsq(name='satellite_azimuth_angle'), make_dsq(name='satellite_zenith_angle'), make_dsq(name='solar_azimuth_angle'), make_dsq(name='solar_zenith_angle') ], name='I01', prerequisites=[], wavelength=(0.6, 0.64, 0.68), resolution=371, calibration='reflectance', modifiers=('sunz_corrected_iband', 'rayleigh_corrected_crefl_iband'), sensor='viirs', url=url, dem_sds=dem_sds, ) assert ref_cor.attrs['modifiers'] == ('sunz_corrected_iband', 'rayleigh_corrected_crefl_iband') assert ref_cor.attrs['calibration'] == 'reflectance' assert ref_cor.attrs['wavelength'] == (0.6, 0.64, 0.68) assert ref_cor.attrs['name'] == 'I01' assert ref_cor.attrs['resolution'] == 371 assert ref_cor.attrs['sensor'] == 'viirs' assert ref_cor.attrs['prerequisites'] == [] assert ref_cor.attrs['optional_prerequisites'] == [ make_dsq(name='satellite_azimuth_angle'), make_dsq(name='satellite_zenith_angle'), make_dsq(name='solar_azimuth_angle'), make_dsq(name='solar_zenith_angle') ] area, data = self.data_area_ref_corrector() c01 = _make_viirs_xarray(data, area, 'I01', 'toa_bidirectional_reflectance', wavelength=(0.6, 0.64, 0.68), units='%', calibration='reflectance') c02 = _make_viirs_xarray(data, area, 'satellite_azimuth_angle', 'sensor_azimuth_angle') c03 = _make_viirs_xarray(data, area, 'satellite_zenith_angle', 'sensor_zenith_angle') c04 = _make_viirs_xarray(data, area, 'solar_azimuth_angle', 'solar_azimuth_angle') c05 = _make_viirs_xarray(data, area, 'solar_zenith_angle', 'solar_zenith_angle') with dem_mock_cm(tmpdir, url), assert_maximum_dask_computes(0): res = ref_cor([c01], [c02, c03, c04, c05]) assert isinstance(res, xr.DataArray) assert isinstance(res.data, da.Array) assert res.attrs['wavelength'] == (0.6, 0.64, 0.68) assert res.attrs['modifiers'] == ('sunz_corrected_iband', 'rayleigh_corrected_crefl_iband') assert res.attrs['calibration'] == 'reflectance' assert res.attrs['resolution'] == 371 assert res.attrs['name'] == 'I01' assert res.attrs['standard_name'] == 'toa_bidirectional_reflectance' assert res.attrs['platform_name'] == 'Suomi-NPP' assert res.attrs['sensor'] == 'viirs' assert res.attrs['units'] == '%' assert res.attrs['start_time'] == datetime(2012, 2, 25, 18, 1, 24, 570942) assert res.attrs['end_time'] == datetime(2012, 2, 25, 18, 11, 21, 175760) assert res.attrs['area'] == area assert res.attrs['ancillary_variables'] == [] data = res.values assert abs(np.mean(data) - 51.12750267805715) < 1e-6 assert data.shape == (3, 5) unique = np.unique(data) np.testing.assert_allclose(unique, [25.20341703, 52.38819447, 75.79089654])
def test_reflectance_corrector_abi(self, name, wavelength, resolution, exp_mean, exp_unique): """Test ReflectanceCorrector modifier with ABI data.""" from satpy.modifiers._crefl import ReflectanceCorrector from satpy.tests.utils import make_dsq ref_cor = ReflectanceCorrector(optional_prerequisites=[ make_dsq(name='satellite_azimuth_angle'), make_dsq(name='satellite_zenith_angle'), make_dsq(name='solar_azimuth_angle'), make_dsq(name='solar_zenith_angle') ], name=name, prerequisites=[], wavelength=wavelength, resolution=resolution, calibration='reflectance', modifiers=( 'sunz_corrected', 'rayleigh_corrected_crefl', ), sensor='abi') assert ref_cor.attrs['modifiers'] == ('sunz_corrected', 'rayleigh_corrected_crefl') assert ref_cor.attrs['calibration'] == 'reflectance' assert ref_cor.attrs['wavelength'] == wavelength assert ref_cor.attrs['name'] == name assert ref_cor.attrs['resolution'] == resolution assert ref_cor.attrs['sensor'] == 'abi' assert ref_cor.attrs['prerequisites'] == [] assert ref_cor.attrs['optional_prerequisites'] == [ make_dsq(name='satellite_azimuth_angle'), make_dsq(name='satellite_zenith_angle'), make_dsq(name='solar_azimuth_angle'), make_dsq(name='solar_zenith_angle') ] area, dnb = self.data_area_ref_corrector() c01 = xr.DataArray(dnb, dims=('y', 'x'), attrs={ 'platform_name': 'GOES-16', 'calibration': 'reflectance', 'units': '%', 'wavelength': wavelength, 'name': name, 'resolution': resolution, 'sensor': 'abi', 'start_time': '2017-09-20 17:30:40.800000', 'end_time': '2017-09-20 17:41:17.500000', 'area': area, 'ancillary_variables': [], 'orbital_parameters': { 'satellite_nominal_longitude': -89.5, 'satellite_nominal_latitude': 0.0, 'satellite_nominal_altitude': 35786023.4375, }, }) with assert_maximum_dask_computes(0): res = ref_cor([c01], []) assert isinstance(res, xr.DataArray) assert isinstance(res.data, da.Array) assert res.attrs['modifiers'] == ('sunz_corrected', 'rayleigh_corrected_crefl') assert res.attrs['platform_name'] == 'GOES-16' assert res.attrs['calibration'] == 'reflectance' assert res.attrs['units'] == '%' assert res.attrs['wavelength'] == wavelength assert res.attrs['name'] == name assert res.attrs['resolution'] == resolution assert res.attrs['sensor'] == 'abi' assert res.attrs['start_time'] == '2017-09-20 17:30:40.800000' assert res.attrs['end_time'] == '2017-09-20 17:41:17.500000' assert res.attrs['area'] == area assert res.attrs['ancillary_variables'] == [] data = res.values unique = np.unique(data[~np.isnan(data)]) np.testing.assert_allclose(np.nanmean(data), exp_mean, rtol=1e-5) assert data.shape == (3, 5) np.testing.assert_allclose(unique, exp_unique, rtol=1e-5)
def test_id_query_interactions(): """Test interactions between DataIDs and DataQuery's.""" from satpy.dataset.dataid import DataQuery, DataID, WavelengthRange, ModifierTuple, minimal_default_keys_config default_id_keys_config = { 'name': { 'required': True, }, 'wavelength': { 'type': WavelengthRange, }, 'resolution': None, 'calibration': { 'enum': ['reflectance', 'brightness_temperature', 'radiance', 'counts'] }, 'modifiers': { 'default': ModifierTuple(), 'type': ModifierTuple, }, } # Check hash equality dq = DataQuery(modifiers=tuple(), name='cheese_shops') did = DataID(default_id_keys_config, name='cheese_shops') assert hash(dq) == hash(did) # Check did filtering did2 = DataID(default_id_keys_config, name='ni') res = dq.filter_dataids([did2, did]) assert len(res) == 1 assert res[0] == did dataid_container = [ DataID(default_id_keys_config, name='ds1', resolution=250, calibration='reflectance', modifiers=tuple()) ] dq = DataQuery(wavelength=0.22, modifiers=tuple()) assert len(dq.filter_dataids(dataid_container)) == 0 dataid_container = [ DataID(minimal_default_keys_config, name='natural_color') ] dq = DataQuery(name='natural_color', resolution=250) assert len(dq.filter_dataids(dataid_container)) == 1 dq = make_dsq(wavelength=0.22, modifiers=('mod1', )) did = make_cid(name='static_image') assert len(dq.filter_dataids([did])) == 0 # Check did sorting dq = DataQuery(name='cheese_shops', wavelength=2, modifiers='*') did = DataID(default_id_keys_config, name='cheese_shops', wavelength=(1, 2, 3)) did2 = DataID(default_id_keys_config, name='cheese_shops', wavelength=(1.1, 2.1, 3.1)) dsids, distances = dq.sort_dataids([did2, did]) assert list(dsids) == [did, did2] assert np.allclose(distances, [0, 0.1]) dq = DataQuery(name='cheese_shops') did = DataID(default_id_keys_config, name='cheese_shops', resolution=200) did2 = DataID(default_id_keys_config, name='cheese_shops', resolution=400) dsids, distances = dq.sort_dataids([did2, did]) assert list(dsids) == [did, did2] assert distances[0] < distances[1] did = DataID(default_id_keys_config, name='cheese_shops', calibration='counts') did2 = DataID(default_id_keys_config, name='cheese_shops', calibration='reflectance') dsids, distances = dq.sort_dataids([did2, did]) assert list(dsids) == [did2, did] assert distances[0] < distances[1] did = DataID(default_id_keys_config, name='cheese_shops', modifiers=tuple()) did2 = DataID(default_id_keys_config, name='cheese_shops', modifiers=tuple(['out_of_stock'])) dsids, distances = dq.sort_dataids([did2, did]) assert list(dsids) == [did, did2] assert distances[0] < distances[1] # Check (in)equality assert DataQuery(wavelength=10) != DataID(default_id_keys_config, name="VIS006")
def test_reflectance_corrector_viirs(self, tmpdir, url): """Test ReflectanceCorrector modifier with VIIRS data.""" import xarray as xr import dask.array as da import numpy as np import datetime from satpy.modifiers._crefl import ReflectanceCorrector from satpy.tests.utils import make_dsq ref_cor = ReflectanceCorrector( optional_prerequisites=[ make_dsq(name='satellite_azimuth_angle'), make_dsq(name='satellite_zenith_angle'), make_dsq(name='solar_azimuth_angle'), make_dsq(name='solar_zenith_angle') ], name='I01', prerequisites=[], wavelength=(0.6, 0.64, 0.68), resolution=371, calibration='reflectance', modifiers=('sunz_corrected_iband', 'rayleigh_corrected_crefl_iband'), sensor='viirs', url=url) assert ref_cor.attrs['modifiers'] == ('sunz_corrected_iband', 'rayleigh_corrected_crefl_iband') assert ref_cor.attrs['calibration'] == 'reflectance' assert ref_cor.attrs['wavelength'] == (0.6, 0.64, 0.68) assert ref_cor.attrs['name'] == 'I01' assert ref_cor.attrs['resolution'] == 371 assert ref_cor.attrs['sensor'] == 'viirs' assert ref_cor.attrs['prerequisites'] == [] assert ref_cor.attrs['optional_prerequisites'] == [ make_dsq(name='satellite_azimuth_angle'), make_dsq(name='satellite_zenith_angle'), make_dsq(name='solar_azimuth_angle'), make_dsq(name='solar_zenith_angle') ] area, dnb = self.data_area_ref_corrector() def make_xarray(name, standard_name, wavelength=None, units='degrees', calibration=None): return xr.DataArray(dnb, dims=('y', 'x'), attrs={ 'start_orbit': 1708, 'end_orbit': 1708, 'wavelength': wavelength, 'level': None, 'modifiers': None, 'calibration': calibration, 'resolution': 371, 'name': name, 'standard_name': standard_name, 'platform_name': 'Suomi-NPP', 'polarization': None, 'sensor': 'viirs', 'units': units, 'start_time': datetime.datetime(2012, 2, 25, 18, 1, 24, 570942), 'end_time': datetime.datetime(2012, 2, 25, 18, 11, 21, 175760), 'area': area, 'ancillary_variables': [] }) c01 = make_xarray('I01', 'toa_bidirectional_reflectance', wavelength=(0.6, 0.64, 0.68), units='%', calibration='reflectance') c02 = make_xarray('satellite_azimuth_angle', 'sensor_azimuth_angle') c03 = make_xarray('satellite_zenith_angle', 'sensor_zenith_angle') c04 = make_xarray('solar_azimuth_angle', 'solar_azimuth_angle') c05 = make_xarray('solar_zenith_angle', 'solar_zenith_angle') rmock_obj = self._start_dem_mock(tmpdir, url) res = ref_cor([c01], [c02, c03, c04, c05]) self._stop_dem_mock(rmock_obj) assert isinstance(res, xr.DataArray) assert isinstance(res.data, da.Array) assert res.attrs['wavelength'] == (0.6, 0.64, 0.68) assert res.attrs['modifiers'] == ('sunz_corrected_iband', 'rayleigh_corrected_crefl_iband') assert res.attrs['calibration'] == 'reflectance' assert res.attrs['resolution'] == 371 assert res.attrs['name'] == 'I01' assert res.attrs['standard_name'] == 'toa_bidirectional_reflectance' assert res.attrs['platform_name'] == 'Suomi-NPP' assert res.attrs['sensor'] == 'viirs' assert res.attrs['units'] == '%' assert res.attrs['start_time'] == datetime.datetime( 2012, 2, 25, 18, 1, 24, 570942) assert res.attrs['end_time'] == datetime.datetime( 2012, 2, 25, 18, 11, 21, 175760) assert res.attrs['area'] == area assert res.attrs['ancillary_variables'] == [] data = res.values assert abs(np.mean(data) - 40.7578684169142) < 1e-10 assert data.shape == (5, 10) unique = np.unique(data) np.testing.assert_allclose( unique, [25.20341702519979, 52.38819447051263, 75.79089653845898])
def test_fy4a_all_resolutions(self): """Test loading data when all resolutions are available.""" from satpy.tests.utils import make_dsq from satpy.readers import load_reader from satpy.dataset.data_dict import get_key filenames = [ 'FY4A-_AGRI--_N_REGC_1047E_L1-_FDI-_MULT_NOM_20190603003000_20190603003416_0500M_V0001.HDF', 'FY4A-_AGRI--_N_REGC_1047E_L1-_FDI-_MULT_NOM_20190603003000_20190603003416_1000M_V0001.HDF', 'FY4A-_AGRI--_N_REGC_1047E_L1-_FDI-_MULT_NOM_20190603003000_20190603003416_2000M_V0001.HDF', 'FY4A-_AGRI--_N_REGC_1047E_L1-_FDI-_MULT_NOM_20190603003000_20190603003416_4000M_V0001.HDF', ] reader = load_reader(self.reader_configs) files = reader.select_files_from_pathnames(filenames) self.assertEqual(4, len(files)) reader.create_filehandlers(files) # Make sure we have some files self.assertTrue(reader.file_handlers) available_datasets = reader.available_dataset_ids # 500m band_names = ['C' + '%02d' % ch for ch in np.linspace(2, 2, 1)] for band_name in band_names: ds_q = make_dsq(name=band_name, resolution=500) res = get_key(ds_q, available_datasets, num_results=0, best=False) self.assertEqual(2, len(res)) # 1km band_names = ['C' + '%02d' % ch for ch in np.linspace(1, 3, 3)] for band_name in band_names: ds_q = make_dsq(name=band_name, resolution=1000) res = get_key(ds_q, available_datasets, num_results=0, best=False) self.assertEqual(2, len(res)) # 2km band_names = ['C' + '%02d' % ch for ch in np.linspace(1, 7, 7)] for band_name in band_names: ds_q = make_dsq(name=band_name, resolution=2000) res = get_key(ds_q, available_datasets, num_results=0, best=False) if band_name < 'C07': self.assertEqual(2, len(res)) else: self.assertEqual(3, len(res)) band_names = ['C' + '%02d' % ch for ch in np.linspace(1, 14, 14)] res = reader.load(band_names) self.assertEqual(14, len(res)) for band_name in band_names: self.assertEqual((2, 5), res[band_name].shape) if band_name < 'C07': self.assertEqual('reflectance', res[band_name].attrs['calibration']) else: self.assertEqual('brightness_temperature', res[band_name].attrs['calibration']) if band_name < 'C07': self.assertEqual('%', res[band_name].attrs['units']) else: self.assertEqual('K', res[band_name].attrs['units']) # check whether the data type of orbital_parameters is float orbital_parameters = res[band_names[0]].attrs['orbital_parameters'] for attr in orbital_parameters: self.assertEqual(type(orbital_parameters[attr]), float) self.assertEqual(orbital_parameters['satellite_nominal_latitude'], 0.) self.assertEqual(orbital_parameters['satellite_nominal_longitude'], 104.7) self.assertEqual(orbital_parameters['satellite_nominal_altitude'], 3.5786E7)
def test_reflectance_corrector_abi(self): """Test ReflectanceCorrector modifier with ABI data.""" import xarray as xr import dask.array as da import numpy as np from satpy.modifiers._crefl import ReflectanceCorrector from satpy.tests.utils import make_dsq ref_cor = ReflectanceCorrector(optional_prerequisites=[ make_dsq(name='satellite_azimuth_angle'), make_dsq(name='satellite_zenith_angle'), make_dsq(name='solar_azimuth_angle'), make_dsq(name='solar_zenith_angle') ], name='C01', prerequisites=[], wavelength=(0.45, 0.47, 0.49), resolution=1000, calibration='reflectance', modifiers=( 'sunz_corrected', 'rayleigh_corrected_crefl', ), sensor='abi') assert ref_cor.attrs['modifiers'] == ('sunz_corrected', 'rayleigh_corrected_crefl') assert ref_cor.attrs['calibration'] == 'reflectance' assert ref_cor.attrs['wavelength'] == (0.45, 0.47, 0.49) assert ref_cor.attrs['name'] == 'C01' assert ref_cor.attrs['resolution'] == 1000 assert ref_cor.attrs['sensor'] == 'abi' assert ref_cor.attrs['prerequisites'] == [] assert ref_cor.attrs['optional_prerequisites'] == [ make_dsq(name='satellite_azimuth_angle'), make_dsq(name='satellite_zenith_angle'), make_dsq(name='solar_azimuth_angle'), make_dsq(name='solar_zenith_angle') ] area, dnb = self.data_area_ref_corrector() c01 = xr.DataArray(dnb, dims=('y', 'x'), attrs={ 'satellite_longitude': -89.5, 'satellite_latitude': 0.0, 'satellite_altitude': 35786023.4375, 'platform_name': 'GOES-16', 'calibration': 'reflectance', 'units': '%', 'wavelength': (0.45, 0.47, 0.49), 'name': 'C01', 'resolution': 1000, 'sensor': 'abi', 'start_time': '2017-09-20 17:30:40.800000', 'end_time': '2017-09-20 17:41:17.500000', 'area': area, 'ancillary_variables': [] }) res = ref_cor([c01], []) assert isinstance(res, xr.DataArray) assert isinstance(res.data, da.Array) assert res.attrs['satellite_longitude'] == -89.5 assert res.attrs['satellite_latitude'] == 0.0 assert res.attrs['satellite_altitude'] == 35786023.4375 assert res.attrs['modifiers'] == ('sunz_corrected', 'rayleigh_corrected_crefl') assert res.attrs['platform_name'] == 'GOES-16' assert res.attrs['calibration'] == 'reflectance' assert res.attrs['units'] == '%' assert res.attrs['wavelength'] == (0.45, 0.47, 0.49) assert res.attrs['name'] == 'C01' assert res.attrs['resolution'] == 1000 assert res.attrs['sensor'] == 'abi' assert res.attrs['start_time'] == '2017-09-20 17:30:40.800000' assert res.attrs['end_time'] == '2017-09-20 17:41:17.500000' assert res.attrs['area'] == area assert res.attrs['ancillary_variables'] == [] data = res.values assert abs(np.nanmean(data) - 26.00760944144745) < 1e-10 assert data.shape == (5, 10) unique = np.unique(data[~np.isnan(data)]) np.testing.assert_allclose(unique, [ -1.0, 4.210745457958135, 6.7833906076177595, 8.730371329824473, 10.286627569545209, 11.744159436709374, 12.20226097829902, 13.501444598985305, 15.344399223932212, 17.173329483996515, 17.28798660754271, 18.29594550575925, 19.076835059905125, 19.288331720959864, 19.77043407084455, 19.887082168377006, 20.091028778326375, 20.230341149334617, 20.457671064690196, 20.82686905639114, 21.021094816441195, 21.129963777952124, 41.601857910095575, 43.963919057675504, 46.21672174361075, 46.972099490462085, 47.497072794632835, 47.80393007974336, 47.956765988770385, 48.043025685032106, 51.909142813383916, 58.8234273736508, 68.84706145641482, 69.91085190887961, 71.10179768327806, 71.33161009169649 ])
def test_reflectance_corrector_viirs(self): """Test ReflectanceCorrector modifier with VIIRS data.""" import xarray as xr import dask.array as da import numpy as np import datetime from satpy.composites.viirs import ReflectanceCorrector from satpy.tests.utils import make_dsq ref_cor = ReflectanceCorrector( dem_filename='_fake.hdf', optional_prerequisites=[ make_dsq(name='satellite_azimuth_angle'), make_dsq(name='satellite_zenith_angle'), make_dsq(name='solar_azimuth_angle'), make_dsq(name='solar_zenith_angle') ], name='I01', prerequisites=[], wavelength=(0.6, 0.64, 0.68), resolution=371, calibration='reflectance', modifiers=('sunz_corrected_iband', 'rayleigh_corrected_crefl_iband'), sensor='viirs') self.assertEqual( ref_cor.attrs['modifiers'], ('sunz_corrected_iband', 'rayleigh_corrected_crefl_iband')) self.assertEqual(ref_cor.attrs['calibration'], 'reflectance') self.assertEqual(ref_cor.attrs['wavelength'], (0.6, 0.64, 0.68)) self.assertEqual(ref_cor.attrs['name'], 'I01') self.assertEqual(ref_cor.attrs['resolution'], 371) self.assertEqual(ref_cor.attrs['sensor'], 'viirs') self.assertEqual(ref_cor.attrs['prerequisites'], []) self.assertEqual(ref_cor.attrs['optional_prerequisites'], [ make_dsq(name='satellite_azimuth_angle'), make_dsq(name='satellite_zenith_angle'), make_dsq(name='solar_azimuth_angle'), make_dsq(name='solar_zenith_angle') ]) area, dnb = self.data_area_ref_corrector() def make_xarray(self, file_key, name, standard_name, wavelength=None, units='degrees', calibration=None, file_type=('gitco', 'gimgo')): return xr.DataArray(dnb, dims=('y', 'x'), attrs={ 'start_orbit': 1708, 'end_orbit': 1708, 'wavelength': wavelength, 'level': None, 'modifiers': None, 'calibration': calibration, 'file_key': file_key, 'resolution': 371, 'file_type': file_type, 'name': name, 'standard_name': standard_name, 'platform_name': 'Suomi-NPP', 'polarization': None, 'sensor': 'viirs', 'units': units, 'start_time': datetime.datetime(2012, 2, 25, 18, 1, 24, 570942), 'end_time': datetime.datetime(2012, 2, 25, 18, 11, 21, 175760), 'area': area, 'ancillary_variables': [] }) c01 = make_xarray(self, None, 'I01', 'toa_bidirectional_reflectance', wavelength=(0.6, 0.64, 0.68), units='%', calibration='reflectance', file_type='svi01') c02 = make_xarray(self, 'All_Data/{file_group}_All/SatelliteAzimuthAngle', 'satellite_azimuth_angle', 'sensor_azimuth_angle') c03 = make_xarray(self, 'All_Data/{file_group}_All/SatelliteZenithAngle', 'satellite_zenith_angle', 'sensor_zenith_angle') c04 = make_xarray(self, 'All_Data/{file_group}_All/SolarAzimuthAngle', 'solar_azimuth_angle', 'solar_azimuth_angle') c05 = make_xarray(self, 'All_Data/{file_group}_All/SolarZenithAngle', 'solar_zenith_angle', 'solar_zenith_angle') res = ref_cor([c01], [c02, c03, c04, c05]) self.assertIsInstance(res, xr.DataArray) self.assertIsInstance(res.data, da.Array) self.assertEqual(res.attrs['wavelength'], (0.6, 0.64, 0.68)) self.assertEqual( res.attrs['modifiers'], ('sunz_corrected_iband', 'rayleigh_corrected_crefl_iband')) self.assertEqual(res.attrs['calibration'], 'reflectance') self.assertEqual(res.attrs['resolution'], 371) self.assertEqual(res.attrs['file_type'], 'svi01') self.assertEqual(res.attrs['name'], 'I01') self.assertEqual(res.attrs['standard_name'], 'toa_bidirectional_reflectance') self.assertEqual(res.attrs['platform_name'], 'Suomi-NPP') self.assertEqual(res.attrs['sensor'], 'viirs') self.assertEqual(res.attrs['units'], '%') self.assertEqual(res.attrs['start_time'], datetime.datetime(2012, 2, 25, 18, 1, 24, 570942)) self.assertEqual(res.attrs['end_time'], datetime.datetime(2012, 2, 25, 18, 11, 21, 175760)) self.assertEqual(res.attrs['area'], area) self.assertEqual(res.attrs['ancillary_variables'], []) data = res.values self.assertLess(abs(np.mean(data) - 40.7578684169142), 1e-10) self.assertEqual(data.shape, (5, 10)) unique = np.unique(data) np.testing.assert_allclose( unique, [25.20341702519979, 52.38819447051263, 75.79089653845898])
def test_reflectance_corrector_modis(self): """Test ReflectanceCorrector modifier with MODIS data.""" import xarray as xr import dask.array as da import numpy as np import datetime from satpy.modifiers._crefl import ReflectanceCorrector from satpy.tests.utils import make_dsq sataa_did = make_dsq(name='satellite_azimuth_angle') satza_did = make_dsq(name='satellite_zenith_angle') solaa_did = make_dsq(name='solar_azimuth_angle') solza_did = make_dsq(name='solar_zenith_angle') ref_cor = ReflectanceCorrector(optional_prerequisites=[ sataa_did, satza_did, solaa_did, solza_did ], name='1', prerequisites=[], wavelength=(0.62, 0.645, 0.67), resolution=250, calibration='reflectance', modifiers=('sunz_corrected', 'rayleigh_corrected_crefl'), sensor='modis') assert ref_cor.attrs['modifiers'] == ('sunz_corrected', 'rayleigh_corrected_crefl') assert ref_cor.attrs['calibration'] == 'reflectance' assert ref_cor.attrs['wavelength'] == (0.62, 0.645, 0.67) assert ref_cor.attrs['name'] == '1' assert ref_cor.attrs['resolution'] == 250 assert ref_cor.attrs['sensor'] == 'modis' assert ref_cor.attrs['prerequisites'] == [] assert ref_cor.attrs['optional_prerequisites'] == [ make_dsq(name='satellite_azimuth_angle'), make_dsq(name='satellite_zenith_angle'), make_dsq(name='solar_azimuth_angle'), make_dsq(name='solar_zenith_angle') ] area, dnb = self.data_area_ref_corrector() def make_xarray(name, calibration, wavelength=None, modifiers=None, resolution=1000, file_type='hdf_eos_geo'): return xr.DataArray(dnb, dims=('y', 'x'), attrs={ 'wavelength': wavelength, 'level': None, 'modifiers': modifiers, 'calibration': calibration, 'resolution': resolution, 'file_type': file_type, 'name': name, 'coordinates': ['longitude', 'latitude'], 'platform_name': 'EOS-Aqua', 'polarization': None, 'sensor': 'modis', 'units': '%', 'start_time': datetime.datetime(2012, 8, 13, 18, 46, 1, 439838), 'end_time': datetime.datetime(2012, 8, 13, 18, 57, 47, 746296), 'area': area, 'ancillary_variables': [] }) c01 = make_xarray('1', 'reflectance', wavelength=(0.62, 0.645, 0.67), modifiers='sunz_corrected', resolution=500, file_type='hdf_eos_data_500m') c02 = make_xarray('satellite_azimuth_angle', None) c03 = make_xarray('satellite_zenith_angle', None) c04 = make_xarray('solar_azimuth_angle', None) c05 = make_xarray('solar_zenith_angle', None) res = ref_cor([c01], [c02, c03, c04, c05]) assert isinstance(res, xr.DataArray) assert isinstance(res.data, da.Array) assert res.attrs['wavelength'] == (0.62, 0.645, 0.67) assert res.attrs['modifiers'] == ( 'sunz_corrected', 'rayleigh_corrected_crefl', ) assert res.attrs['calibration'] == 'reflectance' assert res.attrs['resolution'] == 500 assert res.attrs['file_type'] == 'hdf_eos_data_500m' assert res.attrs['name'] == '1' assert res.attrs['platform_name'] == 'EOS-Aqua' assert res.attrs['sensor'] == 'modis' assert res.attrs['units'] == '%' assert res.attrs['start_time'] == datetime.datetime( 2012, 8, 13, 18, 46, 1, 439838) assert res.attrs['end_time'] == datetime.datetime( 2012, 8, 13, 18, 57, 47, 746296) assert res.attrs['area'] == area assert res.attrs['ancillary_variables'] == [] data = res.values if abs(np.mean(data) - 38.734365117099145) >= 1e-10: raise AssertionError('{} is not within {} of {}'.format( np.mean(data), 1e-10, 38.734365117099145)) assert data.shape == (5, 10) unique = np.unique(data) np.testing.assert_allclose(unique, [24.641586, 50.431692, 69.315375])
def test_load_all_m_radiances(self): """Load all M band radiances.""" from satpy.readers import load_reader from satpy.tests.utils import make_dsq r = load_reader(self.reader_configs) loadables = r.select_files_from_pathnames([ 'SVM01_npp_d20120225_t1801245_e1802487_b01708_c20120226002130255476_noaa_ops.h5', 'SVM02_npp_d20120225_t1801245_e1802487_b01708_c20120226002130255476_noaa_ops.h5', 'SVM03_npp_d20120225_t1801245_e1802487_b01708_c20120226002130255476_noaa_ops.h5', 'SVM04_npp_d20120225_t1801245_e1802487_b01708_c20120226002130255476_noaa_ops.h5', 'SVM05_npp_d20120225_t1801245_e1802487_b01708_c20120226002130255476_noaa_ops.h5', 'SVM06_npp_d20120225_t1801245_e1802487_b01708_c20120226002130255476_noaa_ops.h5', 'SVM07_npp_d20120225_t1801245_e1802487_b01708_c20120226002130255476_noaa_ops.h5', 'SVM08_npp_d20120225_t1801245_e1802487_b01708_c20120226002130255476_noaa_ops.h5', 'SVM09_npp_d20120225_t1801245_e1802487_b01708_c20120226002130255476_noaa_ops.h5', 'SVM10_npp_d20120225_t1801245_e1802487_b01708_c20120226002130255476_noaa_ops.h5', 'SVM11_npp_d20120225_t1801245_e1802487_b01708_c20120226002130255476_noaa_ops.h5', 'SVM12_npp_d20120225_t1801245_e1802487_b01708_c20120226002130255476_noaa_ops.h5', 'SVM13_npp_d20120225_t1801245_e1802487_b01708_c20120226002130255476_noaa_ops.h5', 'SVM14_npp_d20120225_t1801245_e1802487_b01708_c20120226002130255476_noaa_ops.h5', 'SVM15_npp_d20120225_t1801245_e1802487_b01708_c20120226002130255476_noaa_ops.h5', 'SVM16_npp_d20120225_t1801245_e1802487_b01708_c20120226002130255476_noaa_ops.h5', 'GMTCO_npp_d20120225_t1801245_e1802487_b01708_c20120226002130255476_noaa_ops.h5', ]) r.create_filehandlers(loadables) ds = r.load([ make_dsq(name='M01', calibration='radiance'), make_dsq(name='M02', calibration='radiance'), make_dsq(name='M03', calibration='radiance'), make_dsq(name='M04', calibration='radiance'), make_dsq(name='M05', calibration='radiance'), make_dsq(name='M06', calibration='radiance'), make_dsq(name='M07', calibration='radiance'), make_dsq(name='M08', calibration='radiance'), make_dsq(name='M09', calibration='radiance'), make_dsq(name='M10', calibration='radiance'), make_dsq(name='M11', calibration='radiance'), make_dsq(name='M12', calibration='radiance'), make_dsq(name='M13', calibration='radiance'), make_dsq(name='M14', calibration='radiance'), make_dsq(name='M15', calibration='radiance'), make_dsq(name='M16', calibration='radiance'), ]) self.assertEqual(len(ds), 16) for d in ds.values(): self.assertEqual(d.attrs['calibration'], 'radiance') self.assertEqual(d.attrs['units'], 'W m-2 um-1 sr-1') self.assertEqual(d.attrs['rows_per_scan'], 16) self.assertIn('area', d.attrs) self.assertIsNotNone(d.attrs['area'])