def test_vis_cal(self): """Test that we can retrieve VIS data as both radiance and reflectance.""" ds_ids = [make_dataid(name='C01', calibration='radiance')] res = self.reader.load(ds_ids) rad = res['C01'].data ds_ids = [make_dataid(name='C01', calibration='reflectance')] res = self.reader.load(ds_ids) refl = res['C01'].data # Check the RAD->REFL conversion np.testing.assert_allclose(100 * np.pi * rad / float(SOLCONST), refl)
def test_get_dataset_coords(self): """Test whether coordinates returned by get_dataset() are correct.""" lon = self.reader.get_dataset(key=make_dataid(name='longitude'), info={}) lat = self.reader.get_dataset(key=make_dataid(name='latitude'), info={}) # ... this only compares the valid (unmasked) elements self.assertTrue(np.all(lat.to_masked_array() == self.lat), msg='get_dataset() returns invalid latitude') self.assertTrue(np.all(lon.to_masked_array() == self.lon), msg='get_dataset() returns invalid longitude')
def test_get_file_handlers(self): """Test getting filehandler to load a dataset.""" ds_id1 = make_dataid(name='ch01', wavelength=(0.5, 0.6, 0.7), calibration='reflectance', modifiers=()) self.reader.file_handlers = {'ftype1': 'bla'} self.assertEqual(self.reader._get_file_handlers(ds_id1), 'bla') lons = make_dataid(name='lons', modifiers=()) self.assertEqual(self.reader._get_file_handlers(lons), None)
def test_read_geo(self): """Test read_geo() function.""" import h5py from satpy.readers.iasi_l2 import read_geo from satpy.tests.utils import make_dataid with h5py.File(self.fname, 'r') as fid: key = make_dataid(name='sensing_time') data = read_geo(fid, key).compute() self.assertEqual(data.shape, (NUM_SCANLINES, SCAN_WIDTH)) key = make_dataid(name='latitude') data = read_geo(fid, key).compute() self.assertEqual(data.shape, (NUM_SCANLINES, SCAN_WIDTH))
def test_available_dataset_ids(self): """Get ids of the available datasets.""" loadables = self.reader.select_files_from_pathnames(['a001.bla']) self.reader.create_filehandlers(loadables) self.assertSetEqual(set(self.reader.available_dataset_ids), {make_dataid(name='ch02', wavelength=(0.7, 0.75, 0.8), calibration='counts', modifiers=()), make_dataid(name='ch01', wavelength=(0.5, 0.6, 0.7), calibration='reflectance', modifiers=())})
def test_main(fvg, fpsp, tmp_path, xrda): import fogtools.processing.show_fog from satpy import Scene fpsp.return_value = fogtools.processing.show_fog.get_parser().parse_args([ "/no/out/file", "--seviri", "/no/sat/files", "--nwcsaf", "/no/nwcsaf/files", "-a", "fribbulus xax" ]) m_im = MagicMock() m_sc = MagicMock() f_sc = Scene() from satpy.tests.utils import make_dataid f_sc[make_dataid(name="raspberry")] = xrda[0] f_sc[make_dataid(name="banana")] = xrda[1] f_sc[make_dataid(name="fls_day_extra")] = xarray.Dataset({ "a": xrda[0], "b": xrda[1] }) m_sc.__getitem__.side_effect = f_sc.__getitem__ m_sc.keys.side_effect = f_sc.keys fvg.return_value = (m_im, m_sc) fogtools.processing.show_fog.main() fvg.assert_called_once_with("seviri_l1b_hrit", ["/no/sat/files"], "nwcsaf-geo", ["/no/nwcsaf/files"], "fribbulus xax", "overview") fvg.return_value[0].save.assert_called_once_with("/no/out/file") fvg.reset_mock() fvg.return_value[0].reset_mock() fpsp.return_value = fogtools.processing.show_fog.get_parser().parse_args([ str(tmp_path), "--abi", "/no/sat/files", "--cmsaf", "/no/nwcsaf/files", "-a", "fribbulus xax", "-i" ]) with patch("satpy.Scene", autospec=True) as sS: fogtools.processing.show_fog.main() fvg.return_value[0].save.assert_called_once_with( str(tmp_path / "fog_blend.tif")) sS.return_value.save_datasets.assert_called_once_with( writer="cf", datasets={"a", "b"}, filename=str(tmp_path / "intermediates.nc")) fvg.reset_mock() fvg.return_value[0].reset_mock() fpsp.return_value = fogtools.processing.show_fog.get_parser().parse_args([ str(tmp_path), "--seviri", "/no/sat/files", "--nwcsaf", "/no/nwcsaf/files", "-a", "fribbulus xax", "-d" ]) fogtools.processing.show_fog.main() m_sc.save_datasets.assert_called_once_with( filename=str(tmp_path / "{name:s}.tif"), datasets={"raspberry", "banana"})
def test_get_coordinates_for_dataset_keys(self): """Test getting coordinates for keys.""" ds_id1 = make_dataid(name='ch01', wavelength=(0.5, 0.6, 0.7), calibration='reflectance', modifiers=()) ds_id2 = make_dataid(name='ch02', wavelength=(0.7, 0.75, 0.8), calibration='counts', modifiers=()) lons = make_dataid(name='lons', modifiers=()) lats = make_dataid(name='lats', modifiers=()) res = self.reader._get_coordinates_for_dataset_keys([ds_id1, ds_id2, lons]) expected = {ds_id1: [lons, lats], ds_id2: [lons, lats], lons: []} self.assertDictEqual(res, expected)
def test_navigation(self): """Test reading the lon and lats.""" with tempfile.TemporaryFile() as tmpfile: self._header.tofile(tmpfile) tmpfile.seek(22016, 0) self._data.tofile(tmpfile) fh = AVHRRAAPPL1BFile(tmpfile, self.filename_info, self.filetype_info) info = {} key = make_dataid(name='longitude') res = fh.get_dataset(key, info) assert(np.all(res == 0)) key = make_dataid(name='latitude') res = fh.get_dataset(key, info) assert(np.all(res == 0))
def test_get_dataset(self): """Test get_dataset() for different datasets.""" from satpy.tests.utils import make_dataid info = {'eggs': 'spam'} key = make_dataid(name='pressure') data = self.reader.get_dataset(key, info).compute() self.check_pressure(data) self.assertTrue('eggs' in data.attrs) self.assertEqual(data.attrs['eggs'], 'spam') key = make_dataid(name='emissivity') data = self.reader.get_dataset(key, info).compute() self.check_emissivity(data) key = make_dataid(name='sensing_time') data = self.reader.get_dataset(key, info).compute() self.assertEqual(data.shape, (NUM_SCANLINES, SCAN_WIDTH))
def test_get_dataset_qual_flags(self, *mocks): """Test getting the qualitiy flags.""" from satpy.tests.utils import make_dataid qual_flags = np.ones((3, 7)) reader = _get_reader_mocked() reader.get_qual_flags.return_value = qual_flags fh = _get_fh_mocked(reader=reader, start_line=None, end_line=None, strip_invalid_coords=False, interpolate_coords=True) key = make_dataid(name='qual_flags') info = {'name': 'qual_flags'} res = fh.get_dataset(key=key, info=info) exp = xr.DataArray( qual_flags, name=res.name, dims=('y', 'num_flags'), coords={ 'acq_time': ('y', [0, 1, 2]), 'num_flags': [ 'Scan line number', 'Fatal error flag', 'Insufficient data for calibration', 'Insufficient data for calibration', 'Solar contamination of blackbody in channels 3', 'Solar contamination of blackbody in channels 4', 'Solar contamination of blackbody in channels 5' ] }) xr.testing.assert_equal(res, exp)
def test_data_with_area_definition(self, input_file): """Test data loaded with AreaDefinition.""" bufr_obj = SeviriL2BufrData(input_file, with_adef=True) _ = bufr_obj.get_data( DATASET_INFO_LAT) # We need to load the lat/lon data in order to _ = bufr_obj.get_data( DATASET_INFO_LON) # populate the file handler with these data z = bufr_obj.get_data(DATASET_INFO) ad = bufr_obj.fh.get_area_def(None) assert ad == AREA_DEF data_1d = np.concatenate((DATA, DATA), axis=0) # Put BUFR data on 2D grid that the 2D array returned by get_dataset should correspond to lons_1d, lats_1d = da.compute(bufr_obj.fh.longitude, bufr_obj.fh.latitude) icol, irow = ad.get_array_indices_from_lonlat(lons_1d, lats_1d) data_2d = np.empty(ad.shape) data_2d[:] = np.nan data_2d[irow.compressed(), icol.compressed()] = data_1d[~irow.mask] np.testing.assert_array_equal(z.values, data_2d) # Test that the correct AreaDefinition is identified for products with 3 pixel segements bufr_obj.fh.seg_size = 3 ad_ext = bufr_obj.fh._construct_area_def( make_dataid(name='dummmy', resolution=9000)) assert ad_ext == AREA_DEF_EXT
def fake_multiscene2(): """Like fake_multiscene, but with real areas (one stacked).""" from satpy.dataset.dataid import WavelengthRange from satpy.tests.utils import make_dataid common_attrs = { "start_time": datetime.datetime(1900, 1, 1, 0, 0), "end_time": datetime.datetime(1900, 1, 1, 0, 1) } wl = { "C08": WavelengthRange(5.7, 6.2, 6.7), "C10": WavelengthRange(6.8, 7.3, 7.8), "C14": WavelengthRange(10, 11, 12) } content = { make_dataid(name=x, wavelength=wl.get(x)): numpy.arange(5 * 5).reshape(5, 5) for x in ("C08", "C10", "C14", "C14_flash_extent_density") } sc1 = satpy.tests.utils.make_fake_scene(content.copy(), common_attrs=common_attrs) sc2 = satpy.tests.utils.make_fake_scene(content.copy(), common_attrs=common_attrs) sc3 = satpy.tests.utils.make_fake_scene( {k: numpy.concatenate([v, v], 0) for (k, v) in content.items()}, area=pyresample.geometry.StackedAreaDefinition( sc1["C14"].attrs["area"], sc2["C14"].attrs["area"]), common_attrs=common_attrs) return satpy.MultiScene([sc1, sc2, sc3])
def test_latitudes_are_returned(self, Orbital, compute_pixels, get_lonlatalt, SatelliteInterpolator): """Check that latitudes are returned properly.""" self._prepare_mocks(Orbital, SatelliteInterpolator, get_lonlatalt) dataset_id = make_dataid(name='latitude') result = self._get_dataset(dataset_id) assert (result == self.fake_lats).all()
def test_get_dataset(self, mocked_dataset): """Test reading datasets.""" from satpy.readers.olci_nc import NCOLCI2 from satpy.tests.utils import make_dataid import numpy as np import xarray as xr mocked_dataset.return_value = xr.Dataset( { 'mask': (['rows', 'columns'], np.array([1 << x for x in range(30) ]).reshape(5, 6)) }, coords={ 'rows': np.arange(5), 'columns': np.arange(6) }) ds_id = make_dataid(name='mask') filename_info = { 'mission_id': 'S3A', 'dataset_name': 'mask', 'start_time': 0, 'end_time': 0 } test = NCOLCI2('somedir/somefile.nc', filename_info, 'c') res = test.get_dataset(ds_id, {'nc_key': 'mask'}) self.assertEqual(res.dtype, np.dtype('bool'))
def test_get_dataset(self): """Test basic L2 load.""" from satpy.tests.utils import make_dataid key = make_dataid(name='HT') res = self.reader.get_dataset(key, {'file_key': 'HT'}) exp_data = np.array([[2 * 0.3052037, np.nan], [32768 * 0.3052037, 32767 * 0.3052037]]) exp_attrs = { 'instrument_ID': None, 'modifiers': (), 'name': 'HT', 'orbital_slot': None, 'platform_name': 'GOES-16', 'platform_shortname': 'G16', 'production_site': None, 'satellite_altitude': 35786020., 'satellite_latitude': 0.0, 'satellite_longitude': -89.5, 'scan_mode': 'M3', 'scene_id': None, 'sensor': 'abi', 'timeline_ID': None, 'units': 'm' } self.assertTrue(np.allclose(res.data, exp_data, equal_nan=True)) self.assertDictEqual(dict(res.attrs), exp_attrs)
def test_load_counts(self, reader_configs): """Test loading with counts.""" from satpy.tests.utils import make_dataid # testing two filenames to test correctly combined filenames = [ "W_XX-EUMETSAT-Darmstadt,IMG+SAT,MTI1+FCI-1C-RRAD-FDHSI-FD--" "CHK-BODY--L2P-NC4E_C_EUMT_20170410114434_GTT_DEV_" "20170410113925_20170410113934_N__C_0070_0067.nc", "W_XX-EUMETSAT-Darmstadt,IMG+SAT,MTI1+FCI-1C-RRAD-FDHSI-FD--" "CHK-BODY--L2P-NC4E_C_EUMT_20170410114442_GTT_DEV_" "20170410113934_20170410113942_N__C_0070_0068.nc", ] reader = _get_reader_with_filehandlers(filenames, reader_configs) res = reader.load([ make_dataid(name=name, calibration="counts") for name in self._chans["solar"] + self._chans["terran"] ], pad_data=False) assert 16 == len(res) for ch in self._chans["solar"] + self._chans["terran"]: assert res[ch].shape == (200 * 2, 11136) assert res[ch].dtype == np.uint16 assert res[ch].attrs["calibration"] == "counts" assert res[ch].attrs["units"] == "1" if ch == 'ir_38': numpy.testing.assert_array_equal(res[ch][~0], 1) numpy.testing.assert_array_equal(res[ch][0], 5000) else: numpy.testing.assert_array_equal(res[ch], 1)
def test_dataid_pickle(): """Test dataid pickling roundtrip.""" import pickle from satpy.tests.utils import make_dataid did = make_dataid(name='hi', wavelength=(10, 11, 12), resolution=1000, calibration='radiance') assert did == pickle.loads(pickle.dumps(did))
def test_get_dataset(self): """Test basic L2 load.""" from satpy.tests.utils import make_dataid key = make_dataid(name='HT') res = self.reader.get_dataset(key, {'file_key': 'HT'}) exp_data = np.array([[2 * 0.3052037, np.nan], [32768 * 0.3052037, 32767 * 0.3052037]]) exp_attrs = { 'instrument_ID': None, 'modifiers': (), 'name': 'HT', 'observation_type': 'ACHA', 'orbital_slot': None, 'platform_name': 'GOES-16', 'platform_shortname': 'G16', 'production_site': None, 'scan_mode': 'M3', 'scene_abbr': 'M1', 'scene_id': None, 'sensor': 'abi', 'timeline_ID': None, 'units': 'm' } self.assertTrue(np.allclose(res.data, exp_data, equal_nan=True)) _compare_subdict(res.attrs, exp_attrs) _assert_orbital_parameters(res.attrs['orbital_parameters'])
def test_get_dataset(self): """Test the get_dataset method.""" key = make_dataid(name='Rad', calibration='radiance') res = self.reader.get_dataset(key, {'info': 'info'}) exp = {'calibration': 'radiance', 'instrument_ID': None, 'modifiers': (), 'name': 'Rad', 'observation_type': 'Rad', 'orbital_parameters': {'projection_altitude': 1.0, 'projection_latitude': 0.0, 'projection_longitude': -90.0, 'satellite_nominal_altitude': 35786020., 'satellite_nominal_latitude': 0.0, 'satellite_nominal_longitude': -89.5, 'yaw_flip': True}, 'orbital_slot': None, 'platform_name': 'GOES-16', 'platform_shortname': 'G16', 'production_site': None, 'scan_mode': 'M3', 'scene_abbr': 'C', 'scene_id': None, 'sensor': 'abi', 'timeline_ID': None, 'suffix': 'custom', 'units': 'W m-2 um-1 sr-1'} self.assertDictEqual(res.attrs, exp) # we remove any time dimension information self.assertNotIn('t', res.coords) self.assertNotIn('t', res.dims) self.assertNotIn('time', res.coords) self.assertNotIn('time', res.dims)
def test_load_reflectance(self, reader_configs): """Test loading with reflectance.""" from satpy.tests.utils import make_dataid from satpy.readers import load_reader filenames = [ "W_XX-EUMETSAT-Darmstadt,IMG+SAT,MTI1+FCI-1C-RRAD-FDHSI-FD--" "CHK-BODY--L2P-NC4E_C_EUMT_20170410114434_GTT_DEV_" "20170410113925_20170410113934_N__C_0070_0067.nc", ] reader = load_reader(reader_configs) loadables = reader.select_files_from_pathnames(filenames) reader.create_filehandlers(loadables) res = reader.load([ make_dataid(name=name, calibration="reflectance") for name in self._chans["solar"] ], pad_data=False) assert 8 == len(res) for ch in self._chans["solar"]: assert res[ch].shape == (200, 11136) assert res[ch].dtype == np.float64 assert res[ch].attrs["calibration"] == "reflectance" assert res[ch].attrs["units"] == "%" numpy.testing.assert_array_equal(res[ch], 100 * 15 * 1 * np.pi / 50)
def test_get_dataset_counts(self): """Test whether counts returned by get_dataset() are correct.""" from satpy.readers.goes_imager_nc import ALTITUDE, UNKNOWN_SECTOR self.reader.meta.update({'lon0': -75.0, 'lat0': 0.0, 'sector': UNKNOWN_SECTOR, 'nadir_row': 1, 'nadir_col': 2, 'area_def_uni': 'some_area'}) attrs_exp = {'orbital_parameters': {'projection_longitude': -75.0, 'projection_latitude': 0.0, 'projection_altitude': ALTITUDE, 'yaw_flip': True}, 'satellite_longitude': -75.0, 'satellite_latitude': 0.0, 'satellite_altitude': ALTITUDE, 'platform_name': 'GOES-15', 'sensor': 'goes_imager', 'sector': UNKNOWN_SECTOR, 'nadir_row': 1, 'nadir_col': 2, 'area_def_uniform_sampling': 'some_area'} for ch in self.channels: counts = self.reader.get_dataset( key=make_dataid(name=ch, calibration='counts'), info={}) # ... this only compares the valid (unmasked) elements self.assertTrue(np.all(self.counts/32. == counts.to_masked_array()), msg='get_dataset() returns invalid counts for ' 'channel {}'.format(ch)) # Check attributes self.assertDictEqual(counts.attrs, attrs_exp)
def _get_dataset(fh): from satpy.tests.utils import make_dataid key = make_dataid(name='1', calibration='reflectance') info = {'name': '1', 'standard_name': 'my_standard_name'} res = fh.get_dataset(key=key, info=info) return key, res
def test_bright_channel2_has_reflectance_greater_than_100(self): """Test that a bright channel 2 has reflectances greater that 100.""" from satpy.readers.aapp_l1b import AVHRRAAPPL1BFile from satpy.tests.utils import make_dataid file_handler = AVHRRAAPPL1BFile(self.filename, dict(), None) data = file_handler.get_dataset(make_dataid(name='2', calibration='reflectance'), dict()) np.testing.assert_array_less(100, data.values)
def test_bad_quality_warning(self, file_handler): """Test warning about bad VIS quality.""" file_handler.nc.nc['quality_pixel_bitmask'] = 2 vis = make_dataid(name='VIS', resolution=2250, calibration='reflectance') with pytest.warns(UserWarning): file_handler.get_dataset(vis, {})
def test_get_area_def(self): """Get the area definition.""" from satpy.readers.nwcsaf_msg2013_hdf5 import Hdf5NWCSAF from satpy.tests.utils import make_dataid filename_info = {} filetype_info = {} dsid = make_dataid(name="ct") test = Hdf5NWCSAF(self.filename_ct, filename_info, filetype_info) area_def = test.get_area_def(dsid) aext_res = AREA_DEF_DICT['area_extent'] for i in range(4): self.assertAlmostEqual(area_def.area_extent[i], aext_res[i], 4) proj_dict = AREA_DEF_DICT['proj_dict'] self.assertEqual(proj_dict['proj'], area_def.proj_dict['proj']) # Not all elements passed on Appveyor, so skip testing every single element of the proj-dict: # for key in proj_dict: # self.assertEqual(proj_dict[key], area_def.proj_dict[key]) self.assertEqual(AREA_DEF_DICT['x_size'], area_def.width) self.assertEqual(AREA_DEF_DICT['y_size'], area_def.height) self.assertEqual(AREA_DEF_DICT['area_id'], area_def.area_id)
def test_modis_overview_1000m(self): """Test a modis overview dependency calculation with resolution fixed to 1000m.""" from satpy.config import PACKAGE_CONFIG_PATH from satpy.readers.yaml_reader import FileYAMLReader from satpy import DataQuery from satpy.composites import GenericCompositor from satpy.modifiers.geometry import SunZenithCorrector from satpy.dataset import DatasetDict config_file = os.path.join(PACKAGE_CONFIG_PATH, 'readers', 'modis_l1b.yaml') self.reader_instance = FileYAMLReader.from_config_files(config_file) overview = {'_satpy_id': make_dataid(name='overview'), 'name': 'overview', 'optional_prerequisites': [], 'prerequisites': [DataQuery(name='1', modifiers=('sunz_corrected',)), DataQuery(name='2', modifiers=('sunz_corrected',)), DataQuery(name='31')], 'standard_name': 'overview'} compositors = {'modis': DatasetDict()} compositors['modis']['overview'] = GenericCompositor(**overview) modifiers = {'modis': {'sunz_corrected': (SunZenithCorrector, {'optional_prerequisites': ['solar_zenith_angle'], 'name': 'sunz_corrected', 'prerequisites': []})}} dep_tree = DependencyTree({'modis_l1b': self.reader_instance}, compositors, modifiers) dep_tree.populate_with_keys({'overview'}, DataQuery(resolution=1000)) for key in dep_tree._all_nodes.keys(): assert key.get('resolution', 1000) == 1000
def test_load_radiance(self, reader_configs): """Test loading with radiance.""" from satpy.tests.utils import make_dataid filenames = [ "W_XX-EUMETSAT-Darmstadt,IMG+SAT,MTI1+FCI-1C-RRAD-FDHSI-FD--" "CHK-BODY--L2P-NC4E_C_EUMT_20170410114434_GTT_DEV_" "20170410113925_20170410113934_N__C_0070_0067.nc", ] reader = _get_reader_with_filehandlers(filenames, reader_configs) res = reader.load([ make_dataid(name=name, calibration="radiance") for name in self._chans["solar"] + self._chans["terran"] ], pad_data=False) assert 16 == len(res) for ch in self._chans["solar"] + self._chans["terran"]: assert res[ch].shape == (200, 11136) assert res[ch].dtype == np.float64 assert res[ch].attrs["calibration"] == "radiance" assert res[ch].attrs["units"] == 'mW.m-2.sr-1.(cm-1)-1' if ch == 'ir_38': numpy.testing.assert_array_equal(res[ch][~0], 15) numpy.testing.assert_array_equal(res[ch][0], 9700) else: numpy.testing.assert_array_equal(res[ch], 15)
def test_GenericImageFileHandler_nodata(self): """Test nodata handling with direct use of the reader.""" from satpy.readers.generic_image import GenericImageFileHandler fname = os.path.join(self.base_dir, 'test_l_nan_fillvalue.tif') fname_info = {'start_time': self.date} ftype_info = {} reader = GenericImageFileHandler(fname, fname_info, ftype_info) foo = make_dataid(name='image-custom') self.assertTrue(reader.file_content, 'file_content should be set') info = {'nodata_handling': 'nan_mask'} dataset = reader.get_dataset(foo, info) self.assertTrue(isinstance(dataset, xr.DataArray), 'dataset should be a xr.DataArray') self.assertTrue(np.all(np.isnan(dataset.data[0][:10, :10].compute())), 'values should be np.nan') self.assertTrue(np.isnan(dataset.attrs['_FillValue']), '_FillValue should be np.nan') info = {'nodata_handling': 'fill_value'} dataset = reader.get_dataset(foo, info) self.assertTrue(isinstance(dataset, xr.DataArray), 'dataset should be a xr.DataArray') self.assertEqual(np.sum(dataset.data[0][:10, :10].compute()), 0) self.assertEqual(dataset.attrs['_FillValue'], 0) # default same as 'nodata_handling': 'fill_value' dataset = reader.get_dataset(foo, {}) self.assertTrue(isinstance(dataset, xr.DataArray), 'dataset should be a xr.DataArray') self.assertEqual(np.sum(dataset.data[0][:10, :10].compute()), 0) self.assertEqual(dataset.attrs['_FillValue'], 0)
def test_get_dataset(self): """Test the get_dataset method.""" from satpy.tests.utils import make_dataid key = make_dataid(name='flash_extent_density') res = self.reader.get_dataset(key, {'info': 'info'}) exp = { 'instrument_ID': None, 'modifiers': (), 'name': 'flash_extent_density', 'orbital_parameters': { 'projection_altitude': 1.0, 'projection_latitude': 0.0, 'projection_longitude': -90.0, # 'satellite_nominal_altitude': 35786.02, 'satellite_nominal_latitude': 0.0, 'satellite_nominal_longitude': -89.5 }, 'orbital_slot': None, 'platform_name': 'GOES-16', 'platform_shortname': 'G16', 'production_site': None, 'scan_mode': 'M3', 'scene_abbr': 'C', 'scene_id': None, "spatial_resolution": "2km at nadir", 'sensor': 'glm', 'timeline_ID': None, 'grid_mapping': 'goes_imager_projection', 'standard_name': 'flash_extent_density', 'long_name': 'Flash extent density', 'units': 'Count per nominal 3136 microradian^2 pixel per 1.0 min' } self.assertDictEqual(res.attrs, exp)
def test_load_bt(self, reader_configs, caplog): """Test loading with bt.""" from satpy.tests.utils import make_dataid filenames = [ "W_XX-EUMETSAT-Darmstadt,IMG+SAT,MTI1+FCI-1C-RRAD-FDHSI-FD--" "CHK-BODY--L2P-NC4E_C_EUMT_20170410114434_GTT_DEV_" "20170410113925_20170410113934_N__C_0070_0067.nc", ] reader = _get_reader_with_filehandlers(filenames, reader_configs) with caplog.at_level(logging.WARNING): res = reader.load([ make_dataid(name=name, calibration="brightness_temperature") for name in self._chans["terran"] ], pad_data=False) assert caplog.text == "" for ch in self._chans["terran"]: assert res[ch].shape == (200, 11136) assert res[ch].dtype == np.float64 assert res[ch].attrs["calibration"] == "brightness_temperature" assert res[ch].attrs["units"] == "K" if ch == 'ir_38': numpy.testing.assert_array_almost_equal( res[ch][~0], 209.68274099) numpy.testing.assert_array_almost_equal( res[ch][0], 1888.851296) else: numpy.testing.assert_array_almost_equal(res[ch], 209.68274099)