demcompare.metric.vector_metrics

Mainly contains different 2D metric classes

Module Contents

Classes

CumulativeProbabilityFunction

Cumulative Probability Function metric class

ProbabilityDensityFunction

Probability Density Function metric class

RatioAboveThreshold

Ratio above threshold metric class

SlopeOrientationHistogram

Slope orientation histogram of the DEM

class demcompare.metric.vector_metrics.CumulativeProbabilityFunction(parameters: Dict = None)[source]

Bases: demcompare.metric.metric_template.MetricTemplate

Cumulative Probability Function metric class

_BIN_STEP = 0.1[source]
_NB_BIN_MIN = 25[source]
compute_metric(data: numpy.ndarray) Tuple[numpy.ndarray, numpy.ndarray] | numpy.ndarray | float[source]

Metric computation method

Parameters:

data (np.array) – input data to compute the metric

Returns:

the computed cdf (y axis) and bins (y axis)

Return type:

Tuple[np.ndarray, np.ndarray]

save_csv_metric(output_file: str)[source]

Save the metric to a csv file

Parameters:

output_file (str) – path where the csv file is saved

Returns:

None

save_plot_metric(output_file: str)[source]

Compute and save the metric plot

Parameters:

output_file (str) – path where the plot image is saved

Returns:

None

class demcompare.metric.vector_metrics.ProbabilityDensityFunction(parameters: Dict = None)[source]

Bases: demcompare.metric.metric_template.MetricTemplate

Probability Density Function metric class

_BIN_STEP = 0.2[source]
_WIDTH = 0.7[source]
_NB_BIN_MIN = 25[source]
compute_metric(data: numpy.ndarray) Tuple[numpy.ndarray, numpy.ndarray] | numpy.ndarray | float[source]

Metric computation method

Parameters:

data (np.array) – input data to compute the metric

Returns:

the computed pdf (y axis) and bins (y axis)

Return type:

Tuple[np.ndarray, np.ndarray]

save_csv_metric(output_file: str)[source]

Save the metric to a csv file

Parameters:

output_file (str) – path where the csv file is saved

Returns:

None

save_plot_metric(output_file: str)[source]

Compute and save the metric plot

Parameters:

output_file (str) – path where the plot image is saved

Returns:

None

class demcompare.metric.vector_metrics.RatioAboveThreshold(parameters: Dict = None)[source]

Bases: demcompare.metric.metric_template.MetricTemplate

Ratio above threshold metric class

_ELEVATION_THRESHOLDS = [0.5, 1, 3][source]
_ORIGINAL_UNIT = 'm'[source]
static _get_thresholds_in_meters(threshold: List[float], original_unit: str)[source]

Create list of threshold in meters.

compute_metric(data: numpy.ndarray) Tuple[numpy.ndarray, numpy.ndarray] | numpy.ndarray | float[source]

Metric computation method

Parameters:

data (np.array) – input data to compute the metric

Returns:

the computed ratio_above_threshold

Return type:

np.ndarray

save_csv_metric(output_file: str)[source]

Save the metric to a csv file

Parameters:

output_file (str) – path where the csv file is saved

Returns:

None

class demcompare.metric.vector_metrics.SlopeOrientationHistogram(parameters: Dict = None)[source]

Bases: demcompare.metric.metric_template.MetricTemplate

Slope orientation histogram of the DEM

compute_orientation_slope(dem: numpy.ndarray) numpy.ndarray[source]

Return the slope orientation histogram of the input dem.

Parameters:

dem (np.ndarray) – dem

Returns:

slope orientation

Return type:

np.ndarray

compute_slope_orientation(normale: numpy.ndarray) numpy.ndarray[source]

Compute the orientation of a map of vectors defined at each pixel with respect to the North direction. Calculated orientations are between 0° and +360° (+270° = West direction)

Parameters:

normale (np.ndarray) – vector (3D, row, col) normal to the surface

Returns:

vector orientation (row, col) at each pixel

Return type:

np.ndarray

compute_metric(data: numpy.ndarray) Tuple[numpy.ndarray, numpy.ndarray] | numpy.ndarray | float[source]

Metric computation method

Parameters:

data (np.array) – input data to compute the metric

Returns:

the computed cdf (y axis) and bins (y axis)

Return type:

Tuple[np.ndarray, np.ndarray]

save_plot_metric(output_file: str)[source]

Compute and save the metric plot

Parameters:

output_file (str) – path where the plot image is saved

Returns:

None

compute_histogram(data: numpy.ndarray, nbins: int, normalise: bool = True) Tuple[numpy.ndarray, numpy.ndarray][source]

DEM slope orientation histogram computation.

Parameters:
  • data (np.ndarray) – orientation of the DEM

  • nbins (int) – number of bins of the histogram

  • normalise (bool) – normalise or not the histogram

Returns:

the histogram of the orientation

Return type:

Tuple[np.ndarray, np.ndarray]