From 7c47d8947dc41942d40cdea18a4bcf2e3d402282 Mon Sep 17 00:00:00 2001 From: Ben Purinton Date: Fri, 10 May 2024 12:57:20 -0700 Subject: [PATCH] tests for bundle adjust plots --- tests/test_bundle_adjust.py | 26 ++++++++++++++++++ .../ba/ba-final_residuals_pointmap.csv | 7 +++++ .../ba/ba-initial_residuals_pointmap.csv | 9 ++++++ tests/test_data/{ => ba}/ba-log.txt | 0 tests/test_data/{ => stereo}/mini-L_sub.tif | Bin tests/test_data/{ => stereo}/mini-R_sub.tif | Bin .../test_data/{ => stereo}/point2dem-log.txt | 0 tests/test_data/{ => stereo}/stereo-log.txt | 0 tests/test_processing_parameters.py | 6 ++-- tests/{test_scene_plots.py => test_scenes.py} | 4 +-- 10 files changed, 47 insertions(+), 5 deletions(-) create mode 100644 tests/test_bundle_adjust.py create mode 100644 tests/test_data/ba/ba-final_residuals_pointmap.csv create mode 100644 tests/test_data/ba/ba-initial_residuals_pointmap.csv rename tests/test_data/{ => ba}/ba-log.txt (100%) rename tests/test_data/{ => stereo}/mini-L_sub.tif (100%) rename tests/test_data/{ => stereo}/mini-R_sub.tif (100%) rename tests/test_data/{ => stereo}/point2dem-log.txt (100%) rename tests/test_data/{ => stereo}/stereo-log.txt (100%) rename tests/{test_scene_plots.py => test_scenes.py} (77%) diff --git a/tests/test_bundle_adjust.py b/tests/test_bundle_adjust.py new file mode 100644 index 0000000..37d84c6 --- /dev/null +++ b/tests/test_bundle_adjust.py @@ -0,0 +1,26 @@ +import pytest +from asp_plot.bundle_adjust import ReadResiduals, PlotResiduals +import matplotlib +import geopandas as gpd + +matplotlib.use("Agg") + + +class TestBundleAdjust: + @pytest.fixture + def residual_files(self): + directory = "tests/test_data/" + ba_prefix = "ba/ba" + return ReadResiduals(directory, ba_prefix) + + def test_get_residual_gdfs(self, residual_files): + resid_init, resid_final = residual_files.get_residual_gdfs() + assert isinstance(resid_init, gpd.GeoDataFrame) + assert isinstance(resid_final, gpd.GeoDataFrame) + + def test_plot_n_residuals(self, residual_files): + resid_init, resid_final = residual_files.get_residual_gdfs() + try: + PlotResiduals([resid_init, resid_final]).plot_n_residuals(column_name="mean_residual") + except Exception as e: + pytest.fail(f"figure method raised an exception: {str(e)}") diff --git a/tests/test_data/ba/ba-final_residuals_pointmap.csv b/tests/test_data/ba/ba-final_residuals_pointmap.csv new file mode 100644 index 0000000..a788a69 --- /dev/null +++ b/tests/test_data/ba/ba-final_residuals_pointmap.csv @@ -0,0 +1,7 @@ +# lon, lat, height_above_datum, mean_residual, num_observations +# Geodetic Datum --> Name: WGS_1984 Spheroid: WGS 84 Semi-major axis: 6378137 Semi-minor axis: 6356752.3142451793 Meridian: Greenwich at 0 Proj4 Str: +proj=longlat +datum=WGS84 +no_defs +-156.8787621266714, 71.271874841087325, -0.36491041881727709, 0.27929182170458566, 2 +-156.8780547480608, 71.275398550769182, 0.26183095769151948, 0.091659615252865478, 2 +-156.87727580996784, 71.286145888801144, -0.91625511622648326, 0.052193733525443042, 2 +-156.87470631386205, 71.290327538976598, -1.5761793022808819, 0.23095878065626796, 2 +-156.87364518396637, 71.27818895086348, -0.7222090013486745, 0.12443687149487473, 2 diff --git a/tests/test_data/ba/ba-initial_residuals_pointmap.csv b/tests/test_data/ba/ba-initial_residuals_pointmap.csv new file mode 100644 index 0000000..d79be4c --- /dev/null +++ b/tests/test_data/ba/ba-initial_residuals_pointmap.csv @@ -0,0 +1,9 @@ +# lon, lat, height_above_datum, mean_residual, num_observations +# Geodetic Datum --> Name: WGS_1984 Spheroid: WGS 84 Semi-major axis: 6378137 Semi-minor axis: 6356752.3142451793 Meridian: Greenwich at 0 Proj4 Str: +proj=longlat +datum=WGS84 +no_defs +-156.87876206140302, 71.271875132031866, -0.42092562742504364, 0.19631815744360209, 2 +-156.87805391399652, 71.275398639905859, 0.22662260452218885, 0.38524321762160979, 2 +-156.87727461766127, 71.286145872610589, -0.93934368885776565, 0.52892293474772789, 2 +-156.87470605883939, 71.290327757295771, -1.6203314659331238, 0.24375310456064955, 2 +-156.87527466499779, 71.276976449943888, -63.30750525606679, 19.410683117621161, 2 +-156.87364231464838, 71.27818852567637, -0.71749579571765587, 0.25425952709437116, 2 +-156.87361011617145, 71.273405048961152, 0.040032582617270253, 0.53133591364021404, 2 diff --git a/tests/test_data/ba-log.txt b/tests/test_data/ba/ba-log.txt similarity index 100% rename from tests/test_data/ba-log.txt rename to tests/test_data/ba/ba-log.txt diff --git a/tests/test_data/mini-L_sub.tif b/tests/test_data/stereo/mini-L_sub.tif similarity index 100% rename from tests/test_data/mini-L_sub.tif rename to tests/test_data/stereo/mini-L_sub.tif diff --git a/tests/test_data/mini-R_sub.tif b/tests/test_data/stereo/mini-R_sub.tif similarity index 100% rename from tests/test_data/mini-R_sub.tif rename to tests/test_data/stereo/mini-R_sub.tif diff --git a/tests/test_data/point2dem-log.txt b/tests/test_data/stereo/point2dem-log.txt similarity index 100% rename from tests/test_data/point2dem-log.txt rename to tests/test_data/stereo/point2dem-log.txt diff --git a/tests/test_data/stereo-log.txt b/tests/test_data/stereo/stereo-log.txt similarity index 100% rename from tests/test_data/stereo-log.txt rename to tests/test_data/stereo/stereo-log.txt diff --git a/tests/test_processing_parameters.py b/tests/test_processing_parameters.py index 974ecb2..7109e8b 100644 --- a/tests/test_processing_parameters.py +++ b/tests/test_processing_parameters.py @@ -8,9 +8,9 @@ class TestProcessingParameters: @pytest.fixture def processing_parameters(self): - bundle_adjust_log = "tests/test_data/ba-log.txt" - stereo_log = "tests/test_data/stereo-log.txt" - point2dem_log = "tests/test_data/point2dem-log.txt" + bundle_adjust_log = "tests/test_data/ba/ba-log.txt" + stereo_log = "tests/test_data/stereo/stereo-log.txt" + point2dem_log = "tests/test_data/stereo/point2dem-log.txt" return ProcessingParameters(bundle_adjust_log, stereo_log, point2dem_log) def test_init(self, processing_parameters): diff --git a/tests/test_scene_plots.py b/tests/test_scenes.py similarity index 77% rename from tests/test_scene_plots.py rename to tests/test_scenes.py index 6596d18..f45a216 100644 --- a/tests/test_scene_plots.py +++ b/tests/test_scenes.py @@ -8,8 +8,8 @@ class TestScenePlotter: @pytest.fixture def scene_plotter(self): - left_image_fn = "tests/test_data/mini-L_sub.tif" - right_image_fn = "tests/test_data/mini-R_sub.tif" + left_image_fn = "tests/test_data/stereo/mini-L_sub.tif" + right_image_fn = "tests/test_data/stereo/mini-R_sub.tif" return ScenePlotter(left_image_fn, right_image_fn) def test_plot_orthos(self, scene_plotter):