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.73

Georeference 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.73

plot xarray#

See xarray plotting.

swp.DBZH.plot(x="x", y="y", cmap="HomeyerRainbow")
<matplotlib.collections.QuadMesh at 0x7f7db8afcad0>
../../_images/0179aebe333dfb4ec8cbc913a08debe24bec3f801cc22eb6d246d1a8a76a325d.png

plot wradlib#

swp.DBZH.wrl.vis.plot()
<matplotlib.collections.QuadMesh at 0x7f7dcf001590>
../../_images/b6426f7a5b82c805e27a462fefd58c9f7a8fe0e028becb56ac0a93f7dfdfc674.png

plot radarpolarimetry#

rp.plot_moment(swp.DBZH)
<matplotlib.collections.QuadMesh at 0x7f7db75b5950>
../../_images/72c1564b8af5b2b21bb8eb1fcd65c17de6dce7561f6d42c7431e81773487b710.png

Exercise 1#

  • Load sweep n_ppi_031deg from 2018-04-10T19:30 and plot reflectivity.

Add all code into one cell!

Exercise 2#

  • Load sweep n_vertical_scan from 2018-04-10T19:30 and georeference in one cell.

  • Plot two plots on top of each other, top with azimuth on x-axis, bottom with time on x-axis. Set reasonable y-axis limits. Do this in a second cell.

Exercise 3#

  • Load sweep n_rhi_1 from 2018-04-10T19:30 and 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>
../../_images/a9def1c59eabc92c3e5189632cf06fe85c6414d382c5dfcc463356e761a265f9.png

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)
../../_images/ba0c6cc30374f003d88da716d048e52bb345f7d25504e589d9f669d9130216be.png

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>
../../_images/4bacc3ab6850c50c48e0c2f65f61b397821732a94a329081549821c5ec65fd98.png