Skip to content

Commit

Permalink
FIX: changed value in ZDR standardization from -5 to 5 to -1.5 to 5 a…
Browse files Browse the repository at this point in the history
…ccording to Besic (2016)
  • Loading branch information
wolfidan committed Aug 28, 2024
1 parent de64fba commit 73ca678
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
13 changes: 8 additions & 5 deletions pyart/retrieve/echo_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -848,11 +848,11 @@ def hydroclass_semisupervised(
hydro.update({"_FillValue": 0})
labels = ["NC"]
ticks = [1]
boundaries = [0.5, 1.5]
boundaries = [-0.5, 1.5]
for i, hydro_name in enumerate(hydro_names):
labels.append(hydro_name)
ticks.append(i + 2)
boundaries.append(i + 2.5)
ticks.append(i + 1)
boundaries.append(i + 1.5)
hydro.update({"labels": labels, "ticks": ticks, "boundaries": boundaries})
fields_dict.update({"hydro": hydro})

Expand Down Expand Up @@ -910,7 +910,9 @@ def _standardize(data, field_name, mx=None, mn=None):
data[data < -0.5] = -0.5
data = 10.0 * np.ma.log10(data + 0.6)
elif field_name == "RhoHV":
data = 10.0 * np.ma.log10(1.0 - data)
# avoid infinite result
data[data > 1.0] = 1.0
data = 10.0 * np.ma.log10(1.0000000000001 - data)

mask = np.ma.getmaskarray(data)
field_std = 2.0 * (data - mn) / (mx - mn) - 1.0
Expand Down Expand Up @@ -1228,9 +1230,10 @@ def _data_limits_table():
"""
dlimits_dict = dict()
dlimits_dict.update({"Zh": (60.0, -10.0)})
dlimits_dict.update({"ZDR": (5.0, -5.0)})
dlimits_dict.update({"ZDR": (5.0, -1.5)})
dlimits_dict.update({"KDP": (7.0, -10.0)})
dlimits_dict.update({"RhoHV": (-5.23, -50.0)})
dlimits_dict.update({"RelH": (5000.0, -5000.0)})

return dlimits_dict

Expand Down
20 changes: 10 additions & 10 deletions tests/retrieve/test_echo_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,27 +169,27 @@ def test_hydroclass_semisupervised():
assert_allclose(hydro["hydro"]["data"][0][-5:], [2, 2, 2, 2, 2])
assert_allclose(
hydro["entropy"]["data"][0][0:5].data,
[0.269866, 0.269866, 0.269866, 0.269866, 0.269866],
[0.35945634, 0.35945634, 0.35945634, 0.35945634, 0.35945634],
rtol=1e-5,
)
assert_allclose(
hydro["entropy"]["data"][0][-5:].data,
[0.16527913, 0.16527913, 0.16527913, 0.165279136, 0.16527913],
[0.232788, 0.232788, 0.232788, 0.232788, 0.232788],
rtol=1e-5,
)
assert_allclose(
hydro["proportion_CR"]["data"][0][0:5].data,
[0.00713444, 0.00713444, 0.00713444, 0.00713444, 0.00713444],
[0.03524214, 0.03524214, 0.03524214, 0.03524214, 0.03524214],
rtol=1e-5,
)
assert_allclose(
hydro["proportion_CR"]["data"][0][-5:].data,
[
3.96782815e-07,
3.96782815e-07,
3.96782815e-07,
3.96782815e-07,
3.96782815e-07,
8.336829723993246e-05,
8.336829723993246e-05,
8.336829723993246e-05,
8.336829723993246e-05,
8.336829723993246e-05,
],
rtol=1e-5,
)
Expand All @@ -199,11 +199,11 @@ def test_data_limits_table():
dlimits_dict = pyart.retrieve.echo_class._data_limits_table()
test_dict = {
"Zh": (60.0, -10.0),
"ZDR": (5.0, -5.0),
"ZDR": (5, -1.5),
"KDP": (7.0, -10.0),
"RhoHV": (-5.23, -50.0),
"RelH": (5000, -5000),
}

assert isinstance(dlimits_dict, dict)
assert dlimits_dict == test_dict

Expand Down

0 comments on commit 73ca678

Please sign in to comment.