Skip to content

Commit 7413190

Browse files
committed
Screen clutter from weather radar data
1 parent cd869c4 commit 7413190

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

cloudnetpy/cloudnetarray.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def db2lin(self) -> None:
5454
self.data = utils.db2lin(self.data)
5555
self.units = ""
5656

57-
def mask_indices(self, ind: list) -> None:
57+
def mask_indices(self, ind: list | tuple) -> None:
5858
"""Masks data from given indices."""
5959
self.data[ind] = ma.masked
6060

cloudnetpy/instruments/weather_radar.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ def wr2nc(
4545
wr = WeatherRadar(input_files, site_meta, date)
4646
wr.sort_and_dedup_timestamps()
4747
wr.convert_to_cloudnet_arrays()
48+
wr.screen_clutter()
4849
wr.screen_noise()
4950
wr.add_meta()
5051
attributes = output.add_time_attribute(ATTRIBUTES, wr.date)
@@ -145,11 +146,25 @@ def convert_to_cloudnet_arrays(self) -> None:
145146
self.scalars["NEZ"], "calibration_reflectivity_factor"
146147
)
147148

149+
def screen_clutter(self) -> None:
150+
n_range = len(self.data["range"][:])
151+
max_range = 10
152+
threshold = -10 # dBZ
153+
mean_z = np.mean(self.data["Zh"].data[:, :max_range], axis=0)
154+
is_clutter = mean_z > threshold
155+
ind_last = np.nonzero(is_clutter)[0][-1]
156+
mask = np.zeros(n_range, dtype=np.bool)
157+
mask[: ind_last + 1] = True
158+
self._screen_indices((slice(None), mask))
159+
148160
def screen_noise(self) -> None:
149161
is_noise = self.data["SNR"].data < 0
162+
self._screen_indices(is_noise)
163+
164+
def _screen_indices(self, ind: list | tuple) -> None:
150165
for cloudnet_array in self.data.values():
151166
if cloudnet_array.data.ndim == 2:
152-
cloudnet_array.mask_indices(is_noise)
167+
cloudnet_array.mask_indices(ind)
153168

154169

155170
class InvalidRangeError(CloudnetException):

0 commit comments

Comments
 (0)