pandora.check_configuration =========================== .. py:module:: pandora.check_configuration .. autoapi-nested-parse:: This module contains functions allowing to check the configuration given to Pandora pipeline. Attributes ---------- .. autoapisummary:: pandora.check_configuration.input_configuration_schema pandora.check_configuration.input_configuration_schema_integer_disparity pandora.check_configuration.input_configuration_schema_left_disparity_grids_right_none pandora.check_configuration.input_configuration_schema_left_disparity_grids_right_grids pandora.check_configuration.default_short_configuration_input pandora.check_configuration.MEMORY_CONSUMPTION_LIST pandora.check_configuration.default_short_configuration_pipeline pandora.check_configuration.default_short_configuration Functions --------- .. autoapisummary:: pandora.check_configuration.rasterio_can_open_mandatory pandora.check_configuration.rasterio_can_open pandora.check_configuration.check_shape pandora.check_configuration.check_attributes pandora.check_configuration.check_dataset pandora.check_configuration.check_datasets pandora.check_configuration.check_image_dimension pandora.check_configuration.check_images pandora.check_configuration.check_band_names pandora.check_configuration.check_disparity_ranges_are_inside_image pandora.check_configuration.check_disparities_from_input pandora.check_configuration.check_disparities_from_dataset pandora.check_configuration.get_config_input pandora.check_configuration.get_config_pipeline pandora.check_configuration.memory_consumption_estimation pandora.check_configuration.check_pipeline_section pandora.check_configuration.check_input_section pandora.check_configuration.check_conf pandora.check_configuration.concat_conf pandora.check_configuration.read_multiscale_params pandora.check_configuration.read_config_file pandora.check_configuration.update_conf Module Contents --------------- .. py:function:: rasterio_can_open_mandatory(file_: str) -> bool Test if file can be open by rasterio :param file_: File to test :type file_: string :returns: True if rasterio can open file and False otherwise :rtype: bool .. py:function:: rasterio_can_open(file_: str) -> bool Test if file can be open by rasterio :param file_: File to test :type file_: string :returns: True if rasterio can open file and False otherwise :rtype: bool .. py:function:: check_shape(dataset: xarray.Dataset, ref: str, test: str) -> None Check if two data_vars are the same dimensions :param dataset: dataset :type dataset: xr.Dataset :param ref: name of the reference image :type ref: str :param test: the tested image :type test: str :return: None .. py:function:: check_attributes(dataset: xarray.Dataset, attribute_list: set) -> None Check if attributes are in the dataset :param dataset: dataset :type dataset: xr.Dataset :param attribute_list: the attribute to test :type attribute_list: list :return: None .. py:function:: check_dataset(dataset: xarray.Dataset) -> None Check if input dataset is correct :param dataset: dataset :type dataset: xr.Dataset :return: None .. py:function:: check_datasets(left: xarray.Dataset, right: xarray.Dataset) -> None Check that left and right datasets are correct :param left: left dataset :type left: xr.Dataset :param right: right dataset :type right: xr.Dataset :return: None .. py:function:: check_image_dimension(img1: rasterio.io.DatasetReader, img2: rasterio.io.DatasetReader) -> None Check width and height are the same between two images :param img1: image DatasetReader with width and height :type img1: rasterio.io.DatasetReader :param img2: image DatasetReader with width and height :type img2: rasterio.io.DatasetReader :return: None .. py:function:: check_images(user_cfg: Dict[str, dict]) -> None Check the images :param user_cfg: user configuration :type user_cfg: dict :return: None .. py:function:: check_band_names(dataset: xarray.Dataset) -> None Check that band names have the correct format : band names must be strings. :param dataset: dataset :type dataset: xr.Dataset :return: None .. py:function:: check_disparity_ranges_are_inside_image(disparity: list[int], image: rasterio.io.DatasetReader) Raise an error if disparity ranges are out off image. :param disparity: range disparity :type disparity: List :param image: left image :type image: rasterio.io.DatasetReader .. py:function:: check_disparities_from_input(disparity: list[int] | str | None, img_left: str) -> None Check disparities from user configuration :param disparity: disparity to check if disparity is a list of two values: min and max. :type disparity: list[int] | str | None :param img_left: path to the left image :type img_left: str :return: None .. py:function:: check_disparities_from_dataset(disparity: xarray.DataArray) -> None Check disparities with this format disparity: 3D (band_disp, row, col) xarray.DataArray float32 and band_disp = (min, max) :param disparity: disparity to check :type disparity: xr.DataArray :return: None .. py:function:: get_config_input(user_cfg: Dict[str, dict]) -> Dict[str, dict] Get the input configuration :param user_cfg: user configuration :type user_cfg: dict :return cfg: partial configuration :rtype cfg: dict .. py:function:: get_config_pipeline(user_cfg: Dict[str, dict]) -> Dict[str, dict] Get the pipeline configuration :param user_cfg: user configuration :type user_cfg: dict :return cfg: partial configuration :rtype cfg: dict .. py:function:: memory_consumption_estimation(user_pipeline_cfg: Dict[str, dict], user_input: Union[Dict[str, dict], Tuple[str, int, int], Tuple[str, str]], pandora_machine: pandora.state_machine.PandoraMachine, checked_cfg_flag: bool = False) -> Union[Tuple[float, float], None] Return the approximate memory consumption for a given pipeline in GiB. :param user_pipeline_cfg: user pipeline configuration :type user_pipeline_cfg: dict :param user_input: user input configuration, may be given as a dict or directly as (img_path, disp_min, disp_max) where [disp_min, disp_max] is the disparity interval used, or as (img_path, disparity_path) where disparity_path leads to a disparity grid containing two bands: min and max. :type user_input: dict or Tuple[str, int, int] or Tuple[str, str] :param pandora_machine: instance of PandoraMachine :type pandora_machine: PandoraMachine object :param checked_cfg_flag: Flag for checking pipeline :type checked_cfg_flag: bool :return: minimum and maximum memory consumption :rtype: Tuple[float, float] .. py:function:: check_pipeline_section(user_cfg: Dict[str, dict], img_left: xarray.Dataset, img_right: xarray.Dataset, pandora_machine: pandora.state_machine.PandoraMachine) -> Dict[str, dict] Check if the pipeline is correct by - Checking the sequence of steps according to the machine transitions - Checking parameters, define in dictionary, of each Pandora step :param user_cfg: pipeline user configuration :type user_cfg: dict :param img_left: image left with metadata :type img_left: xarray.Dataset :param img_right: image right with metadata :type img_right: xarray.Dataset :param pandora_machine: instance of PandoraMachine :type pandora_machine: PandoraMachine object :return: cfg: pipeline configuration :rtype: cfg: dict .. py:function:: check_input_section(user_cfg: Dict[str, dict]) -> Dict[str, dict] Complete and check if the dictionary is correct :param user_cfg: user configuration :type user_cfg: dict :return: cfg: global configuration :rtype: cfg: dict .. py:function:: check_conf(user_cfg: Dict[str, dict], pandora_machine: pandora.state_machine.PandoraMachine) -> dict Complete and check if the dictionary is correct :param user_cfg: user configuration :type user_cfg: dict :param pandora_machine: instance of PandoraMachine :type pandora_machine: PandoraMachine :return: cfg: global configuration :rtype: cfg: dict .. py:function:: concat_conf(cfg_list: List[Dict[str, dict]]) -> Dict[str, dict] Concatenate dictionaries :param cfg_list: list of configurations :type cfg_list: List of dict :return: cfg: global configuration :rtype: cfg: dict .. py:function:: read_multiscale_params(left_img: xarray.Dataset, right_img: xarray.Dataset, cfg: Dict[str, dict]) -> Tuple[int, int] Returns the multiscale parameters :param cfg: configuration :type cfg: dict :return: - num_scales: number of scales - scale_factor: factor by which each coarser layer is downsampled :rtype: tuple(int, int ) .. py:data:: input_configuration_schema .. py:data:: input_configuration_schema_integer_disparity :type: collections.abc.Mapping .. py:data:: input_configuration_schema_left_disparity_grids_right_none :type: collections.abc.Mapping .. py:data:: input_configuration_schema_left_disparity_grids_right_grids :type: collections.abc.Mapping .. py:data:: default_short_configuration_input .. py:data:: MEMORY_CONSUMPTION_LIST :value: [['matching_cost', 'matching_cost_method', 'mc_cnn', 1.57e-05, 265], ['optimization',... .. py:data:: default_short_configuration_pipeline :type: dict .. py:data:: default_short_configuration .. py:function:: read_config_file(config_file: os.PathLike | str) -> Dict[str, dict] Read a json configuration file :param config_file: path to a json file containing the algorithm parameters :type config_file: PathLike | string :return user_cfg: configuration dictionary :rtype: dict .. py:function:: update_conf(def_cfg: Dict[str, dict], user_cfg: Dict[str, dict]) -> Dict[str, dict] Update the default configuration with the user configuration, :param def_cfg: default configuration :type def_cfg: dict :param user_cfg: user configuration :type user_cfg: dict :return: the user and default configuration :rtype: dict