Skip to content

Commit

Permalink
isce_utils: add unwrap_icu() (#993)
Browse files Browse the repository at this point in the history
+ utils/isce_utils: add unwrap_icu() for pythonic re-use

+ view: ignore whitespaces in output figure file name
  • Loading branch information
yunjunz committed Apr 19, 2023
1 parent 5ca554f commit aba54cf
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
55 changes: 55 additions & 0 deletions src/mintpy/utils/isce_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1095,3 +1095,58 @@ def unwrap_snaphu(int_file, cor_file, unw_file, defo_max=2.0, max_comp=32,
print(f'time used: {m:02.0f} mins {s:02.1f} secs.')

return unw_file


def unwrap_icu(int_file, unw_file):
"""Unwrap interferograms using ICU via isce2.
Modified from ISCE-2/topsStack/unwrap.py.
Parameters: int_file - str, path of wrapped interferogram
unw_file - str, path of unwrapped interferogram
Returns: unw_file - str, path of unwrapped interferogram
"""
import isce
import isceobj
from mroipac.icu.Icu import Icu

start_time = time.time()

# get width
img = isceobj.Image.createImage()
img.load(int_file + '.xml')
width = img.getWidth()

# create image object for .int file
int_img = isceobj.Image.createIntImage()
int_img.initImage(int_file, 'read', width)
int_img.createImage()

# create image object for .unw file
unw_img = isceobj.Image.createImage()
unw_img.setFilename(unw_file)
unw_img.setWidth(width)
unw_img.imageType = 'unw'
unw_img.bands = 2
unw_img.scheme = 'BIL'
unw_img.dataType = 'FLOAT'
unw_img.setAccessMode('write')
unw_img.createImage()

# run ICU
icu_obj = Icu()
icu_obj.filteringFlag = False
icu_obj.useAmplitudeFalg = False
icu_obj.singlePatch = True
icu_obj.initCorrThresdhold = 0.1
icu_obj.icu(intImage=int_img, unwImage=unw_img)

int_img.finalizeImage()
unw_img.finalizeImage()
unw_img.renderHdr()
unw_img.renderVRT()

# time usage
m, s = divmod(time.time() - start_time, 60)
print(f'time used: {m:02.0f} mins {s:02.1f} secs.')

return unw_file
4 changes: 3 additions & 1 deletion src/mintpy/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@ def update_inps_with_file_metadata(inps, metadata):

# Figure output file name
if not inps.outfile:
inps.outfile = [f'{inps.fig_title}{inps.fig_ext}']
# ignore whitespaces in the filename
fbase = inps.fig_title.replace(' ', '')
inps.outfile = [f'{fbase}{inps.fig_ext}']

inps = update_figure_setting(inps)
return inps
Expand Down

0 comments on commit aba54cf

Please sign in to comment.