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

utils0.incidence_angle: read from metadata directly if available for dimension==0 #1152

Merged
merged 3 commits into from
Mar 5, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/api/attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ The following attributes vary for each interferogram:
+ NCORRLOOKS = number of independent looks, as explained in [SNAPHU](https://web.stanford.edu/group/radar/softwareandlinks/sw/snaphu/snaphu.conf.full)
+ UTM_ZONE = UTM zone, comprises a zone number and a hemisphere, e.g. 11N, 60S, for geocoded file with UTM projection only.
+ EPSG = EPSG code for coordinate systems, for geocoded files only.
+ CENTER_INCIDENCE_ANGLE = incidence angle in degrees at the scene center, read from the 2D incidence angle matrix, for isce2 files only.

### Reference ###

Expand Down
26 changes: 18 additions & 8 deletions src/mintpy/utils/utils0.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ def incidence_angle(atr, dem=None, dimension=2, print_msg=True):
EARTH_RADIUS
HEIGHT
WIDTH
LENGTH #for dimension=2
LENGTH #for dimension=2
CENTER_INCIDENCE_ANGLE #for dimension=0
dem : 2D array for height to calculate local incidence angle
dimension : int,
2 for 2d matrix
Expand All @@ -116,11 +117,21 @@ def incidence_angle(atr, dem=None, dimension=2, print_msg=True):
atr = readfile.read_attribute('filt_fine.unw')
inc_angle = ut.incidence_angle(atr, dem=dem)
"""
vprint = print if print_msg else lambda *args, **kwargs: None

# Return center value for geocoded input file
if 'Y_FIRST' in atr.keys() and dimension > 0:
dimension = 0
if print_msg:
print('input file is geocoded, return center incident angle only')
vprint('input file is geocoded, return center incident angle only')

# Check if the center inc angle already exist in the metadata
# Notes on Mar 2024 by Alex Handwerger & Talib Oliver-Cabrera:
# Proposing these changes after encountering a range_n value smaller than the platform height
# for UAVSAR dataset swatch_00540, thus, the calc equation w/o considering topography won't work.
if dimension == 0 and 'CENTER_INCIDENCE_ANGLE' in atr.keys():
inc_angle = float(atr['CENTER_INCIDENCE_ANGLE'])
vprint(f'center incidence angle : {inc_angle:.4f} degree (grabbed from metadata directly)')
return inc_angle

# Read Attributes
range_n = float(atr['STARTING_RANGE'])
Expand All @@ -130,14 +141,13 @@ def incidence_angle(atr, dem=None, dimension=2, print_msg=True):
width = int(atr['WIDTH'])

# Calculation
range_f = range_n+dR*width
range_f = range_n + dR * width
inc_angle_n = (np.pi - np.arccos((r**2 + range_n**2 - (r+H)**2)/(2*r*range_n))) * 180.0/np.pi
inc_angle_f = (np.pi - np.arccos((r**2 + range_f**2 - (r+H)**2)/(2*r*range_f))) * 180.0/np.pi
inc_angle_c = (inc_angle_n + inc_angle_f) / 2.0
if print_msg:
print(f'near incidence angle : {inc_angle_n:.4f} degree')
print(f'center incidence angle : {inc_angle_c:.4f} degree')
print(f'far incidence angle : {inc_angle_f:.4f} degree')
vprint(f'near incidence angle : {inc_angle_n:.4f} degree')
vprint(f'center incidence angle : {inc_angle_c:.4f} degree')
vprint(f'far incidence angle : {inc_angle_f:.4f} degree')

if dimension == 0:
inc_angle = inc_angle_c
Expand Down