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

subset.py: support subseting in radar coord using lat/lon via --force #1233

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 41 additions & 17 deletions src/mintpy/subset.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,27 +183,51 @@ def subset_input_dict2box(subset_dict, meta_dict):

# Use subset_lat/lon input if existed, priority: lat/lon > y/x > len/wid
coord = ut.coordinate(meta_dict)
if subset_dict.get('subset_lat', None):
sub_y = coord.lalo2yx(subset_dict['subset_lat'], None)[0]
elif subset_dict['subset_y']:
sub_y = subset_dict['subset_y']
else:
sub_y = [0, length]

if subset_dict.get('subset_lon', None):
sub_x = coord.lalo2yx(None, subset_dict['subset_lon'])[1]
elif subset_dict['subset_x']:
sub_x = subset_dict['subset_x']
if 'Y_FIRST' in meta_dict.keys():
geocoded =True
else:
sub_x = [0, width]
geocoded =False

# Get subset box in y/x
sub_x = sorted(sub_x)
sub_y = sorted(sub_y)
pix_box = (sub_x[0], sub_y[0], sub_x[1], sub_y[1])
if geocoded:
if subset_dict.get('subset_lat', None):
sub_y = coord.lalo2yx(subset_dict['subset_lat'], None)[0]
else:
sub_y = [0, length]

# Get subset box in lat/lon from subset box in y/x
geo_box = coord.box_pixel2geo(pix_box)
if subset_dict.get('subset_lon', None):
sub_x = coord.lalo2yx(None, subset_dict['subset_lon'])[1]
else:
sub_x = [0, width]

# Get subset box in y/x
sub_x = sorted(sub_x)
sub_y = sorted(sub_y)
pix_box = (sub_x[0], sub_y[0], sub_x[1], sub_y[1])

# Get subset box in lat/lon from subset box in y/x
geo_box = coord.box_pixel2geo(pix_box)
else:
if subset_dict.get('subset_lat', None):
geo_box = (subset_dict['subset_lon'][0], subset_dict['subset_lat'][1], subset_dict['subset_lon'][1], subset_dict['subset_lat'][0])
pix_box = coord.bbox_geo2radar(geo_box, buf=0)
else:
if subset_dict['subset_y']:
sub_y = subset_dict['subset_y']
else:
sub_y = [0, length]

if subset_dict['subset_x']:
sub_x = subset_dict['subset_x']
else:
sub_x = [0, width]
# Get subset box in y/x
sub_x = sorted(sub_x)
sub_y = sorted(sub_y)
pix_box = (sub_x[0], sub_y[0], sub_x[1], sub_y[1])

# Get subset box in lat/lon from subset box in y/x
geo_box = coord.box_pixel2geo(pix_box)

return pix_box, geo_box

Expand Down