Skip to content

Commit

Permalink
use descriptive variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
braingram committed Oct 18, 2024
1 parent f37ab9a commit 70f4045
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/stcal/outlier_detection/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,21 +93,22 @@ def _abs_deriv(array):
out[np.isnan(array)] = np.nan

# compute row-wise absolute diffference
d = np.abs(np.diff(array, axis=0))
np.putmask(out[1:], np.isfinite(d), d) # no need to do max yet
row_diff = np.abs(np.diff(array, axis=0))
np.putmask(out[1:], np.isfinite(row_diff), row_diff) # no need to do max yet

# since these are absolute differences |r0-r1| = |r1-r0|
# make a view of the target portion of the array
v = out[:-1]
row_offset_view = out[:-1]
# compute an in-place maximum
np.putmask(v, d > v, d)
np.putmask(row_offset_view, row_diff > row_offset_view, row_diff)
del row_diff

# compute col-wise absolute difference
d = np.abs(np.diff(array, axis=1))
v = out[:, 1:]
np.putmask(v, d > v, d)
v = out[:, :-1]
np.putmask(v, d > v, d)
col_diff = np.abs(np.diff(array, axis=1))
col_offset_view = out[:, 1:]
np.putmask(col_offset_view, col_diff > col_offset_view, col_diff)
col_offset_view = out[:, :-1]
np.putmask(col_offset_view, col_diff > col_offset_view, col_diff)
return out


Expand Down

0 comments on commit 70f4045

Please sign in to comment.