From da125620a45af703d6beff9f0d7ea0508f9c0f71 Mon Sep 17 00:00:00 2001 From: Zhang Yunjun Date: Sat, 13 Dec 2025 02:15:33 +0800 Subject: [PATCH 1/2] sbApp: generate maskObs.h5 & use it while plotting geometry + smallbaselineApp: - generate maskObs.h5, in addition to maskConnComp.h5 file, in reference_point step - use `-m maskObs.h5` while plotting geometry at the end to get rid of the zero values in the incidence/azimuthAngle and lat/lon data for a more meaningful display + modify_network: print # of acquisitions to keep --- src/mintpy/modify_network.py | 1 + src/mintpy/smallbaselineApp.py | 30 ++++++++++++++++++++---------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/mintpy/modify_network.py b/src/mintpy/modify_network.py index 7e603c2b9..e9da5aebe 100644 --- a/src/mintpy/modify_network.py +++ b/src/mintpy/modify_network.py @@ -331,6 +331,7 @@ def get_date12_to_drop(inps): date_to_drop = sorted(list(set(dateList) - set(date_to_keep))) if len(date_to_drop) > 0: print(f'number of acquisitions to remove: {len(date_to_drop)}\n{date_to_drop}') + print(f'number of acquisitions to keep : {len(date_to_keep)}\n{date_to_keep}') # checking: # 1) no new date12 to drop against existing file diff --git a/src/mintpy/smallbaselineApp.py b/src/mintpy/smallbaselineApp.py index 9e607093a..c5ef29bc6 100644 --- a/src/mintpy/smallbaselineApp.py +++ b/src/mintpy/smallbaselineApp.py @@ -262,15 +262,16 @@ def run_network_modification(self, step_name): def generate_ifgram_aux_file(self): """Generate auxiliary files from ifgramStack file""" - stack_file = ut.check_loaded_dataset(self.workDir, print_msg=False)[0] + stack_file, geom_file = ut.check_loaded_dataset(self.workDir, print_msg=False)[:2] dsNames = readfile.get_dataset_list(stack_file) - mask_file = os.path.join(self.workDir, 'maskConnComp.h5') + mask_cc_file = os.path.join(self.workDir, 'maskConnComp.h5') + mask_obs_file = os.path.join(self.workDir, 'maskObs.h5') coh_file = os.path.join(self.workDir, 'avgSpatialCoh.h5') snr_file = os.path.join(self.workDir, 'avgSpatialSNR.h5') # 1) generate mask file from the common connected components if any('phase' in i.lower() for i in dsNames): - iargs = [stack_file, '--nonzero', '-o', mask_file, '--update'] + iargs = [stack_file, '--nonzero', '-o', mask_cc_file, '--update'] print('\ngenerate_mask.py', ' '.join(iargs)) import mintpy.cli.generate_mask mintpy.cli.generate_mask.main(iargs) @@ -284,6 +285,13 @@ def generate_ifgram_aux_file(self): import mintpy.cli.temporal_average mintpy.cli.temporal_average.main(iargs) + # 3) generate mask of observations from incidence angle + # to better plot files such as geometry + iargs = [geom_file, 'incidenceAngle', '--nonzero', '-o', mask_obs_file, '--update'] + print('\ngenerate_mask.py', ' '.join(iargs)) + import mintpy.cli.generate_mask + mintpy.cli.generate_mask.main(iargs) + def run_reference_point(self, step_name): """Select reference point. @@ -973,16 +981,18 @@ def plot_result(self, print_aux=True): self.workDir, print_msg=False)[:4] mask_file = os.path.join(self.workDir, 'maskTempCoh.h5') + mask_obs_file = os.path.join(self.workDir, 'maskObs.h5') geo_dir = os.path.join(self.workDir, 'geo') pic_dir = os.path.join(self.workDir, 'pic') # use relative path for shorter and cleaner printout view command - stack_file = os.path.relpath(stack_file) if stack_file else stack_file - ion_file = os.path.relpath(ion_file) if ion_file else ion_file - geom_file = os.path.relpath(geom_file) if geom_file else geom_file - lookup_file = os.path.relpath(lookup_file) if lookup_file else lookup_file - mask_file = os.path.relpath(mask_file) if mask_file else mask_file - geo_dir = os.path.relpath(geo_dir) if geo_dir else geo_dir + stack_file = os.path.relpath(stack_file) if stack_file else stack_file + ion_file = os.path.relpath(ion_file) if ion_file else ion_file + geom_file = os.path.relpath(geom_file) if geom_file else geom_file + lookup_file = os.path.relpath(lookup_file) if lookup_file else lookup_file + mask_file = os.path.relpath(mask_file) if mask_file else mask_file + mask_obs_file = os.path.relpath(mask_obs_file) if mask_obs_file else mask_obs_file + geo_dir = os.path.relpath(geo_dir) if geo_dir else geo_dir # view options # for each element list: @@ -996,7 +1006,7 @@ def plot_result(self, print_aux=True): ['maskTempCoh.h5', '-c', 'gray', '-v', '0', '1'], # geometry - [geom_file], + [geom_file, '-m', mask_obs_file], [lookup_file], # ifgramStack From 45ae571b85ec5606ddbebb229fedcc5b81f58e16 Mon Sep 17 00:00:00 2001 From: Zhang Yunjun Date: Sat, 13 Dec 2025 22:17:37 +0800 Subject: [PATCH 2/2] sourcery suggestions --- src/mintpy/smallbaselineApp.py | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/mintpy/smallbaselineApp.py b/src/mintpy/smallbaselineApp.py index c5ef29bc6..049195c54 100644 --- a/src/mintpy/smallbaselineApp.py +++ b/src/mintpy/smallbaselineApp.py @@ -287,10 +287,11 @@ def generate_ifgram_aux_file(self): # 3) generate mask of observations from incidence angle # to better plot files such as geometry - iargs = [geom_file, 'incidenceAngle', '--nonzero', '-o', mask_obs_file, '--update'] - print('\ngenerate_mask.py', ' '.join(iargs)) - import mintpy.cli.generate_mask - mintpy.cli.generate_mask.main(iargs) + if geom_file is not None: + iargs = [geom_file, 'incidenceAngle', '--nonzero', '-o', mask_obs_file, '--update'] + print('\ngenerate_mask.py', ' '.join(iargs)) + import mintpy.cli.generate_mask + mintpy.cli.generate_mask.main(iargs) def run_reference_point(self, step_name): @@ -981,18 +982,16 @@ def plot_result(self, print_aux=True): self.workDir, print_msg=False)[:4] mask_file = os.path.join(self.workDir, 'maskTempCoh.h5') - mask_obs_file = os.path.join(self.workDir, 'maskObs.h5') geo_dir = os.path.join(self.workDir, 'geo') pic_dir = os.path.join(self.workDir, 'pic') # use relative path for shorter and cleaner printout view command - stack_file = os.path.relpath(stack_file) if stack_file else stack_file - ion_file = os.path.relpath(ion_file) if ion_file else ion_file - geom_file = os.path.relpath(geom_file) if geom_file else geom_file - lookup_file = os.path.relpath(lookup_file) if lookup_file else lookup_file - mask_file = os.path.relpath(mask_file) if mask_file else mask_file - mask_obs_file = os.path.relpath(mask_obs_file) if mask_obs_file else mask_obs_file - geo_dir = os.path.relpath(geo_dir) if geo_dir else geo_dir + stack_file = os.path.relpath(stack_file) if stack_file else stack_file + ion_file = os.path.relpath(ion_file) if ion_file else ion_file + geom_file = os.path.relpath(geom_file) if geom_file else geom_file + lookup_file = os.path.relpath(lookup_file) if lookup_file else lookup_file + mask_file = os.path.relpath(mask_file) if mask_file else mask_file + geo_dir = os.path.relpath(geo_dir) if geo_dir else geo_dir # view options # for each element list: @@ -1006,7 +1005,7 @@ def plot_result(self, print_aux=True): ['maskTempCoh.h5', '-c', 'gray', '-v', '0', '1'], # geometry - [geom_file, '-m', mask_obs_file], + [geom_file], [lookup_file], # ifgramStack @@ -1041,6 +1040,11 @@ def plot_result(self, print_aux=True): ['numInvIfgram.h5', '--mask', 'no'], ] + # mask geometry without observations + mask_obs_file = os.path.join(self.workDir, 'maskObs.h5') + if os.path.isfile(mask_obs_file): + iargs_list0[4] += ['-m', mask_obs_file] + if ion_file: iargs_list0 += [ [ion_file, 'unwrapPhase-', '--zero-mask', '--wrap', '-c', 'cmy'],