pandora.common

This module contains functions allowing to save the results and the configuration of Pandora pipeline.

Module Contents

Functions

write_data_array(→ None)

Write a xarray.DataArray in a tiff file

mkdir_p(→ None)

Create a directory without complaining if it already exists.

save_results(→ None)

Save results in the output directory

sliding_window(→ numpy.ndarray)

Create a sliding window of using as_strided function : this function create a new a view (by manipulating

save_config(→ None)

Save the user configuration in json file

is_method(→ bool)

Test if string_method is a method in methods

pandora.common.write_data_array(data_array: xarray.DataArray, filename: str, dtype: rasterio.dtypes = rasterio.dtypes.float32, band_names: List[str] = None, crs: rasterio.crs.CRS | None = None, transform: rasterio.Affine | None = None) None[source]

Write a xarray.DataArray in a tiff file

Parameters:
  • data_array (2D xarray.DataArray (row, col) or 3D xarray.DataArray (row, col, indicator)) – data

  • filename (string) – output filename

  • dtype (rasterio.Affine) – band types

  • band_names – band names

  • crs – coordinate reference support

  • transform – geospatial transform matrix

Returns:

None

pandora.common.mkdir_p(path: str) None[source]

Create a directory without complaining if it already exists. :return: None

pandora.common.save_results(left: xarray.Dataset, right: xarray.Dataset, output: str) None[source]

Save results in the output directory

Parameters:
  • left (xr.Dataset) –

    left dataset, which contains the variables :

    • disparity_map : the disparity map in the geometry of the left image 2D DataArray (row, col)

    • confidence_measure : the confidence measure in the geometry of the left image 3D DataArray (row, col, indicator)

    • validity_mask : the validity mask in the geometry of the left image 2D DataArray (row, col)

  • right (xr.Dataset) –

    right dataset. If there is no validation step, the right Dataset will be empty.If a validation step is configured, the dataset will contain the variables :

    • disparity_map: the disparity map in the geometry of the right image 2D DataArray (row, col)

    • confidence_measure: the confidence in the geometry of the right image 3D DataArray (row, col, indicator)

    • validity_mask: the validity mask in the geometry of the left image 2D DataArray (row, col)

  • output (string) – output directory

Returns:

None

pandora.common.sliding_window(base_array: numpy.ndarray, shape: Tuple[int, int]) numpy.ndarray[source]

Create a sliding window of using as_strided function : this function create a new a view (by manipulating data pointer) of the data array with a different shape. The new view pointing to the same memory block as data so it does not consume any additional memory.

Parameters:
  • base_array (np.array) – the 2D array through which slide the window

  • shape (Tuple[int,int]) – shape of the sliding window

Return type:

np.array

pandora.common.save_config(output: str, user_cfg: Dict) None[source]

Save the user configuration in json file

Parameters:
  • output (string) – Path to output directory

  • user_cfg (dict) – user configuration

Returns:

None

pandora.common.is_method(string_method: str, methods: List[str]) bool[source]

Test if string_method is a method in methods

Parameters:
  • string_method (string) – String to test

  • methods (list of strings) – list of available methods

Returns:

True if string_method a method and False otherwise

Return type:

bool