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_fails_to_add_multiple_datasets_from_the_same_scene_to_a_group( self, multi_scene): """Test that multiple datasets from the same scene in one group fails.""" groups = {DataQuery(name='mygroup'): ['ds1', 'ds2']} multi_scene.group(groups) with pytest.raises(ValueError): next(multi_scene.scenes)
def test_multi_scene_grouping(self, multi_scene, groups, scene1): """Test grouping a MultiScene.""" multi_scene.group(groups) shared_ids_exp = {make_dataid(name="odd"), make_dataid(name="even")} assert multi_scene.shared_dataset_ids == shared_ids_exp assert DataQuery(name='odd') not in scene1 xr.testing.assert_allclose(multi_scene.scenes[0]["ds1"], scene1["ds1"])
def test_modifier_loaded_sensor_order(self): """Test that a modifier is loaded from the first alphabetical sensor.""" from satpy import DataQuery dq = DataQuery(name='ds5', modifiers=('mod1', )) self.dependency_tree.populate_with_keys({dq}) comp_nodes = self.dependency_tree.trunk() self.assertEqual(len(comp_nodes), 1) self.assertEqual(comp_nodes[0].data[0].ret_val, 1)
def _process_legacy_and_rad_products(satpy_names, band_aliases, rad_aliases): """Map all lowercase band names to uppercase names and add radiance product.""" for band in satpy_names: # P2G name is lowercase, Satpy is uppercase PRODUCT_ALIASES[band.lower()] = band band_aliases.append(band.lower()) # radiance products for M and I bands rad_name = band.lower() + "_rad" dq = DataQuery(name=band, calibration="radiance") PRODUCT_ALIASES[rad_name] = dq rad_aliases.append(rad_name)
def groups(self): """Get group definitions for the MultiScene.""" return { DataQuery(name='odd'): ['ds1', 'ds3'], DataQuery(name='even'): ['ds2', 'ds4'] }
dq = DataQuery(name=band, calibration="radiance") PRODUCT_ALIASES[rad_name] = dq rad_aliases.append(rad_name) I_ALIASES = [] I_RAD_PRODUCTS = [] _process_legacy_and_rad_products(I_PRODUCTS, I_ALIASES, I_RAD_PRODUCTS) M_ALIASES = [] M_RAD_PRODUCTS = [] _process_legacy_and_rad_products(M_PRODUCTS, M_ALIASES, M_RAD_PRODUCTS) _AWIPS_TRUE_COLOR = ["viirs_crefl08", "viirs_crefl04", "viirs_crefl03"] _AWIPS_FALSE_COLOR = ["viirs_crefl07", "viirs_crefl09", "viirs_crefl08"] PRODUCT_ALIASES["dnb_solar_zenith_angle"] = DataQuery( name="dnb_solar_zenith_angle") PRODUCT_ALIASES["dnb_solar_azimuth_angle"] = DataQuery( name="dnb_solar_azimuth_angle") PRODUCT_ALIASES["dnb_sat_zenith_angle"] = DataQuery( name="dnb_satellite_zenith_angle") PRODUCT_ALIASES["dnb_sat_azimuth_angle"] = DataQuery( name="dnb_satellite_azimuth_angle") PRODUCT_ALIASES["dnb_lunar_zenith_angle"] = DataQuery( name="dnb_lunar_zenith_angle") PRODUCT_ALIASES["dnb_lunar_azimuth_angle"] = DataQuery( name="dnb_lunar_azimuth_angle") PRODUCT_ALIASES["m_solar_zenith_angle"] = DataQuery(name="solar_zenith_angle", resolution=742) PRODUCT_ALIASES["m_solar_azimuth_angle"] = DataQuery( name="solar_azimuth_angle", resolution=742) PRODUCT_ALIASES["m_sat_zenith_angle"] = DataQuery(
} VIS_PRODUCTS = [ "band1_vis", "band2_vis", "band3a_vis", ] IR_PRODUCTS = [ "band3b_bt", "band4_bt", "band5_bt", ] PRODUCT_ALIASES = { "band1_vis": DataQuery(name="1", calibration="reflectance"), "band2_vis": DataQuery(name="2", calibration="reflectance"), "band3a_vis": DataQuery(name="3a", calibration="reflectance"), "band3b_bt": DataQuery(name="3b", calibration="brightness_temperature"), "band4_bt": DataQuery(name="4", calibration="brightness_temperature"), "band5_bt": DataQuery(name="5", calibration="brightness_temperature"), } class ReaderProxy(ReaderProxyBase): """Provide Polar2Grid-specific information about this reader's products.""" is_polar2grid_reader = True def get_default_products(self) -> list[str]: """Get products to load if users hasn't specified any others."""
] TRUE_COLOR_PRODUCTS = ["true_color"] FALSE_COLOR_PRODUCTS = ["false_color"] OTHER_COMPS = [ "ifog", ] DEFAULT_PRODUCTS = I_PRODUCTS + M_PRODUCTS + DNB_PRODUCTS[ 1:] + TRUE_COLOR_PRODUCTS + FALSE_COLOR_PRODUCTS + OTHER_COMPS # map all lowercase band names to uppercase names PRODUCT_ALIASES = {} for band in I_PRODUCTS + M_PRODUCTS: PRODUCT_ALIASES[band.lower()] = band # radiance products for band in I_PRODUCTS + M_PRODUCTS: dq = DataQuery(name=band, calibration='radiance') PRODUCT_ALIASES[band.lower() + '_rad'] = dq PRODUCT_ALIASES[band.lower() + '_rad'] = dq PRODUCT_ALIASES['awips_true_color'] = [ 'viirs_crefl08', 'viirs_crefl04', 'viirs_crefl03' ] PRODUCT_ALIASES['awips_false_color'] = [ 'viirs_crefl07', 'viirs_crefl09', 'viirs_crefl08' ] FILTERS = { 'day_only': { 'standard_name': [ 'toa_bidirectional_reflectance', 'true_color', 'false_color', 'natural_color', 'corrected_reflectance'
"cloud_mask", "land_sea_mask", "snow_ice_mask", "sst", "lst", "ndvi", "ist", "inversion_strength", "inversion_depth", "ice_concentration", "ctt", "tpw", ] PRODUCT_ALIASES = { "ist": DataQuery(name="ice_surface_temperature"), "sst": DataQuery(name="sea_surface_temperature"), "ctt": DataQuery(name="cloud_top_temperature"), "tpw": DataQuery(name="water_vapor"), } class ReaderProxy(ReaderProxyBase): """Provide Polar2Grid-specific information about this reader's products.""" is_polar2grid_reader = True def get_default_products(self) -> list[str]: """Get products to load if users hasn't specified any others.""" return PRODUCTS
"false_color", "natural_color", ], }, "night_only": { "standard_name": ["temperature_difference"], }, } PRODUCT_ALIASES = {} DEFAULTS = [] VIS_PRODUCTS = [] for chan_num in list(range(1, 8)) + [26]: p2g_name = f"vis{chan_num:02d}" VIS_PRODUCTS.append(p2g_name) PRODUCT_ALIASES[p2g_name] = DataQuery(name=f"{chan_num}", calibration="reflectance") DEFAULTS.append(p2g_name) BT_PRODUCTS = [] RAD_PRODUCTS = [] for chan_num in list(range(20, 26)) + list(range(27, 37)): p2g_name = f"bt{chan_num:02d}" BT_PRODUCTS.append(p2g_name) PRODUCT_ALIASES[p2g_name] = DataQuery(name=f"{chan_num}", calibration="brightness_temperature") DEFAULTS.append(p2g_name) p2g_name = f"ir{chan_num:02d}" RAD_PRODUCTS.append(p2g_name) PRODUCT_ALIASES[p2g_name] = DataQuery(name=f"{chan_num}", calibration="radiance") COMPOSITES = [