demcompare.helpers_init

This is where high level parameters are checked and default options are set

Module Contents

Functions

make_relative_path_absolute(path, directory)

If path is a valid relative path with respect to directory,

read_config_file(→ demcompare.internal_typing.ConfigType)

Read a demcompare input json config file.

save_config_file(config_file, config)

Save a json configuration file

compute_initialization(...)

Compute demcompare initialization process :

check_input_parameters(cfg)

Checks parameters

check_dem_processing_methods(cfg)

Checks that the DEM processing methods

check_curvature_slope(cfg)

Checks that there is no

get_output_files_paths(→ Tuple[str, str, str, str, ...)

Return the paths of the output global files:

demcompare.helpers_init.make_relative_path_absolute(path, directory)[source]

If path is a valid relative path with respect to directory, returns it as an absolute path

Parameters:
  • path (string) – The relative path

  • directory (string) – The directory path should be relative to

Returns:

os.path.join(directory,path) if path is a valid relative path form directory, else path

Return type:

string

demcompare.helpers_init.read_config_file(config_file: str) demcompare.internal_typing.ConfigType[source]

Read a demcompare input json config file. Relative paths will be made absolute.

Parameters:

config_file (str) – Path to json file

Returns:

The json dictionary read from file with absolute paths

Return type:

ConfigType

demcompare.helpers_init.save_config_file(config_file: str, config: demcompare.internal_typing.ConfigType)[source]

Save a json configuration file

Parameters:
  • config_file (string) – path to a json file

  • config (ConfigType) – configuration json dictionary

demcompare.helpers_init.compute_initialization(config_json: str) demcompare.internal_typing.ConfigType[source]

Compute demcompare initialization process : Configuration copy, checking, and initial output content.

Parameters:

config_json (str) – Config json file name

Returns:

demcompare config initialized with default values

Return type:

ConfigType

demcompare.helpers_init.check_input_parameters(cfg: demcompare.internal_typing.ConfigType)[source]

Checks parameters

Parameters:

cfg (ConfigType) – configuration dictionary

demcompare.helpers_init.check_dem_processing_methods(cfg: demcompare.internal_typing.ConfigType)[source]

Checks that the DEM processing methods in the config are correct.

Parameters:

cfg (ConfigType) – configuration dictionary

demcompare.helpers_init.check_curvature_slope(cfg: demcompare.internal_typing.ConfigType)[source]

Checks that there is no DEM processing method ‘..-curvature’ with ‘Slope0’ as ‘classification_layers’

Parameters:

cfg (ConfigType) – configuration dictionary

demcompare.helpers_init.get_output_files_paths(output_dir: str, dir_name: str, file_name: str) Tuple[str, str, str, str, str, str, str, str][source]

Return the paths of the output global files: - dem.tif - dem.png - dem_cdf.tif and dem_cdf.csv - dem_pdf.tif and dem_pdf.csv

Parameters:
  • output_dir (str) – output_dir

  • dir_name (str) – name of the subdirectory

  • file_name (str) – name of the files

Returns:

Output paths

Return type:

Tuple[str, str, str, str, str, str, str, str]