Skip to content

Commit

Permalink
add more comments for NaN value handling in apmlitude dispersion
Browse files Browse the repository at this point in the history
  • Loading branch information
rogerkuou committed Mar 26, 2024
1 parent 7ee2325 commit e21a355
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion sarxarray/stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ def point_selection(self, threshold, method="amplitude_dispersion", chunks=1000)
"""
match method:
case "amplitude_dispersion":
# Amplitude dispersion thresholding
# Note there can be NaN values in the amplitude dispersion
# However NaN values will not pass this threshold
mask = self._amp_disp() < threshold
case _:
raise NotImplementedError
Expand Down Expand Up @@ -111,9 +114,14 @@ def _amp_disp(self, chunk_azimuth=500, chunk_range=500):
{"azimuth": chunk_azimuth, "range": chunk_range, "time": -1}
)

# Compoute amplitude dispersion
# By defalut, the mean and std function from Xarray will skip NaN values
# However, if there is NaN value in time series, we want to discard the pixel
# Therefore, we set skipna=False
# Adding epsilon to avoid zero division
amplitude_dispersion = amplitude.std(axis=t_order, skipna=False) / (
amplitude.mean(axis=t_order, skipna=False) + np.finfo(amplitude.dtype).eps
) # adding epsilon to avoid zero division
)

return amplitude_dispersion

Expand Down

0 comments on commit e21a355

Please sign in to comment.