demcompare.stats_dataset

Mainly contains the StatsDataset class contains the computed stats of a pair of DEMs for the different classification layers

Module Contents

Classes

StatsDataset

StatsDataset class

class demcompare.stats_dataset.StatsDataset(image: numpy.ndarray, dem_processing_method: str = None)[source]

StatsDataset class

The StatsDataset class contains a list of one xr.dataset per classification layer

Each xr.Dataset contains :

Image:

2D (row, col) input image as xarray.DataArray,

Image_by_class:

3D (row, col; nb_classes)

xarray.DataArray containing the image pixels belonging to each class considering the valid pixels

Image_by_class_intersection:

3D (row, col; nb_classes)

xarray.DataArray containing the image pixels belonging to each class considering the intersection mode

Image_by_class_exclusion:

3D (row, col; nb_classes)

xarray.DataArray containing the image pixels belonging to each class considering the exclusion mode

Attributes:
  • name : name of the classification_layer. str

  • stats_by_class : dictionary containing the stats per class considering the standard mode

  • stats_by_class_intersection : dictionary containing the stats per class considering the intersection mode

  • stats_by_class_exclusion : dictionary containing the stats per class considering the exclusion mode

add_classif_layer_and_mode_stats(classif_name: str, input_stats: List[Dict], mode_name: str)[source]

Add the stats of a classification layer and a mode to the corresponding xarray dataset

Parameters:
  • classif_name (str) – classification_layer name

  • input_stats (List[str]) – input statistics

Mode_name:

name of the mode (standard (no name), intersection, exclusion)

Returns:

None

save_as_csv_and_json(classif_name: str, stats_dir: str)[source]

Saves the classification layer’s results to csv and json files on the stats_dir :param classif_name: classification_layer name :type classif_name: str :param stats_dir: output stats directory :type stats_dir: str :return: None

get_classification_layer_names()[source]

Returns the available classification layers

Returns:

None

get_classification_layer_dataset(classification_layer: str) xarray.Dataset[source]

Returns the xr.Dataset corresponding to the input classification layer name

Parameters:

classification_layer (str) – classification_layer name

Returns:

stats dictionary

Return type:

xr.Dataset

get_classification_layer_stats(classification_layer: str) Dict[source]

Returns all the stats corresponding to the input classification layer name

Parameters:

classification_layer (str) – classification_layer name

Returns:

stats dictionary

Return type:

Dict

get_classification_layer_metrics(classification_layer: str) List[str][source]

Returns the metric names available on the input classification layer and mode

Parameters:

classification_layer (str) – classification_layer name

Returns:

available metric names

Return type:

List[str]

get_classification_layer_metric(classification_layer: str, classif_class: int = None, mode: str = '', metric: str = None) List | Tuple[numpy.ndarray, numpy.ndarray] | numpy.ndarray | float[source]

Returns the metric corresponding to the input classification layer and mode

Parameters:
  • classification_layer (str) – classification_layer name

  • classif_class (int) – classification_layer class

  • mode (str) – mode (standard (no name), intersection, exclusion)

  • metric (str) – metric

Returns:

metric

Return type:

Union[List,Tuple[np.ndarray, np.ndarray], np.ndarray, float]