Reading radolan ascii format files

Hello all,

I am trying to read data from (Index of /climate_environment/CDC/grids_germany/hourly/radolan/historical/asc/). I have downloaded the data to my local machine. For reference I am writing my code below in comments.

import os
import sys
import wradlib as wrl
import numpy as np
import warnings


os.environ["WRADLIB_DATA"] = "C:\\Users\Admin\wradlib-data-main"

filename = "Data/Firstyear/RW-200506.tar"
filename = wrl.util.get_wradlib_data_file(filename)
data_raw, meta =

When running the file this is the error I am facing:

runfile(‘D:/Sandeep/Thesis/’, wdir=‘D:/Sandeep/Thesis’)
Traceback (most recent call last):

File “C:\ProgramData\Anaconda3\envs\wradlib\lib\site-packages\spyder_kernels\”, line 356, in compat_exec
exec(code, globals, locals)

File “d:\sandeep\thesis\”, line 19, in
data_raw, meta =

File “C:\ProgramData\Anaconda3\envs\wradlib\lib\site-packages\wradlib\io\”, line 763, in read_radolan_composite
attrs = radfile.attrs

File “C:\ProgramData\Anaconda3\envs\wradlib\lib\site-packages\wradlib\io\”, line 1000, in attrs
self._attrs = self._read_attrs()

File “C:\ProgramData\Anaconda3\envs\wradlib\lib\site-packages\wradlib\io\”, line 1039, in _read_attrs
header = read_radolan_header(self.fp)

File “C:\ProgramData\Anaconda3\envs\wradlib\lib\site-packages\wradlib\io\”, line 691, in read_radolan_header
header += str(mychar.decode())

UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0x8b in position 0: invalid start byte

More details:

  • in python(version: 3.8.13) and wradlib (version: 1.13.0)
1 Like

HI Sandeep,

thanks for the detailed description.

There are two issues here.

First, you’ve linked the ASCII representation of the data, the wradlib radolan reader expects the binary data.

Second, wradlib radolan reader is able to decode files which contain a single dataset. Your tar-archive consists of multiple datasets, which need to be extracted before. The error you are experiencing originates from trying to read that archive. Here you have at least two options:

  • Extract data with some archiving tool beforehand and read single files afterwards. Note: Decompression for single datasets is built-in (eg. from .gz), so no need to decompress those too.
  • Use tar inside python-script to iterate over files and read with wradlib radolan reader (see this SO question/answer for inspiration).

If you want to load RADOLAN data into an xarray Dataset (with coords) you might use wradlib’s radolan backend. Have a look at the wradlib-documentation here for an example.

With wradlib version 1.17.0 the capability to read RADOLAN ASCII GIS files is implemented. Have a look at the documentation RADOLAN data formats — wradlib.

Hello Kai,

That’s wonderful. I thank you so much for the quick enhancement for the ASCII format files. I will try to read ASCII files for now and see how it works.

Many thanks!