1.5.1.2.5. polar2grid.compare module¶
Script for comparing writer output.
- class polar2grid.compare.ArrayComparisonResult(almost_equal: 'bool', num_diff_pixels: 'int', total_pixels: 'int', different_shape: 'bool')[source]¶
Bases:
object
- property diff_percentage¶
- property failed¶
- class polar2grid.compare.CompareHelper(atol: float = 0.0, rtol: float = 0.0, margin_of_error: float = 0.0, create_plot: bool = False)[source]¶
Bases:
object
Wrapper around various comparison operations.
- compare(input1, input2, **kwargs) list[FileComparisonResults] [source]¶
- compare_dirs(dir1, dir2, **kwargs) list[FileComparisonResults] [source]¶
- class polar2grid.compare.FileComparisonResults(file1: 'str', file2: 'str', files_missing: 'bool', unknown_file_type: 'bool', sub_results: 'list[ArrayComparisonResult]' = <factory>)[source]¶
Bases:
object
- sub_results: list[ArrayComparisonResult]¶
- class polar2grid.compare.FlatArrayComparisonResult(almost_equal: 'bool', num_diff_pixels: 'int', total_pixels: 'int', different_shape: 'bool', shape1: 'tuple', shape2: 'tuple', dtype1: 'np.dtype', dtype2: 'np.dtype')[source]¶
Bases:
ArrayComparisonResult
- class polar2grid.compare.VariableComparisonResult(almost_equal: 'bool', num_diff_pixels: 'int', total_pixels: 'int', different_shape: 'bool', variable: 'str', variable_missing: 'bool')[source]¶
Bases:
ArrayComparisonResult
- property failed¶
- polar2grid.compare._compare_gtiff_colormaps(cmap1: dict, cmap2: dict, **kwargs) VariableComparisonResult [source]¶
- polar2grid.compare._generate_matplotlib_1d_thumbnail(input_arr, output_thumbnail_path, max_width) bool [source]¶
- polar2grid.compare._generate_matplotlib_thumbnail(input_arr, output_thumbnail_path, max_width=512) bool [source]¶
- polar2grid.compare._generate_pillow_thumbnail(input_arr, output_thumbnail_path, max_width=512) bool [source]¶
- polar2grid.compare._generate_subresult_table_row(img_dst_dir: str, file_comparison_result: FileComparisonResults, sub_result: ArrayComparisonResult) str [source]¶
- polar2grid.compare._generate_table_rows(output_filename: str, file_comparison_results: list[FileComparisonResults]) list[str] [source]¶
- polar2grid.compare._generate_thumbnail(input_arr, output_thumbnail_path, max_width=512) bool [source]¶
- polar2grid.compare._generate_thumbnail_html(data_pathname: str, variable: str | None, img_dst_dir: str, tn_suffix: str, shape: tuple | None, dtype: dtype | None) str [source]¶
- polar2grid.compare._get_binary_array(input_filename: str, variable: str, shape: tuple | None, dtype: dtype) ndarray | None [source]¶
- polar2grid.compare._get_hdf5_array(input_filename: str, variable: str, shape: tuple | None, dtype: dtype | None) ndarray | None [source]¶
- polar2grid.compare._get_image_array(img_filename: str, variable: str = None, shape: tuple | None = None, dtype: dtype | None = None) ndarray | None [source]¶
- polar2grid.compare._get_netcdf_array(input_filename: str, variable: str, shape: tuple | None, dtype: dtype | None) ndarray | None [source]¶
- polar2grid.compare._get_thumbnail_array(input_data_path: str, variable: str | None, shape: tuple | None, dtype: dtype | None) ndarray | None [source]¶
- polar2grid.compare.compare_array(array1, array2, plot=False, **kwargs) ArrayComparisonResult [source]¶
- polar2grid.compare.compare_binary(fn1, fn2, shape, dtype, atol=0.0, margin_of_error=0.0, **kwargs) list[ArrayComparisonResult] [source]¶
- polar2grid.compare.compare_geotiff(gtiff_fn1, gtiff_fn2, atol=0.0, margin_of_error=0.0, **kwargs) list[ArrayComparisonResult] [source]¶
Compare 2 single banded geotiff files.
Note
The binary arrays will be converted to 32-bit floats before comparison.
- polar2grid.compare.compare_hdf5(h1_name, h2_name, variables, atol=0.0, margin_of_error=0.0, **kwargs) list[ArrayComparisonResult] [source]¶
- polar2grid.compare.compare_image(im1_name, im2_name, atol=0.0, margin_of_error=0.0, **kwargs) list[ArrayComparisonResult] [source]¶
- polar2grid.compare.compare_netcdf(nc1_name, nc2_name, variables, atol=0.0, margin_of_error=0.0, **kwargs) list[VariableComparisonResult] [source]¶
- polar2grid.compare.isclose_array(array1, array2, atol=0.0, rtol=0.0, margin_of_error=0.0, **kwargs) ArrayComparisonResult [source]¶
Compare 2 binary arrays per pixel.
Two pixels are considered different if the absolute value of their difference is greater than 1. This function assumes the arrays are in useful data types, which may cause erroneous results. For example, if both arrays are unsigned integers and the different results in a negative value overflow will occur and the threshold will likely not be met.
- Parameters:
array1 – numpy array for comparison
array2 – numpy array for comparison
atol – absolute tolerance (see numpy
isclose
)rtol – relative tolerance (see numpy
isclose
)margin_of_error – percentage of pixels that can be different and still be considered a passing amount.
kwargs – Unused.
- Returns:
1 if more than margin_of_error pixels are different, 0 otherwise.
- polar2grid.compare.main(argv=['-b', 'html', '-d', 'build/doctrees', 'source', 'build/html'])[source]¶
- polar2grid.compare.num_failed_files(file_comparison_results: list[FileComparisonResults]) int [source]¶