wolfhece.report.compare_arrays ============================== .. py:module:: wolfhece.report.compare_arrays Module Contents --------------- .. py:class:: ArrayDifferenceLayout(title: str, filename='', ox=0, oy=0, tx=0, ty=0, parent=None, is2D=True, idx='', plotted=True, mapviewer=None, need_for_wx=False, bbox=None, find_minmax=True, shared=False, colors=None) Bases: :py:obj:`wolfhece.report.common.DefaultLayoutA4` .. autoapi-inheritance-diagram:: wolfhece.report.compare_arrays.ArrayDifferenceLayout :parts: 1 :private-bases: Layout for comparing two arrays in a report. 1 cadre pour la zone traitée avec photo de fond ign + contour vectoriel 1 cadre avec zoom plus large min 250m 1 cadre avec matrice ref + contour vectoriel 1 cadre avec matrice à comparer + contour vectoriel 1 cadre avec différence 1 cadre avec valeurs de synthèse 1 cadre avec histogramme 1 cadre avec histogramme des différences .. py:attribute:: _hitograms .. py:attribute:: _arrays .. py:class:: CompareArraysLayout(title: str, filename='', ox=0, oy=0, tx=0, ty=0, parent=None, is2D=True, idx='', plotted=True, mapviewer=None, need_for_wx=False, bbox=None, find_minmax=True, shared=False, colors=None) Bases: :py:obj:`wolfhece.report.common.DefaultLayoutA4` .. autoapi-inheritance-diagram:: wolfhece.report.compare_arrays.CompareArraysLayout :parts: 1 :private-bases: Enum for default layout options. .. py:attribute:: _summary .. py:attribute:: _arrays .. py:attribute:: _diff_rect .. py:class:: CompareArraysLayout2(title: str, filename='', ox=0, oy=0, tx=0, ty=0, parent=None, is2D=True, idx='', plotted=True, mapviewer=None, need_for_wx=False, bbox=None, find_minmax=True, shared=False, colors=None) Bases: :py:obj:`wolfhece.report.common.DefaultLayoutA4` .. autoapi-inheritance-diagram:: wolfhece.report.compare_arrays.CompareArraysLayout2 :parts: 1 :private-bases: Enum for default layout options. .. py:attribute:: _summary .. py:attribute:: _arrays .. py:attribute:: _diff_rect .. py:class:: ArrayDifference(reference: wolfhece.wolf_array.WolfArray, to_compare: wolfhece.wolf_array.WolfArray, index: int, label: numpy.ndarray) Class to manage the difference between two WolfArray objects. .. py:attribute:: _dpi :value: 600 .. py:attribute:: default_size_hitograms :value: (12, 6) .. py:attribute:: default_size_arrays :value: (10, 10) .. py:attribute:: _fontsize :value: 6 .. py:attribute:: reference .. py:attribute:: to_compare .. py:attribute:: index .. py:attribute:: label .. py:attribute:: _background :value: 'IGN' .. py:attribute:: _contour :value: None .. py:attribute:: _external_border :value: None .. py:property:: contour :type: wolfhece.wolf_array.vector Get the contour of the difference part. .. py:property:: external_border :type: wolfhece.wolf_array.vector Get the bounds of the difference part. .. py:property:: _summary_text Generate a summary text for the report. .. py:method:: set_palette_distribute(minval: float, maxval: float, step: int = 0) Set the palette for both arrays. .. py:method:: set_palette(values: list[float], colors: list[tuple[int, int, int]]) Set the palette for both arrays based on specific values. .. py:method:: plot_position(figax: tuple[matplotlib.pyplot.Figure, matplotlib.pyplot.Axes] = None) -> tuple[matplotlib.pyplot.Figure, matplotlib.pyplot.Axes] Plot the reference array. .. py:method:: plot_position_scaled(scale=4, figax: tuple[matplotlib.pyplot.Figure, matplotlib.pyplot.Axes] = None) -> tuple[matplotlib.pyplot.Figure, matplotlib.pyplot.Axes] Plot the reference array. .. py:method:: plot_reference(figax: tuple[matplotlib.pyplot.Figure, matplotlib.pyplot.Axes] = None) -> tuple[matplotlib.pyplot.Figure, matplotlib.pyplot.Axes] Plot the reference array. .. py:method:: plot_to_compare(figax: tuple[matplotlib.pyplot.Figure, matplotlib.pyplot.Axes] = None) -> tuple[matplotlib.pyplot.Figure, matplotlib.pyplot.Axes] Plot the array to compare. .. py:property:: difference :type: wolfhece.wolf_array.WolfArray Get the difference between the two arrays. .. py:method:: plot_difference(figax: tuple[matplotlib.pyplot.Figure, matplotlib.pyplot.Axes] = None) -> tuple[matplotlib.pyplot.Figure, matplotlib.pyplot.Axes] Plot the array to compare. .. py:method:: _plot_histogram_reference(figax: tuple[matplotlib.pyplot.Figure, matplotlib.pyplot.Axes] = None, density=True, alpha=0.5, **kwargs) -> tuple[matplotlib.pyplot.Figure, matplotlib.pyplot.Axes] Plot histogram of the reference array. .. py:method:: _plot_histogram_to_compare(figax: tuple[matplotlib.pyplot.Figure, matplotlib.pyplot.Axes] = None, density=True, alpha=0.5, **kwargs) -> tuple[matplotlib.pyplot.Figure, matplotlib.pyplot.Axes] Plot histogram of the array to compare. .. py:method:: plot_histograms(figax: tuple[matplotlib.pyplot.Figure, matplotlib.pyplot.Axes] = None, density=True, alpha=0.5, **kwargs) -> tuple[matplotlib.pyplot.Figure, matplotlib.pyplot.Axes] Plot histograms of both arrays. .. py:method:: plot_histograms_difference(figax: tuple[matplotlib.pyplot.Figure, matplotlib.pyplot.Axes] = None, density=True, alpha=1.0, **kwargs) -> tuple[matplotlib.pyplot.Figure, matplotlib.pyplot.Axes] Plot histogram of the difference between the two arrays. .. py:method:: _complete_report(layout: ArrayDifferenceLayout) Complete the report with the arrays and histograms. .. py:method:: create_report(output_file: str | pathlib.Path = None) -> pathlib.Path Create a page report for the array difference. .. py:class:: CompareArrays(reference: wolfhece.wolf_array.WolfArray | str | pathlib.Path, to_compare: wolfhece.wolf_array.WolfArray | str | pathlib.Path) .. py:attribute:: _dpi :value: 600 .. py:attribute:: default_size_arrays :value: (10, 10) .. py:attribute:: _fontsize :value: 6 .. py:attribute:: array_reference :type: wolfhece.wolf_array.WolfArray .. py:attribute:: array_to_compare :type: wolfhece.wolf_array.WolfArray .. py:attribute:: labeled_array :type: numpy.ndarray :value: None .. py:attribute:: num_features :type: int :value: 0 .. py:attribute:: nb_cells :type: list :value: [] .. py:attribute:: difference_parts :type: dict[int, ArrayDifference] .. py:attribute:: _pdf_path :value: None .. py:attribute:: _background :value: 'IGN' .. py:property:: difference :type: wolfhece.wolf_array.WolfArray .. py:method:: get_zones() Get a Zones object containing the differences. .. py:method:: plot_position(figax: tuple[matplotlib.pyplot.Figure, matplotlib.pyplot.Axes] = None) -> tuple[matplotlib.pyplot.Figure, matplotlib.pyplot.Axes] Plot the reference array with a background. .. py:method:: plot_cartoweb(figax: tuple[matplotlib.pyplot.Figure, matplotlib.pyplot.Axes] = None) -> tuple[matplotlib.pyplot.Figure, matplotlib.pyplot.Axes] Plot the reference array with a background. .. py:method:: plot_topo_grey(figax: tuple[matplotlib.pyplot.Figure, matplotlib.pyplot.Axes] = None) -> tuple[matplotlib.pyplot.Figure, matplotlib.pyplot.Axes] Plot the reference array with a background. .. py:method:: plot_reference(figax: tuple[matplotlib.pyplot.Figure, matplotlib.pyplot.Axes] = None) -> tuple[matplotlib.pyplot.Figure, matplotlib.pyplot.Axes] Plot the reference array. .. py:method:: plot_to_compare(figax: tuple[matplotlib.pyplot.Figure, matplotlib.pyplot.Axes] = None) -> tuple[matplotlib.pyplot.Figure, matplotlib.pyplot.Axes] Plot the array to compare. .. py:method:: plot_difference(figax: tuple[matplotlib.pyplot.Figure, matplotlib.pyplot.Axes] = None) -> tuple[matplotlib.pyplot.Figure, matplotlib.pyplot.Axes] Plot the difference between the two arrays. .. py:method:: localize_differences(threshold: float = 0.0, ignored_patche_area: float = 1.0) -> numpy.ndarray Localize the differences between the two arrays and label them. :param threshold: The threshold value to consider a difference significant. :param ignored_patche_area: The area of patches to ignore (in m²). .. py:property:: summary_text :type: list[str] Generate a summary text for the report. .. py:method:: _complete_report(layout: CompareArraysLayout) Complete the report with the global summary and individual differences. .. py:method:: plot_histogram_features(figax: tuple[matplotlib.pyplot.Figure, matplotlib.pyplot.Axes] = None, density=True, alpha=0.5, **kwargs) -> tuple[matplotlib.pyplot.Figure, matplotlib.pyplot.Axes] Plot histogram of the number of cells in each feature. .. py:method:: plot_histogram_features_difference(figax: tuple[matplotlib.pyplot.Figure, matplotlib.pyplot.Axes] = None, density=True, alpha=1.0, **kwargs) -> tuple[matplotlib.pyplot.Figure, matplotlib.pyplot.Axes] Plot histogram of the volume in each feature for the difference. .. py:method:: _complete_report2(layout: CompareArraysLayout) Complete the report with the individual differences. .. py:method:: create_report(output_file: str | pathlib.Path = None, append_all_differences: bool = True, nb_max_differences: int = -1) -> None Create a page report for the array comparison. .. py:property:: pdf_path :type: pathlib.Path Return the path to the generated PDF report. .. py:class:: CompareArrays_wx(reference: wolfhece.wolf_array.WolfArray | str | pathlib.Path, to_compare: wolfhece.wolf_array.WolfArray | str | pathlib.Path, ignored_patche_area: float = 2.0, nb_max_patches: int = 10, threshold: float = 0.01, dpi=200, **kwargs) Bases: :py:obj:`wolfhece.report.pdf.PDFViewer` .. autoapi-inheritance-diagram:: wolfhece.report.compare_arrays.CompareArrays_wx :parts: 1 :private-bases: A sized frame. Controls added to its content pane will automatically be added to the panes sizer. .. py:attribute:: _report .. py:method:: on_close(event) Handle the close event to clean up resources .. py:method:: get_zones() -> wolfhece.wolf_array.Zones Get the zones from the report.