Lesson 8 - Quantitative Precipitation Estimation (QPE)#

import datetime as dt

import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
import wradlib as wrl
import xarray as xr
import radarpolarimetry as rp

Read Radar Data#

start_time = dt.datetime(2017, 8, 10, 10)
stop_time = dt.datetime(2017, 8, 10, 12)
fname = (
    rp.data_path()
    / "lecture"
    / f"tmp_{start_time:%Y%m%dT%H%M}_{stop_time:%Y%m%dT%H%M}_attcorr_workflow.nc"
)
radar_ds = xr.open_dataset(fname)
display(radar_ds)
<xarray.Dataset> Size: 3GB
Dimensions:            (time2: 24, azimuth: 360, range: 750)
Coordinates: (12/22)
  * time2              (time2) datetime64[ns] 192B 2017-08-10T10:03:32.922000...
  * azimuth            (azimuth) float64 3kB 0.5 1.5 2.5 ... 357.5 358.5 359.5
    elevation          (azimuth) float64 3kB ...
    time               (time2, azimuth) datetime64[ns] 69kB ...
  * range              (range) float32 3kB 100.0 300.0 ... 1.497e+05 1.499e+05
    x                  (azimuth, range) float64 2MB ...
    ...                 ...
    altitude           float64 8B ...
    crs_wkt            int64 8B ...
    band               int64 8B ...
    spatial_ref        int64 8B ...
    NOISE_LEVEL        float64 8B ...
    alpha              float64 8B ...
Data variables: (12/56)
    DBZH               (time2, azimuth, range) float32 26MB ...
    DBZV               (time2, azimuth, range) float32 26MB ...
    KDP                (time2, azimuth, range) float32 26MB ...
    RHOHV              (time2, azimuth, range) float32 26MB ...
    CMAP               (time2, azimuth, range) float32 26MB ...
    DBTH               (time2, azimuth, range) float32 26MB ...
    ...                 ...
    AH                 (time2, azimuth, range) float64 52MB ...
    KDP_AH             (time2, azimuth, range) float64 52MB ...
    PHIDP_CORR5        (time2, azimuth, range) float64 52MB ...
    DBTH_CORR5         (time2, azimuth, range) float64 52MB ...
    DBZH_CORR5         (time2, azimuth, range) float64 52MB ...
    ZDR_CORR5          (time2, azimuth, range) float64 52MB ...
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

Rain Rate Retrieval#

Exercise 1: Calculate Rain Rate Retrievals and Plot#

  • Marshall-Palmer

    • \(z = 200 R^{1.6}\)

    • \(R = \frac{z}{200}^{\frac{1}{1.6}}\)

  • Convective Relation

    • \(z = 300 R^{1.4}\)

    • \(R = \frac{z}{300}^{\frac{1}{1.4}}\)

  • \(R(K_{DP})\)

    • \(R = 16.9 K_{DP}^{0.801} sign(K_{DP})\)

  • \(R(A)\)

    • \(R = 43.5 A^{0.79}\)

Use R(Z) in light rain and R(KDP)/R(A) in strong rain.

Solution 1: Calculate Rain Rate Retrievals and Plot#

print(radar_ds.DBTH_CORR1.shape)
dbth_corr = wrl.trafo.idecibel(radar_ds.DBTH_CORR1)

rr1 = (dbth_corr / 200.0) ** (1.0 / 1.6)
rr2 = (dbth_corr / 300.0) ** (1.0 / 1.4)
(24, 360, 750)

Plot#

cbar_kwargs = dict(
    extend="both",
    extendrect=False,
    extendfrac="auto",
    pad=0.05,
    fraction=0.1,
)
norm = mpl.colors.LogNorm(0.1, 200.0)
cbar_kwargs.update(dict(label="Rainrate"))
cbar_extend = cbar_kwargs.get("extend", None)
cmap = "turbo"
fig = plt.figure(figsize=(10, 8))
ax = fig.add_subplot(111)
rr1[0].plot(x="x", y="y", ax=ax, norm=norm, cbar_kwargs=cbar_kwargs)
<matplotlib.collections.QuadMesh at 0x7f6a64fb0ec0>
../../_images/3e7839d0bfe03b5ec521f8e8b97958c4b52aa1605539ce46401d4dc92d67cc6a.png

Apply \(R(A)\) and \(R(K_{DP})\)#

kdp = radar_ds.KDP_AH
rr_kdp = 16.9 * kdp**0.801 * np.sign(kdp)

# needs ZPHI
rr_a = 43.5 * radar_ds.AH**0.79

Plot Rainrates#

cbar_kwargs = dict(
    extend="both",
    extendrect=False,
    extendfrac="auto",
    pad=0.05,
    fraction=0.1,
)
norm = mpl.colors.LogNorm(0.1, 200.0)
cbar_kwargs.update(dict(label="Rainrate"))
cbar_extend = cbar_kwargs.get("extend", None)
cmap = "turbo"
fig = plt.figure(figsize=(10, 8))
ax = fig.add_subplot(111)
rr_kdp[0].plot(x="x", y="y", ax=ax, norm=norm, cbar_kwargs=cbar_kwargs)
<matplotlib.collections.QuadMesh at 0x7f6a64c67d90>
../../_images/9cbab5b21c6a0a79c3f11806d056344938b39255bbe5ec1509daf162299e2e27.png
fig = plt.figure(figsize=(10, 8))
ax = fig.add_subplot(111)
rr_a[0].plot(x="x", y="y", ax=ax, norm=norm, cbar_kwargs=cbar_kwargs)
<matplotlib.collections.QuadMesh at 0x7f6a64bed450>
../../_images/edb9478c03d9a2cf8c2d51722e7a1805c5d616be4506dcc8cb31d284af40c36b.png

Use R(Z) in light rain and R(KDP) in strong rain#

lightrain = rr1.where((rr1 < 20) & (rr1 >= 0))
strongrain = rr_kdp.where(rr1 >= 20)
fig = plt.figure(figsize=(10, 8))
ax = fig.add_subplot(111)
lightrain[0].plot(x="x", y="y", ax=ax, norm=norm, cbar_kwargs=cbar_kwargs)
strongrain[0].plot(x="x", y="y", ax=ax, norm=norm, add_colorbar=False)
<matplotlib.collections.QuadMesh at 0x7f6a649ce210>
../../_images/95bdb1daba35e88f2cc43eb1c4263f6277ddaa56622651f2e11fc4c29980fe3b.png