RADOLAN data formats#

RADOLAN binary data format#

The RADOLAN binary data file format is described in the RADOLAN Kompositformat. The radolan composite files consists of an ascii header containing all needed information to decode the following binary data block. \(\omega radlib\) provides wradlib.io.read_radolan_composite() to read the data.

The function wradlib.io.parse_dwd_composite_header() takes care of correctly decoding the ascii header. All available header information is transferred into the metadata dictionary.

[1]:
import wradlib as wrl
import matplotlib.pyplot as plt
import warnings
import io
import tarfile

warnings.filterwarnings("ignore")
try:
    get_ipython().run_line_magic("matplotlib inline")
except:
    plt.ion()
import numpy as np
/home/runner/micromamba/envs/wradlib-tests/lib/python3.11/site-packages/h5py/__init__.py:36: UserWarning: h5py is running against HDF5 1.14.3 when it was built against 1.14.2, this may cause problems
  _warn(("h5py is running against HDF5 {0} when it was built against {1}, "
[2]:
# load radolan files
rw_filename = wrl.util.get_wradlib_data_file(
    "radolan/misc/raa01-rw_10000-1408102050-dwd---bin.gz"
)
filehandle = wrl.io.get_radolan_filehandle(rw_filename)
header = wrl.io.read_radolan_header(filehandle)
print(header)
Downloading file 'radolan/misc/raa01-rw_10000-1408102050-dwd---bin.gz' from 'https://github.com/wradlib/wradlib-data/raw/pooch/data/radolan/misc/raa01-rw_10000-1408102050-dwd---bin.gz' to '/home/runner/work/wradlib/wradlib/wradlib-data'.
RW102050100000814BY1620134VS 3SW   2.13.1PR E-01INT  60GP 900x 900MS 62<boo,ros,emd,hnr,umd,pro,ess,asd,neu,nhb,oft,tur,isn,fbg,mem>
[3]:
attrs = wrl.io.parse_dwd_composite_header(header)
print(attrs)
{'producttype': 'RW', 'datetime': datetime.datetime(2014, 8, 10, 20, 50), 'radarid': '10000', 'nrow': 900, 'ncol': 900, 'datasize': 1620000, 'formatversion': 3, 'maxrange': '150 km', 'radolanversion': '2.13.1', 'precision': 0.1, 'intervalseconds': 3600, 'radarlocations': ['boo', 'ros', 'emd', 'hnr', 'umd', 'pro', 'ess', 'asd', 'neu', 'nhb', 'oft', 'tur', 'isn', 'fbg', 'mem']}

In the following example, the header information of four different composites is extracted.

[4]:
# load radolan file
filename = "radolan/showcase/raa01-rx_10000-1408102050-dwd---bin.gz"
rx_filename = wrl.util.get_wradlib_data_file(filename)
filename = "radolan/showcase/raa01-ex_10000-1408102050-dwd---bin.gz"
ex_filename = wrl.util.get_wradlib_data_file(filename)
filename = "radolan/showcase/raa01-rw_10000-1408102050-dwd---bin.gz"
rw_filename = wrl.util.get_wradlib_data_file(filename)
filename = "radolan/showcase/raa01-sf_10000-1408102050-dwd---bin.gz"
sf_filename = wrl.util.get_wradlib_data_file(filename)

rxdata, rxattrs = wrl.io.read_radolan_composite(rx_filename)
exdata, exattrs = wrl.io.read_radolan_composite(ex_filename)
rwdata, rwattrs = wrl.io.read_radolan_composite(rw_filename)
sfdata, sfattrs = wrl.io.read_radolan_composite(sf_filename)

# print the available attributes
print("RX Attributes:")
for key, value in rxattrs.items():
    print(key + ":", value)
print("----------------------------------------------------------------")
# print the available attributes
print("EX Attributes:")
for key, value in exattrs.items():
    print(key + ":", value)
print("----------------------------------------------------------------")

# print the available attributes
print("RW Attributes:")
for key, value in rwattrs.items():
    print(key + ":", value)
print("----------------------------------------------------------------")

# print the available attributes
print("SF Attributes:")
for key, value in sfattrs.items():
    print(key + ":", value)
print("----------------------------------------------------------------")
Downloading file 'radolan/showcase/raa01-rx_10000-1408102050-dwd---bin.gz' from 'https://github.com/wradlib/wradlib-data/raw/pooch/data/radolan/showcase/raa01-rx_10000-1408102050-dwd---bin.gz' to '/home/runner/work/wradlib/wradlib/wradlib-data'.
Downloading file 'radolan/showcase/raa01-ex_10000-1408102050-dwd---bin.gz' from 'https://github.com/wradlib/wradlib-data/raw/pooch/data/radolan/showcase/raa01-ex_10000-1408102050-dwd---bin.gz' to '/home/runner/work/wradlib/wradlib/wradlib-data'.
Downloading file 'radolan/showcase/raa01-rw_10000-1408102050-dwd---bin.gz' from 'https://github.com/wradlib/wradlib-data/raw/pooch/data/radolan/showcase/raa01-rw_10000-1408102050-dwd---bin.gz' to '/home/runner/work/wradlib/wradlib/wradlib-data'.
Downloading file 'radolan/showcase/raa01-sf_10000-1408102050-dwd---bin.gz' from 'https://github.com/wradlib/wradlib-data/raw/pooch/data/radolan/showcase/raa01-sf_10000-1408102050-dwd---bin.gz' to '/home/runner/work/wradlib/wradlib/wradlib-data'.
RX Attributes:
producttype: RX
datetime: 2014-08-10 20:50:00
radarid: 10000
nrow: 900
ncol: 900
datasize: 810000
formatversion: 3
maxrange: 150 km
radolanversion: 2.13.1
precision: 1.0
intervalseconds: 300
radarlocations: ['boo', 'ros', 'emd', 'hnr', 'umd', 'pro', 'ess', 'asd', 'neu', 'nhb', 'oft', 'tur', 'isn', 'fbg', 'mem', 'bdy']
nodataflag: -9999
nodatamask: [     0      1      2 ... 809997 809998 809999]
cluttermask: []
----------------------------------------------------------------
EX Attributes:
producttype: EX
datetime: 2014-08-10 20:50:00
radarid: 10000
nrow: 1500
ncol: 1400
datasize: 2100000
formatversion: 2
maxrange: 128 km
radolanversion: 2.13.1
precision: 1.0
intervalseconds: 300
radarlocations: ['sin', 'rom', 'vir', 'bor', 'nld', 'zav', 'wid', 'sui', 'abv', 'ave', 'tra', 'arc', 'ncy', 'bgs', 'bla', 'sly', 'sem', 'boo', 'ros', 'emd', 'hnr', 'umd', 'pro', 'ess', 'asd', 'neu', 'nhb', 'oft', 'tur', 'isn', 'fbg', 'mem', 'bdy', 'ska']
nodataflag: -9999
nodatamask: [    743     744     745 ... 2099997 2099998 2099999]
cluttermask: []
----------------------------------------------------------------
RW Attributes:
producttype: RW
datetime: 2014-08-10 20:50:00
radarid: 10000
nrow: 900
ncol: 900
datasize: 1620000
formatversion: 3
maxrange: 150 km
radolanversion: 2.13.1
precision: 0.1
intervalseconds: 3600
radarlocations: ['boo', 'ros', 'emd', 'hnr', 'umd', 'pro', 'ess', 'asd', 'neu', 'nhb', 'oft', 'tur', 'isn', 'fbg', 'mem']
nodataflag: -9999
secondary: [   799    800    801 ... 806263 806264 807163]
nodatamask: [     0      1      2 ... 809997 809998 809999]
cluttermask: []
----------------------------------------------------------------
SF Attributes:
producttype: SF
datetime: 2014-08-10 20:50:00
radarid: 10000
nrow: 900
ncol: 900
datasize: 1620000
formatversion: 3
maxrange: 150 km
radolanversion: 2.13.1
precision: 0.1
intervalseconds: 86400
radarlocations: ['boo', 'ros', 'emd', 'hnr', 'umd', 'pro', 'ess', 'asd', 'neu', 'nhb', 'oft', 'tur', 'isn', 'fbg', 'mem']
radardays: ['asd 24', 'boo 24', 'emd 24', 'ess 24', 'fbg 24', 'hnr 24', 'isn 24', 'mem 24', 'neu 24', 'nhb 24', 'oft 24', 'pro 24', 'ros 24', 'tur 24', 'umd 24']
nodataflag: -9999
secondary: [   188    189    190 ... 809566 809567 809568]
nodatamask: [     0      1      2 ... 809997 809998 809999]
cluttermask: []
----------------------------------------------------------------

RADOLAN ASCII data format#

The ASCII GIS Format is prepended by a limited header and has two flavours as follows:

  • RADOLAN / reproc (RADARKLIMATOLOGIE) 2001 – 2019

ncols 900
nrows 1100
xllcorner -443462
yllcorner -4758645
cellsize 1000
nodata_value -9999.0
Units: 1.0 mm
  • RADOLAN / recent, 2020 – jetzt :

ncols 900
nrows 900
xllcorner -523462y
llcorner -4658645
cellsize 1000
NODATA_value -1
Units: 0.1 mm

Product and Datetime need to be extracted from the filename, so extra care has to be taken to not tamper with the filenames.

[5]:
fname = wrl.util.get_wradlib_data_file("radolan/asc/RW-20221018.tar.gz")
fp = tarfile.open(fname)
names = fp.getnames()
buffer = [io.BytesIO(fp.extractfile(name).read()) for name in names]
for buf, name in zip(buffer, names):
    buf.name = name
ds = wrl.io.open_radolan_mfdataset(buffer)
Downloading file 'radolan/asc/RW-20221018.tar.gz' from 'https://github.com/wradlib/wradlib-data/raw/pooch/data/radolan/asc/RW-20221018.tar.gz' to '/home/runner/work/wradlib/wradlib/wradlib-data'.
[6]:
display(ds)
<xarray.Dataset>
Dimensions:  (time: 24, y: 900, x: 900)
Coordinates:
  * time     (time) datetime64[ns] 2022-10-18T00:50:00 ... 2022-10-18T23:50:00
  * y        (y) float64 -4.658e+06 -4.657e+06 ... -3.76e+06 -3.759e+06
  * x        (x) float64 -5.23e+05 -5.22e+05 -5.21e+05 ... 3.75e+05 3.76e+05
Data variables:
    RW       (time, y, x) float32 dask.array<chunksize=(1, 900, 900), meta=np.ndarray>
Attributes:
    radarid:  10000
[7]:
ds.RW.plot(col="time", col_wrap=6, vmax=20)
[7]:
<xarray.plot.facetgrid.FacetGrid at 0x7f711568b110>
../../../_images/notebooks_fileio_radolan_radolan_format_13_1.png