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.

[ ]:
import os
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.

[ ]:
# 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)
[ ]:
# do some masking
sec = rwattrs['secondary']
rwdata.flat[sec] = -9999
rwdata = np.ma.masked_equal(rwdata, -9999)
[ ]:
# Get coordinates
radolan_grid_xy = wrl.georef.get_radolan_grid(900,900)
x = radolan_grid_xy[:,:,0]
y = radolan_grid_xy[:,:,1]
[ ]:
# 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')

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

RADOLAN Xarray backend

From wradlib version 1.10.0 a RADOLAN xarray backend is available. RADOLAN data will be imported into an xarray.Dataset with attached coordinates.

[ ]:
# load radolan files
rw_filename = wrl.util.get_wradlib_data_file('radolan/misc/raa01-rw_10000-1408102050-dwd---bin.gz')
ds = wrl.io.open_radolan_dataset(rw_filename)
# print the xarray dataset
ds

Simple Plot

[ ]:
ds.RW.plot()

Simple selection

[ ]:
ds.RW.sel(x=slice(-100, 100), y=slice(-4400, -4200)).plot()

Map plot using cartopy

[ ]:
import cartopy.crs as ccrs
map_proj = ccrs.Stereographic(true_scale_latitude=60., central_latitude=90.,central_longitude=10.)

Note For correct usage with cartopy we need to adapt the x/y coordinates to meters. It seems that the automatic conversion from km to m via units isn’t possible. The easiest way to convert is using pint.

[ ]:
import xarray as xr
import pint_xarray
ds = ds.pint.quantify()
ds = ds.pint.to(x="m", y="m")
ds
[ ]:
fig = pl.figure(figsize=(10,8))
ds.RW.plot(subplot_kws=dict(projection=map_proj))
ax = pl.gca()
ax.gridlines(draw_labels=True, y_inline=False)

Open multiple files

[ ]:
# load radolan files
sf_filename = os.path.join(wrl.util.get_wradlib_data_path(),'radolan/misc/raa01-sf_10000-1305*')
ds = wrl.io.open_radolan_mfdataset(sf_filename)
# print the xarray dataset
ds
[ ]:
fig = pl.figure(figsize=(10,5))
ds.SF.plot(col="time")

Use xr.open_dataset and xr.open_mfdataset

[ ]:
rw_filename = wrl.util.get_wradlib_data_file('radolan/misc/raa01-rw_10000-1408102050-dwd---bin.gz')
ds = xr.open_dataset(rw_filename, engine="radolan")
ds
[ ]:
sf_filename = os.path.join(wrl.util.get_wradlib_data_path(),'radolan/misc/raa01-sf_10000-1305*')
ds = xr.open_mfdataset(sf_filename, engine="radolan")
ds