Skip to content

Commit

Permalink
bugfix in geocode.py --bbox option for gamma products
Browse files Browse the repository at this point in the history
+ 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
  • Loading branch information
yunjunz committed Jul 13, 2023
1 parent f1fc2e9 commit 97fcad7
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
7 changes: 6 additions & 1 deletion src/mintpy/cli/subset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.')
Expand Down
3 changes: 1 addition & 2 deletions src/mintpy/objects/resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/mintpy/utils/arg_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion src/mintpy/utils/plot_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/mintpy/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 97fcad7

Please sign in to comment.