demcompare.metric.vector_metrics ================================ .. py:module:: demcompare.metric.vector_metrics .. autoapi-nested-parse:: Mainly contains different 2D metric classes Classes ------- .. autoapisummary:: demcompare.metric.vector_metrics.CumulativeProbabilityFunction demcompare.metric.vector_metrics.ProbabilityDensityFunction demcompare.metric.vector_metrics.RatioAboveThreshold demcompare.metric.vector_metrics.SlopeOrientationHistogram Module Contents --------------- .. py:class:: CumulativeProbabilityFunction(parameters: Dict = None) Bases: :py:obj:`demcompare.metric.metric_template.MetricTemplate` Cumulative Probability Function metric class .. py:attribute:: _BIN_STEP :value: 0.1 .. py:attribute:: _NB_BIN_MIN :value: 25 .. py:attribute:: type :value: 'vector' .. py:attribute:: input_type :value: '1D' .. py:attribute:: nb_bins :type: int :value: None .. py:attribute:: max_diff :type: float :value: None .. py:attribute:: nb_nans :type: int :value: None .. py:attribute:: nb_pixels :type: int :value: None .. py:attribute:: bins_count :type: numpy.ndarray :value: None .. py:attribute:: cdf :type: numpy.ndarray :value: None .. py:attribute:: output_csv_path :type: str :value: None .. py:attribute:: output_plot_path :type: str :value: None .. py:attribute:: bin_step :type: float :value: 0.1 .. py:method:: compute_metric(data: numpy.ndarray) -> Union[Tuple[numpy.ndarray, numpy.ndarray], numpy.ndarray, float] Metric computation method :param data: input data to compute the metric :type data: np.array :return: the computed cdf (y axis) and bins (y axis) :rtype: Tuple[np.ndarray, np.ndarray] .. py:method:: save_csv_metric(output_file: str) Save the metric to a csv file :param output_file: path where the csv file is saved :type output_file: str :return: None .. py:method:: save_plot_metric(output_file: str) Compute and save the metric plot :param output_file: path where the plot image is saved :type output_file: str :return: None .. py:class:: ProbabilityDensityFunction(parameters: Dict = None) Bases: :py:obj:`demcompare.metric.metric_template.MetricTemplate` Probability Density Function metric class .. py:attribute:: _BIN_STEP :value: 0.2 .. py:attribute:: _WIDTH :value: 0.7 .. py:attribute:: _NB_BIN_MIN :value: 25 .. py:attribute:: type :value: 'vector' .. py:attribute:: input_type :value: '1D' .. py:attribute:: bin_step :type: float :value: None .. py:attribute:: width :type: float :value: None .. py:attribute:: filter_p98 :type: float :value: None .. py:attribute:: pdf :type: numpy.ndarray :value: None .. py:attribute:: bins :type: numpy.ndarray :value: None .. py:attribute:: output_csv_path :type: str :value: None .. py:attribute:: output_plot_path :type: str :value: None .. py:method:: compute_metric(data: numpy.ndarray) -> Union[Tuple[numpy.ndarray, numpy.ndarray], numpy.ndarray, float] Metric computation method :param data: input data to compute the metric :type data: np.array :return: the computed pdf (y axis) and bins (y axis) :rtype: Tuple[np.ndarray, np.ndarray] .. py:method:: save_csv_metric(output_file: str) Save the metric to a csv file :param output_file: path where the csv file is saved :type output_file: str :return: None .. py:method:: save_plot_metric(output_file: str) Compute and save the metric plot :param output_file: path where the plot image is saved :type output_file: str :return: None .. py:class:: RatioAboveThreshold(parameters: Dict = None) Bases: :py:obj:`demcompare.metric.metric_template.MetricTemplate` Ratio above threshold metric class .. py:attribute:: _ELEVATION_THRESHOLDS :value: [0.5, 1, 3] .. py:attribute:: _ORIGINAL_UNIT :value: 'm' .. py:attribute:: type :value: 'vector' .. py:attribute:: input_type :value: '1D' .. py:attribute:: ratio_above_thrshld :type: List :value: None .. py:attribute:: output_csv_path :type: str :value: None .. py:method:: _get_thresholds_in_meters(threshold: List[float], original_unit: str) :staticmethod: Create list of threshold in meters. .. py:method:: compute_metric(data: numpy.ndarray) -> Union[Tuple[numpy.ndarray, numpy.ndarray], numpy.ndarray, float] Metric computation method :param data: input data to compute the metric :type data: np.array :return: the computed ratio_above_threshold :rtype: np.ndarray .. py:method:: save_csv_metric(output_file: str) Save the metric to a csv file :param output_file: path where the csv file is saved :type output_file: str :return: None .. py:class:: SlopeOrientationHistogram(parameters: Dict = None) Bases: :py:obj:`demcompare.metric.metric_template.MetricTemplate` Slope orientation histogram of the DEM .. py:attribute:: type :value: 'vector' .. py:attribute:: input_type :value: '2D' .. py:attribute:: nb_bins :type: int :value: 100 .. py:attribute:: output_plot_path :type: str :value: None .. py:attribute:: orientation :type: numpy.ndarray :value: None .. py:attribute:: hist :type: numpy.ndarray :value: None .. py:attribute:: angles :type: numpy.ndarray :value: None .. py:attribute:: dx :type: numpy.float64 :value: None .. py:attribute:: dy :type: numpy.float64 :value: None .. py:method:: compute_orientation_slope(dem: numpy.ndarray) -> numpy.ndarray Return the slope orientation histogram of the input dem. :param dem: dem :type dem: np.ndarray :return: slope orientation :rtype: np.ndarray .. py:method:: compute_slope_orientation(normale: numpy.ndarray) -> numpy.ndarray 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) :param normale: vector (3D, row, col) normal to the surface :type normale: np.ndarray :return: vector orientation (row, col) at each pixel :rtype: np.ndarray .. py:method:: compute_metric(data: numpy.ndarray) -> Union[Tuple[numpy.ndarray, numpy.ndarray], numpy.ndarray, float] Metric computation method :param data: input data to compute the metric :type data: np.array :return: the computed cdf (y axis) and bins (y axis) :rtype: Tuple[np.ndarray, np.ndarray] .. py:method:: save_plot_metric(output_file: str) Compute and save the metric plot :param output_file: path where the plot image is saved :type output_file: str :return: None .. py:method:: compute_histogram(data: numpy.ndarray, nbins: int, normalise: bool = True) -> Tuple[numpy.ndarray, numpy.ndarray] DEM slope orientation histogram computation. :param data: orientation of the DEM :type data: np.ndarray :param nbins: number of bins of the histogram :type nbins: int :param normalise: normalise or not the histogram :type normalise: bool :return: the histogram of the orientation :rtype: Tuple[np.ndarray, np.ndarray]