Skip to content

Commit

Permalink
May 2021 fixes (#22)
Browse files Browse the repository at this point in the history
* realized gsd was not provided to mapproject in ctx step, need to have it overwrite the gsd params in case it differs

* fixes for downscaling

* updating versions and changelog, need to update docs soon before version release
  • Loading branch information
AndrewAnnex committed May 30, 2021
1 parent bc9de88 commit be27304
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 26 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ All notable changes to ASAP-Stereo will be documented here
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project tries to adhere to [Semantic Versioning](http://semver.org/).

## [0.2.0] - 2021-05-30
### Added
- Stereo quality report, adds pvl as dependency
- Downscale parameter to both pipelines for faster processing

### Changed
- Changed 2 stage pipeline to use geodiff for max disparity, simplifying pipeline to single step

### Removed
- removed 2nd pc_align step for both ctx/hirise


## [0.1.0] - 2020-10-31
### Added
Expand Down
2 changes: 1 addition & 1 deletion asap_stereo/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version_info = (0, 1, 0)
version_info = (0, 2, 0)
__version__ = ".".join(map(str, version_info))
21 changes: 12 additions & 9 deletions asap_stereo/asap.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ class CommonSteps(object):
/ ___ |___/ / ___ |/ ____/
/_/ |_/____/_/ |_/_/ 𝑆 𝑇 𝐸 𝑅 𝐸 𝑂
asap_stereo (0.1.0)
asap_stereo (0.2.0)
Github: https://github.com/AndrewAnnex/asap_stereo
Expand Down Expand Up @@ -705,7 +705,7 @@ class CTX(object):
/ ___ |___/ / ___ |/ ____/
/_/ |_/____/_/ |_/_/ 𝑆 𝑇 𝐸 𝑅 𝐸 𝑂
asap_stereo (0.1.0)
asap_stereo (0.2.0)
Github: https://github.com/AndrewAnnex/asap_stereo
Expand Down Expand Up @@ -745,7 +745,7 @@ def generate_ctx_pair_list(self, one, two):

@staticmethod
def notebook_pipeline_make_dem(left: str, right: str, config1: str, pedr_list: str = None, downsample: int = None, working_dir ='./',
config2: Optional[str] = None, demgsd = 24.0, imggsd = 6.0, maxdisp = None, out_notebook=None, **kwargs):
config2: Optional[str] = None, dem_gsd = 24.0, img_gsd = 6.0, maxdisp = None, out_notebook=None, **kwargs):
"""
First step in CTX DEM pipeline that uses papermill to persist log
Expand All @@ -761,8 +761,8 @@ def notebook_pipeline_make_dem(left: str, right: str, config1: str, pedr_list: s
:param right: Second image id
:param maxdisp: Maximum expected displacement in meters, use None to determine it automatically
:param downsample: Factor to downsample images for faster production
:param demgsd: desired GSD of output DEMs (4x image GSD)
:param imggsd: desired GSD of output ortho images
:param dem_gsd: desired GSD of output DEMs (4x image GSD)
:param img_gsd: desired GSD of output ortho images
"""
if not out_notebook:
out_notebook = f'{working_dir}/log_asap_notebook_pipeline_make_dem.ipynb'
Expand All @@ -777,8 +777,8 @@ def notebook_pipeline_make_dem(left: str, right: str, config1: str, pedr_list: s
'config2': config2,
'output_path' : working_dir,
'maxdisp': maxdisp,
'demgsd' : demgsd,
'imggsd' : imggsd,
'dem_gsd' : dem_gsd,
'img_gsd' : img_gsd,
'downsample' : downsample,
},
request_save_on_cell_execute=True,
Expand Down Expand Up @@ -922,6 +922,9 @@ def step_nine(self, refdem=None, mpp=6):
else:
refdem = Path(refdem).absolute()
with cd(Path.cwd() / both):
# double check provided gsd
self.cs.check_mpp_against_true_gsd(f'{left}.lev1eo.cub', mpp)
self.cs.check_mpp_against_true_gsd(f'{right}.lev1eo.cub', mpp)
# map project both ctx images against the reference dem
# might need to do par do here
self.cs.mapproject('-t', 'isis', refdem, f'{left}.lev1eo.cub', f'{left}.ba.map.tif', '--mpp', mpp, '--bundle-adjust-prefix', 'adjust/ba')
Expand Down Expand Up @@ -1076,7 +1079,7 @@ class HiRISE(object):
/ ___ |___/ / ___ |/ ____/
/_/ |_/____/_/ |_/_/ 𝑆 𝑇 𝐸 𝑅 𝐸 𝑂
asap_stereo (0.1.0)
asap_stereo (0.2.0)
Github: https://github.com/AndrewAnnex/asap_stereo
Expand Down Expand Up @@ -1504,7 +1507,7 @@ class ASAP(object):
/ ___ |___/ / ___ |/ ____/
/_/ |_/____/_/ |_/_/ 𝑆 𝑇 𝐸 𝑅 𝐸 𝑂
asap_stereo (0.1.0)
asap_stereo (0.2.0)
Github: https://github.com/AndrewAnnex/asap_stereo
Expand Down
30 changes: 20 additions & 10 deletions asap_stereo/asap_ctx_workflow.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"right = None\n",
"config1 = None\n",
"config2 = None\n",
"demgsd = 24.0\n",
"imggsd = 6.0\n",
"dem_gsd = 24.0\n",
"img_gsd = 6.0\n",
"output_path = None\n",
"maxdisp = None\n",
"downsample = None\n",
Expand Down Expand Up @@ -80,7 +80,8 @@
"source": [
"from IPython.display import Image\n",
"from pathlib import Path\n",
"from asap_stereo import asap"
"from asap_stereo import asap\n",
"import math"
]
},
{
Expand Down Expand Up @@ -184,7 +185,16 @@
"outputs": [],
"source": [
"if downsample:\n",
" asap.CommonSteps().rescale_and_overwrite(factor=downsample)\n"
" true_img_gsd_left = asap.CommonSteps().get_image_gsd(f'{left}_{right}/{left}.lev1eo.cub')\n",
" true_img_gsd_right = asap.CommonSteps().get_image_gsd(f'{left}_{right}/{right}.lev1eo.cub')\n",
" # take conservative approach, pick worst image GSD\n",
" res_gsd = max(true_img_gsd_left, true_img_gsd_right)\n",
" # this is because rescale in ISIS does not update GSD in metadata\n",
" asap.CommonSteps().rescale_and_overwrite(factor=downsample)\n",
" img_gsd = math.ceil(res_gsd)*downsample\n",
" dem_gsd = 4*img_gsd\n",
" print('new img gsd', img_gsd)\n",
" print('new dem gsd', dem_gsd)"
],
"metadata": {
"collapsed": false,
Expand Down Expand Up @@ -392,7 +402,7 @@
"execution_count": null,
"outputs": [],
"source": [
"!asap ctx step-nine 2>&1 | tee -i -a ./5_mapproject_to_100m_dem.log ./full_log.log"
"!asap ctx step-nine --mpp {img_gsd} 2>&1 | tee -i -a ./5_mapproject_to_100m_dem.log ./full_log.log"
],
"metadata": {
"collapsed": false,
Expand Down Expand Up @@ -443,7 +453,7 @@
"execution_count": null,
"outputs": [],
"source": [
"!asap ctx step-seven --folder results_map_ba"
"!asap ctx step-seven --mpp {dem_gsd} --folder results_map_ba"
],
"metadata": {
"collapsed": false,
Expand Down Expand Up @@ -539,7 +549,7 @@
"outputs": [],
"source": [
"both = f'{left}_{right}'\n",
"img = f'./{both}/results_map_ba/dem/{both}_ba_24_0-DEM-hillshade.tif'\n",
"img = './' + str(next(Path('./').glob(f'./{both}/results_map_ba/dem/{both}_ba_*-DEM-hillshade.tif')))\n",
"out = img.replace('.tif', '.png')"
]
},
Expand Down Expand Up @@ -622,7 +632,7 @@
"execution_count": null,
"outputs": [],
"source": [
"!asap ctx step_fourteen --mpp {demgsd} 2>&1 | tee -i -a ./9_dems_orthos.log ./full_log.log"
"!asap ctx step_fourteen --mpp {dem_gsd} 2>&1 | tee -i -a ./9_dems_orthos.log ./full_log.log"
],
"metadata": {
"collapsed": false,
Expand Down Expand Up @@ -664,7 +674,7 @@
"execution_count": null,
"outputs": [],
"source": [
"img = './' + str(next(Path('./').glob('./*/results_map_ba/dem_align/*_ba_align_24_0-DEM-hillshade.tif')))\n",
"img = './' + str(next(Path('./').glob('./*/results_map_ba/dem_align/*_ba_align_*-DEM-hillshade.tif')))\n",
"out = img.replace('.tif', '.png')"
],
"metadata": {
Expand Down Expand Up @@ -707,7 +717,7 @@
"execution_count": null,
"outputs": [],
"source": [
"!asap ctx step_fourteen --mpp {imggsd} --just_ortho True 2>&1 | tee -i -a ./12_img_full_ortho.log ./full_log.log"
"!asap ctx step_fourteen --mpp {img_gsd} --just_ortho True 2>&1 | tee -i -a ./12_img_full_ortho.log ./full_log.log"
],
"metadata": {
"collapsed": false,
Expand Down
17 changes: 13 additions & 4 deletions asap_stereo/asap_hirise_workflow.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,16 @@
"outputs": [],
"source": [
"if downsample:\n",
" asap.CommonSteps().rescale_and_overwrite(factor=downsample, postfix='.mos_hijitreged.norm.cub')"
" true_img_gsd_left = asap.CommonSteps().get_image_gsd(f'{left}_{right}/{left}.mos_hijitreged.norm.cub')\n",
" true_img_gsd_right = asap.CommonSteps().get_image_gsd(f'{left}_{right}/{right}.mos_hijitreged.norm.cub')\n",
" # take conservative approach, pick worst image GSD\n",
" res_gsd = max(true_img_gsd_left, true_img_gsd_right)\n",
" # this is because rescale in ISIS does not update GSD in metadata\n",
" asap.CommonSteps().rescale_and_overwrite(factor=downsample, postfix='.mos_hijitreged.norm.cub')\n",
" img_gsd = math.ceil(res_gsd)*downsample\n",
" dem_gsd = 4*imggsd\n",
" print('new img gsd', img_gsd)\n",
" print('new dem gsd', dem_gsd)\n"
],
"metadata": {
"collapsed": false,
Expand Down Expand Up @@ -300,7 +309,7 @@
},
"outputs": [],
"source": [
"!asap hirise step-nine 2>&1 | tee -i -a ./9_previews.log ./full_log.log"
"!asap hirise step-nine --mpp {img_gsd*2} 2>&1 | tee -i -a ./9_previews.log ./full_log.log"
]
},
{
Expand Down Expand Up @@ -444,7 +453,7 @@
},
"outputs": [],
"source": [
"!asap hirise step-eleven {demgsd} 2>&1 | tee -i -a ./11_dems_orthos.log ./full_log.log"
"!asap hirise step-eleven --mpp {demgsd} 2>&1 | tee -i -a ./11_dems_orthos.log ./full_log.log"
]
},
{
Expand Down Expand Up @@ -484,7 +493,7 @@
},
"outputs": [],
"source": [
"!asap hirise step-eleven {imggsd} --just-ortho True 2>&1 | tee -i -a ./13_img_full_ortho.log ./full_log.log"
"!asap hirise step-eleven --mpp {imggsd} --just-ortho True 2>&1 | tee -i -a ./13_img_full_ortho.log ./full_log.log"
]
}
],
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
author = 'Andrew M. Annex'

# The full version, including alpha/beta/rc tags
release = '0.1.0'
release = '0.2.0'


# -- General configuration ---------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# some influences here came from https://github.com/audreyr/cookiecutter/blob/master/setup.py

version = '0.1.0'
version = '0.2.0'


with io.open('README.rst', 'r', encoding='utf-8') as readme_file:
Expand Down

0 comments on commit be27304

Please sign in to comment.