Skip to content

Commit 9d8ea47

Browse files
committed
add more comments for NaN value handling in apmlitude dispersion
1 parent 7ee2325 commit 9d8ea47

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

sarxarray/stack.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ def point_selection(self, threshold, method="amplitude_dispersion", chunks=1000)
5858
"""
5959
match method:
6060
case "amplitude_dispersion":
61+
# Amplitude dispersion thresholding
62+
# Note there can be NaN values in the amplitude dispersion
63+
# However NaN values will not pass this threshold
6164
mask = self._amp_disp() < threshold
6265
case _:
6366
raise NotImplementedError
@@ -111,9 +114,14 @@ def _amp_disp(self, chunk_azimuth=500, chunk_range=500):
111114
{"azimuth": chunk_azimuth, "range": chunk_range, "time": -1}
112115
)
113116

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

118126
return amplitude_dispersion
119127

0 commit comments

Comments
 (0)