Radar - Single Sweep#
Import Section#
import datetime as dt
import os
import matplotlib.pyplot as plt
import xarray as xr
Utility Functions#
import radarpolarimetry as rp
Load Radar Data Sweep#
Select time#
# recent boxpol event
start_time = dt.datetime(2018, 4, 10, 16, 15)
stop_time = dt.datetime(2018, 4, 10, 16, 20)
get file path#
Get function information: Set cursor inside function brackets and use SHIFT-TAB to bring up the function docstring.
# choose radar specific parameters
scan = "n_ppi_010deg"
path = rp.get_xpol_path(start_time=start_time)
file_path = os.path.join(path, scan)
print(file_path)
/radar/rp-data/scans/2018/2018-04/2018-04-10/n_ppi_010deg
get file list#
flist = list(rp.create_filelist(os.path.join(file_path, "*"), start_time, stop_time))
display(flist)
['/radar/rp-data/scans/2018/2018-04/2018-04-10/n_ppi_010deg/n_ppi_010deg_12345_20180410161835_00.h5']
open dataset#
with rp.rpol_data.open(flist[0]) as f:
fname = f.name
swp = xr.open_dataset(fname, engine="gamic", group="sweep_0")
swp = swp.set_coords("sweep_mode")
display(swp)
<xarray.Dataset> Size: 14MB
Dimensions: (azimuth: 360, range: 750)
Coordinates:
* azimuth (azimuth) float64 3kB 0.5109 1.524 2.51 ... 358.5 359.5
elevation (azimuth) float64 3kB ...
time (azimuth) datetime64[ns] 3kB ...
* range (range) float32 3kB 100.0 300.0 ... 1.497e+05 1.499e+05
sweep_mode <U20 80B ...
longitude float64 8B ...
latitude float64 8B ...
altitude float64 8B ...
Data variables: (12/18)
DBZH (azimuth, range) float32 1MB ...
DBZV (azimuth, range) float32 1MB ...
KDP (azimuth, range) float32 1MB ...
RHOHV (azimuth, range) float32 1MB ...
CMAP (azimuth, range) float32 1MB ...
DBTH (azimuth, range) float32 1MB ...
... ...
PHIDP (azimuth, range) float32 1MB ...
sweep_number int64 8B ...
prt_mode <U7 28B ...
follow_mode <U7 28B ...
sweep_fixed_angle float64 8B ...
nyquist_velocity float64 8B ...
Attributes:
source: gamic
ant_gain_h: 44.0
ant_gain_v: 44.0
noise_power_h: -1.39495
noise_power_v: -1.09706
rx_loss_h: 0.73
rx_loss_v: 0.73Georeference Dataset#
Caclulate bin coordinates in xyz-spave with the radar in the center.
swp = swp.wrl.georef.georeference()
display(swp)
<xarray.Dataset> Size: 26MB
Dimensions: (azimuth: 360, range: 750)
Coordinates: (12/15)
* azimuth (azimuth) float64 3kB 0.5109 1.524 2.51 ... 358.5 359.5
elevation (azimuth) float64 3kB 0.9998 0.9998 ... 0.9998 0.9998
time (azimuth) datetime64[ns] 3kB ...
* range (range) float32 3kB 100.0 300.0 ... 1.497e+05 1.499e+05
x (azimuth, range) float64 2MB 0.8915 2.674 ... -1.271e+03
y (azimuth, range) float64 2MB 99.98 299.9 ... 1.498e+05
... ...
bins (azimuth, range) float32 1MB 100.0 300.0 ... 1.499e+05
sweep_mode <U20 80B 'azimuth_surveillance'
longitude float64 8B 7.072
latitude float64 8B 50.73
altitude float64 8B 99.5
crs_wkt int64 8B 0
Data variables: (12/18)
DBZH (azimuth, range) float32 1MB ...
DBZV (azimuth, range) float32 1MB ...
KDP (azimuth, range) float32 1MB ...
RHOHV (azimuth, range) float32 1MB ...
CMAP (azimuth, range) float32 1MB ...
DBTH (azimuth, range) float32 1MB ...
... ...
PHIDP (azimuth, range) float32 1MB ...
sweep_number int64 8B ...
prt_mode <U7 28B ...
follow_mode <U7 28B ...
sweep_fixed_angle float64 8B ...
nyquist_velocity float64 8B ...
Attributes:
source: gamic
ant_gain_h: 44.0
ant_gain_v: 44.0
noise_power_h: -1.39495
noise_power_v: -1.09706
rx_loss_h: 0.73
rx_loss_v: 0.73plot xarray#
See xarray plotting.
swp.DBZH.plot(x="x", y="y", cmap="HomeyerRainbow")
<matplotlib.collections.QuadMesh at 0x7f7db8afcad0>
plot wradlib#
swp.DBZH.wrl.vis.plot()
<matplotlib.collections.QuadMesh at 0x7f7dcf001590>
plot radarpolarimetry#
rp.plot_moment(swp.DBZH)
<matplotlib.collections.QuadMesh at 0x7f7db75b5950>
Exercise 1#
Load sweep
n_ppi_031degfrom2018-04-10T19:30and plot reflectivity.
Add all code into one cell!
Exercise 2#
Load sweep
n_vertical_scanfrom2018-04-10T19:30and georeference in one cell.Plot two plots on top of each other, top with
azimuthonx-axis, bottom withtimeonx-axis. Set reasonabley-axislimits. Do this in a second cell.
Exercise 3#
Load sweep
n_rhi_1from2018-04-10T19:30and georeference in one cell.Plot DBTH and DBZH side-by-side, set reasonable axis-limits.
Solution 1#
start_time = dt.datetime(2018, 4, 10, 19, 30)
stop_time = dt.datetime(2018, 4, 10, 19, 35)
scan = "n_ppi_031deg"
path = rp.get_xpol_path(start_time=start_time)
file_path = os.path.join(path, scan)
flist = list(rp.create_filelist(os.path.join(file_path, "*"), start_time, stop_time))
with rp.rpol_data.open(flist[0]) as f:
fname = f.name
swp = xr.open_dataset(fname, engine="gamic", group="sweep_0")
swp = swp.set_coords("sweep_mode")
swp = swp.wrl.georef.georeference()
rp.plot_moment(swp.DBZH)
<matplotlib.collections.QuadMesh at 0x7f7db751d450>
Solution 2#
start_time = dt.datetime(2018, 4, 10, 19, 30)
stop_time = dt.datetime(2018, 4, 10, 19, 35)
scan = "n_vertical_scan"
path = rp.get_xpol_path(start_time=start_time)
file_path = os.path.join(path, scan)
flist = list(rp.create_filelist(os.path.join(file_path, "*"), start_time, stop_time))
with rp.rpol_data.open(flist[0]) as f:
fname = f.name
swp = xr.open_dataset(fname, engine="gamic", group="sweep_0")
swp = swp.set_coords("sweep_mode")
swp = swp.wrl.georef.georeference()
fig, (ax1, ax2) = plt.subplots(ncols=1, nrows=2, figsize=(6, 8), layout="compressed")
pm1 = swp.DBZH.plot(x="azimuth", cmap="HomeyerRainbow", ax=ax1)
ax1.set_title(swp.DBZH.name)
ax1.set_ylim(0, 6000)
pm2 = swp.DBZH.sortby("time").plot(x="time", cmap="HomeyerRainbow", ax=ax2)
ax2.set_title(swp.DBZH.name)
ax2.set_ylim(0, 6000)
(0.0, 6000.0)
Solution 3#
start_time = dt.datetime(2018, 4, 10, 19, 30)
stop_time = dt.datetime(2018, 4, 10, 19, 35)
scan = "n_rhi_1"
path = rp.get_xpol_path(start_time=start_time)
file_path = os.path.join(path, scan)
flist = list(rp.create_filelist(os.path.join(file_path, "*"), start_time, stop_time))
with rp.rpol_data.open(flist[0]) as f:
fname = f.name
swp = xr.open_dataset(fname, engine="gamic", group="sweep_0")
swp = swp.set_coords("sweep_mode")
swp = swp.wrl.georef.georeference()
fig, (ax1, ax2) = plt.subplots(ncols=2, nrows=1, figsize=(10, 3), layout="compressed")
rp.plot_moment(swp.DBTH, ax=ax1, ylim=(0, 10000), vmin=0)
rp.plot_moment(swp.DBZH, ax=ax2, ylim=(0, 10000), vmin=0)
<matplotlib.collections.QuadMesh at 0x7f7dad3dec10>