├── .coveragerc ├── .github └── workflows │ └── demcompare_ci.yml ├── .gitignore ├── .gitlab ├── issue_templates │ ├── Bug.md │ ├── Proposal.md │ ├── Refacto.md │ └── Release.md └── merge_request_templates │ └── MR.md ├── .pre-commit-config.yaml ├── .pylintrc ├── .readthedocs.yml ├── AUTHORS.md ├── CHANGELOG.md ├── LICENSE ├── Makefile ├── NOTICE ├── README.md ├── data_samples ├── sample_config.json ├── sample_config_full.json ├── sample_config_tiles.json ├── srtm_blurred_and_shifted.tif └── srtm_ref.tif ├── demcompare ├── __init__.py ├── classification_layer │ ├── __init__.py │ ├── classification_layer.py │ ├── classification_layer_template.py │ ├── fusion_classification.py │ ├── global_classification.py │ ├── segmentation_classification.py │ └── slope_classification.py ├── coregistration │ ├── __init__.py │ ├── coregistration.py │ ├── coregistration_template.py │ └── nuth_kaab_internal.py ├── dataset_tools.py ├── dem_processing │ ├── __init__.py │ ├── dem_processing.py │ ├── dem_processing_methods.py │ └── dem_processing_template.py ├── dem_tools.py ├── demcompare.py ├── demcompare_tiles.py ├── geoid │ └── egm96_15.gtx ├── helpers_init.py ├── img_tools.py ├── internal_typing.py ├── log_conf.py ├── logging.json ├── metric │ ├── __init__.py │ ├── matrix_2d_metrics.py │ ├── metric.py │ ├── metric_template.py │ ├── scalar_metrics.py │ └── vector_metrics.py ├── report.py ├── sphinx_project_generator.py ├── stats_dataset.py ├── stats_processing.py └── transformation.py ├── docs ├── Makefile ├── make.bat └── source │ ├── CLA │ ├── .gitkeep │ ├── CCLA-DEMCOMPARE.doc │ └── ICLA-DEMCOMPARE.doc │ ├── _static │ └── css │ │ └── my_custom.css │ ├── conf.py │ ├── developer_guide.rst │ ├── developer_guide │ ├── architecture │ │ ├── coregistration_modules.rst │ │ ├── dem_processing.rst │ │ ├── dem_tools_modules.rst │ │ ├── demcompare_cli.rst │ │ ├── demcompare_module.rst │ │ ├── high_level_description.rst │ │ ├── report_module.rst │ │ └── stats_modules.rst │ ├── coding_guide.rst │ ├── contributing.rst │ ├── demcompare_architecture.rst │ ├── dev_install_env.rst │ ├── dev_tutorials.rst │ └── dev_tutorials │ │ ├── tuto_new_coregistration.rst │ │ ├── tuto_new_dem_processing.rst │ │ └── tuto_new_metric.rst │ ├── faq.rst │ ├── getting_started.rst │ ├── glossary.rst │ ├── images │ ├── AngularDiff.png │ ├── Curvature.png │ ├── ErrorVSslope.png │ ├── HillshadeSVF.png │ ├── coreg_api.png │ ├── dem_intersection.png │ ├── demcompare_picto.png │ ├── doc_out.gif │ ├── doc_ref.gif │ ├── favicon.ico │ ├── final_dh.png │ ├── initial_dh.png │ ├── modules_schema.png │ ├── schema_coregistration.png │ ├── schema_coregistration_class.png │ ├── schema_statistiques_class.png │ ├── slopeOrientationHist.png │ ├── stats_api.png │ ├── stats_fusion_schema.png │ ├── stats_input_after_coreg.png │ ├── stats_input_one_dem.png │ ├── stats_input_two_dems.png │ ├── stats_support_schema.png │ └── workflow.png │ ├── index.rst │ ├── userguide.rst │ └── userguide │ ├── command_line_execution.rst │ ├── coregistration.rst │ ├── inputs.rst │ ├── notebook_execution.rst │ ├── report.rst │ ├── statistics.rst │ └── statistics │ ├── angular_difference.rst │ ├── classification_layers.rst │ ├── dem_processing.rst │ ├── hillshade_sky_view.rst │ ├── metrics.rst │ ├── quality_measures.rst │ ├── slope_normalized_elevation_difference.rst │ ├── statistics_outputs.rst │ └── statistics_parameters.rst ├── notebooks ├── data │ ├── gironde │ │ ├── FinalWaveBathymetry_T30TXR_20200622T105631_D_MSL_invert.TIF │ │ ├── Gironde.tif │ │ └── ref_status.tif │ ├── grenoble │ │ ├── Copernicus_DSM_10_N45_00_E005_00_DEM.tif │ │ ├── Copernicus_blurred_and_shifted.tif │ │ └── copernicus_status.tif │ └── srtm │ │ ├── srtm_blurred_and_shifted_res.tif │ │ └── srtm_ref.tif ├── img │ ├── doc_ref.gif │ ├── logo_demcompare.png │ ├── schema_coreg.png │ ├── stats_fusion_schema.png │ └── stats_input_two_dems.png ├── introduction_and_basic_usage.ipynb ├── reprojection_and_coregistration.ipynb ├── scenario_srtm.ipynb ├── snippets │ ├── __init__.py │ └── utils_notebook.py ├── statistics.ipynb └── statistics_all_metrics.ipynb ├── pyproject.toml ├── pytest.ini ├── report ├── FinalWaveBathymetry_T30TXR_20200622T105631_D_MSL_invert.TIF ├── FinalWaveBathymetry_T30TXR_20200622T105631_Status.TIF ├── Gironde.tif ├── __init__.py ├── app.py ├── assets │ ├── __init__.py │ └── items.py └── config_report.json ├── setup.cfg ├── setup.py ├── sonar-project.properties ├── tests ├── __init__.py ├── classification_layer │ ├── __init__.py │ ├── test_classification_layer.py │ ├── test_fusion_classification.py │ ├── test_get_classification_layer_metrics.py │ ├── test_segmentation_classification.py │ ├── test_slope_classification.py │ └── test_verify_fusion_layer.py ├── conftest.py ├── coregistration │ ├── __init__.py │ ├── test_coregister_dems.py │ ├── test_coregistration_cropped_dem.py │ ├── test_coregistration_errors.py │ ├── test_coregistration_gironde.py │ ├── test_coregistration_nuth_kaab.py │ ├── test_coregistration_outputs.py │ └── test_coregistration_srtm.py ├── data │ ├── end_to_end_data │ │ ├── gironde_test_data │ │ │ ├── data_description.md │ │ │ ├── input │ │ │ │ ├── FinalWaveBathymetry_T30TXR_20200622T105631_D_MSL_invert.TIF │ │ │ │ ├── FinalWaveBathymetry_T30TXR_20200622T105631_Status.TIF │ │ │ │ ├── Gironde.tif │ │ │ │ ├── Small_FinalWaveBathymetry_T30TXR_20200622T105631_Status.TIF │ │ │ │ ├── dem_cm.tif │ │ │ │ ├── reduced_Gironde.tif │ │ │ │ ├── ref_status.tif │ │ │ │ ├── test_config.json │ │ │ │ └── test_config_ref_status.json │ │ │ ├── ref_output │ │ │ │ ├── coregistration │ │ │ │ │ ├── coreg_SEC.tif │ │ │ │ │ ├── coregistration_results.json │ │ │ │ │ ├── reproj_coreg_REF.tif │ │ │ │ │ └── reproj_coreg_SEC.tif │ │ │ │ ├── initial_dem_diff.tif │ │ │ │ ├── stats │ │ │ │ │ ├── alti-diff │ │ │ │ │ │ ├── Fusion0 │ │ │ │ │ │ │ ├── sec_rectified_support_map.tif │ │ │ │ │ │ │ └── stats_results.csv │ │ │ │ │ │ ├── Slope0 │ │ │ │ │ │ │ ├── ref_rectified_support_map.tif │ │ │ │ │ │ │ ├── sec_rectified_support_map.tif │ │ │ │ │ │ │ ├── stats_results.csv │ │ │ │ │ │ │ └── stats_results_intersection.csv │ │ │ │ │ │ ├── Status │ │ │ │ │ │ │ ├── sec_rectified_support_map.tif │ │ │ │ │ │ │ └── stats_results.csv │ │ │ │ │ │ ├── dem_for_stats.tif │ │ │ │ │ │ └── global │ │ │ │ │ │ │ └── stats_results.csv │ │ │ │ │ ├── dh_col_wise_wave_detection.tif │ │ │ │ │ └── dh_row_wise_wave_detection.tif │ │ │ │ └── test_config.json │ │ │ └── ref_output_same_dem │ │ │ │ ├── coregistration │ │ │ │ ├── coreg_SEC.tif │ │ │ │ ├── coregistration_results.json │ │ │ │ ├── reproj_coreg_REF.tif │ │ │ │ └── reproj_coreg_SEC.tif │ │ │ │ ├── initial_dem_diff.tif │ │ │ │ ├── stats │ │ │ │ └── alti-diff │ │ │ │ │ ├── Fusion0 │ │ │ │ │ ├── ref_rectified_support_map.tif │ │ │ │ │ └── stats_results.csv │ │ │ │ │ ├── Slope0 │ │ │ │ │ ├── ref_rectified_support_map.tif │ │ │ │ │ ├── sec_rectified_support_map.tif │ │ │ │ │ ├── stats_results.csv │ │ │ │ │ └── stats_results_intersection.csv │ │ │ │ │ ├── Status │ │ │ │ │ ├── sec_rectified_support_map.tif │ │ │ │ │ └── stats_results.csv │ │ │ │ │ ├── dem_for_stats.tif │ │ │ │ │ └── global │ │ │ │ │ └── stats_results.csv │ │ │ │ └── test_config.json │ │ ├── gironde_test_data_sampling_ref │ │ │ ├── data_description.md │ │ │ ├── input │ │ │ │ ├── FinalWaveBathymetry_T30TXR_20200622T105631_D_MSL_invert.TIF │ │ │ │ ├── Gironde.tif │ │ │ │ ├── ref_status.tif │ │ │ │ └── test_config.json │ │ │ └── ref_output │ │ │ │ ├── coregistration │ │ │ │ ├── coreg_SEC.tif │ │ │ │ ├── coregistration_results.json │ │ │ │ ├── reproj_coreg_REF.tif │ │ │ │ └── reproj_coreg_SEC.tif │ │ │ │ ├── initial_dem_diff.tif │ │ │ │ ├── stats │ │ │ │ └── alti-diff │ │ │ │ │ ├── Fusion0 │ │ │ │ │ ├── ref_rectified_support_map.tif │ │ │ │ │ └── stats_results.csv │ │ │ │ │ ├── Slope0 │ │ │ │ │ ├── ref_rectified_support_map.tif │ │ │ │ │ ├── sec_rectified_support_map.tif │ │ │ │ │ ├── stats_results.csv │ │ │ │ │ └── stats_results_intersection.csv │ │ │ │ │ ├── Status │ │ │ │ │ ├── ref_rectified_support_map.tif │ │ │ │ │ └── stats_results.csv │ │ │ │ │ ├── dem_for_stats.tif │ │ │ │ │ └── global │ │ │ │ │ └── stats_results.csv │ │ │ │ └── test_config.json │ │ ├── srtm_test_data │ │ │ ├── data_description.md │ │ │ ├── input │ │ │ │ ├── srtm_blurred_and_shifted.tif │ │ │ │ ├── srtm_ref.tif │ │ │ │ └── test_config.json │ │ │ └── ref_output │ │ │ │ ├── coregistration │ │ │ │ ├── coreg_SEC.tif │ │ │ │ ├── coregistration_results.json │ │ │ │ ├── reproj_coreg_REF.tif │ │ │ │ └── reproj_coreg_SEC.tif │ │ │ │ ├── initial_dem_diff.tif │ │ │ │ ├── stats │ │ │ │ ├── alti-diff │ │ │ │ │ ├── Slope0 │ │ │ │ │ │ ├── stats_results.csv │ │ │ │ │ │ ├── stats_results_exclusion.csv │ │ │ │ │ │ └── stats_results_intersection.csv │ │ │ │ │ ├── dem_for_stats.tif │ │ │ │ │ ├── dem_for_stats_cdf.csv │ │ │ │ │ └── dem_for_stats_pdf.csv │ │ │ │ ├── dh_col_wise_wave_detection.tif │ │ │ │ ├── dh_row_wise_wave_detection.tif │ │ │ │ ├── initial_dem_diff_cdf.csv │ │ │ │ └── initial_dem_diff_pdf.csv │ │ │ │ └── test_config.json │ │ └── srtm_test_data_with_roi │ │ │ ├── data_description.md │ │ │ ├── input │ │ │ ├── srtm_blurred_and_shifted.tif │ │ │ ├── srtm_ref.tif │ │ │ └── test_config.json │ │ │ └── ref_output │ │ │ ├── coregistration │ │ │ └── coregistration_results.json │ │ │ ├── initial_dem_diff.tif │ │ │ ├── stats │ │ │ ├── alti-diff │ │ │ │ ├── Slope0 │ │ │ │ │ ├── stats_results.csv │ │ │ │ │ └── stats_results_intersection.csv │ │ │ │ ├── dem_for_stats.tif │ │ │ │ ├── dem_for_stats_cdf.csv │ │ │ │ └── dem_for_stats_pdf.csv │ │ │ ├── initial_dem_diff_cdf.csv │ │ │ └── initial_dem_diff_pdf.csv │ │ │ └── test_config.json │ └── geoid │ │ └── egm96_15.gtx ├── dem_processing │ ├── __init__.py │ └── test_dem_processing_methods.py ├── dem_tools │ ├── __init__.py │ ├── test_create_dem.py │ ├── test_dataset_tools.py │ ├── test_dem_tools.py │ ├── test_load_dem_function.py │ ├── test_reproject_dem.py │ └── test_translate_dem.py ├── helpers.py ├── metric │ ├── __init__.py │ ├── test_matrix_2d_metric.py │ ├── test_scalar_metric.py │ └── test_vector_metric.py ├── stats_processing │ ├── __init__.py │ ├── test_stats_processing.py │ ├── test_stats_processing_global.py │ ├── test_stats_processing_segmentaion.py │ └── test_stats_processing_slope.py ├── test_demcompare_gironde_data.py ├── test_demcompare_gironde_test_data.py ├── test_demcompare_srtm_data.py ├── test_demcompare_steps.py ├── test_img_tools.py ├── test_notebooks.py ├── test_stats_dataset.py ├── test_tiling.py └── test_transformation.py └── tox.ini /.coveragerc: -------------------------------------------------------------------------------- 1 | [run] 2 | source = demcompare 3 | omit = 4 | # Omit tests 5 | /tests/* -------------------------------------------------------------------------------- /.github/workflows/demcompare_ci.yml: -------------------------------------------------------------------------------- 1 | name: Demcompare CI 2 | 3 | on: 4 | push: 5 | schedule: 6 | - cron: 0 2 * * * 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - uses: actions/checkout@v2 14 | 15 | - name: Set up Python 3.x 16 | uses: actions/setup-python@v2 17 | with: 18 | python-version: "3.10" 19 | 20 | - name: Install pypa/build 21 | run: | 22 | python3 -m pip install --upgrade pip 23 | python3 -m pip install build 24 | 25 | - name: Upload coverage to Codecov 26 | uses: codecov/codecov-action@v1 27 | 28 | - name: Create source distribution 29 | if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') 30 | run: | 31 | python3 -m build 32 | 33 | - name: Publish package on pypi 34 | if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') 35 | uses: pypa/gh-action-pypi-publish@release/v1 36 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | env/ 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | .pytest_cache/ 49 | pytest-report.xml 50 | 51 | # Code quality 52 | pylint-report.xml 53 | pylint-report.txt 54 | 55 | # Translations 56 | *.mo 57 | *.pot 58 | 59 | # Django stuff: 60 | *.log 61 | local_settings.py 62 | 63 | # Flask stuff: 64 | instance/ 65 | .webassets-cache 66 | 67 | # Scrapy stuff: 68 | .scrapy 69 | 70 | # Sphinx documentation 71 | docs/_build/ 72 | docs/build/ 73 | docs/source/api_reference/ 74 | 75 | # PyBuilder 76 | target/ 77 | 78 | # Jupyter Notebook 79 | .ipynb_checkpoints 80 | 81 | # pyenv 82 | .python-version 83 | 84 | # celery beat schedule file 85 | celerybeat-schedule 86 | 87 | # SageMath parsed files 88 | *.sage.py 89 | 90 | # dotenv 91 | .env 92 | 93 | # virtualenv 94 | .venv 95 | venv/ 96 | ENV/ 97 | 98 | # Spyder project settings 99 | .spyderproject 100 | .spyproject 101 | 102 | # Rope project settings 103 | .ropeproject 104 | 105 | # mkdocs documentation 106 | /site 107 | 108 | # mypy 109 | .mypy_cache/ 110 | 111 | # IDE settings 112 | .vscode/ 113 | .idea/ 114 | 115 | # Swap file 116 | *.swp 117 | 118 | -------------------------------------------------------------------------------- /.gitlab/issue_templates/Bug.md: -------------------------------------------------------------------------------- 1 | Préconisations générales: 2 | 1. Pensez à bien mettre un **titre** d'issue explicite par rapport au bug 3 | 2. Pensez à essayer au maximum d'aider le support (best effort) avec des informations les plus claires et précises 4 | 3. Mettre le bon label 5 | 4. Indiquer la criticité du bug : Urgent, Important, Moyen, Peu, Pas du tout. 6 | 7 | /label ~"Kind - Bug" 8 | 9 | ### Constat 10 | (ce qui permet de dire qu'il y a un bug) 11 | 12 | ### Contexte 13 | (ce qui permet de rejouer le bug) 14 | 15 | - Version utilisée (demcompare --version): 16 | 17 | - Contexte d'utilisation : 18 | 19 | - Commande utilisée 20 | 21 | #### Configuration et données utilisées 22 | 23 | *Copier le input.json(prepare) ou le content.json (compute_dsm) (si applicable)* 24 | 25 | *Pensez à vérifier l'accès par les autres à la donnée en entrée ou copiez dans* 26 | 27 | #### Environnement 28 | *Copier l'environnement python* 29 | 30 | ``` 31 | pip freeze 32 | ``` 33 | *Lister l'environnement modules* 34 | ``` 35 | module list 36 | ``` 37 | 38 | 39 | ### Pistes potentielles pouvant expliquer l'origine du bug 40 | 41 | 42 | ### Pistes potentielles pouvant corriger le bug 43 | -------------------------------------------------------------------------------- /.gitlab/issue_templates/Proposal.md: -------------------------------------------------------------------------------- 1 | 1. Pensez à bien mettre un titre d'issue explicite par rapport au bug 2 | 2. Pensez à essayer au maximum d'aider le support (non garanti) avec des informations les plus claires et précises 3 | 3. Pensez à mettre le label 4 | 5 | /label ~"Kind - Proposal" 6 | 7 | ### Constat 8 | (ce qui motive cette proposition) 9 | 10 | ### Proposition 11 | 12 | **Résumé** 13 | 14 | *Pensez à ajouter les labels associés à la proposition* 15 | 16 | 17 | **Détails techniques de la proposition si applicable** 18 | 19 | 20 | -------------------------------------------------------------------------------- /.gitlab/issue_templates/Refacto.md: -------------------------------------------------------------------------------- 1 | Préconisations générales: 2 | 1. Pensez à bien mettre un **titre** d'issue explicite par rapport au domaine de refactoring/reconception. 3 | 2. Pensez à essayer au maximum d'aider un développeur qui devra reprendre ce travail ou relire avec des informations synthétiques les plus claires et précises 4 | 5 | Il est important d'essayer de se mettre à la place de quelqu'un d'autre qui relira, ou dans la perspective d'une présentation à quelqu'un d'autre pour transférer le travail. 6 | 7 | /label ~"Kind - Refacto" 8 | 9 | ### Contexte 10 | Cette section donne le contexte général du refactoring prévu. 11 | 12 | ### Documentation API et fonctionnel 13 | 14 | Cette partie décrit le fonctionnement du module/domaine visé par l'issue. 15 | 16 | 1. décrire bien ce que fait le bloc logiciel à haut niveau avec API utilisateurs et internes (nom fonctions, paramètres, noms de structures de données (classe ou autre) explicites ) 17 | 2. décrire fonctionnellement les blocs avec le principe de base à haut niveau. 18 | 19 | Des schémas UML sont toujours bien pour des classes. 20 | 21 | Les objectifs: 22 | - qu'un utilisateur sache exactement ce que fait le module par l'API 23 | - qu'un autre développeur puisse comprendre/relire/reprendre le travail rapidement 24 | 25 | ### Plan de validation / tests 26 | 27 | Cette section décrit la manière de tester le domaine fonctionnel du refactoring prévu. 28 | 29 | En cohérence avec la documentation fonctionnel, cette section doit décrire **précisément** la façon de tester le module logiciel visé. 30 | 31 | Il est important de considérer: 32 | - les tests unitaires pour les fonctions de base 33 | - les tests fonctionnels du module : que doit on voir fonctionner pour que le module soit valide ? 34 | - considérer le temps de calcul et séparer si des tests sont trop lourds 35 | 36 | Utiliser les @pytest.mark pour organiser les tests suivant la découpe d'organisations des tests choisie. 37 | -------------------------------------------------------------------------------- /.gitlab/issue_templates/Release.md: -------------------------------------------------------------------------------- 1 | Release 2 | 3 | /label ~"Kind - Release" 4 | 5 | Liste de points à vérifier/faire pour la release en cours: 6 | 7 | - [ ] Vérifier issues milestone (mettre lien milestone) exemple %"Version 0.3.0 : Clean bugs and documentation" 8 | - [ ] Finaliser Changelog de la version en cours: Vérifier comparant avec les issues/MR du milestone de la version. 9 | - [ ] Mise du tag sur la version finale après dernieres MR. 10 | - [ ] Vérification Publication code sur github, read the docs, pypi 11 | - [ ] Vérification si installation (relance CI ou manuellement si pas automatique dans CI) 12 | - [ ] Ajout dans module load si necessaire suivant projet 13 | - [ ] Communication sur la release (si nécessaire) 14 | -------------------------------------------------------------------------------- /.gitlab/merge_request_templates/MR.md: -------------------------------------------------------------------------------- 1 | #### Résumé de la proposition 2 | 3 | 1. Que fait la MR ? (bien etre explicite sur le titre) 4 | 2. Lien vers l'issue source (Closes si la MR ferme l'issue, Relates si en fait une partie) 5 | 3. Liste des taches de la MR qui répondent à l'issue (partiellement ou globalement suivant si Closes ou Relates) 6 | 4. Etat du Reste à faire à reprendre pour finir l'issue 7 | 8 | #### Détails techniques de l'implémentation 9 | 10 | Cette section décrit les solutions techniques que la MR met en oeuvre et qui répondent à la description fonctionnelle de l'issue associée. 11 | 12 | #### Stratégie de validation 13 | En lien avec le plan de validation de l'issue, il faut décrire la stratégie de validation dont s'occupe la MR. 14 | Au moins : 15 | - [ ] Tests Unitaires (obligatoire) 16 | - [ ] Tests Fonctionnels (intégration / interfaces avec d'autres outils) 17 | - [ ] Tests Performances 18 | 19 | Si besoin suivant l'issue/MR: 20 | - [ ] Tests Visuels ? (doc) 21 | - [ ] Tests Comparatifs ? (`feat` métier avec outil de référence) 22 | - dans ce cas citer les outils et leur paramétrage 23 | 24 | #### MR non prête à merger 25 | 26 | Si la Merge Request est en cours de développement, merci d'ajouter le mot clé `WIP` afin d'éviter la fusion de cette dernière. 27 | 28 | #### MR prête à merger 29 | 30 | Si la Merge Request est prête, merci de valider les étapes suivantes: 31 | - [ ] mise à jour de la documentation Sphinx et vérification du résultat. 32 | - [ ] mise à jour du changelog Changelog.md 33 | - uniquement si la MR rempli l'un des objectifs suivants: 34 | - correction d'un bug 35 | - ajout d'une fonctionnalité métier 36 | - ajout d'une fonctionnalité à destination du grand public (communication) 37 | - suivre les recommandations de https://github.com/olivierlacan/keep-a-changelog/blob/master/CHANGELOG.md 38 | - inscrire la modification sous le titre `Unreleased` 39 | - [ ] S'assurer qu'il y a toutes les infos dans la MR pour qu'un autre développeur puisse relire facilement, ce qu'on s'attendrait à avoir soi même pour relire la MR (cf résumé ci dessus) 40 | 41 | #### Integration Continue 42 | 43 | Pour relancer l'intégration continue merci de laisser le commentaire suivant : 44 | `Jenkins! Faster!! And you'd better make it work !` 45 | 46 | 47 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | repos: 2 | - repo: local 3 | hooks: 4 | - id: isort 5 | name: Isort 6 | stages: [pre-commit] 7 | language: system 8 | entry: isort 9 | types: [python] 10 | 11 | - id: black 12 | name: Black 13 | stages: [pre-commit] 14 | language: system 15 | entry: black 16 | types: [python] 17 | 18 | - id: flake8 19 | name: Flake8 20 | stages: [pre-commit] 21 | language: system 22 | entry: flake8 23 | types: [python] 24 | 25 | - id: pylint 26 | name: PyLint 27 | stages: [pre-commit] 28 | language: system 29 | entry: pylint --rcfile=.pylintrc 30 | files: \.py$ 31 | 32 | - id: mypy 33 | name: mypy 34 | stages: [ pre-commit ] 35 | language: system 36 | entry: mypy 37 | files: \.py$ 38 | 39 | - id: jupyter-nb-clear-output 40 | name: jupyter-nb-clear-output 41 | files: \.ipynb$ 42 | stages: [pre-commit] 43 | language: system 44 | entry: jupyter nbconvert --ClearOutputPreprocessor.enabled=True --inplace 45 | 46 | - id: sphinx-checking 47 | name: Checking Sphinx building 48 | entry: sphinx-build -M html docs/source/ docs/build -W --keep-going 49 | language: system 50 | files: ^(docs/.*|demcompare/.*)$ 51 | pass_filenames: False 52 | stages: [pre-push] 53 | -------------------------------------------------------------------------------- /.readthedocs.yml: -------------------------------------------------------------------------------- 1 | # Read the Docs configuration file 2 | # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details 3 | 4 | version: 2 5 | 6 | # Set os required and python version (required) 7 | build: 8 | os: "ubuntu-22.04" 9 | tools: 10 | python: "3.10" 11 | 12 | # add projet [docs] extra url dependencies in sphinx RTD virtualenv 13 | python: 14 | install: 15 | - method: pip 16 | path: . 17 | extra_requirements: 18 | - docs 19 | 20 | # Build documentation in the docs/ directory with Sphinx 21 | sphinx: 22 | configuration: docs/source/conf.py 23 | 24 | -------------------------------------------------------------------------------- /AUTHORS.md: -------------------------------------------------------------------------------- 1 | # Credits 2 | 3 | Copyright (c) 2022 Centre National d'Etudes Spatiales (CNES). 4 | 5 | Demcompare is licensed under permissive Apache 2 license (See LICENSE file). 6 | The copyright is kept CNES only for long term maintenance ease. 7 | 8 | See the [developer guide](https://demcompare.readthedocs.io/en/stable/developer_guide.html) for more details on Contributor License Agreement. 9 | 10 | This file keeps track of authors contributions. 11 | 12 | ## Development Lead 13 | 14 | * Emmanuel Dubois 15 | * Emmanuelle Sarrazin 16 | * Natalia Jimenez 17 | * Alice de Bardonnèche-Richard 18 | 19 | ## Contributors 20 | 21 | * Loïc Dumas 22 | * Julien Michel 23 | * David Youssefi 24 | * Yoann Steux 25 | * Marina Bertolino 26 | * Fabrice Buffe 27 | * Florie Languille 28 | 29 | Update here with new contributors. 30 | 31 | ## Original Developers/Designers/Supporters 32 | 33 | * Julien Michel 34 | * Loïc Dumas 35 | * Myriam Cournet 36 | * Jean Marc Delvit 37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 | Demcompare 3 | 4 |

Demcompare, a DEM comparison tool

5 | 6 | [![Python](https://img.shields.io/badge/python-v3.8+-blue.svg)](https://www.python.org/downloads/release/python-380/) 7 | [![Contributions welcome](https://img.shields.io/badge/contributions-welcome-orange.svg)](https://demcompare.readthedocs.io/en/latest/developer_guide/contributing.html) 8 | [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0/) 9 | [![Docs](https://readthedocs.org/projects/demcompare/badge/?version=latest)](https://demcompare.readthedocs.io/) 10 | 11 |

12 | Overview • 13 | Install • 14 | Usage • 15 | Documentation • 16 |

17 |
18 | 19 | ## Caution 20 | 21 | DemCompare is not maintained anymore. You can use xDEM instead: https://github.com/GlacioHack/xdem. 22 | 23 | ## Overview 24 | 25 | Demcompare is a python software that aims at **comparing two DEMs** together. 26 | 27 | A DEM is a 3D computer graphics representation of elevation data to represent terrain. 28 | 29 | **Demcompare** has several characteristics: 30 | 31 | * Works whether or not the two DEMs share common format projection system, planimetric resolution, and altimetric unit. 32 | * Performs the coregistration based on the Nuth & Kääb universal coregistration method. 33 | * Offers two coregistration modes to choose which of both DEMs is to be adapted during coregistration. 34 | * Provides a wide variety of standard metrics which can be classified. 35 | * Classifies the stats by slope ranges by default, but one can provide any other data to classify the stats. 36 | 37 | ## Install 38 | 39 | Only **Linux Plaforms** are supported (virtualenv or bare machine) with **Python >= 3.8** installed. 40 | 41 | Demcompare is available on Pypi and can be typically installed through a [virtualenv](https://docs.python.org/3/library/venv): 42 | 43 | ``` 44 | python3 -m venv venv 45 | source venv/bin/activate 46 | pip install --upgrade pip 47 | pip install demcompare 48 | ``` 49 | 50 | ## Usage 51 | 52 | Download the data samples and run the python script **demcompare** with sample configuration: 53 | 54 | ```bash 55 | # download data samples 56 | wget https://raw.githubusercontent.com/CNES/demcompare/master/data_samples/srtm_blurred_and_shifted.tif 57 | wget https://raw.githubusercontent.com/CNES/demcompare/master/data_samples/srtm_ref.tif 58 | 59 | # download demcompare predefined configuration 60 | wget https://raw.githubusercontent.com/CNES/demcompare/master/data_samples/sample_config.json 61 | 62 | # run demcompare 63 | demcompare sample_config.json 64 | ``` 65 | 66 | A report can be observed with: 67 | 68 | ``` 69 | firefox test_output/report/published_report/html/index.html 70 | ``` 71 | 72 | ## Documentation 73 | 74 | Please consult [our online documentation](https://demcompare.readthedocs.io). 75 | 76 | ## Licensing 77 | 78 | Demcompare software is distributed under the Apache Software License (ASL) v2.0. 79 | 80 | See [LICENSE](./LICENSE) file or for details. 81 | 82 | Copyrights and authoring can be found in [NOTICE](./NOTICE) file. 83 | 84 | ## Related tools 85 | 86 | [CARS](https://github.com/CNES/CARS) - CNES 3D reconstruction software 87 | 88 | [Pandora](https://github.com/CNES/pandora) - CNES Stereo Matching framework 89 | -------------------------------------------------------------------------------- /data_samples/sample_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "output_dir": "./test_output/", 3 | "input_ref" : { 4 | "path" : "./srtm_ref.tif", 5 | "zunit" : "m" 6 | }, 7 | "input_sec" : { 8 | "path" : "./srtm_blurred_and_shifted.tif", 9 | "zunit" : "m", 10 | "nodata" : -32768 11 | }, 12 | "coregistration": { 13 | "method_name": "nuth_kaab_internal", 14 | "number_of_iterations": 6, 15 | "estimated_initial_shift_x": 0, 16 | "estimated_initial_shift_y": 0 17 | }, 18 | "statistics": { 19 | "alti-diff": { 20 | "classification_layers": { 21 | "Slope0": { 22 | "type": "slope", 23 | "ranges": [ 24 | 0, 25 | 5, 26 | 10, 27 | 25, 28 | 45 29 | ] 30 | } 31 | }, 32 | "remove_outliers": true 33 | } 34 | }, 35 | "report": "default" 36 | } 37 | -------------------------------------------------------------------------------- /data_samples/sample_config_full.json: -------------------------------------------------------------------------------- 1 | { 2 | "output_dir": "./test_output_full/", 3 | "input_ref": { 4 | "path": "./srtm_ref.tif", 5 | "zunit": "m" 6 | }, 7 | "input_sec": { 8 | "path": "./srtm_blurred_and_shifted.tif", 9 | "zunit": "m", 10 | "nodata": -32768 11 | }, 12 | "coregistration": { 13 | "method_name": "nuth_kaab_internal", 14 | "number_of_iterations": 6, 15 | "estimated_initial_shift_x": 0, 16 | "estimated_initial_shift_y": 0 17 | }, 18 | "statistics": { 19 | "alti-diff": { 20 | "classification_layers": { 21 | "Slope0": { 22 | "type": "slope", 23 | "ranges": [ 24 | 0, 25 | 5, 26 | 10, 27 | 25, 28 | 45 29 | ] 30 | } 31 | }, 32 | "remove_outliers": true 33 | }, 34 | "alti-diff-slope-norm": { 35 | "classification_layers": { 36 | "Slope0": { 37 | "type": "slope", 38 | "ranges": [ 39 | 0, 40 | 5, 41 | 10, 42 | 25, 43 | 45 44 | ] 45 | } 46 | }, 47 | "remove_outliers": true 48 | }, 49 | "angular-diff": { 50 | "classification_layers": { 51 | "Slope0": { 52 | "type": "slope", 53 | "ranges": [ 54 | 0, 55 | 5, 56 | 10, 57 | 25, 58 | 45 59 | ] 60 | } 61 | }, 62 | "remove_outliers": true 63 | }, 64 | "sec-curvature": {}, 65 | "ref-curvature": {}, 66 | "sec": { 67 | "metrics": [ 68 | { 69 | "slope-orientation-histogram": { 70 | "output_plot_path": "./test_output_full/sec-slope-orientation-histogram" 71 | } 72 | } 73 | ] 74 | }, 75 | "ref": { 76 | "metrics": [ 77 | { 78 | "slope-orientation-histogram": { 79 | "output_plot_path": "./test_output_full/ref-slope-orientation-histogram" 80 | } 81 | } 82 | ] 83 | } 84 | }, 85 | "report": "default" 86 | } -------------------------------------------------------------------------------- /data_samples/sample_config_tiles.json: -------------------------------------------------------------------------------- 1 | {"output_dir": "out_tiles_srtm", 2 | "input_ref" : { 3 | "path" : "./srtm_ref.tif", 4 | "zunit" : "m" 5 | }, 6 | "input_sec" : { 7 | "path" : "./srtm_blurred_and_shifted.tif", 8 | "zunit" : "m" 9 | }, 10 | "tiling" : { 11 | "width": 500, 12 | "height": 500, 13 | "overlap": 20 14 | }, 15 | "coregistration": { 16 | "method_name": "nuth_kaab_internal", 17 | "number_of_iterations": 6, 18 | "estimated_initial_shift_x": 0, 19 | "estimated_initial_shift_y": 0 20 | }, 21 | "statistics": { 22 | "alti-diff": { 23 | "classification_layers": { 24 | "Slope0": { 25 | "type": "slope", 26 | "ranges": [ 27 | 0, 28 | 5, 29 | 10, 30 | 25, 31 | 45 32 | ] 33 | } 34 | }, 35 | "remove_outliers": true 36 | } 37 | }, 38 | "report": "default" 39 | } 40 | -------------------------------------------------------------------------------- /data_samples/srtm_blurred_and_shifted.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/data_samples/srtm_blurred_and_shifted.tif -------------------------------------------------------------------------------- /data_samples/srtm_ref.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/data_samples/srtm_ref.tif -------------------------------------------------------------------------------- /demcompare/classification_layer/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf8 3 | # 4 | # Copyright (c) 2022 Centre National d'Etudes Spatiales (CNES). 5 | # 6 | # This file is part of demcompare 7 | # (see https://github.com/CNES/demcompare). 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | """ 22 | Init file for classification_layer module. 23 | Imports are used to simplify calls to module API ClassificationLayer. 24 | """ 25 | # Demcompare imports 26 | from . import segmentation_classification, slope_classification 27 | from .classification_layer import ClassificationLayer 28 | from .fusion_classification import FusionClassificationLayer 29 | from .global_classification import GlobalClassificationLayer 30 | 31 | __all__ = [ 32 | "segmentation_classification", 33 | "slope_classification", 34 | "ClassificationLayer", 35 | "FusionClassificationLayer", 36 | "GlobalClassificationLayer", 37 | ] 38 | # To avoid flake8 F401 39 | -------------------------------------------------------------------------------- /demcompare/coregistration/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf8 3 | # 4 | # Copyright (c) 2022 Centre National d'Etudes Spatiales (CNES). 5 | # 6 | # This file is part of demcompare 7 | # (see https://github.com/CNES/demcompare). 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | """ 22 | Init file for coregistration module. 23 | Imports are used to simplify calls to module API Coregistration. 24 | """ 25 | # Demcompare imports 26 | from . import nuth_kaab_internal 27 | from .coregistration import Coregistration 28 | 29 | __all__ = ["nuth_kaab_internal", "Coregistration"] # To avoid flake8 F401 30 | -------------------------------------------------------------------------------- /demcompare/coregistration/coregistration.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf8 3 | # 4 | # Copyright (c) 2022 Centre National d'Etudes Spatiales (CNES). 5 | # 6 | # This file is part of demcompare 7 | # (see https://github.com/CNES/demcompare). 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | """ 22 | This module contains the Coregistration class factory. 23 | This main API Coregistration class generates an object linked 24 | with coregistration configuration "method_name" 25 | (from registered CoregistrationTemplate class) 26 | """ 27 | 28 | # Standard imports 29 | import logging 30 | from typing import Any, Dict 31 | 32 | from ..internal_typing import ConfigType 33 | 34 | 35 | class Coregistration: 36 | """ 37 | Coregistration factory: 38 | A class designed for registered all available coregistration methods 39 | and instantiate them when needed. 40 | """ 41 | 42 | # Dict (method_name: str, class: object) containing registered 43 | # available coregistration methods 44 | available_coregistrations: Dict[str, Any] = {} 45 | default_application = "nuth_kaab_internal" 46 | 47 | def __new__(cls, cfg: ConfigType = None): 48 | """ 49 | Return a CoregistrationTemplate child instance 50 | associated with the "method_name" given in the configuration 51 | through create_coreg local method for clarity. 52 | 53 | :param cfg: JSON configuration {'method_name': value} 54 | :type cfg: ConfigType 55 | """ 56 | return cls.create_coreg(cfg) 57 | 58 | @classmethod 59 | def create_coreg(cls, cfg: ConfigType = None): 60 | """ 61 | Factory command to create the coregistration from method_name 62 | Return a CoregistrationTemplate child instance 63 | associated with the "method_name" given in the configuration 64 | 65 | :param cfg: configuration {'method_name': value} 66 | :type cfg: ConfigType 67 | """ 68 | 69 | # If no cfg is given, use default_application 70 | coreg_method = cls.default_application 71 | if bool(cfg): 72 | coreg_method = cfg["method_name"] 73 | 74 | try: 75 | coreg_class = cls.available_coregistrations[coreg_method] 76 | coreg = coreg_class(cfg) 77 | logging.info("Coregistration method name: %s", coreg_method) 78 | 79 | except KeyError: 80 | logging.error( 81 | "No coregistration method named %s supported", coreg_method 82 | ) 83 | raise 84 | 85 | return coreg 86 | 87 | @classmethod 88 | def print_coregistration_methods(cls): 89 | """ 90 | Print all registered applications 91 | """ 92 | for coreg_method_name in cls.available_coregistrations: 93 | print(coreg_method_name) 94 | 95 | @classmethod 96 | def register(cls, coreg_method_name: str): 97 | """ 98 | Allows to register the CoregistrationTemplate subclass in the factory 99 | with its coregistration method_name through decorator 100 | 101 | :param coreg_method_name: the subclass name to be registered 102 | :type coreg_method_name: string 103 | """ 104 | 105 | def decorator(coreg_subclass): 106 | """ 107 | Register the coregistration subclass in the available methods 108 | 109 | :param coreg_subclass: the subclass to be registered 110 | :type coreg_subclass: object 111 | """ 112 | cls.available_coregistrations[coreg_method_name] = coreg_subclass 113 | return coreg_subclass 114 | 115 | return decorator 116 | -------------------------------------------------------------------------------- /demcompare/dem_processing/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf8 3 | # 4 | # Copyright (c) 2022 Centre National d'Etudes Spatiales (CNES). 5 | # 6 | # This file is part of demcompare 7 | # (see https://github.com/CNES/demcompare). 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | """ 22 | Init file for DEM processing module. 23 | Imports are used to simplify calls to module API DEM processing methods. 24 | """ 25 | 26 | # Demcompare imports 27 | from . import dem_processing_methods 28 | from .dem_processing import DemProcessing 29 | 30 | __all__ = ["dem_processing_methods", "DemProcessing"] # To avoid flake8 F401 31 | -------------------------------------------------------------------------------- /demcompare/dem_processing/dem_processing.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf8 3 | # 4 | # Copyright (c) 2022 Centre National d'Etudes Spatiales (CNES). 5 | # 6 | # This file is part of demcompare 7 | # (see https://github.com/CNES/demcompare). 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | """ 22 | Mainly contains the DEM processing class. 23 | """ 24 | 25 | import logging 26 | from typing import Any, Dict, Union 27 | 28 | 29 | class DemProcessing: 30 | """ 31 | DEM processing method factory: 32 | A class designed for registered all available DEM processing methods 33 | and instantiate them when needed. 34 | """ 35 | 36 | available_dem_processing_methods: Dict[str, Any] = {} 37 | 38 | def __new__( 39 | cls, dem_processing_method: str, params: Union[Dict, None] = None 40 | ): 41 | """ 42 | Return a DemProcessingTemplate child instance 43 | associated with the "dem_processing_method" given in the configuration 44 | through dem_processing_method local method for clarity. 45 | 46 | :param dem_processing_method: DEM processing method 47 | :type dem_processing_method: str 48 | """ 49 | return cls.create_dem_processing_method(dem_processing_method, params) 50 | 51 | @classmethod 52 | def create_dem_processing_method( 53 | cls, dem_processing_method: str, parameters: Dict = None 54 | ): 55 | """ 56 | Factory command to create the DEM processing method from method_name 57 | Return a DemProcessingTemplate child instance 58 | associated with the name given in the configuration 59 | 60 | :param dem_processing_method: DEM processing method 61 | :type dem_processing_method: str 62 | :param parameters: optional input parameters 63 | :type parameters: Dict 64 | """ 65 | try: 66 | dem_processing_class = cls.available_dem_processing_methods[ 67 | dem_processing_method 68 | ] 69 | dem_processing = dem_processing_class(parameters=parameters) 70 | except KeyError: 71 | logging.error( 72 | "No DEM processing type %s supported", dem_processing_method 73 | ) 74 | raise 75 | return dem_processing 76 | 77 | @classmethod 78 | def print_dem_processing_methods(cls): 79 | """ 80 | Print all registered DEM processing methods 81 | """ 82 | for dem_processing_method in cls.available_dem_processing_methods: 83 | print(dem_processing_method) 84 | 85 | @classmethod 86 | def register(cls, dem_processing_method: str): 87 | """ 88 | Allows to register the DemProcessingTemplate 89 | subclass in the factory 90 | with its DEM processing type through decorator 91 | 92 | :param dem_processing_method: the subclass type to be registered 93 | :type dem_processing_method: string 94 | """ 95 | 96 | def decorator(dem_processing_subclass): 97 | """ 98 | Register the DEM processing subclass in the available methods 99 | 100 | :param dem_processing_subclass: the subclass to be registered 101 | :type dem_processing_subclass: object 102 | """ 103 | cls.available_dem_processing_methods[dem_processing_method] = ( 104 | dem_processing_subclass 105 | ) 106 | return dem_processing_subclass 107 | 108 | return decorator 109 | -------------------------------------------------------------------------------- /demcompare/dem_processing/dem_processing_template.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf8 3 | # 4 | # Copyright (c) 2022 Centre National d'Etudes Spatiales (CNES). 5 | # 6 | # This file is part of demcompare 7 | # (see https://github.com/CNES/demcompare). 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | """ 22 | Mainly contains the DemProcessingTemplate class. 23 | """ 24 | # Standard imports 25 | from abc import ABCMeta, abstractmethod 26 | from typing import Dict 27 | 28 | # Third party imports 29 | import xarray as xr 30 | 31 | 32 | class DemProcessingTemplate( 33 | metaclass=ABCMeta 34 | ): # pylint:disable=too-few-public-methods 35 | """ 36 | DEM processing class 37 | """ 38 | 39 | def __init__( 40 | self, parameters: Dict = None 41 | ): # pylint:disable = unused-argument 42 | """ 43 | Initialization of a DEM processing object 44 | 45 | :param parameters: optional input parameters 46 | :type parameters: str 47 | :return: None 48 | """ 49 | 50 | # DEM processing type (set to dataset) 51 | self.type: str = None 52 | # Dem processing information for report (set to dataset) 53 | self.fig_title: str = None 54 | self.colorbar_title: str = None 55 | self.cmap: str = None 56 | 57 | @abstractmethod 58 | def process_dem( 59 | self, 60 | dem_1: xr.Dataset, 61 | dem_2: xr.Dataset, 62 | ) -> xr.Dataset: 63 | """ 64 | DEM processing method 65 | 66 | :param dem_1: dem_1 xr.DataSet containing : 67 | 68 | - image : 2D (row, col) xr.DataArray float32 69 | - georef_transform: 1D (trans_len) xr.DataArray 70 | - classification_layer_masks : 3D (row, col, indicator) 71 | xr.DataArray 72 | :type dem_1: xr.Dataset 73 | :param dem_2: optional argument. 74 | should not be given as input, 75 | when the DEM processing method takes only 1 DEM as input. 76 | xr.DataSet containing: 77 | 78 | - image : 2D (row, col) xr.DataArray float32 79 | - georef_transform: 1D (trans_len) xr.DataArray 80 | - classification_layer_masks : 3D (row, col, indicator) 81 | xr.DataArray 82 | :type dem_2: xr.Dataset 83 | :return: xr.DataSet containing : 84 | 85 | - image : 2D (row, col) xr.DataArray float32 86 | - georef_transform: 1D (trans_len) xr.DataArray 87 | - classification_layer_masks : 3D (row, col, indicator) 88 | xr.DataArray 89 | :rtype: xr.Dataset 90 | """ 91 | -------------------------------------------------------------------------------- /demcompare/demcompare.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf8 3 | # 4 | # Copyright (c) 2022 Centre National d'Etudes Spatiales (CNES). 5 | # 6 | # This file is part of demcompare 7 | # (see https://github.com/CNES/demcompare). 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | # PYTHON_ARGCOMPLETE_OK 22 | """ 23 | demcompare aims at coregistering and comparing two dsms 24 | """ 25 | 26 | # Standard imports 27 | import argparse 28 | import logging 29 | import traceback 30 | 31 | # Third party imports 32 | import argcomplete 33 | 34 | # DEMcompare import 35 | import demcompare 36 | 37 | 38 | def get_parser(): 39 | """ 40 | ArgumentParser for demcompare 41 | 42 | :return: parser 43 | """ 44 | parser = argparse.ArgumentParser( 45 | description=("Compare Digital Elevation Models"), 46 | fromfile_prefix_chars="@", 47 | ) 48 | 49 | parser.add_argument( 50 | "config", 51 | metavar="config.json", 52 | help=( 53 | "path to a json file containing the paths to " 54 | "input and output files and the algorithm " 55 | "parameters" 56 | ), 57 | ) 58 | 59 | parser.add_argument( 60 | "--loglevel", 61 | default="INFO", 62 | choices=("DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"), 63 | help="Logger level (default: INFO. Should be one of " 64 | "(DEBUG, INFO, WARNING, ERROR, CRITICAL)", 65 | ) 66 | 67 | parser.add_argument( 68 | "--version", 69 | "-v", 70 | action="version", 71 | version=f"%(prog)s {demcompare.__version__}", 72 | ) 73 | return parser 74 | 75 | 76 | def main(): 77 | """ 78 | Call demcompare's main 79 | """ 80 | parser = get_parser() 81 | argcomplete.autocomplete(parser) 82 | args = parser.parse_args() 83 | try: 84 | # use a global try/except to cath 85 | demcompare.run(args.config, loglevel=args.loglevel) 86 | 87 | except Exception: # pylint: disable=broad-except 88 | logging.error(" Demcompare %s", traceback.format_exc()) 89 | 90 | 91 | if __name__ == "__main__": 92 | main() 93 | -------------------------------------------------------------------------------- /demcompare/geoid/egm96_15.gtx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/demcompare/geoid/egm96_15.gtx -------------------------------------------------------------------------------- /demcompare/internal_typing.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf8 3 | # 4 | # Copyright (c) 2023 Centre National d'Etudes Spatiales (CNES). 5 | # 6 | # This file is part of demcompare 7 | # (see https://github.com/CNES/demcompare). 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | """ 22 | This module regroup demcompare internal typing for type hinting 23 | """ 24 | 25 | from typing import Any, Dict 26 | 27 | # Type for input configuration json 28 | ConfigType = Dict[str, Any] 29 | -------------------------------------------------------------------------------- /demcompare/log_conf.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf8 3 | # 4 | # Copyright (c) 2022 Centre National d'Etudes Spatiales (CNES). 5 | # 6 | # This file is part of demcompare 7 | # (see https://github.com/CNES/demcompare). 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | """ 22 | Logconf demcompare: 23 | contains logging configuration 24 | """ 25 | 26 | import json 27 | 28 | # Standard imports 29 | import logging 30 | import os 31 | from datetime import datetime 32 | 33 | 34 | def setup_logging( 35 | logconf_path="logging.json", 36 | default_level=logging.INFO, 37 | ): 38 | """ 39 | Setup the logging configuration 40 | If logconf_path is found, set the json logging configuration 41 | Else put default_level 42 | 43 | :param logconf_path: path to the configuration file 44 | :type logconf_path: string 45 | :param default_level: default level 46 | :type default_level: logging level 47 | :param cfg: input cfg 48 | :type cfg: Dict 49 | """ 50 | logconf_path = os.path.abspath( 51 | os.path.join(os.path.dirname(__file__), logconf_path) 52 | ) 53 | if os.path.exists(logconf_path): 54 | with open(logconf_path, "rt", encoding="utf8") as logconf_file: 55 | config = json.load(logconf_file) 56 | # Set config and force default_level from command_line 57 | logging.config.dictConfig(config) 58 | logging.getLogger().setLevel(default_level) 59 | else: 60 | # take default python config with default_level from command line 61 | logging.basicConfig(level=default_level) 62 | 63 | 64 | def add_log_file(out_dir: str): 65 | """ 66 | Add dated file handler to the logger. 67 | 68 | :param out_dir: output directory in which the log file will be created 69 | :type out_dir: str 70 | :return: None 71 | """ 72 | # set file log handler 73 | now = datetime.now() 74 | date = now.strftime("%y-%m-%d_%Hh%Mm") 75 | h_log_file = logging.FileHandler(os.path.join(out_dir, f"{date}_logs.log")) 76 | 77 | # add it to the logger 78 | logging.getLogger().addHandler(h_log_file) 79 | -------------------------------------------------------------------------------- /demcompare/logging.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "disable_existing_loggers": true, 4 | "formatters": { 5 | "simple": { 6 | "format": "%(asctime)s :: %(levelname)s :: %(message)s", 7 | "datefmt": "%Y-%m-%d/%H:%M:%S" 8 | } 9 | }, 10 | "handlers": { 11 | "console": { 12 | "class": "logging.StreamHandler", 13 | "level": "DEBUG", 14 | "formatter": "simple", 15 | "stream": "ext://sys.stdout" 16 | }, 17 | "file_handler": { 18 | "class": "logging.handlers.RotatingFileHandler", 19 | "level": "DEBUG", 20 | "formatter": "simple", 21 | "filename": "debug.log", 22 | "maxBytes": 10485760, 23 | "backupCount": 20, 24 | "encoding": "utf8" 25 | } 26 | }, 27 | "loggers": { 28 | "__name__": { 29 | "level": "WARNING", 30 | "handlers": [ 31 | "console", 32 | "file_handler" 33 | ], 34 | "propagate": false 35 | } 36 | }, 37 | "root": { 38 | "level": "INFO", 39 | "handlers": [ 40 | "console" 41 | ] 42 | } 43 | } -------------------------------------------------------------------------------- /demcompare/metric/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf8 3 | # 4 | # Copyright (c) 2022 Centre National d'Etudes Spatiales (CNES). 5 | # 6 | # This file is part of demcompare 7 | # (see https://github.com/CNES/demcompare). 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | """ 22 | Init file for metric module. 23 | Imports are used to simplify calls to module API Metrics. 24 | """ 25 | 26 | # Demcompare imports 27 | from . import matrix_2d_metrics, scalar_metrics, vector_metrics 28 | from .metric import Metric 29 | 30 | __all__ = [ 31 | "scalar_metrics", 32 | "vector_metrics", 33 | "matrix_2d_metrics", 34 | "Metric", 35 | ] # To avoid flake8 F401 36 | -------------------------------------------------------------------------------- /demcompare/metric/metric.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf8 3 | # 4 | # Copyright (c) 2022 Centre National d'Etudes Spatiales (CNES). 5 | # 6 | # This file is part of demcompare 7 | # (see https://github.com/CNES/demcompare). 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | """ 22 | Mainly contains the Metric class. 23 | A metric defines a way to compute a statistic on an input data 24 | such as an altitude difference map 25 | """ 26 | 27 | import logging 28 | from typing import Any, Dict, Union 29 | 30 | 31 | class Metric: 32 | """ 33 | Metric factory: 34 | A class designed for registered all available metric methods 35 | and instantiate them when needed. 36 | """ 37 | 38 | available_metrics: Dict[str, Any] = {} 39 | 40 | def __new__(cls, metric_method: str, params: Union[Dict, None] = None): 41 | """ 42 | Return a MetricTemplate child instance 43 | associated with the "metric_method" given in the configuration 44 | through metric_method local method for clarity. 45 | 46 | :param metric_method: metric method 47 | :type metric_method: str 48 | """ 49 | return cls.create_metric(metric_method, params) 50 | 51 | @classmethod 52 | def create_metric(cls, metric_method: str, parameters: Dict = None): 53 | """ 54 | Factory command to create the metric from method_name 55 | Return a MetricTemplate child instance 56 | associated with the name given in the configuration 57 | 58 | :param metric_method: metric method 59 | :type metric_method: str 60 | :param parameters: optional input parameters 61 | :type parameters: Dict 62 | """ 63 | 64 | try: 65 | metric_class = cls.available_metrics[metric_method] 66 | metric = metric_class(parameters=parameters) 67 | except KeyError: 68 | logging.error("No metric layer type %s supported", metric_method) 69 | raise 70 | return metric 71 | 72 | @classmethod 73 | def print_metric_methods(cls): 74 | """ 75 | Print all registered metric methods 76 | """ 77 | for metric_method in cls.available_metrics: 78 | print(metric_method) 79 | 80 | @classmethod 81 | def register(cls, metric_method: str): 82 | """ 83 | Allows to register the MetricTemplate 84 | subclass in the factory 85 | with its metric type through decorator 86 | 87 | :param metric_method: the subclass type to be registered 88 | :type metric_method: string 89 | """ 90 | 91 | def decorator(metric_subclass): 92 | """ 93 | Register the metric subclass in the available methods 94 | 95 | :param metric_subclass: the subclass to be registered 96 | :type metric_subclass: object 97 | """ 98 | cls.available_metrics[metric_method] = metric_subclass 99 | return metric_subclass 100 | 101 | return decorator 102 | -------------------------------------------------------------------------------- /demcompare/metric/metric_template.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf8 3 | # 4 | # Copyright (c) 2022 Centre National d'Etudes Spatiales (CNES). 5 | # 6 | # This file is part of demcompare 7 | # (see https://github.com/CNES/demcompare). 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | """ 22 | Mainly contains the MetricTemplate class. 23 | """ 24 | # Standard imports 25 | from abc import ABCMeta, abstractmethod 26 | from typing import Dict, Tuple, Union 27 | 28 | # Third party imports 29 | import numpy as np 30 | import xarray as xr 31 | 32 | 33 | class MetricTemplate( 34 | metaclass=ABCMeta 35 | ): # pylint:disable=too-few-public-methods 36 | """ 37 | Metric class 38 | """ 39 | 40 | # Default metric type 41 | DEFAULT_TYPE = "scalar" 42 | 43 | def __init__( 44 | self, parameters: Dict = None 45 | ): # pylint:disable = unused-argument 46 | """ 47 | Initialization of a metric object 48 | 49 | :param parameters: optional input parameters 50 | :type parameters: str 51 | :return: None 52 | """ 53 | 54 | # Metric type 55 | self.type = self.DEFAULT_TYPE 56 | 57 | @abstractmethod 58 | def compute_metric( 59 | self, data: np.ndarray 60 | ) -> Union[Tuple[np.ndarray, np.ndarray], np.ndarray, float, xr.Dataset]: 61 | """ 62 | Metric computation method 63 | """ 64 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2020 Centre National d'Etudes Spatiales (CNES). 3 | # 4 | # This file is part of PANDORA2D 5 | # 6 | # https://github.com/CNES/Pandora2D 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # 20 | 21 | # Minimal makefile for Sphinx documentation 22 | # 23 | 24 | # You can set these variables from the command line, and also 25 | # from the environment for the first two. 26 | SPHINXOPTS ?= 27 | SPHINXBUILD ?= sphinx-build 28 | SOURCEDIR = source 29 | BUILDDIR = build 30 | 31 | # Put it first so that "make" without argument is like "make help". 32 | help: 33 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 34 | 35 | .PHONY: help Makefile 36 | 37 | # Catch-all target: route all unknown targets to Sphinx using the new 38 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 39 | %: Makefile 40 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 41 | -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | :: 2 | :: Copyright (c) 2020 Centre National d'Etudes Spatiales (CNES). 3 | :: 4 | :: This file is part of PANDORA2D 5 | :: 6 | :: https://github.com/CNES/Pandora2D 7 | :: 8 | :: Licensed under the Apache License, Version 2.0 (the "License"); 9 | :: you may not use this file except in compliance with the License. 10 | :: You may obtain a copy of the License at 11 | :: 12 | :: http://www.apache.org/licenses/LICENSE-2.0 13 | :: 14 | :: Unless required by applicable law or agreed to in writing, software 15 | :: distributed under the License is distributed on an "AS IS" BASIS, 16 | :: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | :: See the License for the specific language governing permissions and 18 | :: limitations under the License. 19 | :: 20 | @ECHO OFF 21 | 22 | pushd %~dp0 23 | 24 | REM Command file for Sphinx documentation 25 | 26 | if "%SPHINXBUILD%" == "" ( 27 | set SPHINXBUILD=sphinx-build 28 | ) 29 | set SOURCEDIR=sources 30 | set BUILDDIR=build 31 | 32 | if "%1" == "" goto help 33 | 34 | %SPHINXBUILD% >NUL 2>NUL 35 | if errorlevel 9009 ( 36 | echo. 37 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 38 | echo.installed, then set the SPHINXBUILD environment variable to point 39 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 40 | echo.may add the Sphinx directory to PATH. 41 | echo. 42 | echo.If you don't have Sphinx installed, grab it from 43 | echo.http://sphinx-doc.org/ 44 | exit /b 1 45 | ) 46 | 47 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 48 | goto end 49 | 50 | :help 51 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 52 | 53 | :end 54 | popd 55 | -------------------------------------------------------------------------------- /docs/source/CLA/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/docs/source/CLA/.gitkeep -------------------------------------------------------------------------------- /docs/source/CLA/CCLA-DEMCOMPARE.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/docs/source/CLA/CCLA-DEMCOMPARE.doc -------------------------------------------------------------------------------- /docs/source/CLA/ICLA-DEMCOMPARE.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/docs/source/CLA/ICLA-DEMCOMPARE.doc -------------------------------------------------------------------------------- /docs/source/_static/css/my_custom.css: -------------------------------------------------------------------------------- 1 | .wy-side-nav-search, .wy-nav-top { 2 | background: #FFFFFF; 3 | } 4 | .wy-side-nav-search>div.version{ 5 | color: #123D62; 6 | } 7 | .wy-side-nav-search .wy-dropdown > a img.logo, .wy-side-nav-search > a img.logo { 8 | width: 200px; 9 | } -------------------------------------------------------------------------------- /docs/source/conf.py: -------------------------------------------------------------------------------- 1 | # pylint: skip-file 2 | # flake8: noqa 3 | # type: ignore 4 | # coding: utf8 5 | # Copyright (c) 2023 Centre National d'Etudes Spatiales (CNES). 6 | # 7 | # This file is part of demcompare 8 | # 9 | # https://github.com/CNES/demcompare 10 | # 11 | # Licensed under the Apache License, Version 2.0 (the "License"); 12 | # you may not use this file except in compliance with the License. 13 | # You may obtain a copy of the License at 14 | # 15 | # http://www.apache.org/licenses/LICENSE-2.0 16 | # 17 | # Unless required by applicable law or agreed to in writing, software 18 | # distributed under the License is distributed on an "AS IS" BASIS, 19 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | # See the License for the specific language governing permissions and 21 | # limitations under the License. 22 | # 23 | # Configuration file for the Sphinx documentation builder. 24 | # 25 | # This file only contains a selection of the most common options. For a full 26 | # list see the documentation: 27 | # https://www.sphinx-doc.org/en/master/usage/configuration.html 28 | 29 | # -- Path setup -------------------------------------------------------------- 30 | 31 | # If extensions (or modules to document with autodoc) are in another directory, 32 | # add these directories to sys.path here. If the directory is relative to the 33 | # documentation root, use os.path.abspath to make it absolute, like shown here. 34 | # 35 | import os 36 | import sys 37 | 38 | from pkg_resources import get_distribution 39 | 40 | sys.path.insert(0, os.path.abspath("")) 41 | 42 | # -- Project information ----------------------------------------------------- 43 | 44 | project = "Demcompare" 45 | copyright = "2023, CNES" 46 | author = "CNES" 47 | # The full version, including alpha/beta/rc tags 48 | 49 | try: 50 | version = get_distribution("demcompare").version 51 | release = version 52 | except Exception as error: 53 | print("WARNING: cannot find demcompare version") 54 | version = "Unknown" 55 | release = version 56 | 57 | # The master toctree document. 58 | master_doc = "index" 59 | 60 | 61 | # -- General configuration --------------------------------------------------- 62 | 63 | # Add any Sphinx extension module names here, as strings. They can be 64 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom 65 | # ones. 66 | extensions = [ 67 | "sphinx.ext.todo", 68 | "sphinx.ext.viewcode", 69 | "sphinx.ext.autodoc", 70 | "sphinx_rtd_theme", 71 | "sphinx.ext.imgmath", 72 | "autoapi.extension", 73 | "sphinx_tabs.tabs", 74 | ] 75 | 76 | autoapi_dirs = ["../../demcompare"] 77 | autoapi_root = "api_reference" 78 | autoapi_keep_files = True 79 | autoapi_options = [ 80 | "members", 81 | "undoc-members", 82 | "private-members", 83 | "show-inheritance", 84 | "show-module-summary", 85 | "special-members", 86 | ] 87 | # Add any paths that contain templates here, relative to this directory.cd 88 | templates_path = ["_templates"] 89 | 90 | # These folders are copied to the documentation's HTML output 91 | html_static_path = ["_static"] 92 | 93 | # These paths are either relative to html_static_path 94 | # or fully qualified paths (eg. https://...) 95 | html_css_files = ["css/my_custom.css"] 96 | # List of patterns, relative to source directory, that match files and 97 | # directories to ignore when looking for source files. 98 | # This pattern also affects html_static_path and html_extra_path. 99 | exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] 100 | 101 | 102 | # -- Options for HTML output ------------------------------------------------- 103 | 104 | # The theme to use for HTML and HTML Help pages. See the documentation for 105 | # a list of builtin themes. 106 | # 107 | html_theme = "sphinx_rtd_theme" 108 | # Title 109 | html_title = "Demcompare Documentation" 110 | html_short_title = "Demcompare Documentation" 111 | 112 | # Logo 113 | html_logo = "images/demcompare_picto.png" 114 | 115 | # Favicon 116 | html_favicon = "images/favicon.ico" 117 | 118 | # Theme options 119 | html_theme_options = { 120 | "logo_only": True, 121 | "navigation_depth": 3, 122 | } 123 | 124 | latex_elements = { 125 | "papersize": "letterpaper", 126 | "pointsize": "10pt", 127 | "preamble": "", 128 | "figure_align": "htbp", 129 | } 130 | 131 | numfig = True 132 | -------------------------------------------------------------------------------- /docs/source/developer_guide.rst: -------------------------------------------------------------------------------- 1 | .. _developer_guide: 2 | 3 | Developer guide 4 | =============== 5 | 6 | .. toctree:: 7 | developer_guide/contributing.rst 8 | developer_guide/dev_install_env.rst 9 | developer_guide/coding_guide.rst 10 | developer_guide/demcompare_architecture.rst 11 | developer_guide/dev_tutorials.rst 12 | 13 | In this section all the general information concerning new developments can be found. 14 | 15 | -------------------------------------------------------------------------------- /docs/source/developer_guide/architecture/coregistration_modules.rst: -------------------------------------------------------------------------------- 1 | .. _coregistration_modules: 2 | 3 | 4 | Coregistration module 5 | ====================== 6 | 7 | This section explains coregistration module in demcompare. 8 | 9 | In the following image, we can find the classes that take part in demcompare's coregistration step, along 10 | with their relationship. 11 | 12 | Coregistration step architecture 13 | -------------------------------- 14 | 15 | The `coregistration_class`_ and `transformation_class`_ handle the API for the dem coregistration. The :ref:`demcompare_module` 16 | creates a `coregistration_class`_ object. The `coregistration_class`_ creates a `transformation_class`_ object when the coregistration offsets are 17 | obtained. 18 | 19 | The `transformation_class`_ object is in charge of storing the offsets and applying them to the secondary dem. 20 | 21 | .. figure:: /images/schema_coregistration_class.png 22 | :width: 400px 23 | :align: center 24 | 25 | Coregistration classes relationship. 26 | 27 | Coregistration 28 | ************** 29 | 30 | .. _coregistration_class: 31 | 32 | The coregistration class in demcompare has the following structure: 33 | 34 | - **Coregistration**: The class Factory in `Coregistration file `_ 35 | 36 | - **CoregistrationTemplate**: The abstract class in `CoregistrationTemplate file `_ 37 | 38 | - **NuthKaabInternal**: Nuth et kaab coregistration algorithm in `NuthKaabInternal file `_ 39 | 40 | A Coregistration object is in charge of computing the offsets between two DEMs that have the same resolution and size, giving as an output 41 | a **Transformation** object, along with the two reprojected and coregistered dems. 42 | 43 | It is to be noticed that to compute the offsets between two DEMs, they need to have the same resolution and size. For this reason, the **coregistration** 44 | module perfoms a reprojection using the :ref:`dem_tools_modules` API. 45 | 46 | One can find here the full list of API functions available in the `coregistration_class`_, as well as their description and 47 | input and output parameters: 48 | `Coregistration API `_ 49 | 50 | For information on how to create a new coregistration class, please see :ref:`tuto_new_coregistration`. 51 | 52 | 53 | Transformation 54 | ************** 55 | 56 | .. _transformation_class: 57 | 58 | - **Transformation** class in `Transformation file `_ 59 | 60 | The Transformation class stores the offsets obtained during the coregistration step. It also has the API to apply the 61 | offsets to an input DEM. It is created by the Coregistration class and given as an output. 62 | 63 | One can find here the full list of API functions available in the `transformation_class`_, as well as their description and 64 | input and output parameters: 65 | `Transformation API `_ -------------------------------------------------------------------------------- /docs/source/developer_guide/architecture/dem_processing.rst: -------------------------------------------------------------------------------- 1 | .. _dem_processing: 2 | 3 | DEM processing module 4 | ===================== 5 | 6 | **DemProcessing**: Implemented in `DemProcessing file `_ 7 | 8 | The `dem_processing`_ class creates the input needed to the :ref:`stats_processing_class`. 9 | 10 | Several **DEM processing methods** can be used: 11 | 12 | - DEM processing methods using only one DEM: 13 | 14 | - **ref** 15 | - **sec** 16 | - **ref-curvature** 17 | - **sec-curvature** 18 | 19 | - DEM processing methods using two DEMs: 20 | 21 | - **alti-diff** 22 | - **alti-diff-slope-norm** 23 | - **angular-diff** 24 | 25 | One can find here the full list of API functions available in the `dem_processing`_ module, as well as their description and 26 | input and output parameters: 27 | `DemProcessing API `_ 28 | -------------------------------------------------------------------------------- /docs/source/developer_guide/architecture/dem_tools_modules.rst: -------------------------------------------------------------------------------- 1 | .. _dem_tools_modules: 2 | 3 | Dem Tools modules 4 | ================= 5 | 6 | This section describes all dem tools modules: :ref:`dem_tools`, :ref:`dataset_tools`, :ref:`img_tools`. 7 | 8 | As explained below, the `dem_tools`_ module handles the main API for dem manipulation through a dataset described in `dataset_tools`_ below. 9 | 10 | .. _dem_tools: 11 | 12 | Dem_tools module 13 | ---------------- 14 | 15 | **demcompare.dem_tools** module file is `dem_tools.py `_ 16 | 17 | This module contains main functions to manipulate DEM raster images. 18 | 19 | It represents the primary API to manipulate DEM as xarray dataset in demcompare. 20 | Dataset and associated internal functions are described in `dataset_tools`_ 21 | 22 | As one can see in :ref:`demcompare_module`, the main demcompare module in `__init__.py `_ file uses `dem_tools`_'s 23 | functions such as **load_dem** and **reproject_dems**. 24 | 25 | The full list of API functions available in the `dem_tools`_ module, as well as their description and 26 | input and output parameters can be found here: :doc:`/api_reference/demcompare/dem_tools/index` 27 | 28 | .. _dataset_tools: 29 | 30 | Dataset_tools module 31 | -------------------- 32 | 33 | **demcompare.dataset_tools** module file is `dataset_tools.py `_ 34 | 35 | This module contains functions associated to demcompare's DEM dataset creation. It shall not be used directly, 36 | as it is the `dem_tools`_ module who handles its API. 37 | 38 | The **demcompare DEM dataset** is a xarray Dataset created by demcompare for each DEM, it contains all the necessary information 39 | for demcompare to perform all the different available processes on a DEM. 40 | 41 | One can see here all the information inside a demcompare dataset: 42 | 43 | .. _demcompare_dataset: 44 | 45 | .. code-block:: text 46 | 47 | :image: 2D (row, col) image as xarray.DataArray, 48 | :georef_transform: 1D (trans_len) xarray.DataArray with the parameters: 49 | 50 | - c: x-coordinate of the upper left pixel, 51 | - a: pixel size in the x-direction in map units/pixel, 52 | - b: rotation about x-axis, 53 | - f: y-coordinate of the upper left pixel, 54 | - d: rotation about y-axis, 55 | - e: pixel size in the y-direction in map units, negative 56 | 57 | :classification_layers: 3D (row, col, indicator) xarray.DataArray: 58 | 59 | It contains the maps of all classification layers, 60 | being the indicator a list with each 61 | classification_layer name. 62 | 63 | :attributes: 64 | 65 | - nodata : image nodata value. float 66 | - input_img : image input path. str or None 67 | - crs : image crs. rasterio.crs.CRS 68 | - xres : x resolution (value of transform[1]). float 69 | - yres : y resolution (value of transform[5]). float 70 | - plani_unit : georefence planimetric unit. astropy.units 71 | - zunit : input image z unit value. astropy.units 72 | - bounds : image bounds. rasterio.coords.BoundingBox 73 | - geoid_path : geoid path. str or None 74 | - source_rasterio : rasterio's DatasetReader object or None. 75 | 76 | 77 | .. _img_tools: 78 | 79 | Img_tools module 80 | ---------------- 81 | 82 | **demcompare.img_tools** module file is `img_tools.py `_ 83 | 84 | This module contains generic functions associated to raster images. 85 | It consists mainly on wrappers to rasterio functions. Like `dataset_tools`_, this module shall not be used directly, 86 | as it is the `dem_tools`_ module who handles its API. 87 | -------------------------------------------------------------------------------- /docs/source/developer_guide/architecture/demcompare_cli.rst: -------------------------------------------------------------------------------- 1 | .. _demcompare_cli: 2 | 3 | Demcompare CLI 4 | =============== 5 | 6 | Demcompare command line is the main tool entrance. 7 | 8 | The user can execute `demcompare` command line using an input configuration file. 9 | Read :ref:`command_line_execution` in user manual for more details. 10 | 11 | Different logging outputs can be chosen (ie. INFO or DEBUG modes) 12 | to give the user different information during the execution. 13 | The debug mode is especially interesting for developers. 14 | 15 | The demcompare CLI module is in `demcompare.py `_ file 16 | and handles argparse conversion to the :ref:`demcompare_module`, 17 | which will orchestrate the demcompare API from the input configuration file. 18 | 19 | This python file includes demcompare's main and input parser. 20 | 21 | -------------------------------------------------------------------------------- /docs/source/developer_guide/architecture/demcompare_module.rst: -------------------------------------------------------------------------------- 1 | .. _demcompare_module: 2 | 3 | 4 | Demcompare pipeline module 5 | =========================== 6 | 7 | The main demcompare module in `demcompare_module file `_ orchestrates the demcompare 8 | API from an input configuration file, hence, from an execution using the :ref:`demcompare_cli`. 9 | 10 | The configuration file specifies digital elevation models inputs to compare and also the pipeline to execute. 11 | This pipeline depends on the optional :ref:`coregistration` and/or :ref:`statistics` steps configuration. 12 | 13 | If coregistration and/or statistics steps are to be computed, 14 | then each step orchestration will be handled by demcompare module as follows: 15 | 16 | Coregistration step orchestration 17 | --------------------------------- 18 | 19 | .. figure:: /images/coreg_api.png 20 | :width: 800px 21 | :align: center 22 | 23 | Demcompare coregistration step orchestration 24 | 25 | 26 | To perform the dems coregistration :ref:`coregistration`, demcompare's module performs the following steps: 27 | 28 | 1. Loads the input dems using the **dem_tools** module's *load_dem* function. 29 | 2. Creates a **Coregistration** object and obtains the dem's transformation object using the **coregistration**'s *compute_coregistration* function. 30 | 3. Applies the obtained transformation to the secondary dem using the **transformation**'s *apply_transform* function. 31 | 32 | For more details on the coregistration modules architecture, please see :ref:`coregistration_modules`. 33 | 34 | Statistics step orchestration 35 | ----------------------------- 36 | 37 | .. figure:: /images/stats_api.png 38 | :width: 800px 39 | :align: center 40 | 41 | Demcompare's orchestration for statistics step. 42 | 43 | To perform the dems statistics :ref:`statistics`, demcompare's module performs the following steps: 44 | 45 | 1. Loads the input dems using the **dem_tools** module's *load_dem* function. 46 | 2. Reprojects both dems to the same size and resolution using **dem_tools** module's *reproject_dems* function. 47 | 3. Process the two DEMs by using the **dem_processing** module (see :ref:`dem_processing`). 48 | 4. Creates a **Stats_processing** object and obtains the **stats_dataset** using the **stats_processing**'s *compute_stats* function. 49 | 50 | .. note:: 51 | 52 | If coregistration has previously been done, the **coregistration**'s objects internal dems called **reproj_coreg_ref** and **reproj_coreg_sec** are used for the altitude difference computation, so that no manual reprojection needs to be done. Please see :ref:`statistics` "With coregistration step" section for more details. 53 | 54 | .. note:: 55 | 56 | If only one input is provided to demcompare, this input is directly used by the **dem_processing** module (there is no reprojection). 57 | 58 | For more details on the statistics modules architecture, please see :ref:`stats_modules`. 59 | 60 | Module files description 61 | ************************ 62 | 63 | - **helpers_init** module in `helpers_init.py file `_ 64 | 65 | .. _helpers_init: 66 | 67 | In this module high level parameters of the input configuration are checked and default options are set when 68 | not already defined. Some helper functions to handle the output paths from the ` are also included here. 69 | 70 | - **log_conf** module in `log_conf.pyfile `_ 71 | 72 | .. _log_conf: 73 | 74 | The logconf module in demcompare contains logging configuration functions. -------------------------------------------------------------------------------- /docs/source/developer_guide/architecture/high_level_description.rst: -------------------------------------------------------------------------------- 1 | .. _high_level_description: 2 | 3 | 4 | Demcompare high level description 5 | ================================== 6 | 7 | Demcompare can be run through :ref:`demcompare_cli` that uses :ref:`demcompare_module`. 8 | 9 | With an input configuration file, :ref:`demcompare_module` orchestrates : 10 | 11 | * functions from :ref:`dem_tools_modules` for DEM manipulation 12 | 13 | * functions from :ref:`coregistration_modules` for DEM coregistration 14 | 15 | * functions from :ref:`dem_processing` to handle DEM processing methods computation 16 | 17 | * functions from :ref:`stats_modules` to handle statistics metrics computation 18 | 19 | * functions from :ref:`report_module` to create the output report (Work in progress) 20 | 21 | .. figure:: /images/modules_schema.png 22 | :width: 800px 23 | :align: center 24 | 25 | Modules relationship. 26 | 27 | Demcompare API is also detailed in `notebooks `_ and automatic API is generated in :doc:`/api_reference/index` section. 28 | 29 | 30 | Demcompare architecture combines simple **python modules** with **python classes**. To generalize some parts, some of those classes have an **abstract architecture**. 31 | 32 | Demcompare's abstraction are all implemented with the following structure: 33 | 34 | 1. The **class factory**, which is python file named like the class. It only handles the class object generation. 35 | 2. The **abstract class template**, which is a python file named like the class + "_template". This file includes all the abstract functions and attributes. 36 | 3. The **subclasses**, which are python files implementing the subclasses derived from the abstract class. With the class factory and the abstract class template, different subclasses can be implemented deriving from the abstract class template. 37 | 38 | -------------------------------------------------------------------------------- /docs/source/developer_guide/architecture/report_module.rst: -------------------------------------------------------------------------------- 1 | .. _report_module: 2 | 3 | Report module 4 | ================= 5 | 6 | 7 | .. warning:: 8 | This section is Work in progress. Report in demcompare is not finalized. 9 | 10 | 11 | 12 | 13 | - **demcompare.report** modules in `report file `_ 14 | 15 | Module in charge of generating output demcompare's report to visualize the results (graphs, stats, ...) 16 | 17 | - **sphinx_project_generator** module in `sphinx_project_generator file `_ 18 | 19 | sphinx_project_generator is a module containing the helper functions for the creation of the output demcompare's report 20 | and ease its manipulation. -------------------------------------------------------------------------------- /docs/source/developer_guide/demcompare_architecture.rst: -------------------------------------------------------------------------------- 1 | .. _demcompare_architecture: 2 | 3 | Demcompare architecture 4 | ======================= 5 | 6 | This section gives insights of demcompare architecture and design to help understand how the software works, in order to ease 7 | developer contributions. 8 | 9 | 10 | The following sections give details for each subpart. 11 | 12 | .. toctree:: 13 | :maxdepth: 1 14 | 15 | architecture/high_level_description.rst 16 | architecture/demcompare_cli.rst 17 | architecture/demcompare_module.rst 18 | architecture/dem_tools_modules.rst 19 | architecture/coregistration_modules.rst 20 | architecture/dem_processing.rst 21 | architecture/stats_modules.rst 22 | architecture/report_module.rst 23 | 24 | 25 | 26 | .. note:: 27 | 28 | Please contribute if elements are missing or are unclear on demcompare source code. 29 | -------------------------------------------------------------------------------- /docs/source/developer_guide/dev_install_env.rst: -------------------------------------------------------------------------------- 1 | .. _developer_install: 2 | 3 | Developer Install 4 | ***************** 5 | 6 | This package can be installed through the following commands: 7 | 8 | .. code-block:: bash 9 | 10 | git clone https://github.com/CNES/demcompare 11 | cd demcompare 12 | make install 13 | source venv/bin/activate # to go in installed dev environment 14 | 15 | Dependencies : **git**, **make** 16 | 17 | The Makefile wrapper helps to install development environment and give the developer the commands to do a manual installation. 18 | By default, a python `virtualenv `_ is automatically created with the **make install** command. 19 | 20 | Please run **make help** command to see all the available commands. 21 | 22 | It is also possible to change the virtualenv directory: 23 | 24 | .. code-block:: bash 25 | 26 | git clone https://github.com/CNES/demcompare 27 | cd demcompare 28 | VENV="other-venv-directory" make install 29 | source venv/bin/activate # to go in installed dev environment 30 | 31 | .. note:: 32 | Use **make clean** command to redo the install when environment state is undefined. 33 | 34 | 35 | Sample execution from source 36 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% 37 | 38 | Getting started example from source code of a basic DEM coregistration + statistics execution with the sample images and input configuration available on **demcompare** : 39 | 40 | .. code-block:: bash 41 | 42 | cd data_samples # considering demcompare command is available (see above) 43 | demcompare sample_config.json # run demcompare example 44 | 45 | - For more information about **demcompare**'s command line execution, please refer to: :ref:`command_line_execution` 46 | - For more information about **demcompare**'s steps, please refer to: :ref:`coregistration`, :ref:`statistics`, :ref:`report` 47 | 48 | -------------------------------------------------------------------------------- /docs/source/developer_guide/dev_tutorials.rst: -------------------------------------------------------------------------------- 1 | Development tutorials 2 | ======================= 3 | 4 | .. toctree:: 5 | :maxdepth: 2 6 | 7 | dev_tutorials/tuto_new_coregistration.rst 8 | dev_tutorials/tuto_new_metric.rst 9 | dev_tutorials/tuto_new_dem_processing.rst -------------------------------------------------------------------------------- /docs/source/developer_guide/dev_tutorials/tuto_new_dem_processing.rst: -------------------------------------------------------------------------------- 1 | .. _tuto_new_dem_processing: 2 | 3 | New DEM processing method implementation 4 | ======================================== 5 | 6 | Demcompare's architecture allows to easily implement a **new DEM processing method computation**. 7 | 8 | To do so, a new class has to be implemented within `demcompare/dem_processing/dem_processing_methods.py `_ file, according to 9 | the new DEM processing method's structure (see :ref:`stats_modules`). 10 | 11 | 12 | Basic DEM processing method structure and functions 13 | *************************************************** 14 | 15 | The new DEM processing method class inherits from the **DemProcessingTemplate** class and must implement the **process_dem** function. This 16 | function takes two *xr.Dataset* as an entry and performs the corresponding DEM processing computation on the datasets. The output should be a *xr.Dataset*. 17 | 18 | One may also implement the **__init__** function of the new DEM Processing class, mostly if this DEM Processing contains class attributes. 19 | 20 | Hence, a basic *NewDemProcessingClass* would be implemented with the following structure : 21 | 22 | .. code-block:: bash 23 | 24 | @DemProcessing.register("new_dem_processing_class") 25 | class NewDemProcessingClass(DemProcessingTemplate): 26 | 27 | # Optional, only needed if the DEM processing object has its own parameters 28 | def __init__(self, parameters: Dict = None): 29 | """ 30 | Initialization the DEM Processing object 31 | 32 | :param parameters: optional input parameters 33 | :type parameters: dict 34 | :return: None 35 | """ 36 | 37 | def process_dem( 38 | self, 39 | dem_1: xr.Dataset, 40 | dem_2: xr.Dataset, 41 | ) -> xr.Dataset: -------------------------------------------------------------------------------- /docs/source/developer_guide/dev_tutorials/tuto_new_metric.rst: -------------------------------------------------------------------------------- 1 | .. _tuto_new_metric: 2 | 3 | New metric implementation 4 | ========================= 5 | 6 | Demcompare's architecture allows to easily implement a **new metric computation**. 7 | 8 | To do so, a new class has to be implemented within `demcompare/scalar_metrics.py `_, `demcompare/vector_metrics.py `_ or `demcompare/matrix_2d_metrics.py `_ file, according to 9 | the new metric's structure (see :ref:`stats_modules`). 10 | 11 | 12 | Basic metric structure and functions 13 | ************************************ 14 | 15 | The new metric class inherits from the **MetricTemplate** class and must implement the **compute_metric** function. This 16 | function takes a *np.array* as an entry and performs the corresponding metric computation on the input array. The computed metric can be 17 | a float (that would be a scalar metric), a *Tuple[np.array, np.array]* (vector metric), or a *np.ndarray* (maxtrix 2D metric). 18 | 19 | One may also implement the **__init__** function of the new metric class, mostly if this metric contains class attributes (ie. the RatioAboveThreshold 20 | metric contains the *elevation_thresholds* attribute). 21 | 22 | Hence, a basic *NewMetricClass* would be implemented with the following structure : 23 | 24 | .. code-block:: bash 25 | 26 | @Metric.register("new_metric_class") 27 | class NewMetricClass(MetricTemplate): 28 | 29 | # Optional, only needed if the metric object has its own parameters 30 | def __init__(self, parameters: Dict = None): 31 | """ 32 | Initialization the metric object 33 | 34 | :param parameters: optional input parameters 35 | :type parameters: dict 36 | :return: None 37 | """ 38 | 39 | def compute_metric( 40 | self, data: np.ndarray 41 | ) -> Union[Tuple[np.ndarray, np.ndarray], np.ndarray, float]: 42 | """ 43 | Metric computation method 44 | 45 | :param data: input data to compute the metric 46 | :type data: np.array 47 | :return: the computed mean 48 | :rtype: float 49 | """ 50 | 51 | Advanced metric functions 52 | ************************* 53 | 54 | It is to be noticed that more functionalities regarding the output visualisation can be implemented within a class Metric. 55 | An example of such functionalities would be the *ProbabilityDensityFunction* implemented in `demcompare/vector_metrics.py `_. 56 | This metric implements, in addition to the **__init__** and **compute_metrics** function, the **save_csv_metric** and **save_plot_metric** 57 | functions. Those functions will be called if the input metric configuration contains the arguments *"output_plot_path"* or *"output_csv_path"*, 58 | allowing the user to obtain plot and csv output files for better analyzing the computed metric (see :ref:`statistics`). -------------------------------------------------------------------------------- /docs/source/faq.rst: -------------------------------------------------------------------------------- 1 | .. _faq: 2 | 3 | .. role:: bash(code) 4 | :language: bash 5 | 6 | 7 | Frequently Asked Questions 8 | =========================== 9 | 10 | Installation troubleshooting 11 | **************************** 12 | 13 | Depending on pip version, installation problems can happen with packages dependencies installation order. Install and upgrade pip and numpy if demcompare installation crashes: 14 | 15 | .. code-block:: bash 16 | 17 | python3 -m pip install --upgrade pip 18 | python3 -m pip install --upgrade numpy 19 | 20 | .. note:: Be careful: Rasterio has its own embedded version of GDAL. Please use rasterio no-binary version in Makefile install if you want to use a GDAL local version: 21 | 22 | .. code-block:: bash 23 | 24 | python3 -m pip install --no-binary rasterio rasterio 25 | 26 | Data Dimension Management 27 | ************************* 28 | 29 | There are no constraints on the dimensions of input data, except that they must share a geographical footprint (cf: Intersection DEM schema). 30 | However, classification masks must have the same dimensions as the associated DEM. 31 | The constraints and returned error we impose are directly derived from the rasterio mask class . `Documentation rasterio mask`_ 32 | 33 | .. figure:: /images/dem_intersection.png 34 | :width: 1000px 35 | :align: center 36 | 37 | Intersection DEM schema 38 | 39 | .. _`Documentation rasterio mask`: https://rasterio.readthedocs.io/en/stable/api/rasterio.mask.html 40 | -------------------------------------------------------------------------------- /docs/source/getting_started.rst: -------------------------------------------------------------------------------- 1 | 2 | .. role:: bash(code) 3 | :language: bash 4 | 5 | Getting started 6 | =============== 7 | 8 | Install 9 | ####### 10 | 11 | Demcompare is available on Pypi and can be installed by: 12 | 13 | .. code-block:: bash 14 | 15 | python3 -m venv venv 16 | source venv/bin/activate 17 | pip install --upgrade pip 18 | pip install demcompare 19 | 20 | .. note:: In case of installation problems, please refer to :ref:`faq` 21 | 22 | Command line execution 23 | ###################### 24 | 25 | Example of a basic DEM coregistration + statistics execution with the sample images and input configuration available on demcompare : 26 | 27 | .. code-block:: bash 28 | 29 | # download data samples 30 | wget https://raw.githubusercontent.com/CNES/demcompare/master/data_samples/srtm_blurred_and_shifted.tif 31 | wget https://raw.githubusercontent.com/CNES/demcompare/master/data_samples/srtm_ref.tif 32 | 33 | # download demcompare predefined configuration 34 | wget https://raw.githubusercontent.com/CNES/demcompare/master/data_samples/sample_config.json 35 | 36 | # run demcompare 37 | demcompare sample_config.json 38 | 39 | Another configuration is also available, allowing to compute more interesting metrics: 40 | 41 | .. code-block:: bash 42 | 43 | # download the other demcompare predefined configuration file, 44 | # this one allows to compute all the interesting metrics available for comparing the 2 input DEMs 45 | wget https://raw.githubusercontent.com/CNES/demcompare/master/data_samples/sample_config_full.json 46 | # run demcompare 47 | demcompare sample_config_full.json 48 | 49 | For more details, please refer to :ref:`command_line_execution` section. -------------------------------------------------------------------------------- /docs/source/glossary.rst: -------------------------------------------------------------------------------- 1 | .. _glossary: 2 | 3 | ======== 4 | Glossary 5 | ======== 6 | 7 | Demcompare common words and shortened terms are detailed here. 8 | 9 | To update, follow `glossary sphinx documentation`_ in RST source documentation. 10 | 11 | .. glossary:: 12 | disp 13 | The short version of "disparity" 14 | 15 | disparity 16 | The column difference between a pixel in the left image and its homologous pixel in the right image. 17 | 18 | DEM 19 | `Digital Elevation Model`_. Usually means all elevation models in raster: DSM, DTM,... 20 | 21 | DSM 22 | Digital Surface Model. Represents the earth's surface and includes all objects on it. See `Digital Elevation Model`_ 23 | 24 | steps 25 | In demcompare, it represents all functional steps in the DSM comparison pipeline. 26 | 27 | ROI 28 | `Region of Interest`_ means a subpart of the `DSM` raster in demcompare. 29 | It can be defined by a file or a bounding box. 30 | 31 | .. _`Digital Elevation Model`: https://en.wikipedia.org/wiki/Digital_elevation_model 32 | .. _`Digital Surface Model`: https://en.wikipedia.org/wiki/Digital_elevation_model 33 | .. _`Region of Interest`: https://en.wikipedia.org/wiki/Region_of_interest 34 | 35 | .. _`glossary sphinx documentation`: https://sublime-and-sphinx-guide.readthedocs.io/en/latest/glossary.html -------------------------------------------------------------------------------- /docs/source/images/AngularDiff.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/docs/source/images/AngularDiff.png -------------------------------------------------------------------------------- /docs/source/images/Curvature.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/docs/source/images/Curvature.png -------------------------------------------------------------------------------- /docs/source/images/ErrorVSslope.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/docs/source/images/ErrorVSslope.png -------------------------------------------------------------------------------- /docs/source/images/HillshadeSVF.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/docs/source/images/HillshadeSVF.png -------------------------------------------------------------------------------- /docs/source/images/coreg_api.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/docs/source/images/coreg_api.png -------------------------------------------------------------------------------- /docs/source/images/dem_intersection.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/docs/source/images/dem_intersection.png -------------------------------------------------------------------------------- /docs/source/images/demcompare_picto.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/docs/source/images/demcompare_picto.png -------------------------------------------------------------------------------- /docs/source/images/doc_out.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/docs/source/images/doc_out.gif -------------------------------------------------------------------------------- /docs/source/images/doc_ref.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/docs/source/images/doc_ref.gif -------------------------------------------------------------------------------- /docs/source/images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/docs/source/images/favicon.ico -------------------------------------------------------------------------------- /docs/source/images/final_dh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/docs/source/images/final_dh.png -------------------------------------------------------------------------------- /docs/source/images/initial_dh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/docs/source/images/initial_dh.png -------------------------------------------------------------------------------- /docs/source/images/modules_schema.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/docs/source/images/modules_schema.png -------------------------------------------------------------------------------- /docs/source/images/schema_coregistration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/docs/source/images/schema_coregistration.png -------------------------------------------------------------------------------- /docs/source/images/schema_coregistration_class.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/docs/source/images/schema_coregistration_class.png -------------------------------------------------------------------------------- /docs/source/images/schema_statistiques_class.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/docs/source/images/schema_statistiques_class.png -------------------------------------------------------------------------------- /docs/source/images/slopeOrientationHist.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/docs/source/images/slopeOrientationHist.png -------------------------------------------------------------------------------- /docs/source/images/stats_api.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/docs/source/images/stats_api.png -------------------------------------------------------------------------------- /docs/source/images/stats_fusion_schema.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/docs/source/images/stats_fusion_schema.png -------------------------------------------------------------------------------- /docs/source/images/stats_input_after_coreg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/docs/source/images/stats_input_after_coreg.png -------------------------------------------------------------------------------- /docs/source/images/stats_input_one_dem.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/docs/source/images/stats_input_one_dem.png -------------------------------------------------------------------------------- /docs/source/images/stats_input_two_dems.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/docs/source/images/stats_input_two_dems.png -------------------------------------------------------------------------------- /docs/source/images/stats_support_schema.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/docs/source/images/stats_support_schema.png -------------------------------------------------------------------------------- /docs/source/images/workflow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/docs/source/images/workflow.png -------------------------------------------------------------------------------- /docs/source/index.rst: -------------------------------------------------------------------------------- 1 | Welcome to demcompare documentation! 2 | ==================================== 3 | 4 | **Demcompare** is a python software that aims at **comparing two DEMs** together. 5 | 6 | Demcompare has several benefits: 7 | 8 | - Works whether or not the two DEMs share common format projection system, planimetric resolution, and altimetric unit. 9 | - Performs the coregistration based on the Nuth & Kääb universal coregistration method. 10 | - Computes the statistics on an input DEM, or on the difference of two input DEMs. 11 | - Provides a wide variety of standard metrics and allows one to classify the DEMs to obtain statistics by class. 12 | 13 | A comparison report can be compiled as *html* or *pdf* documentation with statistics printed as tables and plots. 14 | 15 | .. toctree:: 16 | :maxdepth: 4 17 | :caption: Contents: 18 | 19 | getting_started 20 | userguide 21 | developer_guide 22 | api_reference/index.rst 23 | faq 24 | glossary 25 | 26 | .. toctree:: 27 | :caption: Related: 28 | :maxdepth: 4 29 | 30 | CARS, CNES 3D reconstruction software 31 | 32 | 33 | -------------------------------------------------------------------------------- /docs/source/userguide.rst: -------------------------------------------------------------------------------- 1 | .. _userguide: 2 | 3 | User guide 4 | ========== 5 | 6 | .. toctree:: 7 | :maxdepth: 4 8 | 9 | 10 | userguide/command_line_execution.rst 11 | userguide/inputs.rst 12 | userguide/coregistration.rst 13 | userguide/statistics.rst 14 | userguide/report.rst 15 | userguide/notebook_execution.rst -------------------------------------------------------------------------------- /docs/source/userguide/command_line_execution.rst: -------------------------------------------------------------------------------- 1 | .. _command_line_execution: 2 | 3 | .. role:: bash(code) 4 | :language: bash 5 | 6 | Execution from the command line 7 | =============================== 8 | 9 | **Demcompare** is executed from the command line with an input configuration file: 10 | 11 | .. code-block:: bash 12 | 13 | demcompare config_file.json #run demcompare 14 | 15 | The following code-block is an input configuration file example including 16 | both **coregistration**, **statistics** and **report** steps with demcompare data samples. 17 | 18 | .. code-block:: json 19 | 20 | { 21 | "output_dir": "./test_output/", 22 | "input_ref": { 23 | "path": "./srtm_ref.tif" 24 | }, 25 | "input_sec": { 26 | "path": "./srtm_blurred_and_shifted.tif" 27 | }, 28 | "coregistration": { 29 | "method_name": "nuth_kaab_internal" 30 | }, 31 | "statistics": { 32 | "alti-diff": { 33 | "remove_outliers": false 34 | } 35 | }, 36 | "report" : "default" 37 | } 38 | 39 | The **coregistration** and **report** steps are optional. 40 | Remove one of them from the config file to prevent demcompare from running it. 41 | 42 | The mandatory **statistics** step includes an **alti-diff** :ref:`DEM_processing_methods` section. 43 | This **alti-diff** configuration allows to compute the difference in altitude between the two input DEMs. 44 | All :ref:`DEM_processing_methods` can be found in :ref:`List of DEM processing methods `. 45 | They can be used one after the other in the **statistics** step. 46 | 47 | The optional **report** step generates a report from computed statistics. 48 | 49 | Configuration parameters are described in associated sub-sections: 50 | 51 | - :ref:`input_dem` 52 | - :ref:`coregistration` 53 | - :ref:`statistics` 54 | - :ref:`report` 55 | -------------------------------------------------------------------------------- /docs/source/userguide/notebook_execution.rst: -------------------------------------------------------------------------------- 1 | 2 | 3 | Notebook execution 4 | ****************** 5 | 6 | Execution from the example notebooks 7 | ==================================== 8 | 9 | **Demcompare** offers some execution notebooks. Those notebooks show a detailed execution of demcompare's steps 10 | where the user can easily get familiarized with the API and visualize the intermediate results in a dynamic way. 11 | Those notebooks include all demcompare's steps such as the DEMs loading, its reprojection, coregistration and statistics computation. 12 | 13 | The available notebooks are: 14 | 15 | - Notebook introduction and basic usage 16 | - Notebook reprojection and coregistration 17 | - Notebook statistics 18 | -------------------------------------------------------------------------------- /docs/source/userguide/report.rst: -------------------------------------------------------------------------------- 1 | .. _report: 2 | 3 | Generated output report 4 | ======================= 5 | 6 | .. warning:: 7 | Demcompare report is work in progress ! 8 | 9 | 10 | If the **demcompare** execution includes the **statistics** step 11 | and the output directory has been specified, a report can be generated using the "report" step. 12 | 13 | For now, only a HTML and PDF report can be generated from a specific sphinx source report. 14 | 15 | Report configuration: 16 | 17 | .. csv-table:: 18 | :header: "Report config", "Description", "Type" 19 | :widths: auto 20 | :align: left 21 | 22 | ``'default'``,"default choice, equal to sphinx for now","string" 23 | ``'sphinx'``,"demcompare sphinx report generator (only one for now)","string" 24 | 25 | Example of json syntax for configuration file: 26 | 27 | .. code-block:: json 28 | 29 | "report": "default" 30 | 31 | 32 | Sphinx report 33 | ************* 34 | 35 | The output `/report/published_report/` directory contains 36 | a full generated sphinx documentation with the results in html or latex format. 37 | 38 | The source of the sphinx report is in `/report/src`` 39 | 40 | Once **demcompare** has been executed with report configuration, 41 | the report can be observed using a browser: 42 | 43 | .. code-block:: bash 44 | 45 | firefox test_output/report/published_report/html/index.html & 46 | 47 | 48 | -------------------------------------------------------------------------------- /docs/source/userguide/statistics.rst: -------------------------------------------------------------------------------- 1 | .. _statistics: 2 | 3 | 4 | Statistics 5 | ========== 6 | 7 | .. note:: 8 | 9 | In this chapter, we use *ref* and *sec* abbreviations when refering to the reference input DEM (``input_ref``) and the secondary input DEM (``input_sec``) respectively **after coregistration or reprojection, if specified in the configuration file**. 10 | 11 | The following subsections detail each statistics topics: 12 | 13 | .. toctree:: 14 | :maxdepth: 4 15 | 16 | statistics/dem_processing.rst 17 | statistics/metrics.rst 18 | statistics/classification_layers.rst 19 | statistics/statistics_parameters.rst 20 | statistics/statistics_outputs.rst -------------------------------------------------------------------------------- /docs/source/userguide/statistics/angular_difference.rst: -------------------------------------------------------------------------------- 1 | .. _angular_difference: 2 | 3 | Angular difference 4 | ================== 5 | 6 | While elevation differences—whether normalized by slope or not—can detect variations in height between two DEMs, they might not efficiently capture biases in their shapes. 7 | To address this limitation, a new method was implemented to compare the angle between the two normal vectors :math:`\vec{n_{k}}` of each pixel from two DEMs. 8 | This angle :math:`\theta` can be computed using the following relation: 9 | 10 | .. math:: 11 | 12 | \cos(\theta) = \frac{\vec{n_{1}} \cdot \vec{n_{2}}}{ \| \vec{n_{1}} \| \| \vec{n_{2}} \|} 13 | 14 | A high angle indicates the presence of distortions and biases between the two DEMs. 15 | This can highlight some discrepancies not distinguishable with the simple elevation difference. 16 | For instance, in the figure bellow, high differences can be observed in some areas. 17 | In particular the straight line in the top left-hand corner is not visible with the elevation difference and corresponds in fact to a power line or a ski lift which is visible in the reference DEM but not in the second DEM generated from satellite optical images. 18 | 19 | .. figure:: /images/AngularDiff.png 20 | :width: 500px 21 | :align: center 22 | 23 | Angular difference over a DEM covering a mountainous region in the Alps. White noisy areas correspond to no-data pixels. -------------------------------------------------------------------------------- /docs/source/userguide/statistics/hillshade_sky_view.rst: -------------------------------------------------------------------------------- 1 | .. _hillshade_sky_view: 2 | 3 | Hillshade and sky-view factor representations 4 | ============================================= 5 | 6 | A DEM is usually represented with a map of its elevation, but this view can sometimes be challenging to interpret. 7 | Therefore, more visual representations were added into demcompare to help analyse a DEM: Hillshade and sky-view factor representations. 8 | These additional visualizations are illustrated in the figure below. 9 | 10 | The hillshade is a representation based on slope orientation. 11 | By convention, a north-oriented slope is assigned a value of 0°, an east-oriented slope 90°, a south-oriented slope 180°, and a west-oriented slope 270°. 12 | As a result, east-oriented slopes appear darker than west-oriented ones in this visualization. 13 | 14 | This hillshade visualization not only helps users grasp the topography or 3D aspect of a DEM but also helps in identifying artifacts or other anomalous features. 15 | 16 | On the other hand, the sky view factor assumes that the light is arriving from all the directions instead of coming from a punctual luminous source (the sun). 17 | Then, a point is lit up proportionally to the solid angle of sky visible from its position. 18 | This makes it particularly easy to pinpoint features such as valleys. 19 | This representation serves as a valuable complement to the hillshade. 20 | 21 | .. figure:: /images/HillshadeSVF.png 22 | :width: 1000px 23 | :align: center 24 | 25 | Hillshade (left) and sky-view factor (right) for a DEM located in the Pyrenees. -------------------------------------------------------------------------------- /docs/source/userguide/statistics/quality_measures.rst: -------------------------------------------------------------------------------- 1 | .. _quality_measures: 2 | 3 | Quality measures 4 | ================ 5 | 6 | Metrics such as elevation difference or angular difference rely on a reference DEM. This dependence can be problematic for several reasons: 7 | 8 | * Not all reference DEMs boast a high spatial resolution. 9 | * The reference DEM and the DEM under evaluation might represent different time frames, during which the area of interest could have experienced changes, be it from natural phenomena like landslides or human activities like construction. 10 | * The two DEMs could differ in spatial resolution, and resampling a DEM can introduce errors and biases, especially concerning slopes and reliefs. 11 | 12 | Thus, introducing some methods to assess the quality of a DEM without comparing it to a reference DEM can be beneficial. 13 | Such methods are called quality measures. Two of these methods have been implemented into demcompare: the curvature and the slope orientation histogram. 14 | 15 | .. _curvature: 16 | 17 | Curvature 18 | ********* 19 | 20 | Given these potential discrepancies, it's important to incorporate standalone quality metrics like Curvature when evaluating a DEM. 21 | 22 | Curvature represents the second derivative of the elevation (the slope being the first derivative). 23 | For a given DEM :math:`u`, curvature is calculated with the formula :math:`div(\frac{\nabla u}{ \| \nabla u \|})`. 24 | Negative values are associated with convex profiles, whereas positive values are associated with concave profiles. 25 | 26 | It is a really useful measure in urban areas as it highlights the restitution quality of buildings and streets. 27 | For more natural areas, it can for instance bring some light on hydrologic networks or valleys. 28 | This is illustrated in the figure bellow. 29 | 30 | .. figure:: /images/Curvature.png 31 | :width: 500px 32 | :align: center 33 | 34 | Curvature for an urban DEM and a mountainous DEM. Features such as buildings, trees or valleys are easily identifiable. 35 | 36 | .. _slope_orientation_histogram: 37 | 38 | Slope orientation histogram 39 | *************************** 40 | 41 | Using the same convention with slopes as with the hillshade (0° for north orientation, 90° for east orientation…), it is possible to plot a circular distribution of the pixels according to their slope orientation. 42 | This quality measure is called the “slope orientation histogram” and it is very helpful in identifying the presence of artifacts. 43 | 44 | For instance, it can detect if the method of DEM construction or sampling generates some slope orientations in the main direction of the interpolation grid. 45 | Therefore, it can spot the artefacts dependent on the DEM generation method, independently from the input data. 46 | An example is illustrated below with 2 DEMs, one of them containing artifacts and the other being more realistic and homogeneous. 47 | 48 | .. figure:: /images/slopeOrientationHist.png 49 | :width: 500px 50 | :align: center 51 | 52 | Slope orientation histogram for 2 DEMs covering the same hilly area. On the left, some artifacts can be identified in the main and secondary directions of the grid (0°, 90°, 180°, 270°, and 45°, 135°, 225°, 315°). On the right, a dominant direction of the hills can be identified toward the south-east. -------------------------------------------------------------------------------- /docs/source/userguide/statistics/slope_normalized_elevation_difference.rst: -------------------------------------------------------------------------------- 1 | .. _slope_normalized_elevation_difference: 2 | 3 | Slope normalized elevation difference 4 | ===================================== 5 | 6 | The most intuitive method used for comparing two DEMs is measuring the elevation difference pixel by pixel. 7 | However, this method has some biases due to the slope: the differences tend to be higher in the areas with steeper slopes. 8 | This phenomenon is illustrated in the plot below, generated using statistics from demcompare for DEMs over a mountainous region. 9 | Such systemic error can be problematic. 10 | For instance, a DEM could have high errors in a flat zone that could be undetected because it would be dominated by the errors in a zone with important reliefs. 11 | 12 | .. figure:: /images/ErrorVSslope.png 13 | :width: 500px 14 | :align: center 15 | 16 | To address the aforementioned bias, it seems relevant to normalize the elevation difference with the slope to remove this systemic error. 17 | This normalization would facilitate a more accurate comparison of errors across pixels, regardless of their slope. 18 | [Reinartz]_ established a linear relation between the root mean square (rms) of the height difference and the tangent of the slope :math:`\alpha`: 19 | 20 | .. math:: 21 | 22 | rms = a + b \times \tan(\alpha) 23 | 24 | To mitigate the influence of the slope, one can adjust the elevation error by dividing it by :math:`1 + b \times \tan(\alpha)`, where :math:`b` is calculated by computing a linear regression between the slope and the rms of the elevation difference. 25 | This will attenuate the bias and reveal the areas where the differences can actually be reduced as they would not result from the slope. 26 | 27 | References 28 | ********** 29 | 30 | For the linear relation between the root mean square (rms) of the height difference and the tangent of the slope :math:`\alpha`: 31 | 32 | .. [Reinartz] Reinartz P, Pablo D, Krauss T, Poli D, Jacobsen K, Buyuksalih G. Benchmarking and quality analysis of DEM generated from high and very high resolution optical stereo satellite data. In Conference Proceedings: International Archives of Photogrammetry and Remote Sensing - ISSN: 1682-1777. Vol. XXXVIII. Enschede (The Netherlands): ITC; 2010. JRC57049 -------------------------------------------------------------------------------- /docs/source/userguide/statistics/statistics_outputs.rst: -------------------------------------------------------------------------------- 1 | .. _statistics_outputs: 2 | 3 | Statistics outputs 4 | ================== 5 | 6 | Output files and their required parameters 7 | ****************************************** 8 | 9 | The images and files saved with the ``statistics`` option activated on the configuration : 10 | 11 | 12 | +--------------------------------------------------------------------+------------------------------------------------------------------------------------------+ 13 | | Name | Description | 14 | +====================================================================+==========================================================================================+ 15 | | *dem_for_stats.tif* | DEM on which the statistics have been computed | 16 | +--------------------------------------------------------------------+------------------------------------------------------------------------------------------+ 17 | | *ref and sec_rectified_support_map.tif* | | Stored on each classification layer folder, the rectified support maps | 18 | | | | where each pixel has a class value. | 19 | +--------------------------------------------------------------------+------------------------------------------------------------------------------------------+ 20 | | *stats_results.csv and .json* | | Stored on each classification layer folder, | 21 | | | | the CSV and Json files storing the computed statistics by class. | 22 | +--------------------------------------------------------------------+------------------------------------------------------------------------------------------+ 23 | | *stats_results_intersection.csv and .json* | | Stored on each classification layer folder, the CSV and Json files | 24 | | | | storing the computed statistics by class in mode intersection. | 25 | +--------------------------------------------------------------------+------------------------------------------------------------------------------------------+ 26 | | *stats_results_exclusion.csv and .json* | | Stored on each classification layer folder, the CSV and Json files | 27 | | | | storing the computed statistics by class in mode exclusion. | 28 | +--------------------------------------------------------------------+------------------------------------------------------------------------------------------+ 29 | 30 | Output directories 31 | ****************** 32 | 33 | With the command line execution, the following statistics directories that may store the respective files will be automatically generated. 34 | 35 | One output directory per **DEM processing method** is created: 36 | 37 | .. code-block:: bash 38 | 39 | .output_dir 40 | +-- stats 41 | +-- *dem_processing_method* 42 | +-- dem_for_stats.tif 43 | +-- *classification_layer_name* 44 | +-- stats_results.json/csv 45 | +-- stats_results_intersection.json/csv 46 | +-- stats_results_exclusion.json/csv 47 | +-- ref_rectified_support_map.tif 48 | +-- sec_rectified_support_map.tif 49 | 50 | .. note:: 51 | Please notice that even if no classification layer has been specified, the results will be stored in a folder called ``global``, as it 52 | is the classification layer that is always computed and only considers all valid pixels. 53 | 54 | .. note:: 55 | Please notice that some data may be missing if it has not been computed for the classification layer (ie. intersection maps are only computed under certain conditions :ref:`modes`). 56 | -------------------------------------------------------------------------------- /notebooks/data/gironde/FinalWaveBathymetry_T30TXR_20200622T105631_D_MSL_invert.TIF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/notebooks/data/gironde/FinalWaveBathymetry_T30TXR_20200622T105631_D_MSL_invert.TIF -------------------------------------------------------------------------------- /notebooks/data/gironde/Gironde.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/notebooks/data/gironde/Gironde.tif -------------------------------------------------------------------------------- /notebooks/data/gironde/ref_status.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/notebooks/data/gironde/ref_status.tif -------------------------------------------------------------------------------- /notebooks/data/grenoble/Copernicus_DSM_10_N45_00_E005_00_DEM.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/notebooks/data/grenoble/Copernicus_DSM_10_N45_00_E005_00_DEM.tif -------------------------------------------------------------------------------- /notebooks/data/grenoble/Copernicus_blurred_and_shifted.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/notebooks/data/grenoble/Copernicus_blurred_and_shifted.tif -------------------------------------------------------------------------------- /notebooks/data/grenoble/copernicus_status.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/notebooks/data/grenoble/copernicus_status.tif -------------------------------------------------------------------------------- /notebooks/data/srtm/srtm_blurred_and_shifted_res.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/notebooks/data/srtm/srtm_blurred_and_shifted_res.tif -------------------------------------------------------------------------------- /notebooks/data/srtm/srtm_ref.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/notebooks/data/srtm/srtm_ref.tif -------------------------------------------------------------------------------- /notebooks/img/doc_ref.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/notebooks/img/doc_ref.gif -------------------------------------------------------------------------------- /notebooks/img/logo_demcompare.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/notebooks/img/logo_demcompare.png -------------------------------------------------------------------------------- /notebooks/img/schema_coreg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/notebooks/img/schema_coreg.png -------------------------------------------------------------------------------- /notebooks/img/stats_fusion_schema.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/notebooks/img/stats_fusion_schema.png -------------------------------------------------------------------------------- /notebooks/img/stats_input_two_dems.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/notebooks/img/stats_input_two_dems.png -------------------------------------------------------------------------------- /notebooks/snippets/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf8 3 | # 4 | # Copyright (c) 2022 Centre National d'Etudes Spatiales (CNES). 5 | # 6 | # This file is part of demcompare 7 | # (see https://github.com/CNES/demcompare). 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | """ 22 | Demcompare snippets module 23 | """ -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf8 3 | # 4 | # Copyright (c) 2022 Centre National d'Etudes Spatiales (CNES). 5 | # 6 | # This file is part of demcompare 7 | # (see https://github.com/CNES/demcompare). 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | 22 | # pyproject.toml 23 | [build-system] 24 | requires = ["setuptools>=65.5", "wheel", "setuptools_scm[toml]>=6.2"] 25 | build-backend = "setuptools.build_meta" 26 | 27 | [tool.setuptools_scm] 28 | 29 | [tool.black] 30 | # https://github.com/psf/black 31 | line-length = 80 32 | exclude = "(.eggs|.git|.mypy_cache|.nox|.tox|_build|build|dist|venv)" 33 | 34 | [tool.isort] 35 | profile = 'black' 36 | line_length = 80 37 | 38 | [tool.mypy] 39 | explicit_package_bases = true 40 | no_implicit_optional = false 41 | strict_optional = false 42 | allow_redefinition = true 43 | allow_untyped_globals = true 44 | local_partial_types = false 45 | warn_unused_ignores = true 46 | check_untyped_defs = true 47 | ignore_missing_imports = true 48 | disable_error_code = 'attr-defined' 49 | 50 | [[tool.mypy.overrides]] 51 | module = [ 52 | 'setuptools', 53 | 'matplotlib', 54 | 'rasterio', 55 | 'astropy', 56 | ] 57 | ignore_missing_imports = true -------------------------------------------------------------------------------- /pytest.ini: -------------------------------------------------------------------------------- 1 | # content of pytest.ini 2 | [pytest] 3 | log_cli = 0 4 | log_cli_level = WARNING 5 | log_cli_date_format=%y-%m-%d %H:%M:%S 6 | log_cli_format=%(asctime)s :: %(levelname)s :: %(message)s 7 | addopts = -ra 8 | markers = 9 | unit_tests: Unit tests 10 | end2end_tests: End2end tests 11 | notebook_tests : notebook test 12 | functional_tests : functional test 13 | testpaths = tests 14 | norecursedirs = .git doc conf .gitlab 15 | # filterwarnings: put warnings as errors for CI/CD, see tests marks examples to ignore pytest warnings if needed. 16 | filterwarnings = 17 | error 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /report/FinalWaveBathymetry_T30TXR_20200622T105631_D_MSL_invert.TIF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/report/FinalWaveBathymetry_T30TXR_20200622T105631_D_MSL_invert.TIF -------------------------------------------------------------------------------- /report/FinalWaveBathymetry_T30TXR_20200622T105631_Status.TIF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/report/FinalWaveBathymetry_T30TXR_20200622T105631_Status.TIF -------------------------------------------------------------------------------- /report/Gironde.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/report/Gironde.tif -------------------------------------------------------------------------------- /report/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf8 3 | # 4 | # Copyright (c) 2022 Centre National d'Etudes Spatiales (CNES). 5 | # 6 | # This file is part of demcompare 7 | # (see https://github.com/CNES/demcompare). 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | """ 22 | Demcompare report module 23 | """ -------------------------------------------------------------------------------- /report/assets/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf8 3 | # 4 | # Copyright (c) 2022 Centre National d'Etudes Spatiales (CNES). 5 | # 6 | # This file is part of demcompare 7 | # (see https://github.com/CNES/demcompare). 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | """ 22 | Init file for assets 23 | """ 24 | -------------------------------------------------------------------------------- /report/config_report.json: -------------------------------------------------------------------------------- 1 | { 2 | "output_dir": "./full_outputs", 3 | "input_ref": { 4 | "path": "Gironde.tif", 5 | "zunit": "m" 6 | }, 7 | "input_sec": { 8 | "path": "FinalWaveBathymetry_T30TXR_20200622T105631_D_MSL_invert.TIF", 9 | "zunit": "m", 10 | "nodata": -32768, 11 | "classification_layers": { 12 | "Status": { 13 | "map_path": "FinalWaveBathymetry_T30TXR_20200622T105631_Status.TIF" 14 | } 15 | } 16 | }, 17 | "coregistration": { 18 | "method_name": "nuth_kaab_internal", 19 | "number_of_iterations": 6, 20 | "estimated_initial_shift_x": 0, 21 | "estimated_initial_shift_y": 0, 22 | "save_optional_outputs": true 23 | }, 24 | "statistics": { 25 | "alti-diff": { 26 | "remove_outliers": false, 27 | "classification_layers": { 28 | "Status": { 29 | "type": "segmentation", 30 | "classes": { 31 | "valid": [ 32 | 0 33 | ], 34 | "KO": [ 35 | 1 36 | ], 37 | "Land": [ 38 | 2 39 | ], 40 | "NoData": [ 41 | 3 42 | ], 43 | "Outside_detector": [ 44 | 4 45 | ] 46 | } 47 | }, 48 | "Slope0": { 49 | "type": "slope", 50 | "ranges": [ 51 | 0, 52 | 10, 53 | 25, 54 | 50, 55 | 90 56 | ] 57 | }, 58 | "Fusion0": { 59 | "type": "fusion", 60 | "sec": [ 61 | "Slope0", 62 | "Status" 63 | ] 64 | } 65 | } 66 | } 67 | } 68 | } -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 Centre National d'Etudes Spatiales (CNES). 2 | # 3 | # This file is part of demcompare 4 | # (see https://github.com/CNES/demcompare). 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | # Demcompare setup configuration file 20 | 21 | # package setup main metadata 22 | [metadata] 23 | name = demcompare 24 | author = CNES 25 | author_email = cars@cnes.fr 26 | url = https://github.com/CNES/demcompare 27 | description = A tool to compare Digital Elevation Models 28 | long_description = file:README.md 29 | long_description_content_type = text/markdown 30 | license = Apache License 2.0 31 | license_files = LICENSE 32 | platform = any 33 | keywords= demcompare,3D,DEM,cars,pandora, photogrammetry 34 | classifiers = 35 | Development Status :: 4 - Beta 36 | Intended Audience :: Developers 37 | Intended Audience :: End Users/Desktop 38 | Intended Audience :: Science/Research 39 | Environment :: Console 40 | Topic :: Software Development :: Libraries :: Python Modules 41 | License :: OSI Approved :: Apache Software License 42 | Operating System :: OS Independent 43 | Programming Language :: Python 44 | Programming Language :: Python :: 3.8 45 | 46 | [options] 47 | python_requires = >=3.8 48 | 49 | setup_requires = 50 | setuptools>=65.5 51 | setuptools_scm[toml]>=6.2 # Following https://pypi.org/project/setuptools-scm/ 52 | wheel 53 | 54 | # demcompare packages dependencies 55 | install_requires = 56 | numpy 57 | matplotlib>=3.5.1 58 | xarray>=0.13.0 59 | pyarrow # bug pandas in xarray with tests 60 | scipy!=1.10.0 61 | rasterio 62 | pyproj 63 | astropy 64 | sphinx 65 | lib_programname 66 | argcomplete 67 | json_checker 68 | dash_bootstrap_components 69 | 70 | package_dir = 71 | . = demcompare 72 | packages = find: 73 | 74 | [options.extras_require] 75 | dev = 76 | pre-commit 77 | isort>=5.8.0 # Check imports 78 | black[jupyter]>=21.5b0 # PEP8 format code 79 | flake8>=3.9.1 # General linter 80 | flake8-comprehensions>=3.4.0 # Check list/dict/set 81 | flake8-bugbear>=21.4.3 # Add some rules to flake8 82 | pylint!=3.2.4 # General linter 83 | setuptools_scm # versions from git tag 84 | virtualenv 85 | twine # for pypi upload 86 | build 87 | pytest 88 | pytest-cov 89 | pytest-sugar 90 | tox 91 | mypy 92 | 93 | docs = 94 | sphinx>=4.3.0 95 | sphinx_rtd_theme>=0.5.1 96 | sphinx_autoapi 97 | sphinx_tabs 98 | 99 | notebook = 100 | bokeh 101 | matplotlib 102 | notebook 103 | tabulate 104 | jupyter_dash 105 | 106 | [options.package_data] 107 | demcompare = geoid/*.gtx, logging.json 108 | 109 | # demcompare entry points cli scripts 110 | # demcompare : main cli Program 111 | [options.entry_points] 112 | console_scripts = 113 | demcompare = demcompare.demcompare:main 114 | demcompare-tiles = demcompare.demcompare_tiles:main 115 | 116 | # Specify no universal wheel supported (only Python3) 117 | [bdist_wheel] 118 | universal = false 119 | 120 | # Flake8 configuration 121 | [flake8] 122 | exclude = .git, venv, build, dist, tests/test_output, 123 | # Add flake8 ignored rules 124 | ignore = 125 | # from black compatibility 126 | extend-ignore = E203, W503 127 | max-complexity = 15 128 | max-line-length = 80 129 | #show-source = true 130 | # errors types are not selected by default, so add them to your selection 131 | select = E,F,W,C,B9,C4,B 132 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf8 3 | # 4 | # Copyright (c) 2022 Centre National d'Etudes Spatiales (CNES). 5 | # 6 | # This file is part of demcompare 7 | # (see https://github.com/CNES/demcompare). 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | """ 22 | Packaging setup.py for compatibility 23 | All packaging in setup.cfg, except setuptools_scm version activation 24 | """ 25 | 26 | from setuptools import setup 27 | 28 | try: 29 | setup() 30 | except Exception: 31 | print( 32 | "\n\nAn error occurred while building the project, " 33 | "please ensure you have the most updated version of setuptools, " 34 | "setuptools_scm and wheel with:\n" 35 | " pip install -U setuptools setuptools_scm wheel\n\n" 36 | ) 37 | raise 38 | -------------------------------------------------------------------------------- /sonar-project.properties: -------------------------------------------------------------------------------- 1 | # unique project identifier (required) 2 | sonar.projectKey=cars:demcompare 3 | 4 | # project metadata 5 | sonar.projectName=Demcompare 6 | 7 | # path to source directories (required) 8 | sonar.sources=demcompare/ 9 | 10 | # path to test source directories (optional) 11 | sonar.tests=tests/ 12 | 13 | # exclude files or directories 14 | #sonar.exclusions=src/ 15 | #sonar.test.exclusions=test.xml 16 | 17 | # path to pylint analysis report (optional) 18 | sonar.python.pylint.reportPath=pylint-report.txt 19 | 20 | # path to pytest report (optional) 21 | sonar.python.xunit.reportPath=pytest-report.xml 22 | 23 | # path to coverage report (optional) 24 | sonar.python.coverage.reportPaths=coverage.xml 25 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf8 3 | # 4 | # Copyright (c) 2022 Centre National d'Etudes Spatiales (CNES). 5 | # 6 | # This file is part of demcompare 7 | # (see https://github.com/CNES/demcompare). 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | """ 21 | Demcompare tests module 22 | """ 23 | -------------------------------------------------------------------------------- /tests/classification_layer/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf8 3 | # 4 | # Copyright (c) 2022 Centre National d'Etudes Spatiales (CNES). 5 | # 6 | # This file is part of demcompare 7 | # (see https://github.com/CNES/demcompare). 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | """ 22 | Demcompare classification_layer tests module 23 | """ 24 | -------------------------------------------------------------------------------- /tests/coregistration/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf8 3 | # 4 | # Copyright (c) 2022 Centre National d'Etudes Spatiales (CNES). 5 | # 6 | # This file is part of demcompare 7 | # (see https://github.com/CNES/demcompare). 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | """ 22 | Demcompare coregistration tests module 23 | """ 24 | -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data/data_description.md: -------------------------------------------------------------------------------- 1 | ## Data description 2 | 3 | The test data **gironde_test_data** folder contains the following elements: 4 | 5 | * **input** folder containing: 6 | * A reference DEM *Gironde.tif* of size 1093x1142 pixels and resolution (-0.0010416, 0.0010416). 7 | * A dem to align *FinalWaveBathymetry_T30TXR_20200622T105631_D_MSL_invert.TIF.tif* of size 218x218 pixels and resolution (500.00, -500.00). 8 | * A classification layer map named **Status** for the sec**FinalWaveBathymetry_T30TXR_20200622T105631_Status.TIF* of size 218x218 pixels and resolution (500.00, -500.00). 9 | * *test_config.json* : input configuration file to run demcompare on the input dems with *nuth_kaab_internal* and the default *sampling_source* (*sec*). 10 | * **ref_output** folder containing: 11 | * *test_config.json* : resulting input configuration file from running demcompare (filled with the defaut parameters when not set). 12 | * *coregistration_results.json*: output results from coregistration and stats. 13 | * *final_dh.tif* and *initial_dh.tif*: initial and final altitude difference DEMs to evaluate the coregistration. 14 | * **coregistration** folder: internal DEMs of the coregistration and output coregistered dem to align (*coreg_SEC.tif*). 15 | * **stats**: one folder for each classification layer (**slope**, **Status** and **fusion_layer**) containing the *.csv* files of the *exclusion/intersection* segmentations and the *support_map.tif* if it is to be tested. 16 | -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data/input/FinalWaveBathymetry_T30TXR_20200622T105631_D_MSL_invert.TIF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/gironde_test_data/input/FinalWaveBathymetry_T30TXR_20200622T105631_D_MSL_invert.TIF -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data/input/FinalWaveBathymetry_T30TXR_20200622T105631_Status.TIF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/gironde_test_data/input/FinalWaveBathymetry_T30TXR_20200622T105631_Status.TIF -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data/input/Gironde.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/gironde_test_data/input/Gironde.tif -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data/input/Small_FinalWaveBathymetry_T30TXR_20200622T105631_Status.TIF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/gironde_test_data/input/Small_FinalWaveBathymetry_T30TXR_20200622T105631_Status.TIF -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data/input/dem_cm.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/gironde_test_data/input/dem_cm.tif -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data/input/reduced_Gironde.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/gironde_test_data/input/reduced_Gironde.tif -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data/input/ref_status.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/gironde_test_data/input/ref_status.tif -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data/input/test_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "output_dir": "./test_classification_layer_output/", 3 | "input_ref": { 4 | "path": "./Gironde.tif", 5 | "zunit": "m" 6 | }, 7 | "input_sec": { 8 | "path": "./FinalWaveBathymetry_T30TXR_20200622T105631_D_MSL_invert.TIF", 9 | "zunit": "m", 10 | "nodata": -32768, 11 | "classification_layers": { 12 | "Status": { 13 | "map_path": "./FinalWaveBathymetry_T30TXR_20200622T105631_Status.TIF" 14 | } 15 | } 16 | }, 17 | "coregistration": { 18 | "method_name": "nuth_kaab_internal", 19 | "number_of_iterations": 6, 20 | "estimated_initial_shift_x": 0, 21 | "estimated_initial_shift_y": 0 22 | }, 23 | "statistics": { 24 | "alti-diff": { 25 | "remove_outliers": false, 26 | "classification_layers": { 27 | "Status": { 28 | "type": "segmentation", 29 | "classes": { 30 | "valid": [ 31 | 0 32 | ], 33 | "KO": [ 34 | 1 35 | ], 36 | "Land": [ 37 | 2 38 | ], 39 | "NoData": [ 40 | 3 41 | ], 42 | "Outside_detector": [ 43 | 4 44 | ] 45 | } 46 | }, 47 | "Slope0": { 48 | "type": "slope", 49 | "ranges": [ 50 | 0, 51 | 10, 52 | 25, 53 | 50, 54 | 90 55 | ] 56 | }, 57 | "Fusion0": { 58 | "type": "fusion", 59 | "sec": [ 60 | "Slope0", 61 | "Status" 62 | ] 63 | } 64 | } 65 | } 66 | } 67 | } -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data/input/test_config_ref_status.json: -------------------------------------------------------------------------------- 1 | { 2 | "output_dir": "./test_classification_layer_output/", 3 | "input_ref": { 4 | "path": "Gironde.tif", 5 | "zunit": "m", 6 | "classification_layers": { 7 | "Status": { 8 | "map_path": "ref_status.tif" 9 | } 10 | } 11 | }, 12 | "input_sec": { 13 | "path": "./FinalWaveBathymetry_T30TXR_20200622T105631_D_MSL_invert.TIF", 14 | "zunit": "m", 15 | "nodata": -32768 16 | }, 17 | "coregistration": { 18 | "method_name": "nuth_kaab_internal", 19 | "number_of_iterations": 6, 20 | "estimated_initial_shift_x": 0, 21 | "estimated_initial_shift_y": 0 22 | }, 23 | "statistics": { 24 | "alti-diff": { 25 | "remove_outliers": false, 26 | "classification_layers": { 27 | "Status": { 28 | "type": "segmentation", 29 | "classes": { 30 | "sea": [ 31 | 0 32 | ], 33 | "deep_land": [ 34 | 1 35 | ], 36 | "coast": [ 37 | 2 38 | ] 39 | } 40 | }, 41 | "Slope0": { 42 | "type": "slope", 43 | "ranges": [ 44 | 0, 45 | 10, 46 | 25, 47 | 50, 48 | 90 49 | ] 50 | }, 51 | "Fusion0": { 52 | "type": "fusion", 53 | "ref": [ 54 | "Slope0", 55 | "Status" 56 | ] 57 | } 58 | } 59 | } 60 | } 61 | } -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data/ref_output/coregistration/coreg_SEC.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/gironde_test_data/ref_output/coregistration/coreg_SEC.tif -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data/ref_output/coregistration/coregistration_results.json: -------------------------------------------------------------------------------- 1 | { 2 | "coregistration_results": { 3 | "reproj_coreg_ref": { 4 | "path": "TO/PATH/demcompare/test_output/coregistration/reproj_coreg_REF.tif", 5 | "nodata": -32768, 6 | "nb_points": 35422, 7 | "nb_valid_points": 34057 8 | }, 9 | "reproj_coreg_sec": { 10 | "path": "TO/PATH/demcompare/test_output/coregistration/reproj_coreg_SEC.tif", 11 | "nodata": -32768, 12 | "nb_points": 35422, 13 | "nb_valid_points": 10364 14 | }, 15 | "dz": { 16 | "total_bias_value": -3.40256, 17 | "unit_bias_value": "m", 18 | "percent": 28.7025, 19 | "nodata": -32768, 20 | "nb_points": 35422, 21 | "nb_valid_points": 10167 22 | }, 23 | "dx": { 24 | "nuth_offset": -1.43664, 25 | "total_offset": -1.43664, 26 | "unit_offset": "px", 27 | "total_bias_value": -718.31906, 28 | "unit_bias_value": "m" 29 | }, 30 | "dy": { 31 | "nuth_offset": -0.41903, 32 | "total_offset": -0.41903, 33 | "unit_offset": "px", 34 | "total_bias_value": -209.51619, 35 | "unit_bias_value": "m" 36 | }, 37 | "gdal_translate_bounds": { 38 | "ulx": 599536.68093, 39 | "uly": 5099954.51619, 40 | "lrx": 708536.68093, 41 | "lry": 4990954.51619 42 | } 43 | }, 44 | "stats_results": { 45 | "images": { 46 | "list": [ 47 | "row_wise", 48 | "col_wise" 49 | ], 50 | "row_wise": { 51 | "path": "TO/PATH/demcompare/test_output/dh_row_wise_wave_detection.tif", 52 | "zunit": "m", 53 | "nodata": -32768, 54 | "nb_valid_points": 10167 55 | }, 56 | "col_wise": { 57 | "path": "TO/PATH/demcompare/test_output/dh_col_wise_wave_detection.tif", 58 | "zunit": "m", 59 | "nodata": -32768, 60 | "nb_valid_points": 10167 61 | } 62 | }, 63 | "classification_layer_masks": { 64 | "Slope0": { 65 | "standard": { 66 | "ref_support": { 67 | "nodata": -32768.0, 68 | "path": "TO/PATH/demcompare/test_output/stats/Slope0/ref_support_map.tif" 69 | }, 70 | "sec_support": { 71 | "nodata": -32768.0, 72 | "path": "TO/PATH/demcompare/test_output/stats/Slope0/sec_support_map.tif" 73 | } 74 | } 75 | }, 76 | "Status": { 77 | "standard": { 78 | "sec_support": { 79 | "nodata": -32768.0, 80 | "path": "TO/PATH/demcompare/demcompare/tests/data/gironde_test_data/input/FinalWaveBathymetry_T30TXR_20200622T105631_Status.TIF" 81 | } 82 | } 83 | }, 84 | "fusion_layer": { 85 | "standard": { 86 | "sec_support": { 87 | "nodata": -32768.0, 88 | "path": "TO/PATH/demcompare/test_output/stats/fusion_layer/sec_fusion_layer.tif" 89 | } 90 | } 91 | } 92 | } 93 | } 94 | } -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data/ref_output/coregistration/reproj_coreg_REF.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/gironde_test_data/ref_output/coregistration/reproj_coreg_REF.tif -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data/ref_output/coregistration/reproj_coreg_SEC.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/gironde_test_data/ref_output/coregistration/reproj_coreg_SEC.tif -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data/ref_output/initial_dem_diff.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/gironde_test_data/ref_output/initial_dem_diff.tif -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data/ref_output/stats/alti-diff/Fusion0/sec_rectified_support_map.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/gironde_test_data/ref_output/stats/alti-diff/Fusion0/sec_rectified_support_map.tif -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data/ref_output/stats/alti-diff/Fusion0/stats_results.csv: -------------------------------------------------------------------------------- 1 | "Set Name","mean","median","max","min","sum","percentil_90","squared_sum","nmad","rmse","std","nbpts","percent_valid_points" 2 | "Slope0_[0%;10%[_&_Status_valid:1",1.32648,1.91784,58.27498,-36.03861,1306.58569,12.44713,68871.8125,4.58626,8.36186,8.25597,985,2.78076 3 | "Slope0_[0%;10%[_&_Status_KO:2",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 4 | "Slope0_[0%;10%[_&_Status_Land:3",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 5 | "Slope0_[0%;10%[_&_Status_NoData:4",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 6 | "Slope0_[0%;10%[_&_Status_Outside_detector:5",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 7 | "Slope0_[10%;25%[_&_Status_valid:6",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 8 | "Slope0_[10%;25%[_&_Status_KO:7",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 9 | "Slope0_[10%;25%[_&_Status_Land:8",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 10 | "Slope0_[10%;25%[_&_Status_NoData:9",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 11 | "Slope0_[10%;25%[_&_Status_Outside_detector:10",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 12 | "Slope0_[25%;50%[_&_Status_valid:11",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 13 | "Slope0_[25%;50%[_&_Status_KO:12",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 14 | "Slope0_[25%;50%[_&_Status_Land:13",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 15 | "Slope0_[25%;50%[_&_Status_NoData:14",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 16 | "Slope0_[25%;50%[_&_Status_Outside_detector:15",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 17 | "Slope0_[50%;90%[_&_Status_valid:16",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 18 | "Slope0_[50%;90%[_&_Status_KO:17",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 19 | "Slope0_[50%;90%[_&_Status_Land:18",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 20 | "Slope0_[50%;90%[_&_Status_NoData:19",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 21 | "Slope0_[50%;90%[_&_Status_Outside_detector:20",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 22 | "Slope0_[90%;inf[_&_Status_valid:21",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 23 | "Slope0_[90%;inf[_&_Status_KO:22",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 24 | "Slope0_[90%;inf[_&_Status_Land:23",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 25 | "Slope0_[90%;inf[_&_Status_NoData:24",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 26 | "Slope0_[90%;inf[_&_Status_Outside_detector:25",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 27 | -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data/ref_output/stats/alti-diff/Slope0/ref_rectified_support_map.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/gironde_test_data/ref_output/stats/alti-diff/Slope0/ref_rectified_support_map.tif -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data/ref_output/stats/alti-diff/Slope0/sec_rectified_support_map.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/gironde_test_data/ref_output/stats/alti-diff/Slope0/sec_rectified_support_map.tif -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data/ref_output/stats/alti-diff/Slope0/stats_results.csv: -------------------------------------------------------------------------------- 1 | "Set Name","mean","median","max","min","sum","percentil_90","squared_sum","nmad","rmse","std","nbpts","percent_valid_points" 2 | "[0%;10%[:0",-3.46984,-1.28035,100.99401,-56.72004,-35114.75781,25.70998,2460827.5,10.53829,15.59374,15.2028,10120,28.56982 3 | "[10%;25%[:10",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 4 | "[25%;50%[:25",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 5 | "[50%;90%[:50",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 6 | "[90%;inf[:90",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 7 | -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data/ref_output/stats/alti-diff/Slope0/stats_results_intersection.csv: -------------------------------------------------------------------------------- 1 | "Set Name","mean","median","max","min","sum","percentil_90","squared_sum","nmad","rmse","std","nbpts","percent_valid_points" 2 | "[0%;10%[:0",1.29293,1.89064,58.27498,-36.03861,1268.36646,12.36407,68430.46875,4.54593,8.352,8.25131,981,2.76947 3 | "[10%;25%[:10",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 4 | "[25%;50%[:25",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 5 | "[50%;90%[:50",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 6 | "[90%;inf[:90",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 7 | -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data/ref_output/stats/alti-diff/Status/sec_rectified_support_map.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/gironde_test_data/ref_output/stats/alti-diff/Status/sec_rectified_support_map.tif -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data/ref_output/stats/alti-diff/Status/stats_results.csv: -------------------------------------------------------------------------------- 1 | "Set Name","mean","median","max","min","sum","percentil_90","squared_sum","nmad","rmse","std","nbpts","percent_valid_points" 2 | "valid:[0]",-3.40256,-1.23687,100.99401,-56.72004,-34593.86328,25.78921,2480901.5,10.59014,15.62098,15.24591,10167,28.7025 3 | "KO:[1]",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 4 | "Land:[2]",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 5 | "NoData:[3]",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 6 | "Outside_detector:[4]",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 7 | -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data/ref_output/stats/alti-diff/dem_for_stats.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/gironde_test_data/ref_output/stats/alti-diff/dem_for_stats.tif -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data/ref_output/stats/alti-diff/global/stats_results.csv: -------------------------------------------------------------------------------- 1 | "Set Name","nbpts","percent_valid_points","mean","median","max","min","sum","percentil_90","squared_sum","nmad","rmse","std" 2 | "global:[1]",10167,28.7025,-3.40256,-1.23687,100.99401,-56.72004,-34593.86328,25.78921,2480901.5,10.59014,15.62098,15.24591 3 | -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data/ref_output/stats/dh_col_wise_wave_detection.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/gironde_test_data/ref_output/stats/dh_col_wise_wave_detection.tif -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data/ref_output/stats/dh_row_wise_wave_detection.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/gironde_test_data/ref_output/stats/dh_row_wise_wave_detection.tif -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data/ref_output/test_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "output_dir": "./test_classification_layer_output/", 3 | "input_ref": { 4 | "path": "./Gironde.tif", 5 | "zunit": "m" 6 | }, 7 | "input_sec": { 8 | "path": "./FinalWaveBathymetry_T30TXR_20200622T105631_D_MSL_invert.TIF", 9 | "zunit": "m", 10 | "nodata": -32768, 11 | "classification_layers": { 12 | "Status": { 13 | "map_path": "./FinalWaveBathymetry_T30TXR_20200622T105631_Status.TIF" 14 | } 15 | } 16 | }, 17 | "coregistration": { 18 | "method_name": "nuth_kaab_internal", 19 | "number_of_iterations": 6, 20 | "estimated_initial_shift_x": 0, 21 | "estimated_initial_shift_y": 0, 22 | "save_optional_outputs": true 23 | }, 24 | "statistics": { 25 | "alti-diff": { 26 | "remove_outliers": false, 27 | "classification_layers": { 28 | "Status": { 29 | "type": "segmentation", 30 | "sec": "./FinalWaveBathymetry_T30TXR_20200622T105631_Status.TIF", 31 | "classes": { 32 | "valid": [ 33 | 0 34 | ], 35 | "KO": [ 36 | 1 37 | ], 38 | "Land": [ 39 | 2 40 | ], 41 | "NoData": [ 42 | 3 43 | ], 44 | "Outside_detector": [ 45 | 4 46 | ] 47 | } 48 | } 49 | } 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data/ref_output_same_dem/coregistration/coreg_SEC.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/gironde_test_data/ref_output_same_dem/coregistration/coreg_SEC.tif -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data/ref_output_same_dem/coregistration/coregistration_results.json: -------------------------------------------------------------------------------- 1 | { 2 | "coregistration_results": { 3 | "reproj_coreg_ref": { 4 | "path": "./test_classification_layer_output/./coregistration/reproj_coreg_REF.tif", 5 | "nodata": -32768, 6 | "nb_points": 1248206, 7 | "nb_valid_points": 1248206 8 | }, 9 | "reproj_coreg_sec": { 10 | "path": "./test_classification_layer_output/./coregistration/reproj_coreg_SEC.tif", 11 | "nodata": -32768, 12 | "nb_points": 1248206, 13 | "nb_valid_points": 1248206 14 | }, 15 | "dz": { 16 | "total_bias_value": 0.0, 17 | "unit_bias_value": "m", 18 | "percent": 100.0, 19 | "nodata": -32768, 20 | "nb_points": 1248206, 21 | "nb_valid_points": 1248206 22 | }, 23 | "dx": { 24 | "total_offset": 0.0, 25 | "unit_offset": "px", 26 | "total_bias_value": 0.0, 27 | "unit_bias_value": "m", 28 | "nuth_offset": 0.0 29 | }, 30 | "dy": { 31 | "total_offset": 0.0, 32 | "unit_offset": "px", 33 | "total_bias_value": 0.0, 34 | "unit_bias_value": "m", 35 | "nuth_offset": -0.0 36 | }, 37 | "gdal_translate_bounds": { 38 | "ulx": -1.74139, 39 | "uly": 45.93948, 40 | "lrx": -0.60285, 41 | "lry": 44.7499 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data/ref_output_same_dem/coregistration/reproj_coreg_REF.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/gironde_test_data/ref_output_same_dem/coregistration/reproj_coreg_REF.tif -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data/ref_output_same_dem/coregistration/reproj_coreg_SEC.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/gironde_test_data/ref_output_same_dem/coregistration/reproj_coreg_SEC.tif -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data/ref_output_same_dem/initial_dem_diff.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/gironde_test_data/ref_output_same_dem/initial_dem_diff.tif -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data/ref_output_same_dem/stats/alti-diff/Fusion0/ref_rectified_support_map.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/gironde_test_data/ref_output_same_dem/stats/alti-diff/Fusion0/ref_rectified_support_map.tif -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data/ref_output_same_dem/stats/alti-diff/Fusion0/stats_results.csv: -------------------------------------------------------------------------------- 1 | "Set Name","mean","median","max","min","sum","percentil_90","squared_sum","nmad","rmse","std","nbpts","percent_valid_points" 2 | "Slope0_[0%;10%[_&_Status_sea:1",0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,584673,46.84107 3 | "Slope0_[0%;10%[_&_Status_deep_land:2",0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,389196,31.18043 4 | "Slope0_[0%;10%[_&_Status_coast:3",0.0,0.0,0.0,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,267565,21.43596 5 | "Slope0_[10%;25%[_&_Status_sea:4",0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,3958,0.3171 6 | "Slope0_[10%;25%[_&_Status_deep_land:5",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 7 | "Slope0_[10%;25%[_&_Status_coast:6",0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,56,0.00449 8 | "Slope0_[25%;50%[_&_Status_sea:7",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 9 | "Slope0_[25%;50%[_&_Status_deep_land:8",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 10 | "Slope0_[25%;50%[_&_Status_coast:9",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 11 | "Slope0_[50%;90%[_&_Status_sea:10",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 12 | "Slope0_[50%;90%[_&_Status_deep_land:11",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 13 | "Slope0_[50%;90%[_&_Status_coast:12",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 14 | "Slope0_[90%;inf[_&_Status_sea:13",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 15 | "Slope0_[90%;inf[_&_Status_deep_land:14",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 16 | "Slope0_[90%;inf[_&_Status_coast:15",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 17 | -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data/ref_output_same_dem/stats/alti-diff/Slope0/ref_rectified_support_map.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/gironde_test_data/ref_output_same_dem/stats/alti-diff/Slope0/ref_rectified_support_map.tif -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data/ref_output_same_dem/stats/alti-diff/Slope0/sec_rectified_support_map.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/gironde_test_data/ref_output_same_dem/stats/alti-diff/Slope0/sec_rectified_support_map.tif -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data/ref_output_same_dem/stats/alti-diff/Slope0/stats_results.csv: -------------------------------------------------------------------------------- 1 | "Set Name","mean","median","max","min","sum","percentil_90","squared_sum","nmad","rmse","std","nbpts","percent_valid_points" 2 | "[0%;10%[:0",0.0,0.0,0.0,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,1244149,99.67497 3 | "[10%;25%[:10",0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,4057,0.32503 4 | "[25%;50%[:25",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 5 | "[50%;90%[:50",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 6 | "[90%;inf[:90",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 7 | -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data/ref_output_same_dem/stats/alti-diff/Slope0/stats_results_intersection.csv: -------------------------------------------------------------------------------- 1 | "Set Name","mean","median","max","min","sum","percentil_90","squared_sum","nmad","rmse","std","nbpts","percent_valid_points" 2 | "[0%;10%[:0",0.0,0.0,0.0,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,1244149,99.67497 3 | "[10%;25%[:10",0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,4057,0.32503 4 | "[25%;50%[:25",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 5 | "[50%;90%[:50",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 6 | "[90%;inf[:90",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 7 | -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data/ref_output_same_dem/stats/alti-diff/Status/sec_rectified_support_map.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/gironde_test_data/ref_output_same_dem/stats/alti-diff/Status/sec_rectified_support_map.tif -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data/ref_output_same_dem/stats/alti-diff/Status/stats_results.csv: -------------------------------------------------------------------------------- 1 | "Set Name","mean","median","max","min","sum","percentil_90","squared_sum","nmad","rmse","std","nbpts","percent_valid_points" 2 | "sea:[0]",0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,588631,47.15816 3 | "deep_land:[1]",0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,389196,31.18043 4 | "coast:[2]",0.0,0.0,0.0,-0.0,0.0,0.0,0.0,0.0,0.0,0.0,267621,21.44045 5 | -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data/ref_output_same_dem/stats/alti-diff/dem_for_stats.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/gironde_test_data/ref_output_same_dem/stats/alti-diff/dem_for_stats.tif -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data/ref_output_same_dem/stats/alti-diff/global/stats_results.csv: -------------------------------------------------------------------------------- 1 | "Set Name","nbpts","percent_valid_points","mean","median","max","min","sum","percentil_90","squared_sum","nmad","rmse","std" 2 | "global:[1]",1248206,100.0,0.0,0.0,0.0,-0.0,0.0,0.0,0.0,0.0,0.0,0.0 3 | -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data/ref_output_same_dem/test_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "output_dir": "./test_classification_layer_output", 3 | "input_ref": { 4 | "path": "./Gironde.tif", 5 | "zunit": "m", 6 | "classification_layers": { 7 | "Status": { 8 | "map_path": "./ref_status.tif" 9 | } 10 | } 11 | }, 12 | "input_sec": { 13 | "path": "./Gironde.tif", 14 | "zunit": "m", 15 | "classification_layers": { 16 | "Status": { 17 | "map_path": "./ref_status.tif" 18 | } 19 | } 20 | }, 21 | "coregistration": { 22 | "method_name": "nuth_kaab_internal", 23 | "number_of_iterations": 6, 24 | "estimated_initial_shift_x": 0, 25 | "estimated_initial_shift_y": 0, 26 | "save_optional_outputs": true, 27 | "output_dir": "./test_classification_layer_output/coregistration" 28 | }, 29 | "statistics": { 30 | "alti-diff": { 31 | "remove_outliers": false, 32 | "classification_layers": { 33 | "Status": { 34 | "type": "segmentation", 35 | "classes": { 36 | "sea": [ 37 | 0 38 | ], 39 | "deep_land": [ 40 | 1 41 | ], 42 | "coast": [ 43 | 2 44 | ] 45 | } 46 | }, 47 | "Slope0": { 48 | "type": "slope", 49 | "ranges": [ 50 | 0, 51 | 10, 52 | 25, 53 | 50, 54 | 90 55 | ] 56 | }, 57 | "Fusion0": { 58 | "type": "fusion", 59 | "ref": [ 60 | "Slope0", 61 | "Status" 62 | ] 63 | } 64 | }, 65 | "output_dir": "./test_classification_layer_output" 66 | } 67 | } 68 | } -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data_sampling_ref/data_description.md: -------------------------------------------------------------------------------- 1 | ## Data description 2 | 3 | The test data **classification_layer_sampling_ref** folder contains the following elements: 4 | 5 | * **input** folder containing: 6 | * A reference DEM *Gironde.tif* of size 1093x1142 pixels and resolution (-0.0010416, 0.0010416). 7 | * A dem to align *FinalWaveBathymetry_T30TXR_20200622T105631_D_MSL_invert.TIF.tif* of size 218x218 pixels and resolution (500.00, -500.00). 8 | * A classification layer map named **Status** for the sec**FinalWaveBathymetry_T30TXR_20200622T105631_Status.TIF* of size 218x218 pixels and resolution (500.00, -500.00). 9 | * *test_config.json* : input configuration file to run demcompare on the input dems with *nuth_kaab_internal* and a *sampling_source = ref*. 10 | * **ref_output** folder containing: 11 | * *test_config.json* : resulting input configuration file from running demcompare (filled with the defaut parameters when not set). 12 | * *coregistration_results.json*: output results from coregistration and stats. 13 | * *final_dh.tif* and *initial_dh.tif*: initial and final altitude difference DEMs to evaluate the coregistration. 14 | * **coregistration** folder: internal DEMs of the coregistration and output coregistered dem to align (*coreg_SEC.tif*). 15 | * **stats**: one folder for each classification layer (**slope**, **Status** and **fusion_layer**) containing the *.csv* files of the *exclusion/intersection* segmentations and the *support_map.tif* if it is to be tested. 16 | -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data_sampling_ref/input/FinalWaveBathymetry_T30TXR_20200622T105631_D_MSL_invert.TIF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/gironde_test_data_sampling_ref/input/FinalWaveBathymetry_T30TXR_20200622T105631_D_MSL_invert.TIF -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data_sampling_ref/input/Gironde.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/gironde_test_data_sampling_ref/input/Gironde.tif -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data_sampling_ref/input/ref_status.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/gironde_test_data_sampling_ref/input/ref_status.tif -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data_sampling_ref/input/test_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "output_dir": "./test_classification_layer_output/", 3 | "input_ref": { 4 | "path": "./Gironde.tif", 5 | "zunit": "m", 6 | "classification_layers": { 7 | "Status": { 8 | "map_path": "./ref_status.tif" 9 | } 10 | } 11 | }, 12 | "input_sec": { 13 | "path": "./FinalWaveBathymetry_T30TXR_20200622T105631_D_MSL_invert.TIF", 14 | "zunit": "m", 15 | "nodata": -32768 16 | }, 17 | "coregistration": { 18 | "sampling_source": "ref", 19 | "method_name": "nuth_kaab_internal", 20 | "number_of_iterations": 6, 21 | "estimated_initial_shift_x": 0, 22 | "estimated_initial_shift_y": 0 23 | }, 24 | "statistics": { 25 | "alti-diff": { 26 | "remove_outliers": false, 27 | "classification_layers": { 28 | "Status": { 29 | "type": "segmentation", 30 | "classes": { 31 | "sea": [ 32 | 0 33 | ], 34 | "deep_land": [ 35 | 1 36 | ], 37 | "coast": [ 38 | 2 39 | ] 40 | } 41 | }, 42 | "Slope0": { 43 | "type": "slope", 44 | "ranges": [ 45 | 0, 46 | 10, 47 | 25, 48 | 50, 49 | 90 50 | ] 51 | }, 52 | "Fusion0": { 53 | "type": "fusion", 54 | "ref": [ 55 | "Slope0", 56 | "Status" 57 | ] 58 | } 59 | } 60 | } 61 | } 62 | } -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data_sampling_ref/ref_output/coregistration/coreg_SEC.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/gironde_test_data_sampling_ref/ref_output/coregistration/coreg_SEC.tif -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data_sampling_ref/ref_output/coregistration/coregistration_results.json: -------------------------------------------------------------------------------- 1 | { 2 | "coregistration_results": { 3 | "reproj_coreg_ref": { 4 | "path": "TO/PATH/demcompare/test_output/coregistration/reproj_coreg_REF.tif", 5 | "nodata": -32768, 6 | "nb_points": 927936, 7 | "nb_valid_points": 927936 8 | }, 9 | "reproj_coreg_sec": { 10 | "path": "TO/PATH/demcompare/test_output/coregistration/reproj_coreg_SEC.tif", 11 | "nodata": -32768, 12 | "nb_points": 927936, 13 | "nb_valid_points": 85312 14 | }, 15 | "dz": { 16 | "total_bias_value": -0.53005, 17 | "unit_bias_value": "m", 18 | "percent": 9.19374, 19 | "nodata": -32768, 20 | "nb_points": 927936, 21 | "nb_valid_points": 85312 22 | }, 23 | "dx": { 24 | "nuth_offset": -1.08642, 25 | "total_offset": -1.08642, 26 | "unit_offset": "px", 27 | "total_bias_value": -543.21172, 28 | "unit_bias_value": "m" 29 | }, 30 | "dy": { 31 | "nuth_offset": -0.22552, 32 | "total_offset": -0.22552, 33 | "unit_offset": "px", 34 | "total_bias_value": -112.76041, 35 | "unit_bias_value": "m" 36 | }, 37 | "gdal_translate_bounds": { 38 | "ulx": 599711.78828, 39 | "uly": 5099857.76041, 40 | "lrx": 708711.78828, 41 | "lry": 4990857.76041 42 | } 43 | }, 44 | "stats_results": { 45 | "images": { 46 | "list": [ 47 | "row_wise", 48 | "col_wise" 49 | ], 50 | "row_wise": { 51 | "path": "TO/PATH/demcompare/test_output/dh_row_wise_wave_detection.tif", 52 | "zunit": "m", 53 | "nodata": -32768, 54 | "nb_valid_points": 10167 55 | }, 56 | "col_wise": { 57 | "path": "TO/PATH/demcompare/test_output/dh_col_wise_wave_detection.tif", 58 | "zunit": "m", 59 | "nodata": -32768, 60 | "nb_valid_points": 10167 61 | } 62 | }, 63 | "classification_layer_masks": { 64 | "Slope0": { 65 | "standard": { 66 | "ref_support": { 67 | "nodata": -32768.0, 68 | "path": "TO/PATH/demcompare/test_output/stats/Slope0/ref_support_map.tif" 69 | }, 70 | "sec_support": { 71 | "nodata": -32768.0, 72 | "path": "TO/PATH/demcompare/test_output/stats/Slope0/sec_support_map.tif" 73 | } 74 | } 75 | }, 76 | "Status": { 77 | "standard": { 78 | "ref_support": { 79 | "nodata": -32768.0, 80 | "path": "TO/PATH/demcompare/demcompare/tests/data/gironde_test_data/input/ref_status.tif" 81 | } 82 | } 83 | }, 84 | "fusion_layer": { 85 | "standard": { 86 | "ref_support": { 87 | "nodata": -32768.0, 88 | "path": "TO/PATH/demcompare/test_output/stats/fusion_layer/sec_fusion_layer.tif" 89 | } 90 | } 91 | } 92 | } 93 | } 94 | } -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data_sampling_ref/ref_output/coregistration/reproj_coreg_REF.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/gironde_test_data_sampling_ref/ref_output/coregistration/reproj_coreg_REF.tif -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data_sampling_ref/ref_output/coregistration/reproj_coreg_SEC.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/gironde_test_data_sampling_ref/ref_output/coregistration/reproj_coreg_SEC.tif -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data_sampling_ref/ref_output/initial_dem_diff.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/gironde_test_data_sampling_ref/ref_output/initial_dem_diff.tif -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data_sampling_ref/ref_output/stats/alti-diff/Fusion0/ref_rectified_support_map.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/gironde_test_data_sampling_ref/ref_output/stats/alti-diff/Fusion0/ref_rectified_support_map.tif -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data_sampling_ref/ref_output/stats/alti-diff/Fusion0/stats_results.csv: -------------------------------------------------------------------------------- 1 | "Set Name","mean","median","max","min","sum","percentil_90","squared_sum","nmad","rmse","std","nbpts","percent_valid_points" 2 | "Slope0_[0%;10%[_&_Status_sea:1",26.05652,25.09911,59.24025,8.23831,50445.42969,12.55843,1443453.25,7.88869,27.30541,8.16352,1936,0.20864 3 | "Slope0_[0%;10%[_&_Status_deep_land:2",-9.87232,-8.50879,16.17525,-50.81603,-293000.5,15.43977,5848462.5,9.92778,14.03771,9.97971,29679,3.19839 4 | "Slope0_[0%;10%[_&_Status_coast:3",3.59373,2.95817,68.16121,-18.42142,188174.67188,9.82811,2965910.75,3.50792,7.52612,6.61268,52362,5.64285 5 | "Slope0_[10%;25%[_&_Status_sea:4",31.96144,29.81546,46.87021,21.69983,639.22888,10.29972,21339.7168,6.48327,32.66475,6.74182,20,0.00216 6 | "Slope0_[10%;25%[_&_Status_deep_land:5",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 7 | "Slope0_[10%;25%[_&_Status_coast:6",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 8 | "Slope0_[25%;50%[_&_Status_sea:7",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 9 | "Slope0_[25%;50%[_&_Status_deep_land:8",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 10 | "Slope0_[25%;50%[_&_Status_coast:9",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 11 | "Slope0_[50%;90%[_&_Status_sea:10",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 12 | "Slope0_[50%;90%[_&_Status_deep_land:11",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 13 | "Slope0_[50%;90%[_&_Status_coast:12",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 14 | "Slope0_[90%;inf[_&_Status_sea:13",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 15 | "Slope0_[90%;inf[_&_Status_deep_land:14",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 16 | "Slope0_[90%;inf[_&_Status_coast:15",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 17 | -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data_sampling_ref/ref_output/stats/alti-diff/Slope0/ref_rectified_support_map.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/gironde_test_data_sampling_ref/ref_output/stats/alti-diff/Slope0/ref_rectified_support_map.tif -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data_sampling_ref/ref_output/stats/alti-diff/Slope0/sec_rectified_support_map.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/gironde_test_data_sampling_ref/ref_output/stats/alti-diff/Slope0/sec_rectified_support_map.tif -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data_sampling_ref/ref_output/stats/alti-diff/Slope0/stats_results.csv: -------------------------------------------------------------------------------- 1 | "Set Name","mean","median","max","min","sum","percentil_90","squared_sum","nmad","rmse","std","nbpts","percent_valid_points" 2 | "[0%;10%[:0",-0.5408,1.21741,68.16121,-50.81603,-46116.84375,19.74269,10487127.0,6.10316,11.08957,11.07638,85276,9.18986 3 | "[10%;25%[:10",24.92254,26.31802,46.87021,-3.70952,897.2113,16.81604,26825.9375,9.79576,27.29771,11.13698,36,0.00388 4 | "[25%;50%[:25",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 5 | "[50%;90%[:50",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 6 | "[90%;inf[:90",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 7 | -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data_sampling_ref/ref_output/stats/alti-diff/Slope0/stats_results_intersection.csv: -------------------------------------------------------------------------------- 1 | "Set Name","mean","median","max","min","sum","percentil_90","squared_sum","nmad","rmse","std","nbpts","percent_valid_points" 2 | "[0%;10%[:0",0.04807,1.65037,55.3683,-49.06409,2790.38672,17.6937,5895165.0,5.33963,10.07728,10.07716,58051,6.25593 3 | "[10%;25%[:10",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 4 | "[25%;50%[:25",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 5 | "[50%;90%[:50",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 6 | "[90%;inf[:90",nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,0,0.0 7 | -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data_sampling_ref/ref_output/stats/alti-diff/Status/ref_rectified_support_map.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/gironde_test_data_sampling_ref/ref_output/stats/alti-diff/Status/ref_rectified_support_map.tif -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data_sampling_ref/ref_output/stats/alti-diff/Status/stats_results.csv: -------------------------------------------------------------------------------- 1 | "Set Name","mean","median","max","min","sum","percentil_90","squared_sum","nmad","rmse","std","nbpts","percent_valid_points" 2 | "sea:[0]",26.1169,25.21216,59.24025,8.23831,51084.65625,12.59526,1464792.875,7.96016,27.36552,8.17185,1956,0.21079 3 | "deep_land:[1]",-9.87232,-8.50879,16.17525,-50.81603,-293000.5,15.43977,5848462.5,9.92778,14.03771,9.97971,29679,3.19839 4 | "coast:[2]",3.59373,2.95817,68.16121,-18.42142,188174.67188,9.82811,2965910.75,3.50792,7.52612,6.61268,52362,5.64285 5 | -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data_sampling_ref/ref_output/stats/alti-diff/dem_for_stats.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/gironde_test_data_sampling_ref/ref_output/stats/alti-diff/dem_for_stats.tif -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data_sampling_ref/ref_output/stats/alti-diff/global/stats_results.csv: -------------------------------------------------------------------------------- 1 | "Set Name","nbpts","percent_valid_points","mean","median","max","min","sum","percentil_90","squared_sum","nmad","rmse","std" 2 | "global:[1]",85312,9.19374,-0.53005,1.21965,68.16121,-50.81603,-45219.63281,19.77699,10513953.0,6.10544,11.10141,11.08874 3 | -------------------------------------------------------------------------------- /tests/data/end_to_end_data/gironde_test_data_sampling_ref/ref_output/test_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "output_dir": "/output/", 3 | "input_ref": { 4 | "path": "/Gironde.tif", 5 | "zunit": "m", 6 | "classification_layers": { 7 | "Status": { 8 | "map_path": "./ref_status.tif" 9 | } 10 | } 11 | }, 12 | "input_sec": { 13 | "path": "/FinalWaveBathymetry_T30TXR_20200622T105631_D_MSL_invert.TIF", 14 | "zunit": "m", 15 | "nodata": -32768 16 | }, 17 | "mode": "coregistration", 18 | "coregistration": { 19 | "sampling_source": "ref", 20 | "method_name": "nuth_kaab_internal", 21 | "number_of_iterations": 6, 22 | "estimated_initial_shift_x": 0, 23 | "estimated_initial_shift_y": 0, 24 | "save_optional_outputs": true 25 | }, 26 | "statistics": { 27 | "alti-diff": { 28 | "remove_outliers": false, 29 | "classification_layers": { 30 | "Status": { 31 | "type": "segmentation", 32 | "ref": "ref_status.tif", 33 | "classes": { 34 | "sea": [ 35 | 0 36 | ], 37 | "deep_land": [ 38 | 1 39 | ], 40 | "coast": [ 41 | 2 42 | ] 43 | } 44 | } 45 | } 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /tests/data/end_to_end_data/srtm_test_data/data_description.md: -------------------------------------------------------------------------------- 1 | ## Data description 2 | 3 | The test data **strm_test_data** folder contains the following elements: 4 | 5 | * **input** folder containing: 6 | * A reference DEM *strm_ref.tif* of size 1000x1000 pixels. 7 | * A dem to align *strm_blurred_and_shifted.tif* that has been manually created by blurring and shifting the reference DEM by (3, 5) pixels. Its size is 997x995 pixels. 8 | * Both reference and dem to align have the same resolution. 9 | * *test_config.json* : input configuration file to run demcompare on the input dems with *nuth_kaab_internal* and the default *sampling_source* (*sec*). 10 | * **ref_output** folder containing: 11 | * *test_config.json* : resulting input configuration file from running demcompare (filled with the defaut parameters when not set). 12 | * *coregistration_results.json*: output results from coregistration and stats. 13 | * *final_dh.tif* and *initial_dh.tif*: initial and final altitude difference DEMs to evaluate the coregistration. 14 | * **coregistration** folder: internal DEMs of the coregistration and output coregistered dem to align (*coreg_SEC.tif*). 15 | * **stats**: contains: 16 | * one folder for each classification layer containing the *.csv* files of the *exclusion/intersection segmentations and the*support_map.tif* if it is to be tested. 17 | * initial and final *.csv* files of the PDF (Probability Density Function) and CDF (Cumulative Density Function) to evaluate the coregistration. 18 | -------------------------------------------------------------------------------- /tests/data/end_to_end_data/srtm_test_data/input/srtm_blurred_and_shifted.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/srtm_test_data/input/srtm_blurred_and_shifted.tif -------------------------------------------------------------------------------- /tests/data/end_to_end_data/srtm_test_data/input/srtm_ref.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/srtm_test_data/input/srtm_ref.tif -------------------------------------------------------------------------------- /tests/data/end_to_end_data/srtm_test_data/input/test_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "output_dir": "./test_standard_output/", 3 | "input_ref": { 4 | "path": "./srtm_ref.tif", 5 | "zunit": "m" 6 | }, 7 | "input_sec": { 8 | "path": "./srtm_blurred_and_shifted.tif", 9 | "zunit": "m", 10 | "nodata": -32768 11 | }, 12 | "coregistration": { 13 | "method_name": "nuth_kaab_internal", 14 | "number_of_iterations": 6, 15 | "estimated_initial_shift_x": 0, 16 | "estimated_initial_shift_y": 0 17 | }, 18 | "statistics": { 19 | "alti-diff": { 20 | "classification_layers": { 21 | "Slope0": { 22 | "type": "slope", 23 | "ranges": [ 24 | 0, 25 | 5, 26 | 10, 27 | 25, 28 | 45 29 | ] 30 | } 31 | }, 32 | "remove_outliers": true 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /tests/data/end_to_end_data/srtm_test_data/ref_output/coregistration/coreg_SEC.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/srtm_test_data/ref_output/coregistration/coreg_SEC.tif -------------------------------------------------------------------------------- /tests/data/end_to_end_data/srtm_test_data/ref_output/coregistration/coregistration_results.json: -------------------------------------------------------------------------------- 1 | { 2 | "coregistration_results": { 3 | "reproj_coreg_ref": { 4 | "path": "TO/PATH/demcompare/test_output/coregistration/reproj_coreg_REF.tif", 5 | "nodata": -32768, 6 | "nb_points": 983070, 7 | "nb_valid_points": 983070 8 | }, 9 | "reproj_coreg_sec": { 10 | "path": "TO/PATH/demcompare/test_output/coregistration/reproj_coreg_SEC.tif", 11 | "nodata": -32768, 12 | "nb_points": 983070, 13 | "nb_valid_points": 983070 14 | }, 15 | "dz": { 16 | "total_bias_value": -0.01765, 17 | "unit_bias_value": "m", 18 | "percent": 100.0, 19 | "nodata": -32768, 20 | "nb_points": 983070, 21 | "nb_valid_points": 983070 22 | }, 23 | "dx": { 24 | "nuth_offset": 3.0, 25 | "total_offset": 3.0, 26 | "unit_offset": "px", 27 | "total_bias_value": 0.0025, 28 | "unit_bias_value": "m" 29 | }, 30 | "dy": { 31 | "nuth_offset": 5.0, 32 | "total_offset": 5.0, 33 | "unit_offset": "px", 34 | "total_bias_value": 0.00417, 35 | "unit_bias_value": "m" 36 | }, 37 | "gdal_translate_bounds": { 38 | "ulx": 40.0025, 39 | "uly": 39.99583, 40 | "lrx": 40.83333, 41 | "lry": 39.16667 42 | } 43 | }, 44 | "stats_results": { 45 | "images": { 46 | "list": [ 47 | "row_wise", 48 | "col_wise" 49 | ], 50 | "row_wise": { 51 | "path": "TO/PATH/demcompare/test_output/dh_row_wise_wave_detection.tif", 52 | "zunit": "m", 53 | "nodata": -32768, 54 | "nb_valid_points": 983070 55 | }, 56 | "col_wise": { 57 | "path": "TO/PATH/demcompare/test_output/dh_col_wise_wave_detection.tif", 58 | "zunit": "m", 59 | "nodata": -32768, 60 | "nb_valid_points": 983070 61 | } 62 | }, 63 | "classification_layer_masks": { 64 | "slope": { 65 | "standard": { 66 | "ref_support": { 67 | "nodata": -32768.0, 68 | "path": "TO/PATH/demcompare/test_output/stats/Slope0/ref_support_map.tif" 69 | }, 70 | "sec_support": { 71 | "nodata": -32768.0, 72 | "path": "TO/PATH/demcompare/test_output/stats/Slope0/sec_support_map.tif" 73 | } 74 | } 75 | } 76 | } 77 | } 78 | } -------------------------------------------------------------------------------- /tests/data/end_to_end_data/srtm_test_data/ref_output/coregistration/reproj_coreg_REF.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/srtm_test_data/ref_output/coregistration/reproj_coreg_REF.tif -------------------------------------------------------------------------------- /tests/data/end_to_end_data/srtm_test_data/ref_output/coregistration/reproj_coreg_SEC.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/srtm_test_data/ref_output/coregistration/reproj_coreg_SEC.tif -------------------------------------------------------------------------------- /tests/data/end_to_end_data/srtm_test_data/ref_output/initial_dem_diff.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/srtm_test_data/ref_output/initial_dem_diff.tif -------------------------------------------------------------------------------- /tests/data/end_to_end_data/srtm_test_data/ref_output/stats/alti-diff/Slope0/stats_results.csv: -------------------------------------------------------------------------------- 1 | "Set Name","mean","median","max","min","sum","percentil_90","squared_sum","nmad","rmse","std","nbpts","percent_valid_points" 2 | "[0%;5%[:0",-0.05006,0.0,16.0,-16.0,-4060.0,3.0574,457980.0,1.4826,2.37626,2.37573,81271,8.26706 3 | "[5%;10%[:5",-0.26992,0.0,16.0,-16.0,-30546.0,5.71186,1427112.0,2.9652,3.55114,3.54086,113759,11.57181 4 | "[10%;25%[:10",-0.14188,0.0,16.0,-16.0,-55625.99219,7.83889,8077278.0,2.9652,4.53896,4.53674,395916,40.27343 5 | "[25%;45%[:25",0.1636,0.0,16.0,-16.0,48644.06641,10.20855,9738370.0,5.9304,5.72303,5.72069,303591,30.88193 6 | "[45%;inf[:45",0.14426,0.0,16.00012,-16.00012,12445.9541,11.23231,3161528.5,5.9304,6.05356,6.05184,88533,9.00577 7 | -------------------------------------------------------------------------------- /tests/data/end_to_end_data/srtm_test_data/ref_output/stats/alti-diff/Slope0/stats_results_exclusion.csv: -------------------------------------------------------------------------------- 1 | "Set Name","mean","median","max","min","sum","percentil_90","squared_sum","nmad","rmse","std","nbpts","percent_valid_points" 2 | "[0%;5%[:0",-0.02668,0.0,16.0,-16.0,-287.0,6.0541,143073.0,1.4826,3.64698,3.64688,10831,1.10175 3 | "[5%;10%[:5",-0.15291,0.0,16.0,-16.0,-4146.0,7.16888,448358.0,2.9652,4.06645,4.06358,27351,2.7822 4 | "[10%;25%[:10",-0.18101,0.0,16.0,-16.0,-7633.99756,8.82095,955417.9375,4.4478,4.75959,4.75614,42681,4.3416 5 | "[25%;45%[:25",0.18583,0.0,16.0,-16.0,9507.02344,9.79484,1509078.25,4.4478,5.43119,5.42801,51985,5.28803 6 | "[45%;inf[:45",0.51524,0.0,16.00012,-16.0,11648.01562,10.62273,791514.0,5.9304,5.91709,5.89461,23103,2.35009 7 | -------------------------------------------------------------------------------- /tests/data/end_to_end_data/srtm_test_data/ref_output/stats/alti-diff/Slope0/stats_results_intersection.csv: -------------------------------------------------------------------------------- 1 | "Set Name","mean","median","max","min","sum","percentil_90","squared_sum","nmad","rmse","std","nbpts","percent_valid_points" 2 | "[0%;5%[:0",-0.05363,0.0,16.0,-16.0,-3773.0,2.94209,314907.0,1.4826,2.11572,2.11504,70440,7.16531 3 | "[5%;10%[:5",-0.30678,0.0,16.0,-16.0,-26400.0,5.32588,978754.0,2.9652,3.37249,3.35851,86408,8.78961 4 | "[10%;25%[:10",-0.13717,0.0,16.0,-16.0,-47992.0,7.84106,7121860.0,2.9652,4.51164,4.50955,353235,35.93183 5 | "[25%;45%[:25",0.15899,0.0,16.0,-16.0,39137.04297,10.79074,8229290.0,5.9304,5.78183,5.77964,251606,25.5939 6 | "[45%;inf[:45",0.01253,0.0,16.00012,-16.00012,797.93835,11.09445,2370014.5,5.9304,6.10129,6.10128,65430,6.65568 7 | -------------------------------------------------------------------------------- /tests/data/end_to_end_data/srtm_test_data/ref_output/stats/alti-diff/dem_for_stats.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/srtm_test_data/ref_output/stats/alti-diff/dem_for_stats.tif -------------------------------------------------------------------------------- /tests/data/end_to_end_data/srtm_test_data/ref_output/stats/dh_col_wise_wave_detection.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/srtm_test_data/ref_output/stats/dh_col_wise_wave_detection.tif -------------------------------------------------------------------------------- /tests/data/end_to_end_data/srtm_test_data/ref_output/stats/dh_row_wise_wave_detection.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/srtm_test_data/ref_output/stats/dh_row_wise_wave_detection.tif -------------------------------------------------------------------------------- /tests/data/end_to_end_data/srtm_test_data/ref_output/test_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "output_dir": "./test_output/", 3 | "input_ref": { 4 | "path": "tests/tests_data/strm_test_data/srtm_ref.tif", 5 | "zunit": "m" 6 | }, 7 | "input_sec": { 8 | "path": "tests/tests_data/strm_test_data/srtm_blurred_and_shifted.tif", 9 | "zunit": "m", 10 | "nodata": -32768 11 | }, 12 | "coregistration": { 13 | "method_name": "nuth_kaab_internal", 14 | "number_of_iterations": 6, 15 | "estimated_initial_shift_x": 0, 16 | "estimated_initial_shift_y": 0, 17 | "save_optional_outputs": true 18 | }, 19 | "statistics": { 20 | "alti-diff": { 21 | "classification_layers": { 22 | "Slope0": { 23 | "type": "slope", 24 | "ranges": [ 25 | 0, 26 | 5, 27 | 10, 28 | 25, 29 | 45 30 | ] 31 | } 32 | }, 33 | "remove_outliers": true 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /tests/data/end_to_end_data/srtm_test_data_with_roi/data_description.md: -------------------------------------------------------------------------------- 1 | ## Data description 2 | 3 | The test data **strm_test_data_with_roi** folder contains the following elements: 4 | 5 | * **input** folder containing: 6 | * A reference DEM *strm_ref.tif* of size 1000x1000 pixels. 7 | * A dem to align *strm_blurred_and_shifted.tif* that has been manually created by blurring and shifting the reference DEM by (3, 5) pixels. Its size is 997x995 pixels. 8 | * Both reference and dem to align have the same resolution. 9 | * *test_config.json* : input configuration file to run demcompare on the input dems with *nuth_kaab_internal*, the default *sampling_source* (*sec*), **and an input Region of Interest for the dem to align**. 10 | * **ref_output** folder containing: 11 | * *test_config.json* : resulting input configuration file from running demcompare (filled with the defaut parameters when not set). 12 | * *coregistration_results.json*: output results from coregistration and stats. 13 | * *final_dh.tif* and *initial_dh.tif*: initial and final altitude difference DEMs to evaluate the coregistration. 14 | * **coregistration** folder: internal DEMs of the coregistration and output coregistered dem to align (*coreg_SEC.tif*). 15 | * **stats**: contains: 16 | * one folder for the **slope** classification layer containing the *.csv* files of the *exclusion/intersection* segmentation. 17 | * initial and final *.csv* files of the PDF (Probability Density Function) and CDF (Cumulative Density Function) to evaluate the coregistration. 18 | -------------------------------------------------------------------------------- /tests/data/end_to_end_data/srtm_test_data_with_roi/input/srtm_blurred_and_shifted.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/srtm_test_data_with_roi/input/srtm_blurred_and_shifted.tif -------------------------------------------------------------------------------- /tests/data/end_to_end_data/srtm_test_data_with_roi/input/srtm_ref.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/srtm_test_data_with_roi/input/srtm_ref.tif -------------------------------------------------------------------------------- /tests/data/end_to_end_data/srtm_test_data_with_roi/input/test_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "output_dir": "./test_standard_output/", 3 | "input_ref": { 4 | "path": "./srtm_ref.tif", 5 | "zunit": "m" 6 | }, 7 | "input_sec": { 8 | "path": "./srtm_blurred_and_shifted.tif", 9 | "zunit": "m", 10 | "nodata": -32768, 11 | "roi": { 12 | "left": 40.5, 13 | "bottom": 38.0, 14 | "right": 44.0, 15 | "top": 41.0 16 | } 17 | }, 18 | "coregistration": { 19 | "method_name": "nuth_kaab_internal", 20 | "number_of_iterations": 6, 21 | "estimated_initial_shift_x": 0, 22 | "estimated_initial_shift_y": 0 23 | }, 24 | "statistics": { 25 | "alti-diff": { 26 | "classification_layers": { 27 | "Slope0": { 28 | "type": "slope", 29 | "ranges": [ 30 | 0, 31 | 5, 32 | 10, 33 | 25, 34 | 45 35 | ] 36 | } 37 | }, 38 | "remove_outliers": true 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /tests/data/end_to_end_data/srtm_test_data_with_roi/ref_output/coregistration/coregistration_results.json: -------------------------------------------------------------------------------- 1 | { 2 | "coregistration_results": { 3 | "reproj_coreg_ref": { 4 | "path": "TO/PATH/demcompare/test_output/coregistration/reproj_coreg_REF.tif", 5 | "nodata": -32768, 6 | "nb_points": 389070, 7 | "nb_valid_points": 389070 8 | }, 9 | "reproj_coreg_sec": { 10 | "path": "TO/PATH/demcompare/test_output/coregistration/reproj_coreg_SEC.tif", 11 | "nodata": -32768, 12 | "nb_points": 389070, 13 | "nb_valid_points": 389070 14 | }, 15 | "dz": { 16 | "total_bias_value": -0.01813, 17 | "unit_bias_value": "m", 18 | "percent": 100.0, 19 | "nodata": -32768, 20 | "nb_points": 389070, 21 | "nb_valid_points": 389070 22 | }, 23 | "dx": { 24 | "nuth_offset": 3.0, 25 | "total_offset": 3.0, 26 | "unit_offset": "px", 27 | "total_bias_value": 0.0025, 28 | "unit_bias_value": "m" 29 | }, 30 | "dy": { 31 | "nuth_offset": 5.0, 32 | "total_offset": 5.0, 33 | "unit_offset": "px", 34 | "total_bias_value": 0.00417, 35 | "unit_bias_value": "m" 36 | }, 37 | "gdal_translate_bounds": { 38 | "ulx": 40.0025, 39 | "uly": 39.99583, 40 | "lrx": 40.83333, 41 | "lry": 39.16667 42 | } 43 | }, 44 | "stats_results": { 45 | "images": { 46 | "list": [ 47 | "row_wise", 48 | "col_wise" 49 | ], 50 | "row_wise": { 51 | "path": "TO/PATH/demcompare/test_output/dh_row_wise_wave_detection.tif", 52 | "zunit": "m", 53 | "nodata": -32768, 54 | "nb_valid_points": 389070 55 | }, 56 | "col_wise": { 57 | "path": "TO/PATH/demcompare/test_output/dh_col_wise_wave_detection.tif", 58 | "zunit": "m", 59 | "nodata": -32768, 60 | "nb_valid_points": 389070 61 | } 62 | }, 63 | "classification_layer_masks": { 64 | "slope": { 65 | "standard": { 66 | "ref_support": { 67 | "nodata": -32768.0, 68 | "path": "TO/PATH/demcompare/test_output/stats/Slope0/ref_support_map.tif" 69 | }, 70 | "sec_support": { 71 | "nodata": -32768.0, 72 | "path": "TO/PATH/demcompare/test_output/stats/Slope0/sec_support_map.tif" 73 | } 74 | } 75 | } 76 | } 77 | } 78 | } -------------------------------------------------------------------------------- /tests/data/end_to_end_data/srtm_test_data_with_roi/ref_output/initial_dem_diff.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/srtm_test_data_with_roi/ref_output/initial_dem_diff.tif -------------------------------------------------------------------------------- /tests/data/end_to_end_data/srtm_test_data_with_roi/ref_output/stats/alti-diff/Slope0/stats_results.csv: -------------------------------------------------------------------------------- 1 | "Set Name","mean","median","max","min","sum","percentil_90","squared_sum","nmad","rmse","std","nbpts","percent_valid_points" 2 | "[0%;5%[:0",-0.10028,0.0,14.0,-14.0,-3447.99951,3.11939,182215.98438,1.4826,2.30205,2.29987,34492,8.86524 3 | "[5%;10%[:5",-0.26652,0.0,14.0,-14.0,-15193.99609,5.29328,591591.9375,1.4826,3.22136,3.21032,57347,14.73951 4 | "[10%;25%[:10",-0.06551,0.0,14.0,-14.0,-11013.9541,7.10912,2805935.5,2.9652,4.08523,4.0847,170226,43.75202 5 | "[25%;45%[:25",0.1933,0.0,14.00012,-14.0,19135.05469,9.75722,2764097.5,4.4478,5.28422,5.28068,101984,26.21225 6 | "[45%;inf[:45",0.20554,0.0,14.00012,-14.00012,4933.8916,10.69247,790188.0,5.9304,5.73751,5.73383,25021,6.43098 7 | -------------------------------------------------------------------------------- /tests/data/end_to_end_data/srtm_test_data_with_roi/ref_output/stats/alti-diff/Slope0/stats_results_intersection.csv: -------------------------------------------------------------------------------- 1 | "Set Name","mean","median","max","min","sum","percentil_90","squared_sum","nmad","rmse","std","nbpts","percent_valid_points" 2 | "[0%;5%[:0",-0.09714,0.0,14.0,-14.0,-2857.99951,2.89016,126723.98438,1.4826,2.07543,2.07316,29479,7.57679 3 | "[5%;10%[:5",-0.29266,0.0,14.0,-14.0,-12964.99707,4.67859,418852.9375,1.4826,3.07485,3.06089,44510,11.4401 4 | "[10%;25%[:10",-0.04971,0.0,14.0,-14.0,-7468.95898,7.09584,2486008.75,2.9652,4.06763,4.06732,152090,39.09065 5 | "[25%;45%[:25",0.18408,0.0,14.00012,-14.0,14904.03906,10.23776,2314990.25,4.4478,5.34719,5.34402,83541,21.47197 6 | "[45%;inf[:45",0.08145,0.0,14.00012,-14.00012,1405.901,11.18334,576757.0625,5.9304,5.78064,5.78007,18048,4.63875 7 | -------------------------------------------------------------------------------- /tests/data/end_to_end_data/srtm_test_data_with_roi/ref_output/stats/alti-diff/dem_for_stats.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/end_to_end_data/srtm_test_data_with_roi/ref_output/stats/alti-diff/dem_for_stats.tif -------------------------------------------------------------------------------- /tests/data/end_to_end_data/srtm_test_data_with_roi/ref_output/test_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "output_dir": "./test_output/", 3 | "input_ref": { 4 | "path": "tests/tests_data/strm_test_data/srtm_ref.tif", 5 | "zunit": "m" 6 | }, 7 | "input_sec": { 8 | "path": "tests/tests_data/strm_test_data/srtm_blurred_and_shifted.tif", 9 | "zunit": "m", 10 | "nodata": -32768, 11 | "roi": { 12 | "left": 40.5, 13 | "bottom": 38.0, 14 | "right": 44.0, 15 | "top": 39.0 16 | } 17 | }, 18 | "coregistration": { 19 | "method_name": "nuth_kaab_internal", 20 | "number_of_iterations": 6, 21 | "estimated_initial_shift_x": 0, 22 | "estimated_initial_shift_y": 0, 23 | "save_optional_outputs": true 24 | }, 25 | "statistics": { 26 | "alti-diff": { 27 | "classification_layers": { 28 | "Slope0": { 29 | "type": "slope", 30 | "ranges": [ 31 | 0, 32 | 5, 33 | 10, 34 | 25, 35 | 45 36 | ] 37 | } 38 | }, 39 | "remove_outliers": true 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /tests/data/geoid/egm96_15.gtx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CNES/demcompare/f10db8b7a5b5ca3929e699327a50d59a0bc40735/tests/data/geoid/egm96_15.gtx -------------------------------------------------------------------------------- /tests/dem_processing/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf8 3 | # 4 | # Copyright (c) 2022 Centre National d'Etudes Spatiales (CNES). 5 | # 6 | # This file is part of demcompare 7 | # (see https://github.com/CNES/demcompare). 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | """ 22 | Demcompare DEM processing tests module 23 | """ 24 | -------------------------------------------------------------------------------- /tests/dem_tools/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf8 3 | # 4 | # Copyright (c) 2022 Centre National d'Etudes Spatiales (CNES). 5 | # 6 | # This file is part of demcompare 7 | # (see https://github.com/CNES/demcompare). 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | """ 22 | Demcompare dem_tools tests module 23 | """ 24 | -------------------------------------------------------------------------------- /tests/metric/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf8 3 | # 4 | # Copyright (c) 2022 Centre National d'Etudes Spatiales (CNES). 5 | # 6 | # This file is part of demcompare 7 | # (see https://github.com/CNES/demcompare). 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | """ 22 | Demcompare metric tests module 23 | """ 24 | -------------------------------------------------------------------------------- /tests/metric/test_matrix_2d_metric.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf8 3 | # 4 | # Copyright (c) 2022 Centre National d'Etudes Spatiales (CNES). 5 | # 6 | # This file is part of demcompare 7 | # (see https://github.com/CNES/demcompare). 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | """ 22 | This module contains functions to test the 23 | methods in the matrix 2D metric class. 24 | """ 25 | # pylint:disable=protected-access 26 | # Third party imports 27 | import numpy as np 28 | import pytest 29 | 30 | from demcompare.metric import Metric 31 | from tests.helpers import RESULT_TOL 32 | 33 | 34 | @pytest.mark.unit_tests 35 | def test_svf(): 36 | """ 37 | Test the svf metric class function compute_metric. 38 | Input data: 39 | - Manually computed data array 40 | - Coregistration object created by fixture initialize_dem_and_coreg 41 | Validation data: 42 | - Manually computed ground truth gt_output, gt_bins and gt= with numpy 43 | Validation process: 44 | - Create the metric object and test compute_metric 45 | - Check that the obtained metrics are the same as ground truth 46 | """ 47 | # Test without percentil 98 filtering --------------------------- 48 | 49 | # Initialize input data 50 | data = np.array( 51 | [ 52 | [1982.0, 1967.0, 1950.0], 53 | [2005.0, 1988.0, 1969.0], 54 | [2012.0, 1990.0, 1967.0], 55 | ], 56 | dtype=np.float32, 57 | ) 58 | 59 | # Create metric object 60 | metric_obj = Metric("svf") 61 | 62 | # Compute metric from metric class 63 | output = metric_obj.compute_metric(data) 64 | 65 | gt = np.array( 66 | [ 67 | [223.102478, 72.567892, 0.0], 68 | [255.0, 255.0, 185.740152], 69 | [255.0, 255.0, 46.564479], 70 | ] 71 | ) 72 | 73 | np.testing.assert_allclose(output["image"].data, gt, rtol=RESULT_TOL) 74 | 75 | 76 | @pytest.mark.unit_tests 77 | def test_hillshade(): 78 | """ 79 | Test the hillshade metric class function compute_metric. 80 | Input data: 81 | - Manually computed data array 82 | - Coregistration object created by fixture initialize_dem_and_coreg 83 | Validation data: 84 | - Manually computed ground truth gt_output, gt_bins and gt= with numpy 85 | Validation process: 86 | - Create the metric object and test compute_metric 87 | - Check that the obtained metrics are the same as ground truth 88 | """ 89 | # Test without percentil 98 filtering --------------------------- 90 | 91 | # Initialize input data 92 | data = np.array( 93 | [ 94 | [1982.0, 1967.0, 1950.0], 95 | [2005.0, 1988.0, 1969.0], 96 | [2012.0, 1990.0, 1967.0], 97 | ], 98 | dtype=np.float32, 99 | ) 100 | 101 | # Create metric object 102 | metric_obj = Metric("hillshade") 103 | 104 | # Compute metric from metric class 105 | output = metric_obj.compute_metric(data) 106 | 107 | gt = np.array( 108 | [ 109 | [149.34193, 142.97736, 136.03064], 110 | [125.85443, 112.33784, 99.7046], 111 | [90.020424, 73.68868, 62.433144], 112 | ] 113 | ) 114 | 115 | np.testing.assert_allclose(output["image"].data, gt, rtol=RESULT_TOL) 116 | -------------------------------------------------------------------------------- /tests/stats_processing/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf8 3 | # 4 | # Copyright (c) 2022 Centre National d'Etudes Spatiales (CNES). 5 | # 6 | # This file is part of demcompare 7 | # (see https://github.com/CNES/demcompare). 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | """ 22 | Demcompare stats_processing tests module 23 | """ 24 | -------------------------------------------------------------------------------- /tests/test_tiling.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf8 3 | # 4 | # Copyright (c) 2024 Centre National d'Etudes Spatiales (CNES). 5 | # 6 | # This file is part of demcompare 7 | # (see https://github.com/CNES/demcompare). 8 | # 9 | # Licensed under the Apache License, Version 2.0 (the "License"); 10 | # you may not use this file except in compliance with the License. 11 | # You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | # 21 | """ 22 | This module contains functions to test the 23 | methods in the demcompare_tiles module. 24 | """ 25 | 26 | import pytest 27 | 28 | from demcompare.demcompare_tiles import verify_config 29 | 30 | 31 | @pytest.mark.unit_tests 32 | @pytest.mark.parametrize( 33 | ["dict_config", "expected_error"], 34 | [ 35 | pytest.param( 36 | {"height": "100", "width": 100, "overlap": 100, "nb_cpu": 1}, 37 | "Height is not consistent", 38 | ), 39 | pytest.param( 40 | {"height": 100, "width": -100, "overlap": 100, "nb_cpu": 1}, 41 | "Width is not consistent", 42 | ), 43 | pytest.param( 44 | {"height": 100, "width": 100, "nb_cpu": 1}, 45 | "Overlap is not consistent", 46 | ), 47 | pytest.param( 48 | {"height": 100, "width": 100, "overlap": 100, "nb_cpu": -5}, 49 | "Number of CPUs is incorrect", 50 | ), 51 | pytest.param( 52 | {"height": 100, "width": 100, "overlap": 100, "nb_cpu": 999999}, 53 | "Number of CPUs in the config is more than available CPUs", 54 | ), 55 | ], 56 | ) 57 | def test_verify_config(dict_config, expected_error): 58 | """ 59 | Test the verify_config function 60 | Input data: 61 | - handcraft tiling parameter dictionary 62 | Validation data: 63 | - handcraft error message 64 | Validation process: 65 | - Check that the config dictionary does contain error 66 | - Checked function : verify_config 67 | """ 68 | 69 | with pytest.raises(ValueError) as exc_info: 70 | verify_config(dict_config) 71 | 72 | assert str(exc_info.value) == expected_error 73 | -------------------------------------------------------------------------------- /tox.ini: -------------------------------------------------------------------------------- 1 | [tox] 2 | # Environment list run by tox (-e to choose) 3 | envlist = clean,py310,coverage 4 | 5 | [testenv] 6 | # Main test environment configuration 7 | 8 | # Configure 9 | setenv = 10 | py{310}: COVERAGE_FILE = .coverage.{envname} 11 | 12 | # Main command for testing 13 | # {posargs} can be used in tox cli see https://tox.wiki/en/latest/example/general.html 14 | commands = pytest -o log_cli=true --junitxml=pytest-report.xml --cov-config=.coveragerc --cov --cov-append --cov-report=term-missing {posargs:-vv} 15 | 16 | # Dependencies to install to run main command 17 | deps = 18 | pytest 19 | pytest-cov 20 | 21 | # Environment dependencies : run clean before py envs and coverage after 22 | depends = 23 | {py310}: clean 24 | coverage: py310 25 | 26 | [testenv:coverage] 27 | # Coverage environment definition 28 | # Do not install in this env. 29 | skip_install = true 30 | # Install coverage package. 31 | deps = coverage 32 | # Commands to run in this environment : 33 | # combine coverage parallel results and generate coverage in html and xml. 34 | commands = 35 | coverage combine 36 | coverage html 37 | coverage xml 38 | 39 | [testenv:clean] 40 | # Clean coverage environment before 41 | deps = coverage 42 | skip_install = true 43 | commands = coverage erase 44 | --------------------------------------------------------------------------------