asp-plot 0.5.2__tar.gz → 0.5.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. {asp_plot-0.5.2 → asp_plot-0.5.4}/PKG-INFO +33 -16
  2. {asp_plot-0.5.2 → asp_plot-0.5.4}/README.md +32 -15
  3. {asp_plot-0.5.2 → asp_plot-0.5.4}/asp_plot/bundle_adjust.py +51 -11
  4. {asp_plot-0.5.2 → asp_plot-0.5.4}/asp_plot/cli/asp_plot.py +136 -127
  5. {asp_plot-0.5.2 → asp_plot-0.5.4}/asp_plot/csm_camera.py +27 -24
  6. {asp_plot-0.5.2 → asp_plot-0.5.4}/asp_plot/processing_parameters.py +78 -35
  7. {asp_plot-0.5.2 → asp_plot-0.5.4}/asp_plot/stereo.py +48 -18
  8. {asp_plot-0.5.2 → asp_plot-0.5.4}/asp_plot.egg-info/PKG-INFO +33 -16
  9. {asp_plot-0.5.2 → asp_plot-0.5.4}/notebooks/bundle_adjust_plots.ipynb +26 -11
  10. asp_plot-0.5.4/notebooks/processing_parameters.ipynb +166 -0
  11. {asp_plot-0.5.2 → asp_plot-0.5.4}/notebooks/stereo_plots.ipynb +54 -7
  12. {asp_plot-0.5.2 → asp_plot-0.5.4}/pyproject.toml +1 -1
  13. {asp_plot-0.5.2 → asp_plot-0.5.4}/setup.py +1 -1
  14. {asp_plot-0.5.2 → asp_plot-0.5.4}/tests/test_processing_parameters.py +14 -4
  15. {asp_plot-0.5.2 → asp_plot-0.5.4}/tests/test_stereo.py +13 -0
  16. asp_plot-0.5.2/notebooks/processing_parameters.ipynb +0 -91
  17. {asp_plot-0.5.2 → asp_plot-0.5.4}/.flake8 +0 -0
  18. {asp_plot-0.5.2 → asp_plot-0.5.4}/.github/workflows/run-tests.yml +0 -0
  19. {asp_plot-0.5.2 → asp_plot-0.5.4}/.gitignore +0 -0
  20. {asp_plot-0.5.2 → asp_plot-0.5.4}/.pre-commit-config.yaml +0 -0
  21. {asp_plot-0.5.2 → asp_plot-0.5.4}/LICENSE +0 -0
  22. {asp_plot-0.5.2 → asp_plot-0.5.4}/asp_plot/__init__.py +0 -0
  23. {asp_plot-0.5.2 → asp_plot-0.5.4}/asp_plot/altimetry.py +0 -0
  24. {asp_plot-0.5.2 → asp_plot-0.5.4}/asp_plot/cli/__init__.py +0 -0
  25. {asp_plot-0.5.2 → asp_plot-0.5.4}/asp_plot/cli/csm_camera_plot.py +0 -0
  26. {asp_plot-0.5.2 → asp_plot-0.5.4}/asp_plot/scenes.py +0 -0
  27. {asp_plot-0.5.2 → asp_plot-0.5.4}/asp_plot/stereopair_metadata_parser.py +0 -0
  28. {asp_plot-0.5.2 → asp_plot-0.5.4}/asp_plot/utils.py +0 -0
  29. {asp_plot-0.5.2 → asp_plot-0.5.4}/asp_plot.egg-info/SOURCES.txt +0 -0
  30. {asp_plot-0.5.2 → asp_plot-0.5.4}/asp_plot.egg-info/dependency_links.txt +0 -0
  31. {asp_plot-0.5.2 → asp_plot-0.5.4}/asp_plot.egg-info/entry_points.txt +0 -0
  32. {asp_plot-0.5.2 → asp_plot-0.5.4}/asp_plot.egg-info/top_level.txt +0 -0
  33. {asp_plot-0.5.2 → asp_plot-0.5.4}/environment.yml +0 -0
  34. {asp_plot-0.5.2 → asp_plot-0.5.4}/notebooks/icesat2_plots.ipynb +0 -0
  35. {asp_plot-0.5.2 → asp_plot-0.5.4}/notebooks/scene_plots.ipynb +0 -0
  36. {asp_plot-0.5.2 → asp_plot-0.5.4}/original_code/asp_plot_util.py +0 -0
  37. {asp_plot-0.5.2 → asp_plot-0.5.4}/original_code/bundle_adjust_plots.ipynb +0 -0
  38. {asp_plot-0.5.2 → asp_plot-0.5.4}/original_code/bundle_adjust_plots_BP_tmp.ipynb +0 -0
  39. {asp_plot-0.5.2 → asp_plot-0.5.4}/original_code/corr_and_dem_plots.ipynb +0 -0
  40. {asp_plot-0.5.2 → asp_plot-0.5.4}/original_code/corr_and_dem_plots_DS.ipynb +0 -0
  41. {asp_plot-0.5.2 → asp_plot-0.5.4}/original_code/disparity_plot.ipynb +0 -0
  42. {asp_plot-0.5.2 → asp_plot-0.5.4}/original_code/gallery.py +0 -0
  43. {asp_plot-0.5.2 → asp_plot-0.5.4}/original_code/gen_asp_extras.sh +0 -0
  44. {asp_plot-0.5.2 → asp_plot-0.5.4}/original_code/make_dem_stack.sh +0 -0
  45. {asp_plot-0.5.2 → asp_plot-0.5.4}/original_code/plot_disparity.py +0 -0
  46. {asp_plot-0.5.2 → asp_plot-0.5.4}/original_code/seaice_correction.ipynb +0 -0
  47. {asp_plot-0.5.2 → asp_plot-0.5.4}/original_code/stack_plots.ipynb +0 -0
  48. {asp_plot-0.5.2 → asp_plot-0.5.4}/setup.cfg +0 -0
  49. {asp_plot-0.5.2 → asp_plot-0.5.4}/tests/__init__.py +0 -0
  50. {asp_plot-0.5.2 → asp_plot-0.5.4}/tests/test_altimetry.py +0 -0
  51. {asp_plot-0.5.2 → asp_plot-0.5.4}/tests/test_bundle_adjust.py +0 -0
  52. {asp_plot-0.5.2 → asp_plot-0.5.4}/tests/test_csm_camera.py +0 -0
  53. {asp_plot-0.5.2 → asp_plot-0.5.4}/tests/test_data/10300100D0772D00.r100.xml +0 -0
  54. {asp_plot-0.5.2 → asp_plot-0.5.4}/tests/test_data/10300100D12D7400.r100.xml +0 -0
  55. {asp_plot-0.5.2 → asp_plot-0.5.4}/tests/test_data/ba/ba-final_residuals_pointmap-diff.csv +0 -0
  56. {asp_plot-0.5.2 → asp_plot-0.5.4}/tests/test_data/ba/ba-final_residuals_pointmap.csv +0 -0
  57. {asp_plot-0.5.2 → asp_plot-0.5.4}/tests/test_data/ba/ba-initial_residuals_pointmap-diff.csv +0 -0
  58. {asp_plot-0.5.2 → asp_plot-0.5.4}/tests/test_data/ba/ba-initial_residuals_pointmap.csv +0 -0
  59. {asp_plot-0.5.2 → asp_plot-0.5.4}/tests/test_data/ba/ba-mapproj_match_offsets.txt +0 -0
  60. {asp_plot-0.5.2 → asp_plot-0.5.4}/tests/test_data/ba/ba-triangulation_uncertainty.txt +0 -0
  61. {asp_plot-0.5.2 → asp_plot-0.5.4}/tests/test_data/ba/log-bundle_adjust.txt +0 -0
  62. {asp_plot-0.5.2 → asp_plot-0.5.4}/tests/test_data/ba_cams/1040010074793300.adjust +0 -0
  63. {asp_plot-0.5.2 → asp_plot-0.5.4}/tests/test_data/ba_cams/1040010074793300.adjusted_state.json +0 -0
  64. {asp_plot-0.5.2 → asp_plot-0.5.4}/tests/test_data/ba_cams/1040010074793300.json +0 -0
  65. {asp_plot-0.5.2 → asp_plot-0.5.4}/tests/test_data/ba_cams/1040010074793300.xml +0 -0
  66. {asp_plot-0.5.2 → asp_plot-0.5.4}/tests/test_data/ba_cams/1040010075633C00.adjust +0 -0
  67. {asp_plot-0.5.2 → asp_plot-0.5.4}/tests/test_data/ba_cams/1040010075633C00.adjusted_state.json +0 -0
  68. {asp_plot-0.5.2 → asp_plot-0.5.4}/tests/test_data/ba_cams/1040010075633C00.json +0 -0
  69. {asp_plot-0.5.2 → asp_plot-0.5.4}/tests/test_data/ba_cams/1040010075633C00.xml +0 -0
  70. {asp_plot-0.5.2 → asp_plot-0.5.4}/tests/test_data/ba_cams/linescan_to_csm.sh +0 -0
  71. {asp_plot-0.5.2 → asp_plot-0.5.4}/tests/test_data/icesat_data/atl06sr_defaults_filtered.csv +0 -0
  72. {asp_plot-0.5.2 → asp_plot-0.5.4}/tests/test_data/icesat_data/atl06sr_defaults_filtered.parquet +0 -0
  73. {asp_plot-0.5.2 → asp_plot-0.5.4}/tests/test_data/jitter/uyuni/csm-104001001427B900.r100.adjusted_state.json +0 -0
  74. {asp_plot-0.5.2 → asp_plot-0.5.4}/tests/test_data/jitter/uyuni/csm-1040010014761800.r100.adjusted_state.json +0 -0
  75. {asp_plot-0.5.2 → asp_plot-0.5.4}/tests/test_data/jitter/uyuni/jitter_correction_uyuni.png +0 -0
  76. {asp_plot-0.5.2 → asp_plot-0.5.4}/tests/test_data/jitter/uyuni/jitter_solved_run-csm-104001001427B900.r100.adjusted_state.json +0 -0
  77. {asp_plot-0.5.2 → asp_plot-0.5.4}/tests/test_data/jitter/uyuni/jitter_solved_run-csm-1040010014761800.r100.adjusted_state.json +0 -0
  78. {asp_plot-0.5.2 → asp_plot-0.5.4}/tests/test_data/ref_dem.tif +0 -0
  79. {asp_plot-0.5.2 → asp_plot-0.5.4}/tests/test_data/stereo/date_time_left_right-D.tif +0 -0
  80. {asp_plot-0.5.2 → asp_plot-0.5.4}/tests/test_data/stereo/date_time_left_right-D_sub.tif +0 -0
  81. {asp_plot-0.5.2 → asp_plot-0.5.4}/tests/test_data/stereo/date_time_left_right-L.tif +0 -0
  82. {asp_plot-0.5.2 → asp_plot-0.5.4}/tests/test_data/stereo/date_time_left_right-L__R.csv +0 -0
  83. {asp_plot-0.5.2 → asp_plot-0.5.4}/tests/test_data/stereo/date_time_left_right-L__R.match +0 -0
  84. {asp_plot-0.5.2 → asp_plot-0.5.4}/tests/test_data/stereo/date_time_left_right-L_sub.tif +0 -0
  85. {asp_plot-0.5.2 → asp_plot-0.5.4}/tests/test_data/stereo/date_time_left_right-R_sub.tif +0 -0
  86. {asp_plot-0.5.2 → asp_plot-0.5.4}/tests/test_data/stereo/date_time_left_right_1m-DEM.tif +0 -0
  87. {asp_plot-0.5.2 → asp_plot-0.5.4}/tests/test_data/stereo/date_time_left_right_1m-DEM_ref_dem_diff.tif +0 -0
  88. {asp_plot-0.5.2 → asp_plot-0.5.4}/tests/test_data/stereo/date_time_left_right_1m-IntersectionErr.tif +0 -0
  89. {asp_plot-0.5.2 → asp_plot-0.5.4}/tests/test_data/stereo/log-point2dem.txt +0 -0
  90. {asp_plot-0.5.2 → asp_plot-0.5.4}/tests/test_imports.py +0 -0
  91. {asp_plot-0.5.2 → asp_plot-0.5.4}/tests/test_scenes.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: asp_plot
3
- Version: 0.5.2
3
+ Version: 0.5.4
4
4
  Summary: Package for plotting outputs Ames Stereo Pipeline processing
5
5
  Author: Ben Purinton
6
6
  Author-email: Ben Purinton <purinton@uw.edu>
@@ -67,7 +67,16 @@ Examples of the modular usage of the package can be found in the [`notebooks/` d
67
67
 
68
68
  ## CLI usage: `asp_plot`
69
69
 
70
- A full report and individual plots can be output via the command-line:
70
+ A full report can be output via the command-line. At its simplest, you can run:
71
+
72
+ ```
73
+ $ asp_plot --directory ./ \
74
+ --stereo_directory stereo
75
+ ```
76
+
77
+ with only the directory where the ASP processing was done (`--directory`) and the subdirectory inside of that where the stereo files were output (`--stereo`). The reference DEM used in ASP processing will also be searched for in the logs, and used for difference maps if found.
78
+
79
+ If you also ran bundle adjustment and/or would like to specify a reference DEM to use for plotting (rather than searching the logs):
71
80
 
72
81
  ```
73
82
  $ asp_plot --directory ./ \
@@ -84,29 +93,37 @@ Before that, we recommend running `asp_plot --help` for details (and defaults) o
84
93
  Usage: asp_plot [OPTIONS]
85
94
 
86
95
  Options:
87
- --directory TEXT Directory of ASP processing with scenes and
88
- sub-directories for bundle adjustment and
89
- stereo. Default: current directory
90
- --bundle_adjust_directory TEXT Directory of bundle adjustment files.
91
- Default: ba
92
- --stereo_directory TEXT Directory of stereo files. Default: stereo
93
- --map_crs TEXT Projection for bundle adjustment plots.
94
- Default: EPSG:4326
95
- --reference_dem TEXT Reference DEM used in ASP processing. No
96
- default. Must be supplied.
96
+ --directory TEXT Required directory of ASP processing with
97
+ scenes and sub-directories for stereo and
98
+ optionally bundle adjustment. Default:
99
+ current directory.
100
+ --bundle_adjust_directory TEXT Optional directory of bundle adjustment
101
+ files. If expected *residuals_pointmap.csv
102
+ files are not found in the supplied
103
+ directory, no bundle adjustment plots will
104
+ be generated. Default: None.
105
+ --stereo_directory TEXT Required directory of stereo files. Default:
106
+ stereo.
107
+ --map_crs TEXT Projection for ICESat and bundle adjustment
108
+ plots. Default: None.
109
+ --reference_dem TEXT Optional reference DEM used in ASP
110
+ processing. No default. If not supplied, the
111
+ logs will be examined to find it. If not
112
+ found, no difference plots will be
113
+ generated.
97
114
  --add_basemap BOOLEAN If True, add a contextily basemap to the
98
115
  figure, which requires internet connection.
99
- Default: True
116
+ Default: True.
100
117
  --plot_icesat BOOLEAN If True, plot an ICESat-2 difference plot
101
118
  with the DEM result. This requires internet
102
119
  connection to pull ICESat data. Default:
103
- True
120
+ True.
104
121
  --report_filename TEXT PDF file to write out for report into the
105
122
  processing directory supplied by
106
123
  --directory. Default: Directory name of ASP
107
- processing
124
+ processing.
108
125
  --report_title TEXT Title for the report. Default: Directory
109
- name of ASP processing
126
+ name of ASP processing.
110
127
  ```
111
128
 
112
129
  ## CLI usage: `csm_camera_plot`
@@ -52,7 +52,16 @@ Examples of the modular usage of the package can be found in the [`notebooks/` d
52
52
 
53
53
  ## CLI usage: `asp_plot`
54
54
 
55
- A full report and individual plots can be output via the command-line:
55
+ A full report can be output via the command-line. At its simplest, you can run:
56
+
57
+ ```
58
+ $ asp_plot --directory ./ \
59
+ --stereo_directory stereo
60
+ ```
61
+
62
+ with only the directory where the ASP processing was done (`--directory`) and the subdirectory inside of that where the stereo files were output (`--stereo`). The reference DEM used in ASP processing will also be searched for in the logs, and used for difference maps if found.
63
+
64
+ If you also ran bundle adjustment and/or would like to specify a reference DEM to use for plotting (rather than searching the logs):
56
65
 
57
66
  ```
58
67
  $ asp_plot --directory ./ \
@@ -69,29 +78,37 @@ Before that, we recommend running `asp_plot --help` for details (and defaults) o
69
78
  Usage: asp_plot [OPTIONS]
70
79
 
71
80
  Options:
72
- --directory TEXT Directory of ASP processing with scenes and
73
- sub-directories for bundle adjustment and
74
- stereo. Default: current directory
75
- --bundle_adjust_directory TEXT Directory of bundle adjustment files.
76
- Default: ba
77
- --stereo_directory TEXT Directory of stereo files. Default: stereo
78
- --map_crs TEXT Projection for bundle adjustment plots.
79
- Default: EPSG:4326
80
- --reference_dem TEXT Reference DEM used in ASP processing. No
81
- default. Must be supplied.
81
+ --directory TEXT Required directory of ASP processing with
82
+ scenes and sub-directories for stereo and
83
+ optionally bundle adjustment. Default:
84
+ current directory.
85
+ --bundle_adjust_directory TEXT Optional directory of bundle adjustment
86
+ files. If expected *residuals_pointmap.csv
87
+ files are not found in the supplied
88
+ directory, no bundle adjustment plots will
89
+ be generated. Default: None.
90
+ --stereo_directory TEXT Required directory of stereo files. Default:
91
+ stereo.
92
+ --map_crs TEXT Projection for ICESat and bundle adjustment
93
+ plots. Default: None.
94
+ --reference_dem TEXT Optional reference DEM used in ASP
95
+ processing. No default. If not supplied, the
96
+ logs will be examined to find it. If not
97
+ found, no difference plots will be
98
+ generated.
82
99
  --add_basemap BOOLEAN If True, add a contextily basemap to the
83
100
  figure, which requires internet connection.
84
- Default: True
101
+ Default: True.
85
102
  --plot_icesat BOOLEAN If True, plot an ICESat-2 difference plot
86
103
  with the DEM result. This requires internet
87
104
  connection to pull ICESat data. Default:
88
- True
105
+ True.
89
106
  --report_filename TEXT PDF file to write out for report into the
90
107
  processing directory supplied by
91
108
  --directory. Default: Directory name of ASP
92
- processing
109
+ processing.
93
110
  --report_title TEXT Title for the report. Default: Directory
94
- name of ASP processing
111
+ name of ASP processing.
95
112
  ```
96
113
 
97
114
  ## CLI usage: `csm_camera_plot`
@@ -6,8 +6,15 @@ import matplotlib.pyplot as plt
6
6
  import numpy as np
7
7
  import pandas as pd
8
8
 
9
+ from asp_plot.processing_parameters import ProcessingParameters
9
10
  from asp_plot.stereopair_metadata_parser import StereopairMetadataParser
10
- from asp_plot.utils import ColorBar, Plotter, glob_file, save_figure
11
+ from asp_plot.utils import (
12
+ ColorBar,
13
+ Plotter,
14
+ glob_file,
15
+ run_subprocess_command,
16
+ save_figure,
17
+ )
11
18
 
12
19
  logging.basicConfig(level=logging.WARNING)
13
20
  logger = logging.getLogger(__name__)
@@ -26,18 +33,51 @@ class ReadBundleAdjustFiles:
26
33
  ]
27
34
 
28
35
  if geodiff_files:
29
- filenames = [f.replace(".csv", "-diff.csv") for f in filenames]
36
+ base_paths = [glob_file(self.full_directory, f) for f in filenames]
37
+ diff_paths = []
38
+ for path in base_paths:
39
+ diff_path = path.replace(".csv", "-diff.csv")
40
+ if not os.path.exists(diff_path):
41
+ self.generate_geodiff(path)
42
+ diff_paths.append(diff_path)
43
+ initial_diff, final_diff = diff_paths
44
+ return initial_diff, final_diff
30
45
 
31
- paths = [glob_file(self.full_directory, f) for f in filenames]
32
-
33
- for path in paths:
34
- if path is None:
35
- raise ValueError(
36
- "\n\nInitial and final bundle adjust CSV file not found. Did you run bundle_adjust?\n\n"
37
- )
46
+ else:
47
+ paths = [glob_file(self.full_directory, f) for f in filenames]
48
+ for path in paths:
49
+ if path is None:
50
+ raise ValueError(
51
+ "\n\nInitial and final bundle adjust CSV file not found. Did you run bundle_adjust?\n\n"
52
+ )
53
+ initial, final = paths
54
+ return initial, final
55
+
56
+ def generate_geodiff(self, path):
57
+ processing_parameters = ProcessingParameters(
58
+ processing_directory=self.directory,
59
+ bundle_adjust_directory=self.bundle_adjust_directory,
60
+ )
61
+ refdem = processing_parameters.get_reference_dem(
62
+ processing_parameters.bundle_adjust_log
63
+ )
38
64
 
39
- initial, final = paths
40
- return initial, final
65
+ try:
66
+ command = [
67
+ "geodiff",
68
+ "--csv-format",
69
+ "1:lon,2:lat,3:height_above_datum",
70
+ f"{path}",
71
+ f"{refdem}",
72
+ "-o",
73
+ f"{path.replace('.csv', '')}",
74
+ ]
75
+
76
+ run_subprocess_command(command)
77
+ except Exception:
78
+ logger.warning(
79
+ f"\n\nCould not generate geodiff file for {path}. Check that the geodiff ASP tool is installed and the reference DEM {refdem} exists.\n\n"
80
+ )
41
81
 
42
82
  def get_residuals_gdf(self, csv_path, residuals_in_meters=True):
43
83
  cols = [
@@ -18,55 +18,55 @@ from asp_plot.utils import compile_report
18
18
  "--directory",
19
19
  prompt=True,
20
20
  default="./",
21
- help="Directory of ASP processing with scenes and sub-directories for bundle adjustment and stereo. Default: current directory",
21
+ help="Required directory of ASP processing with scenes and sub-directories for stereo and optionally bundle adjustment. Default: current directory.",
22
22
  )
23
23
  @click.option(
24
24
  "--bundle_adjust_directory",
25
- prompt=True,
26
- default="ba",
27
- help="Directory of bundle adjustment files. Default: ba",
25
+ prompt=False,
26
+ default=None,
27
+ help="Optional directory of bundle adjustment files. If expected *residuals_pointmap.csv files are not found in the supplied directory, no bundle adjustment plots will be generated. Default: None.",
28
28
  )
29
29
  @click.option(
30
30
  "--stereo_directory",
31
31
  prompt=True,
32
32
  default="stereo",
33
- help="Directory of stereo files. Default: stereo",
33
+ help="Required directory of stereo files. Default: stereo.",
34
34
  )
35
35
  @click.option(
36
36
  "--map_crs",
37
- prompt=True,
38
- default="EPSG:4326",
39
- help="Projection for bundle adjustment plots. Default: EPSG:4326",
37
+ prompt=False,
38
+ default=None,
39
+ help="Projection for ICESat and bundle adjustment plots. Default: None.",
40
40
  )
41
41
  @click.option(
42
42
  "--reference_dem",
43
- prompt=True,
44
- default="",
45
- help="Reference DEM used in ASP processing. No default. Must be supplied.",
43
+ prompt=False,
44
+ default=None,
45
+ help="Optional reference DEM used in ASP processing. No default. If not supplied, the logs will be examined to find it. If not found, no difference plots will be generated.",
46
46
  )
47
47
  @click.option(
48
48
  "--add_basemap",
49
49
  prompt=False,
50
50
  default=True,
51
- help="If True, add a contextily basemap to the figure, which requires internet connection. Default: True",
51
+ help="If True, add a contextily basemap to the figure, which requires internet connection. Default: True.",
52
52
  )
53
53
  @click.option(
54
54
  "--plot_icesat",
55
55
  prompt=False,
56
56
  default=True,
57
- help="If True, plot an ICESat-2 difference plot with the DEM result. This requires internet connection to pull ICESat data. Default: True",
57
+ help="If True, plot an ICESat-2 difference plot with the DEM result. This requires internet connection to pull ICESat data. Default: True.",
58
58
  )
59
59
  @click.option(
60
60
  "--report_filename",
61
61
  prompt=False,
62
62
  default=None,
63
- help="PDF file to write out for report into the processing directory supplied by --directory. Default: Directory name of ASP processing",
63
+ help="PDF file to write out for report into the processing directory supplied by --directory. Default: Directory name of ASP processing.",
64
64
  )
65
65
  @click.option(
66
66
  "--report_title",
67
67
  prompt=False,
68
68
  default=None,
69
- help="Title for the report. Default: Directory name of ASP processing",
69
+ help="Title for the report. Default: Directory name of ASP processing.",
70
70
  )
71
71
  def main(
72
72
  directory,
@@ -79,7 +79,7 @@ def main(
79
79
  report_filename,
80
80
  report_title,
81
81
  ):
82
- print(f"\n\nProcessing ASP files in {directory}\n\n")
82
+ print(f"\nProcessing ASP files in {directory}\n")
83
83
 
84
84
  plots_directory = os.path.join(directory, "tmp_asp_report_plots/")
85
85
  os.makedirs(plots_directory, exist_ok=True)
@@ -92,6 +92,13 @@ def main(
92
92
 
93
93
  figure_counter = count(0)
94
94
 
95
+ if map_crs is None:
96
+ print(
97
+ "\nNo map projection supplied. Defaulting to EPSG:4326. If you want a different projection, supply it with the --map_crs flag.\n"
98
+ )
99
+ map_crs = "EPSG:4326"
100
+ add_basemap = False
101
+
95
102
  if add_basemap:
96
103
  ctx_kwargs = {
97
104
  "crs": map_crs,
@@ -102,23 +109,57 @@ def main(
102
109
  else:
103
110
  ctx_kwargs = {}
104
111
 
105
- # Detailed hillshade plot
112
+ # Stereo plots
106
113
  plotter = StereoPlotter(
107
114
  directory,
108
115
  stereo_directory,
109
- reference_dem,
116
+ reference_dem=reference_dem,
110
117
  out_dem_gsd=1,
111
118
  title="Hillshade with details",
112
119
  )
113
120
 
121
+ asp_dem = plotter.dem_fn
122
+
114
123
  plotter.plot_detailed_hillshade(
115
124
  save_dir=plots_directory,
116
125
  fig_fn=f"{next(figure_counter):02}.png",
117
126
  )
118
127
 
128
+ plotter.title = "Stereo DEM Results"
129
+ plotter.plot_dem_results(
130
+ save_dir=plots_directory,
131
+ fig_fn=f"{next(figure_counter):02}.png",
132
+ )
133
+
134
+ plotter.title = "Disparity (pixels)"
135
+ plotter.plot_disparity(
136
+ unit="pixels",
137
+ quiver=True,
138
+ save_dir=plots_directory,
139
+ fig_fn=f"{next(figure_counter):02}.png",
140
+ )
141
+
142
+ plotter.title = "Stereo Match Points"
143
+ plotter.plot_match_points(
144
+ save_dir=plots_directory,
145
+ fig_fn=f"{next(figure_counter):02}.png",
146
+ )
147
+
148
+ # Scene plot
149
+ plotter = ScenePlotter(directory, stereo_directory, title="Mapprojected Scenes")
150
+ plotter.plot_orthos(
151
+ save_dir=plots_directory, fig_fn=f"{next(figure_counter):02}.png"
152
+ )
153
+
154
+ # Geometry plot
155
+ plotter = SceneGeometryPlotter(directory)
156
+ plotter.dg_geom_plot(
157
+ save_dir=plots_directory, fig_fn=f"{next(figure_counter):02}.png"
158
+ )
159
+
119
160
  # ICESat-2 comparison
120
161
  if plot_icesat:
121
- icesat = Altimetry(dem_fn=plotter.dem_fn)
162
+ icesat = Altimetry(dem_fn=asp_dem)
122
163
 
123
164
  icesat.pull_atl06sr(
124
165
  esa_worldcover=True,
@@ -144,118 +185,86 @@ def main(
144
185
  fig_fn=f"{next(figure_counter):02}.png",
145
186
  )
146
187
 
147
- # Geometry plot
148
- plotter = SceneGeometryPlotter(directory)
149
-
150
- plotter.dg_geom_plot(
151
- save_dir=plots_directory, fig_fn=f"{next(figure_counter):02}.png"
152
- )
153
-
154
- # Scene plot
155
- plotter = ScenePlotter(directory, stereo_directory, title="Mapprojected Scenes")
156
-
157
- plotter.plot_orthos(
158
- save_dir=plots_directory, fig_fn=f"{next(figure_counter):02}.png"
159
- )
160
-
161
188
  # Bundle adjustment plots
162
- ba_files = ReadBundleAdjustFiles(directory, bundle_adjust_directory)
163
- resid_initial_gdf, resid_final_gdf = ba_files.get_initial_final_residuals_gdfs()
164
- geodiff_initial_gdf, geodiff_final_gdf = ba_files.get_initial_final_geodiff_gdfs()
165
- resid_mapprojected_gdf = ba_files.get_mapproj_residuals_gdf()
166
-
167
- plotter = PlotBundleAdjustFiles(
168
- [resid_initial_gdf, resid_final_gdf],
169
- lognorm=True,
170
- title="Bundle Adjust Initial and Final Residuals (Log Scale)",
171
- )
172
-
173
- plotter.plot_n_gdfs(
174
- column_name="mean_residual",
175
- cbar_label="Mean residual (px)",
176
- map_crs=map_crs,
177
- save_dir=plots_directory,
178
- fig_fn=f"{next(figure_counter):02}.png",
179
- **ctx_kwargs,
180
- )
181
-
182
- plotter.lognorm = False
183
- plotter.title = "Bundle Adjust Initial and Final Residuals (Linear Scale)"
184
-
185
- plotter.plot_n_gdfs(
186
- column_name="mean_residual",
187
- cbar_label="Mean residual (px)",
188
- common_clim=False,
189
- map_crs=map_crs,
190
- save_dir=plots_directory,
191
- fig_fn=f"{next(figure_counter):02}.png",
192
- **ctx_kwargs,
193
- )
194
-
195
- plotter = PlotBundleAdjustFiles(
196
- [resid_mapprojected_gdf],
197
- title="Bundle Adjust Midpoint distance between\nfinal interest points projected onto reference DEM",
198
- )
199
-
200
- plotter.plot_n_gdfs(
201
- column_name="mapproj_ip_dist_meters",
202
- cbar_label="Interest point distance (m)",
203
- map_crs=map_crs,
204
- save_dir=plots_directory,
205
- fig_fn=f"{next(figure_counter):02}.png",
206
- **ctx_kwargs,
207
- )
208
-
209
- plotter = PlotBundleAdjustFiles(
210
- [geodiff_initial_gdf, geodiff_final_gdf],
211
- lognorm=False,
212
- title="Bundle Adjust Initial and Final Geodiff vs. Reference DEM",
213
- )
214
-
215
- plotter.plot_n_gdfs(
216
- column_name="height_diff_meters",
217
- cbar_label="Height difference (m)",
218
- map_crs=map_crs,
219
- cmap="RdBu",
220
- symm_clim=True,
221
- save_dir=plots_directory,
222
- fig_fn=f"{next(figure_counter):02}.png",
223
- **ctx_kwargs,
224
- )
225
-
226
- # Stereo plots
227
- plotter = StereoPlotter(
228
- directory,
229
- stereo_directory,
230
- reference_dem,
231
- out_dem_gsd=1,
232
- title="Stereo Match Points",
233
- )
234
-
235
- plotter.plot_match_points(
236
- save_dir=plots_directory,
237
- fig_fn=f"{next(figure_counter):02}.png",
238
- )
239
-
240
- plotter.title = "Disparity (pixels)"
241
-
242
- plotter.plot_disparity(
243
- unit="pixels",
244
- quiver=True,
245
- save_dir=plots_directory,
246
- fig_fn=f"{next(figure_counter):02}.png",
247
- )
248
-
249
- plotter.title = "Stereo DEM Results"
250
-
251
- plotter.plot_dem_results(
252
- save_dir=plots_directory,
253
- fig_fn=f"{next(figure_counter):02}.png",
254
- )
189
+ if bundle_adjust_directory:
190
+ try:
191
+ ba_files = ReadBundleAdjustFiles(directory, bundle_adjust_directory)
192
+ resid_initial_gdf, resid_final_gdf = (
193
+ ba_files.get_initial_final_residuals_gdfs()
194
+ )
195
+ geodiff_initial_gdf, geodiff_final_gdf = (
196
+ ba_files.get_initial_final_geodiff_gdfs()
197
+ )
198
+ resid_mapprojected_gdf = ba_files.get_mapproj_residuals_gdf()
199
+
200
+ plotter = PlotBundleAdjustFiles(
201
+ [resid_initial_gdf, resid_final_gdf],
202
+ lognorm=True,
203
+ title="Bundle Adjust Initial and Final Residuals (Log Scale)",
204
+ )
205
+
206
+ plotter.plot_n_gdfs(
207
+ column_name="mean_residual",
208
+ cbar_label="Mean residual (px)",
209
+ map_crs=map_crs,
210
+ save_dir=plots_directory,
211
+ fig_fn=f"{next(figure_counter):02}.png",
212
+ **ctx_kwargs,
213
+ )
214
+
215
+ plotter.lognorm = False
216
+ plotter.title = "Bundle Adjust Initial and Final Residuals (Linear Scale)"
217
+
218
+ plotter.plot_n_gdfs(
219
+ column_name="mean_residual",
220
+ cbar_label="Mean residual (px)",
221
+ common_clim=False,
222
+ map_crs=map_crs,
223
+ save_dir=plots_directory,
224
+ fig_fn=f"{next(figure_counter):02}.png",
225
+ **ctx_kwargs,
226
+ )
227
+
228
+ plotter = PlotBundleAdjustFiles(
229
+ [resid_mapprojected_gdf],
230
+ title="Bundle Adjust Midpoint distance between\nfinal interest points projected onto reference DEM",
231
+ )
232
+
233
+ plotter.plot_n_gdfs(
234
+ column_name="mapproj_ip_dist_meters",
235
+ cbar_label="Interest point distance (m)",
236
+ map_crs=map_crs,
237
+ save_dir=plots_directory,
238
+ fig_fn=f"{next(figure_counter):02}.png",
239
+ **ctx_kwargs,
240
+ )
241
+
242
+ plotter = PlotBundleAdjustFiles(
243
+ [geodiff_initial_gdf, geodiff_final_gdf],
244
+ lognorm=False,
245
+ title="Bundle Adjust Initial and Final Geodiff vs. Reference DEM",
246
+ )
247
+
248
+ plotter.plot_n_gdfs(
249
+ column_name="height_diff_meters",
250
+ cbar_label="Height difference (m)",
251
+ map_crs=map_crs,
252
+ cmap="RdBu",
253
+ symm_clim=True,
254
+ save_dir=plots_directory,
255
+ fig_fn=f"{next(figure_counter):02}.png",
256
+ **ctx_kwargs,
257
+ )
258
+ except ValueError:
259
+ print(
260
+ f"\n\nNo bundle adjustment files found in directory {os.path.join(directory, bundle_adjust_directory):}. If you want bundle adjustment plots, make sure you run the tool and supply the correct directory to asp_plot.\n\n"
261
+ )
255
262
 
256
263
  # Compile report
257
264
  processing_parameters = ProcessingParameters(
258
- directory, bundle_adjust_directory, stereo_directory
265
+ processing_directory=directory,
266
+ bundle_adjust_directory=bundle_adjust_directory,
267
+ stereo_directory=stereo_directory,
259
268
  )
260
269
  processing_parameters_dict = processing_parameters.from_log_files()
261
270
 
@@ -304,17 +304,25 @@ def csm_camera_summary_plot(
304
304
 
305
305
  # Trim the beginning and end of the geodataframes
306
306
  if trim:
307
- gdf_cam1 = trim_gdf(
308
- gdf_cam1,
309
- near_zero_tolerance=near_zero_tolerance,
310
- trim_percentage=trim_percentage,
311
- )
312
- if cam2_list:
313
- gdf_cam2 = trim_gdf(
314
- gdf_cam2,
307
+ # When position changes are all zero, the trimming will fail
308
+ # https://github.com/uw-cryo/asp_plot/issues/54
309
+ if np.sum(gdf_cam1.position_diff_magnitude > 0) == 0:
310
+ print(
311
+ "\nWarning: No data to trim from the beginning and end of the camera files. Position changes are all zero.\n"
312
+ )
313
+ trim = False
314
+ else:
315
+ gdf_cam1 = trim_gdf(
316
+ gdf_cam1,
315
317
  near_zero_tolerance=near_zero_tolerance,
316
318
  trim_percentage=trim_percentage,
317
319
  )
320
+ if cam2_list:
321
+ gdf_cam2 = trim_gdf(
322
+ gdf_cam2,
323
+ near_zero_tolerance=near_zero_tolerance,
324
+ trim_percentage=trim_percentage,
325
+ )
318
326
 
319
327
  # Calculate colorbar ranges
320
328
  position_values = gdf_cam1.position_diff_magnitude[
@@ -323,26 +331,21 @@ def csm_camera_summary_plot(
323
331
  angular_values = gdf_cam1.angular_diff_magnitude[
324
332
  gdf_cam1.angular_diff_magnitude > 0
325
333
  ]
326
- cam1_position_vmin, cam1_position_vmax = np.percentile(
327
- position_values, [0, upper_magnitude_percentile]
328
- )
329
- cam1_angular_vmin, cam1_angular_vmax = np.percentile(
330
- angular_values, [0, upper_magnitude_percentile]
331
- )
332
-
333
- if cam2_list:
334
- position_values = gdf_cam2.position_diff_magnitude[
335
- gdf_cam2.position_diff_magnitude > 0
336
- ]
337
- angular_values = gdf_cam2.angular_diff_magnitude[
338
- gdf_cam2.angular_diff_magnitude > 0
339
- ]
340
- cam2_position_vmin, cam2_position_vmax = np.percentile(
334
+ # When position or angular changes are all zero, the percentile calculation will fail
335
+ # https://github.com/uw-cryo/asp_plot/issues/54
336
+ try:
337
+ cam1_position_vmin, cam1_position_vmax = np.percentile(
341
338
  position_values, [0, upper_magnitude_percentile]
342
339
  )
343
- cam2_angular_vmin, cam2_angular_vmax = np.percentile(
340
+ except IndexError:
341
+ cam1_position_vmin, cam1_position_vmax = 0, 0
342
+
343
+ try:
344
+ cam1_angular_vmin, cam1_angular_vmax = np.percentile(
344
345
  angular_values, [0, upper_magnitude_percentile]
345
346
  )
347
+ except IndexError:
348
+ cam1_angular_vmin, cam1_angular_vmax = 0, 0
346
349
 
347
350
  if upper_magnitude_percentile == 100:
348
351
  extend = "neither"