Skip to content

Commit

Permalink
fix IndexError in calculating the slowest 25 percentile pixels for th…
Browse files Browse the repository at this point in the history
…e velocity error estimate
  • Loading branch information
leiyangleon committed Apr 23, 2021
1 parent 67570d9 commit 818a8de
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions testautoRIFT.py
Original file line number Diff line number Diff line change
Expand Up @@ -665,8 +665,11 @@ def generateAutoriftProduct(indir_m, indir_s, grid_location, init_offset, search
stable_count = np.sum(SSM & np.logical_not(np.isnan(DX)) & (DX-DXref > -5) & (DX-DXref < 5) & (DY-DYref > -5) & (DY-DYref < 5))

V_temp = np.sqrt(VX**2 + VY**2)
V_temp_threshold = np.percentile(V_temp[np.logical_not(np.isnan(V_temp))],25)
SSM1 = (V_temp <= V_temp_threshold)
try:
V_temp_threshold = np.percentile(V_temp[np.logical_not(np.isnan(V_temp))],25)
SSM1 = (V_temp <= V_temp_threshold)
except IndexError:
SSM1 = np.zeros(V_temp.shape).astype('bool')

stable_count1 = np.sum(SSM1 & np.logical_not(np.isnan(DX)) & (DX-DXref > -5) & (DX-DXref < 5) & (DY-DYref > -5) & (DY-DYref < 5))

Expand Down
7 changes: 5 additions & 2 deletions testautoRIFT_ISCE.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,8 +667,11 @@ def generateAutoriftProduct(indir_m, indir_s, grid_location, init_offset, search
stable_count = np.sum(SSM & np.logical_not(np.isnan(DX)) & (DX-DXref > -5) & (DX-DXref < 5) & (DY-DYref > -5) & (DY-DYref < 5))

V_temp = np.sqrt(VX**2 + VY**2)
V_temp_threshold = np.percentile(V_temp[np.logical_not(np.isnan(V_temp))],25)
SSM1 = (V_temp <= V_temp_threshold)
try:
V_temp_threshold = np.percentile(V_temp[np.logical_not(np.isnan(V_temp))],25)
SSM1 = (V_temp <= V_temp_threshold)
except IndexError:
SSM1 = np.zeros(V_temp.shape).astype('bool')

stable_count1 = np.sum(SSM1 & np.logical_not(np.isnan(DX)) & (DX-DXref > -5) & (DX-DXref < 5) & (DY-DYref > -5) & (DY-DYref < 5))

Expand Down

0 comments on commit 818a8de

Please sign in to comment.