# Reading radolan ascii format files

**URL:** <https://openradar.discourse.group/t/reading-radolan-ascii-format-files/35>\
**Category:** Openradar\
**Tags:** wradlib\
**Created:** [October 3, 2022, 3:16pm UTC](https://openradar.discourse.group/t/reading-radolan-ascii-format-files/35 "2022-10-03T15:16:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![SandeepAllampalli](https://yyz2.discourse-cdn.com/free1/user_avatar/openradar.discourse.group/sandeepallampalli/32/17_2.png) [@SandeepAllampalli](https://openradar.discourse.group/u/SandeepAllampalli)\
**Post date:** [October 3, 2022, 3:16pm UTC](https://openradar.discourse.group/t/reading-radolan-ascii-format-files/35/1 "2022-10-03T15:16:08Z")

</div>

Hello all,

I am trying to read data from ([Index of /climate\_environment/CDC/grids\_germany/hourly/radolan/historical/asc/](https://opendata.dwd.de/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.

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

warnings.filterwarnings("ignore")

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 = wrl.io.read_radolan_composite(filename)

```

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

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

File “C:\ProgramData\Anaconda3\envs\wradlib\lib\site-packages\spyder\_kernels\py3compat.py”, line 356, in compat\_exec  
exec(code, globals, locals)

File “d:\sandeep\thesis\thesis.py”, line 19, in   
data\_raw, meta = wrl.io.read\_radolan\_composite(filename)

File “C:\ProgramData\Anaconda3\envs\wradlib\lib\site-packages\wradlib\io\radolan.py”, line 763, in read\_radolan\_composite  
attrs = radfile.attrs

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

File “C:\ProgramData\Anaconda3\envs\wradlib\lib\site-packages\wradlib\io\radolan.py”, line 1039, in \_read\_attrs  
header = read\_radolan\_header(self.fp)

File “C:\ProgramData\Anaconda3\envs\wradlib\lib\site-packages\wradlib\io\radolan.py”, 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)

---

<div class="post-metadata">

**Author:** ![kmuehlbauer](https://yyz2.discourse-cdn.com/free1/user_avatar/openradar.discourse.group/kmuehlbauer/32/439_2.png) [@kmuehlbauer](https://openradar.discourse.group/u/kmuehlbauer)\
**Post date:** [October 3, 2022, 4:57pm UTC](https://openradar.discourse.group/t/reading-radolan-ascii-format-files/35/2 "2022-10-03T16:57:52Z")

</div>

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](https://opendata.dwd.de/climate_environment/CDC/grids_germany/hourly/radolan/historical/bin/).

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](https://stackoverflow.com/questions/2018512/reading-tar-file-contents-without-untarring-it-in-python-script) 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](https://docs.wradlib.org/en/stable/notebooks/fileio/wradlib_radolan_backend.html) for an example.

---

<div class="post-metadata">

**Author:** ![kmuehlbauer](https://yyz2.discourse-cdn.com/free1/user_avatar/openradar.discourse.group/kmuehlbauer/32/439_2.png) [@kmuehlbauer](https://openradar.discourse.group/u/kmuehlbauer)\
**Post date:** [October 20, 2022, 7:36am UTC](https://openradar.discourse.group/t/reading-radolan-ascii-format-files/35/3 "2022-10-20T07:36:10Z")

</div>

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](https://docs.wradlib.org/en/latest/notebooks/radolan/radolan_format.html#RADOLAN-ASCII-data-format).

---

<div class="post-metadata">

**Author:** ![SandeepAllampalli](https://yyz2.discourse-cdn.com/free1/user_avatar/openradar.discourse.group/sandeepallampalli/32/17_2.png) [@SandeepAllampalli](https://openradar.discourse.group/u/SandeepAllampalli)\
**Post date:** [October 20, 2022, 7:52am UTC](https://openradar.discourse.group/t/reading-radolan-ascii-format-files/35/4 "2022-10-20T07:52:07Z")

</div>

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!
