From 97fcad776fe95ac3f819c22f72637b7ba9b71dc8 Mon Sep 17 00:00:00 2001 From: Zhang Yunjun Date: Wed, 21 Jun 2023 11:04:35 +0800 Subject: [PATCH] bugfix in geocode.py --bbox option for gamma products + objects/resample.py: fix a bug for `geocode.py --bbox` option while geocoding gamma products with customized SNWE from --bbox option, the output dest_box does not start from 0, thus, should use box[3/4] directly, instead of box[3]-box[1] and box[2]-box[0] + cli/subset: check input file exsitence + view.py --coord: update help msg to avoid potential confusions by updating utils.arg_utils.add_figure_argument() + view.py --coord: set the other choices as yx, instead of radar, and keep radar still in the loop for backward compatiability --- src/mintpy/cli/subset.py | 7 ++++++- src/mintpy/objects/resample.py | 3 +-- src/mintpy/utils/arg_utils.py | 4 ++-- src/mintpy/utils/plot_ext.py | 2 +- src/mintpy/view.py | 6 +++--- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/mintpy/cli/subset.py b/src/mintpy/cli/subset.py index b4515f239..9e4ef5351 100755 --- a/src/mintpy/cli/subset.py +++ b/src/mintpy/cli/subset.py @@ -95,8 +95,13 @@ def cmd_line_parse(iargs=None): # import from mintpy.utils import utils1 as ut + # check: existence of input file + flist = ut.get_file_list(inps.file) + if len(flist) == 0: + raise FileNotFoundError(f'NO file found in: {inps.file}!') + inps.file = flist + # default: disable --output option for multiple input files - inps.file = ut.get_file_list(inps.file) if len(inps.file) > 1 and inps.outfile: inps.outfile = None print('WARNING: disable --output option for multiple input files.') diff --git a/src/mintpy/objects/resample.py b/src/mintpy/objects/resample.py index d256ab646..ef1d25a18 100644 --- a/src/mintpy/objects/resample.py +++ b/src/mintpy/objects/resample.py @@ -619,8 +619,7 @@ def project_yx2lalo(yy, xx, SNWE, laloScale): print(f'output area extent in (S, N, W, E) in degree: {self.SNWE}') # parameter 3 - length / width (output grid) - self.length = dest_box[3] - dest_box[1] - self.width = dest_box[2] - dest_box[0] + self.length, self.width = dest_box[3], dest_box[2] # parameter 4 - list of boxes & geometry definitions diff --git a/src/mintpy/utils/arg_utils.py b/src/mintpy/utils/arg_utils.py index 6dec7e987..290fc88d4 100644 --- a/src/mintpy/utils/arg_utils.py +++ b/src/mintpy/utils/arg_utils.py @@ -208,8 +208,8 @@ def add_figure_argument(parser): fig.add_argument('--no-tight-layout', dest='fig_tight_layout', action='store_false', help='disable automatic tight layout for multiple subplots') - fig.add_argument('--coord', dest='fig_coord', choices=['radar', 'geo'], default='geo', - help='Display in radar/geo coordination system ' + fig.add_argument('--coord', dest='fig_coord', choices=['geo','radar','yx'], default='geo', + help='Display axes in geo or yx coordinates ' '(for geocoded file only; default: %(default)s).') fig.add_argument('--animation', action='store_true', help='enable animation mode') diff --git a/src/mintpy/utils/plot_ext.py b/src/mintpy/utils/plot_ext.py index d97b3fc56..da5a06fd4 100644 --- a/src/mintpy/utils/plot_ext.py +++ b/src/mintpy/utils/plot_ext.py @@ -96,7 +96,7 @@ def get_poly_mask(fname, datasetName, print_msg=True, view_cmd=''): d_v, atr ,inps = view.prep_slice(cmd) ax = plt.subplots(figsize=inps.fig_size)[1] - inps.fig_coord = 'radar' #selector works for radar coord plot only + inps.fig_coord = 'yx' # selector works for y/x coord plot only ax, inps, im = view.plot_slice(ax, d_v, atr, inps)[0:3] ## Option 2 - Simple plot with matplotlib diff --git a/src/mintpy/view.py b/src/mintpy/view.py index a084836fb..3f245e109 100644 --- a/src/mintpy/view.py +++ b/src/mintpy/view.py @@ -185,7 +185,7 @@ def check_map_projection(inps, metadata, print_msg=True): This function will update the following variables: inps.map_proj_obj # cartopy.crs.* object or None inps.coord_unit # degree or meter - inps.fig_coord # geo or radar + inps.fig_coord # geo or yx """ inps.map_proj_obj = None @@ -215,7 +215,7 @@ def check_map_projection(inps, metadata, print_msg=True): else: print(f'WARNING: Un-recognized coordinate unit: {inps.coord_unit}') print(' Switch to the native Y/X and continue to plot') - inps.fig_coord = 'radar' + inps.fig_coord = 'yx' return inps @@ -605,7 +605,7 @@ def format_coord(x, y): #------------------------ Plot in Y/X-coordinate ------------------------------------------------# else: - inps.fig_coord = 'radar' + inps.fig_coord = 'yx' vprint('plotting in Y/X coordinate ...') # Plot DEM