Beispiel #1
0
def load_compositor_configs_for_sensor(sensor_name: str) -> tuple[dict[str, dict], dict[str, dict], dict]:
    """Load compositor, modifier, and DataID key information from configuration files for the specified sensor.

    Args:
        sensor_name: Sensor name that has matching ``sensor_name.yaml``
            config files.

    Returns:
        (comps, mods, data_id_keys): Where `comps` is a dictionary:

                composite ID -> compositor object

            And `mods` is a dictionary:

                modifier name -> (modifier class, modifiers options)

            Add `data_id_keys` is a dictionary:

                DataID key -> key properties

    """
    config_filename = sensor_name + ".yaml"
    logger.debug("Looking for composites config file %s", config_filename)
    paths = get_entry_points_config_dirs('satpy.composites')
    composite_configs = config_search_paths(
        os.path.join("composites", config_filename),
        search_dirs=paths, check_exists=True)
    if not composite_configs:
        logger.debug("No composite config found called %s",
                     config_filename)
        return {}, {}, minimal_default_keys_config
    return _load_config(composite_configs)
Beispiel #2
0
def all_composite_sensors():
    """Get all sensor names from available composite configs."""
    paths = get_entry_points_config_dirs('satpy.composites')
    composite_configs = glob_config(
        os.path.join("composites", "*.yaml"),
        search_dirs=paths)
    yaml_names = set([os.path.splitext(os.path.basename(fn))[0]
                      for fn in composite_configs])
    non_sensor_yamls = ('visir',)
    sensor_names = [x for x in yaml_names if x not in non_sensor_yamls]
    return sensor_names
Beispiel #3
0
    def test_get_plugin_configs(self, iter_entry_points):
        """Check that the plugin configs are looked for."""
        import pkg_resources
        ep = pkg_resources.EntryPoint.parse('example_composites = satpy_cpe')
        ep.dist = pkg_resources.Distribution.from_filename('satpy_cpe-0.0.0-py3.8.egg')
        ep.dist.module_path = os.path.join(os.path.sep + 'bla', 'bla')
        iter_entry_points.return_value = [ep]

        from satpy._config import get_entry_points_config_dirs
        dirs = get_entry_points_config_dirs('satpy.composites')
        self.assertListEqual(dirs, [os.path.join(ep.dist.module_path, 'satpy_cpe', 'etc')])
Beispiel #4
0
 def load_sensor_composites(self, sensor_name):
     """Load all compositor configs for the provided sensor."""
     config_filename = sensor_name + ".yaml"
     logger.debug("Looking for composites config file %s", config_filename)
     paths = get_entry_points_config_dirs('satpy.composites')
     composite_configs = config_search_paths(os.path.join(
         "composites", config_filename),
                                             search_dirs=paths,
                                             check_exists=True)
     if not composite_configs:
         logger.debug("No composite config found called %s",
                      config_filename)
         return
     self._load_config(composite_configs)