Skip to content

Commit 7f50c56

Browse files
authored
DOC: Add example for dealiasing rhi data (#1775)
* DOC: Add example for dealiasing rhi data * Update examples/correct/plot_dealias_rhi.py
1 parent 13eb5eb commit 7f50c56

File tree

1 file changed

+141
-0
lines changed

1 file changed

+141
-0
lines changed
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
"""
2+
==========================================
3+
Dealias doppler velocities for an RHI file
4+
==========================================
5+
6+
In this example doppler velocities from range height indicator (RHI) scans are dealiased,
7+
using custom parameters with the region-based dealiasing algorithm in Py-ART.
8+
"""
9+
10+
print(__doc__)
11+
12+
# Author: Max Grover (mgrover@anl.gov)
13+
14+
import matplotlib.pyplot as plt
15+
from open_radar_data import DATASETS
16+
17+
import pyart
18+
19+
# Read data from the open-radar-data package
20+
file = DATASETS.fetch("cfrad.20211011_223602.712_to_20211011_223612.091_DOW8_RHI.nc")
21+
radar = pyart.io.read(file)
22+
23+
#################################################
24+
# **Apply the default parameters for dealiasing**
25+
#
26+
# Now let's apply the default region-based technique
27+
28+
# Retrieve the nyquist velocity from the first sweep
29+
nyq = radar.instrument_parameters["nyquist_velocity"]["data"][0]
30+
31+
# Apply the dealiasing algorithm with default parameters
32+
velocity_dealiased = pyart.correct.dealias_region_based(
33+
radar,
34+
vel_field="VEL",
35+
nyquist_vel=nyq,
36+
)
37+
38+
# Add the field to the radar object
39+
radar.add_field("corrected_velocity", velocity_dealiased, replace_existing=True)
40+
41+
# Visualize the output
42+
fig = plt.figure(figsize=(12, 4))
43+
ax1 = fig.add_subplot(121)
44+
display = pyart.graph.RadarDisplay(radar)
45+
display.plot(
46+
"VEL",
47+
ax=ax1,
48+
vmin=-30,
49+
vmax=30,
50+
cmap="balance",
51+
title="Uncorrected Radial Velocity",
52+
)
53+
cbar = display.cbs[0]
54+
# Modify the colorbar label and size
55+
cbar.set_label(label="Raw Radial Velocity ($V_{R}$) [m/s]", fontsize=12)
56+
plt.ylim(0, 10)
57+
plt.xlim(20, 60)
58+
59+
ax2 = fig.add_subplot(122)
60+
display = pyart.graph.RadarDisplay(radar)
61+
display.plot(
62+
"corrected_velocity",
63+
ax=ax2,
64+
vmin=-30,
65+
vmax=30,
66+
cmap="balance",
67+
title="Corrected Radial Velocity",
68+
)
69+
cbar = display.cbs[0]
70+
# Modify the colorbar label and size
71+
cbar.set_label(label="Corrected Radial Velocity ($V_{R}$) [m/s]", fontsize=12)
72+
plt.ylim(0, 10)
73+
plt.xlim(20, 60)
74+
75+
#################################################
76+
# **Refining the technique**
77+
#
78+
# If we use the default configuration, notice how extreme
79+
# the values are for the output. The algorithm keys on the
80+
# small variations in the clear air returns, and
81+
# results in much larger values than would be expected.
82+
# It is considered best practice to apply a base-level of
83+
# quality control here to improve the results. We can use velocity
84+
# texture as a base level, where the noisier data will be removed.
85+
86+
# Calculate the velocity texture and add it to the radar object
87+
vel_texture = pyart.retrieve.calculate_velocity_texture(
88+
radar,
89+
vel_field="VEL",
90+
nyq=nyq,
91+
)
92+
radar.add_field("velocity_texture", vel_texture, replace_existing=True)
93+
94+
# Set up the gatefilter to be based on the velocity texture.
95+
gatefilter = pyart.filters.GateFilter(radar)
96+
gatefilter.exclude_above("velocity_texture", 6)
97+
98+
# Dealias with the gatefilter and add the corrected field to the radar object
99+
velocity_dealiased = pyart.correct.dealias_region_based(
100+
radar,
101+
vel_field="VEL",
102+
nyquist_vel=nyq,
103+
gatefilter=gatefilter,
104+
)
105+
radar.add_field("corrected_velocity", velocity_dealiased, replace_existing=True)
106+
107+
# Visualize the output
108+
fig = plt.figure(figsize=(12, 4))
109+
ax1 = fig.add_subplot(121)
110+
display = pyart.graph.RadarDisplay(radar)
111+
display.plot(
112+
"VEL",
113+
ax=ax1,
114+
vmin=-30,
115+
vmax=30,
116+
cmap="balance",
117+
title="Uncorrected Radial Velocity",
118+
)
119+
cbar = display.cbs[0]
120+
121+
# Modify the colorbar label and size
122+
cbar.set_label(label="Raw Radial Velocity ($V_{R}$) [m/s]", fontsize=12)
123+
plt.ylim(0, 10)
124+
plt.xlim(20, 60)
125+
126+
ax2 = fig.add_subplot(122)
127+
display = pyart.graph.RadarDisplay(radar)
128+
display.plot(
129+
"corrected_velocity",
130+
ax=ax2,
131+
vmin=-30,
132+
vmax=30,
133+
cmap="balance",
134+
title="Corrected Radial Velocity",
135+
)
136+
cbar = display.cbs[0]
137+
138+
# Modify the colorbar label and size
139+
cbar.set_label(label="Corrected Radial Velocity ($V_{R}$) [m/s]", fontsize=12)
140+
plt.ylim(0, 10)
141+
plt.xlim(20, 60)

0 commit comments

Comments
 (0)