Skip to content

Commit

Permalink
Merge pull request #28 from leiyangleon/fix_25_percentile_index_error
Browse files Browse the repository at this point in the history
fix IndexError in calculating the slowest 25 percentile pixels for the velocity error estimate
  • Loading branch information
leiyangleon authored Apr 23, 2021
2 parents 67570d9 + 818a8de commit b973c1b
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 b973c1b

Please sign in to comment.