RADOLAN Quick Start

Import modules, filter warnings to avoid cluttering output with DeprecationWarnings and use matplotlib inline or interactive mode if running in ipython or python respectively.

[1]:
import wradlib as wrl
import matplotlib.pyplot as pl
import warnings
warnings.filterwarnings('ignore')
try:
    get_ipython().magic("matplotlib inline")
except:
    pl.ion()
import numpy as np

Normal reader

All RADOLAN composite products can be read by the following function:

data, metadata = wradlib.io.read_radolan_composite("mydrive:/path/to/my/file/filename")

Here, data is a two dimensional integer or float array of shape (number of rows, number of columns). metadata is a dictionary which provides metadata from the files header section, e.g. using the keys producttype, datetime, intervalseconds, nodataflag.

The RADOLAN Grid coordinates can be calculated with wradlib.georef.get_radolan_grid().

With the following code snippet the RW-product is shown in the Polar Stereographic Projection.

[2]:
# load radolan files
rw_filename = wrl.util.get_wradlib_data_file('radolan/misc/raa01-rw_10000-1408102050-dwd---bin.gz')
rwdata, rwattrs = wrl.io.read_radolan_composite(rw_filename)
# print the available attributes
print("RW Attributes:", rwattrs)
RW Attributes: {'producttype': 'RW', 'datetime': datetime.datetime(2014, 8, 10, 20, 50), 'radarid': '10000', 'datasize': 1620000, 'maxrange': '150 km', 'radolanversion': '2.13.1', 'precision': 0.1, 'intervalseconds': 3600, 'nrow': 900, 'ncol': 900, 'radarlocations': ['boo', 'ros', 'emd', 'hnr', 'umd', 'pro', 'ess', 'asd', 'neu', 'nhb', 'oft', 'tur', 'isn', 'fbg', 'mem'], 'nodataflag': -9999, 'secondary': array([   799,    800,    801, ..., 806263, 806264, 807163]), 'nodatamask': array([     0,      1,      2, ..., 809997, 809998, 809999]), 'cluttermask': array([], dtype=int64)}
[3]:
# do some masking
sec = rwattrs['secondary']
rwdata.flat[sec] = -9999
rwdata = np.ma.masked_equal(rwdata, -9999)
[4]:
# Get coordinates
radolan_grid_xy = wrl.georef.get_radolan_grid(900,900)
x = radolan_grid_xy[:,:,0]
y = radolan_grid_xy[:,:,1]
[5]:
# plot function
pl.pcolormesh(x, y, rwdata, cmap="viridis")
cb = pl.colorbar(shrink=0.75)
cb.set_label("mm * h-1")
pl.title('RADOLAN RW Product Polar Stereo \n' + rwattrs['datetime'].isoformat())
pl.grid(color='r')
../../_images/notebooks_radolan_radolan_quickstart_9_0.png

A much more comprehensive section using several RADOLAN composites is shown in chapter RADOLAN Product Showcase.

RADOLAN Xarray reader

When calling with loaddata='xarray' the radolan product is imported into an Xarray Dataset. The polar stereographic ccordinates are added to the dataset.

[6]:
# load radolan files
rw_filename = wrl.util.get_wradlib_data_file('radolan/misc/raa01-rw_10000-1408102050-dwd---bin.gz')
ds, rwattrs = wrl.io.read_radolan_composite(rw_filename, loaddata='xarray')
# print the xarray dataset
ds
[6]:
<xarray.Dataset>
Dimensions:  (x: 900, y: 900)
Coordinates:
    time     datetime64[ns] ...
  * x        (x) float64 -523.5 -522.5 -521.5 -520.5 ... 372.5 373.5 374.5 375.5
  * y        (y) float64 -4.659e+03 -4.658e+03 ... -3.761e+03 -3.76e+03
Data variables:
    RW       (y, x) float32 ...

Simple Plot

[7]:
ds.RW.plot()
[7]:
<matplotlib.collections.QuadMesh at 0x7f7ef8180908>
../../_images/notebooks_radolan_radolan_quickstart_15_1.png

Simple selection

[8]:
ds.RW.sel(x=slice(-100, 100), y=slice(-4400, -4200)).plot()
[8]:
<matplotlib.collections.QuadMesh at 0x7f7ef812ec18>
../../_images/notebooks_radolan_radolan_quickstart_17_1.png