pandora2d.check_configuration
This module contains functions allowing to check the configuration given to Pandora2d pipeline.
Attributes
Functions
|
Check that left and right datasets are correct |
|
Validate and complete the user configuration. |
|
Get the section configuration from key |
|
Update global_cfg with completed_cfg |
|
Complete and check if the segment mode dictionary is correct |
|
Check if the pipeline is correct by |
Check if we have a subpix value of 1 with a dichotomy refinement method, |
|
Check the correlation method used in relation to ambiguity |
|
|
Check that matching_cost window_size does not exceed left image dimensions. |
|
Validate the given output section. |
|
Check if expert mode section is correct |
|
Complete and check if the input is correct |
|
All checks on disparity |
|
Check that disparity grids contains two bands and are the same size as the input image |
|
Load attributes from json file in disparity directory. |
|
Validate that the initial disparity attributes match the pipeline configuration. |
Check that disparity grids lie within image boundaries. |
|
|
Construct ROI from input disparity grids when there are smaller than image, |
|
Get correct dictionaries to give as input of check_disparity_ranges_are_inside_image method |
Raise an error if disparity ranges are out of image. |
|
|
Complete and check if roi section is correct |
|
Check that the first ROI coords are lower than the last. |
|
Check that only int is accepted for nodata of right image when matching_cost_method is sad or ssd. |
Default configuration input |
|
Default segment mode |
Module Contents
- pandora2d.check_configuration.check_datasets(left: xarray.Dataset, right: xarray.Dataset) None[source]
Check that left and right datasets are correct
- Parameters:
left – dataset
right – dataset
- Raises:
ValueError – If required disparities are missing or dataset shapes differ.
- pandora2d.check_configuration.check_conf(user_cfg: dict, pandora2d_machine: pandora2d.state_machine.Pandora2DMachine) dict[source]
Validate and complete the user configuration.
- Parameters:
user_cfg – user configuration dictionary
pandora2d_machine – Pandora2DMachine instance
- Returns:
global configuration
- pandora2d.check_configuration.get_section_config(user_cfg: dict[str, dict], key: str) dict[str, dict][source]
Get the section configuration from key
- Parameters:
user_cfg – user configuration dictionary
key – section name
- Return cfg:
configuration section dictionary or empty dict
- pandora2d.check_configuration.update_global_conf(global_cfg: dict[str, dict], completed_cfg: dict[str, dict]) None[source]
Update global_cfg with completed_cfg
- Parameters:
global_cfg – configuration to be updated
completed_cfg – configuration used for the update
- pandora2d.check_configuration.check_segment_mode_section(user_cfg: dict[str, dict]) None[source]
Complete and check if the segment mode dictionary is correct
- Parameters:
user_cfg – user configuration dictionary
- pandora2d.check_configuration.check_pipeline_section(user_cfg: dict[str, dict], pandora2d_machine: pandora2d.state_machine.Pandora2DMachine) None[source]
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
- Parameters:
user_cfg – user configuration dictionary
pandora2d_machine – Pandora2DMachine instance
- Raises:
KeyError – If the pipeline section is missing
- pandora2d.check_configuration.check_subpix_value_with_dichotomy(refinement_method: str, subpix: int) None[source]
Check if we have a subpix value of 1 with a dichotomy refinement method, in which case we return a warning to prevent aliasing.
- Parameters:
refinement_method – refinement method in user configuration
subpix – subpix value in user configuration
- pandora2d.check_configuration.check_matching_cost_method_with_ambiguity(matching_cost_method: str) None[source]
Check the correlation method used in relation to ambiguity
- Parameters:
matching_cost_method – matching_cost method in user configuration
- pandora2d.check_configuration.check_window_size_limit(user_cfg: dict) None[source]
Check that matching_cost window_size does not exceed left image dimensions.
Expected call order within check_conf: after check_pipeline_section (completed matching_cost including window_size) and check_input_section (left image path).
- Parameters:
user_cfg – user configuration dictionary
- Raises:
ValueError – if window_size is larger than image rows or columns
- pandora2d.check_configuration.check_output_section(user_cfg: dict[str, dict]) None[source]
Validate the given output section.
- Parameters:
user_cfg – user configuration dictionary
- pandora2d.check_configuration.check_expert_mode_section(user_cfg: dict[str, dict]) None[source]
Check if expert mode section is correct
- Parameters:
user_cfg – user configuration dictionary
- pandora2d.check_configuration.check_input_section(user_cfg: dict[str, dict], estimation_config: dict = None) None[source]
Complete and check if the input is correct
- Parameters:
user_cfg – user configuration dictionary
estimation_config – get estimation config if in user_config
- Raises:
KeyError – If the input section is missing or incompatible with estimation mode
- pandora2d.check_configuration.check_disparity(image_metadata: xarray.Dataset, input_cfg: dict, user_cfg: dict) None[source]
All checks on disparity
- Parameters:
image_metadata – left image metadata
input_cfg – input configuration with default value
user_cfg – user configuration dictionary
- Raises:
AttributeError – If disparity definitions or grids are invalid
ValueError – If disparity ranges are inconsistent with the image
- pandora2d.check_configuration.check_disparity_grids(image_metadata: xarray.Dataset, disparity_row_reader: rasterio.io.DatasetReader, disparity_col_reader: rasterio.io.DatasetReader, row_path: pathlib.Path, user_cfg: dict) None[source]
Check that disparity grids contains two bands and are the same size as the input image
- Parameters:
image_metadata – left image metadata
disparity_row_reader – row disparity raster reader
disparity_col_reaser – col disparity raster reader
row_path – disparity file or directory path
user_cfg – user configuration dictionary
- Raises:
AttributeError – If grid dimensions, bands, or attributes are invalid
- pandora2d.check_configuration.load_attributes(disparity_directory: pathlib.Path) dict[source]
Load attributes from json file in disparity directory.
- Parameters:
disparity_directory – directory where to find attributes’ file.
- Returns:
attributes dictionary
- pandora2d.check_configuration.check_step_from_attributes(attributes: dict, expected_step_value: list[int]) None[source]
Validate that the initial disparity attributes match the pipeline configuration.
- Parameters:
attributes – dictionary grid attributes
expected_step_value – expected step values.
- Raises:
AttributeError – If the steps do not match.
- pandora2d.check_configuration.check_disparity_grids_from_directory_within_image(attributes: dict, disparity_row_reader: rasterio.io.DatasetReader, image_metadata: xarray.Dataset) dict | None[source]
Check that disparity grids lie within image boundaries.
- Parameters:
attributes – dictionary grid attributes
disparity_row_reader – row disparity raster reader
image_metadata – left image metadata
- Returns:
ROI dictionary if grids define a sub-area, otherwise None
- Raises:
AttributeError – If disparity grids exceed image boundaries
- pandora2d.check_configuration.update_roi_from_disparity_grid(row_min: int, row_max: int, col_min: int, col_max: int) dict[source]
Construct ROI from input disparity grids when there are smaller than image,
- Parameters:
row_min – minimum row index
row_max – maximum row index (exclusive)
col_min – minimum col index
col_max – maximum col index (exclusive)
- Returns:
ROI dictionary
- pandora2d.check_configuration.get_dictionary_from_init_grid(disparity_reader: rasterio.io.DatasetReader, disp_range: int) dict[source]
Get correct dictionaries to give as input of check_disparity_ranges_are_inside_image method from initial disparity grids.
- Parameters:
disparity_reader – disparity grid reader
disp_range – range of exploration
- Returns:
a disparity dictionary to give to check_disparity_ranges_are_inside_image() method
- Raises:
ValueError – If the disparity grid is full on invalid values
- pandora2d.check_configuration.check_disparity_ranges_are_inside_image(image_metadata: xarray.Dataset, row_disparity: dict, col_disparity: dict) None[source]
Raise an error if disparity ranges are out of image.
- Parameters:
image_metadata – left image metadata
row_disparity – row disparity configuration
col_disparity – column disparity configuration
- Raises:
ValueError – If ranges exceed image bounds
- pandora2d.check_configuration.check_roi_section(user_cfg: dict[str, dict]) None[source]
Complete and check if roi section is correct
- Parameters:
user_cfg – user configuration dictionary
- pandora2d.check_configuration.check_roi_coherence(roi_cfg: dict) None[source]
Check that the first ROI coords are lower than the last.
- Parameters:
roi_cfg – user configuration for ROI
- Raises:
ValueError – If first coordinate is greater than last
- pandora2d.check_configuration.check_right_nodata_condition(cfg_input: dict, cfg_pipeline: dict) None[source]
Check that only int is accepted for nodata of right image when matching_cost_method is sad or ssd. :param cfg_input: inputs section of configuration :param cfg_pipeline: pipeline section of configuration :raises ValueError: If nodata type is invalid
- pandora2d.check_configuration.build_default_short_configuration_input() dict[source]
Default configuration input