Skip to content

Commit

Permalink
revert move of default params out of common steps, realized it was mo…
Browse files Browse the repository at this point in the history
…re useful in common steps
  • Loading branch information
AndrewAnnex committed Jul 7, 2021
1 parent 614e913 commit b35e3b4
Showing 1 changed file with 33 additions and 33 deletions.
66 changes: 33 additions & 33 deletions asap_stereo/asap.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,31 +64,6 @@
_threads_multiprocess = _threads_singleprocess // 2 if _threads_singleprocess > 1 else 1 # 12, 8
_processes = _threads_multiprocess // 4 if _threads_multiprocess > 3 else 1 # 3, 2

# defaults for first 3 steps parallel stereo
defaults_ps1 = {
'--processes' : _processes,
'--threads-singleprocess': _threads_singleprocess,
'--threads-multiprocess' : _threads_multiprocess,
'--stop-point' : 4,
'--bundle-adjust-prefix' : 'adjust/ba'
}

# defaults for first last step parallel stereo (triangulation)
defaults_ps2 = {
'--processes' : _threads_singleprocess, # use more cores for triangulation!
'--threads-singleprocess': _threads_singleprocess,
'--threads-multiprocess' : _threads_multiprocess,
'--entry-point' : 4,
'--bundle-adjust-prefix' : 'adjust/ba'
}

# default eqc Iau projections, eventually replace with proj4 lookups
projections = {
"IAU_Mars" : "+proj=eqc +lat_ts=0 +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 +a=3396190 +b=3396190 +units=m +no_defs",
"IAU_Moon" : "+proj=eqc +lat_ts=0 +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 +a=1737400 +b=1737400 +units=m +no_defs",
"IAU_Mercury": "+proj=eqc +lat_ts=0 +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 +a=2439700 +b=2439700 +units=m +no_defs"
}


pool = Semaphore(cores)

Expand Down Expand Up @@ -270,6 +245,31 @@ class CommonSteps(object):
█████████████████████████████████████████████████████████████
"""

# defaults for first 3 steps parallel stereo
defaults_ps1 = {
'--processes': _processes,
'--threads-singleprocess': _threads_singleprocess,
'--threads-multiprocess': _threads_multiprocess,
'--stop-point': 4,
'--bundle-adjust-prefix': 'adjust/ba'
}

# defaults for first last step parallel stereo (triangulation)
defaults_ps2 = {
'--processes': _threads_singleprocess, # use more cores for triangulation!
'--threads-singleprocess': _threads_singleprocess,
'--threads-multiprocess': _threads_multiprocess,
'--entry-point': 4,
'--bundle-adjust-prefix': 'adjust/ba'
}

# default eqc Iau projections, eventually replace with proj4 lookups
projections = {
"IAU_Mars": "+proj=eqc +lat_ts=0 +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 +a=3396190 +b=3396190 +units=m +no_defs",
"IAU_Moon": "+proj=eqc +lat_ts=0 +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 +a=1737400 +b=1737400 +units=m +no_defs",
"IAU_Mercury": "+proj=eqc +lat_ts=0 +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 +a=2439700 +b=2439700 +units=m +no_defs"
}

def __init__(self):
self.parallel_stereo = Command('parallel_stereo').bake(_out=sys.stdout, _err=sys.stderr)
self.point2dem = Command('point2dem').bake(_out=sys.stdout, _err=sys.stderr)
Expand Down Expand Up @@ -749,7 +749,7 @@ def __init__(self, https=False, datum="D_MARS", proj: Optional[str] = None):
self.datum = datum
# if proj is not none, get the corresponding proj or else override with proj,
# otherwise it's a none so remain a none
self.proj = projections.get(proj, proj)
self.proj = self.cs.projections.get(proj, proj)

def get_first_pass_refdem(self)-> str:
left, right, both = self.cs.parse_stereopairs()
Expand Down Expand Up @@ -888,7 +888,7 @@ def step_five(self, stereo_conf, posargs='', **kwargs):
Run first part of parallel_stereo asp_ctx_lev1eo2dem.sh
"""
return self.cs.stereo_asap(stereo_conf, postfix='.lev1eo.cub', posargs=posargs, **{**defaults_ps1, **kwargs})
return self.cs.stereo_asap(stereo_conf, postfix='.lev1eo.cub', posargs=posargs, **{**self.cs.defaults_ps1, **kwargs})

@rich_logger
def step_six(self, stereo_conf, posargs='', **kwargs):
Expand All @@ -897,7 +897,7 @@ def step_six(self, stereo_conf, posargs='', **kwargs):
Run second part of parallel_stereo, asp_ctx_lev1eo2dem.sh stereo is completed after this step
"""
return self.cs.stereo_asap(stereo_conf, postfix='.lev1eo.cub', posargs=posargs, **{**defaults_ps2, **kwargs})
return self.cs.stereo_asap(stereo_conf, postfix='.lev1eo.cub', posargs=posargs, **{**self.cs.defaults_ps2, **kwargs})

@rich_logger
def step_seven(self, mpp=24, just_dem=False, folder='results_ba', **kwargs):
Expand Down Expand Up @@ -978,7 +978,7 @@ def step_ten(self, stereo_conf, refdem=None, posargs='', **kwargs):
:param kwargs:
"""
refdem = str(Path(self.get_first_pass_refdem() if not refdem else refdem).absolute())
return self.cs.stereo_asap(stereo_conf=stereo_conf, refdem=refdem, postfix=['.ba.map.tif', '.lev1eo.cub'], output_file_prefix='results_map_ba/${both}_ba', posargs=posargs, **{**defaults_ps1, **kwargs})
return self.cs.stereo_asap(stereo_conf=stereo_conf, refdem=refdem, postfix=['.ba.map.tif', '.lev1eo.cub'], output_file_prefix='results_map_ba/${both}_ba', posargs=posargs, **{**self.cs.defaults_ps1, **kwargs})

@rich_logger
def step_eleven(self, stereo_conf, refdem=None, posargs='', **kwargs):
Expand All @@ -991,7 +991,7 @@ def step_eleven(self, stereo_conf, refdem=None, posargs='', **kwargs):
:param kwargs:
"""
refdem = str(Path(self.get_first_pass_refdem() if not refdem else refdem).absolute())
return self.cs.stereo_asap(stereo_conf=stereo_conf, refdem=refdem, postfix=['.ba.map.tif', '.lev1eo.cub'], output_file_prefix='results_map_ba/${both}_ba', posargs=posargs, **{**defaults_ps2, **kwargs})
return self.cs.stereo_asap(stereo_conf=stereo_conf, refdem=refdem, postfix=['.ba.map.tif', '.lev1eo.cub'], output_file_prefix='results_map_ba/${both}_ba', posargs=posargs, **{**self.cs.defaults_ps2, **kwargs})

@rich_logger
def step_twelve(self, pedr_list=None, postfix='.lev1eo'):
Expand Down Expand Up @@ -1121,7 +1121,7 @@ def __init__(self, https=False, threads=cores, datum="D_MARS", proj: Optional[st
self.cam2map4stereo = sh.Command('cam2map4stereo.py')
# if proj is not none, get the corresponding proj or else override with proj,
# otherwise it's a none so remain a none
self.proj = projections.get(proj, proj)
self.proj = self.cs.projections.get(proj, proj)

def get_hirise_emission_angle(self, pid: str)-> float:
"""
Expand Down Expand Up @@ -1330,7 +1330,7 @@ def step_seven(self, stereo_conf, postfix='_RED.map.cub', posargs='', **kwargs):
Run first part of parallel_stereo
"""
return self.cs.stereo_asap(stereo_conf, postfix=postfix, posargs=posargs, **{**defaults_ps1, **kwargs})
return self.cs.stereo_asap(stereo_conf, postfix=postfix, posargs=posargs, **{**self.cs.defaults_ps1, **kwargs})

@rich_logger
def step_eight(self, stereo_conf, postfix='_RED.map.cub', posargs='', **kwargs):
Expand All @@ -1339,7 +1339,7 @@ def step_eight(self, stereo_conf, postfix='_RED.map.cub', posargs='', **kwargs):
Run second part of parallel_stereo, stereo is completed after this step
"""
return self.cs.stereo_asap(stereo_conf, postfix=postfix, posargs=posargs, **{**defaults_ps2, **kwargs})
return self.cs.stereo_asap(stereo_conf, postfix=postfix, posargs=posargs, **{**self.cs.defaults_ps2, **kwargs})

@rich_logger
def step_nine(self, mpp=2, just_dem=False, postfix='_RED.map.cub', **kwargs):
Expand Down

0 comments on commit b35e3b4

Please sign in to comment.