Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

load multiple stack files + resize ionosphere on the fly #796

Merged
merged 4 commits into from
Jun 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/api/module_hierarchy.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Hierarchy of sub-modules within MintPy. Level _N_ modules depends on level _N-1_
/utils
plot (objects/{stack, coord, colors}, utils/{ptime, utils0, readfile, network, map})
utils (objects/{stack, coord}, utils/{ptime, utils1, readfile})
isce_utils (utils/{ptime, readfile, writefile, utils1})
isce_utils (objects/{constants}, utils/{ptime, readfile, writefile, attribute, utils1})
------------------ level 6 --------------------
/objects
insar_vs_gps (objects/{stack, giant}, utils/{readfile, gps, plot, utils})
Expand Down
62 changes: 31 additions & 31 deletions mintpy/defaults/smallbaselineApp.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -26,46 +26,46 @@ mintpy.compute.config = auto #[none / slurm / pbs / lsf ], auto for none (sam
## no - save 0% disk usage, fast [default]
## lzf - save ~57% disk usage, relative slow
## gzip - save ~62% disk usage, very slow [not recommend]
mintpy.load.processor = auto #[isce, aria, hyp3, gmtsar, snap, gamma, roipac], auto for isce
mintpy.load.autoPath = auto #[yes / no], auto for no, use pre-defined auto path
mintpy.load.updateMode = auto #[yes / no], auto for yes, skip re-loading if HDF5 files are complete
mintpy.load.compression = auto #[gzip / lzf / no], auto for no.
mintpy.load.processor = auto #[isce, aria, hyp3, gmtsar, snap, gamma, roipac], auto for isce
mintpy.load.autoPath = auto #[yes / no], auto for no, use pre-defined auto path
mintpy.load.updateMode = auto #[yes / no], auto for yes, skip re-loading if HDF5 files are complete
mintpy.load.compression = auto #[gzip / lzf / no], auto for no.
##---------for ISCE only:
mintpy.load.metaFile = auto #[path of common metadata file for the stack], i.e.: ./reference/IW1.xml, ./referenceShelve/data.dat
mintpy.load.baselineDir = auto #[path of the baseline dir], i.e.: ./baselines
mintpy.load.metaFile = auto #[path of common metadata file for the stack], i.e.: ./reference/IW1.xml, ./referenceShelve/data.dat
mintpy.load.baselineDir = auto #[path of the baseline dir], i.e.: ./baselines
##---------interferogram stack:
mintpy.load.unwFile = auto #[path pattern of unwrapped interferogram files]
mintpy.load.corFile = auto #[path pattern of spatial coherence files]
mintpy.load.connCompFile = auto #[path pattern of connected components files], optional but recommended
mintpy.load.intFile = auto #[path pattern of wrapped interferogram files], optional
mintpy.load.magFile = auto #[path pattern of interferogram magnitude files], optional
mintpy.load.unwFile = auto #[path pattern of unwrapped interferogram files]
mintpy.load.corFile = auto #[path pattern of spatial coherence files]
mintpy.load.connCompFile = auto #[path pattern of connected components files], optional but recommended
mintpy.load.intFile = auto #[path pattern of wrapped interferogram files], optional
mintpy.load.magFile = auto #[path pattern of interferogram magnitude files], optional
##---------ionosphere stack (optional):
mintpy.load.ionUnwFile = auto #[path pattern of unwrapped interferogram files]
mintpy.load.ionCorFile = auto #[path pattern of spatial coherence files]
mintpy.load.ionConnCompFile = auto #[path pattern of connected components files], optional but recommended
mintpy.load.ionUnwFile = auto #[path pattern of unwrapped interferogram files]
mintpy.load.ionCorFile = auto #[path pattern of spatial coherence files]
mintpy.load.ionConnCompFile = auto #[path pattern of connected components files], optional but recommended
##---------offset stack (optional):
mintpy.load.azOffFile = auto #[path pattern of azimuth offset file]
mintpy.load.rgOffFile = auto #[path pattern of range offset file]
mintpy.load.azOffStdFile = auto #[path pattern of azimuth offset variance file], optional but recommended
mintpy.load.rgOffStdFile = auto #[path pattern of range offset variance file], optional but recommended
mintpy.load.offSnrFile = auto #[path pattern of offset signal-to-noise ratio file], optional
mintpy.load.azOffFile = auto #[path pattern of azimuth offset file]
mintpy.load.rgOffFile = auto #[path pattern of range offset file]
mintpy.load.azOffStdFile = auto #[path pattern of azimuth offset variance file], optional but recommended
mintpy.load.rgOffStdFile = auto #[path pattern of range offset variance file], optional but recommended
mintpy.load.offSnrFile = auto #[path pattern of offset signal-to-noise ratio file], optional
##---------geometry:
mintpy.load.demFile = auto #[path of DEM file]
mintpy.load.lookupYFile = auto #[path of latitude /row /y coordinate file], not required for geocoded data
mintpy.load.lookupXFile = auto #[path of longitude/column/x coordinate file], not required for geocoded data
mintpy.load.incAngleFile = auto #[path of incidence angle file], optional but recommended
mintpy.load.azAngleFile = auto #[path of azimuth angle file], optional
mintpy.load.shadowMaskFile = auto #[path of shadow mask file], optional but recommended
mintpy.load.waterMaskFile = auto #[path of water mask file], optional but recommended
mintpy.load.bperpFile = auto #[path pattern of 2D perpendicular baseline file], optional
mintpy.load.demFile = auto #[path of DEM file]
mintpy.load.lookupYFile = auto #[path of latitude /row /y coordinate file], not required for geocoded data
mintpy.load.lookupXFile = auto #[path of longitude/column/x coordinate file], not required for geocoded data
mintpy.load.incAngleFile = auto #[path of incidence angle file], optional but recommended
mintpy.load.azAngleFile = auto #[path of azimuth angle file], optional
mintpy.load.shadowMaskFile = auto #[path of shadow mask file], optional but recommended
mintpy.load.waterMaskFile = auto #[path of water mask file], optional but recommended
mintpy.load.bperpFile = auto #[path pattern of 2D perpendicular baseline file], optional
##---------multilook (optional):
## multilook while loading data with nearest interpolation, to reduce dataset size
mintpy.load.ystep = auto #[int >= 1], auto for 1 - no multilooking
mintpy.load.xstep = auto #[int >= 1], auto for 1 - no multilooking
mintpy.load.ystep = auto #[int >= 1], auto for 1 - no multilooking
mintpy.load.xstep = auto #[int >= 1], auto for 1 - no multilooking
##---------subset (optional):
## if both yx and lalo are specified, use lalo option unless a) no lookup file AND b) dataset is in radar coord
mintpy.subset.yx = auto #[y0:y1,x0:x1 / no], auto for no
mintpy.subset.lalo = auto #[S:N,W:E / no], auto for no
mintpy.subset.yx = auto #[y0:y1,x0:x1 / no], auto for no
mintpy.subset.lalo = auto #[S:N,W:E / no], auto for no


########## 2. modify_network
Expand Down
55 changes: 31 additions & 24 deletions mintpy/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ def create_parser():

parser.add_argument('file1', help='file to be subtracted.')
parser.add_argument('file2', nargs='+', help='file used to subtract')
parser.add_argument('-o', '--output', dest='outfile',
parser.add_argument('-o', '--output', dest='out_file',
help='output file name, default is file1_diff_file2.h5')
parser.add_argument('--force', action='store_true',
parser.add_argument('--force','--force-diff', dest='force_diff', action='store_true',
help='Enforce the differencing for the shared dates only for time-series files')
return parser

Expand All @@ -53,11 +53,20 @@ def cmd_line_parse(iargs=None):
parser = create_parser()
inps = parser.parse_args(args=iargs)

# for timeseries and ifgramStack, only two files differencing is supported
atr = readfile.read_attribute(inps.file1)
if atr['FILE_TYPE'] in ['timeseries', 'ifgramStack']:
# ONLY TWO files differencing is supported for timeseries and ifgramStack types
ftype = readfile.read_attribute(inps.file1)['FILE_TYPE']
if ftype in ['timeseries', 'ifgramStack']:
if len(inps.file2) > 1:
raise SystemExit('ERROR: only one file2 is inputed for {} type'.format(atr['FILE_TYPE']))
raise SystemExit(f'ERROR: ONLY ONE file2 is inputed for {ftype} type!')

# --output
if not inps.out_file:
if len(inps.file2) > 1:
raise ValueError('--output is required for >=2 files!')
fbase1, fext = os.path.splitext(inps.file1)
fbase2 = os.path.splitext(os.path.basename(inps.file2[0]))[0]
inps.out_file = f'{fbase1}_diff_{fbase2}{fext}'

return inps


Expand Down Expand Up @@ -95,22 +104,15 @@ def check_reference(atr1, atr2):
return ref_date, ref_y, ref_x


def diff_file(file1, file2, out_file=None, force=False, max_num_pixel=2e8):
def diff_file(file1, file2, out_file, force_diff=False, max_num_pixel=2e8):
"""calculate/write file1 - file2

Parameters: file1 - str, path of file1
file2 - list of str, path of file2(s)
out_file - str, path of output file
force - bool, overwrite existing output file
Parameters: file1 - str, path of file1
file2 - list(str), path of file2(s)
out_file - str, path of output file
force_diff - bool, overwrite existing output file
max_num_pixel - float, maximum number of pixels for each block
"""
start_time = time.time()

if not out_file:
fbase, fext = os.path.splitext(file1)
if len(file2) > 1:
raise ValueError('Output file name is needed for more than 2 files input.')
out_file = '{}_diff_{}{}'.format(fbase, os.path.splitext(os.path.basename(file2[0]))[0], fext)
print('{} - {} --> {}'.format(file1, file2, out_file))

# Read basic info
Expand Down Expand Up @@ -142,7 +144,7 @@ def diff_file(file1, file2, out_file=None, force=False, max_num_pixel=2e8):
dateShared = np.ones((len(dateList1)), dtype=np.bool_)
if dateListShared != dateList1:
print('WARNING: {} does not contain all dates in {}'.format(file2, file1))
if force:
if force_diff:
dateListEx = list(set(dateList1) - set(dateListShared))
print('Continue and enforce the differencing for their shared dates only.')
print('\twith following dates are ignored for differencing:\n{}'.format(dateListEx))
Expand Down Expand Up @@ -275,18 +277,23 @@ def diff_file(file1, file2, out_file=None, force=False, max_num_pixel=2e8):
print('use metadata from the 1st file: {}'.format(file1))
writefile.write(dsDict, out_file=out_file, metadata=atr1, ref_file=file1)

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

return out_file


def main(iargs=None):
inps = cmd_line_parse(iargs)
start_time = time.time()

inps.outfile = diff_file(inps.file1, inps.file2, inps.outfile, force=inps.force)
diff_file(file1=inps.file1,
file2=inps.file2,
out_file=inps.out_file,
force_diff=inps.force_diff)

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

return inps.outfile
return


#####################################################################################
Expand Down