EOFError: Unexpected EOF detected while reading RADOLAN header

Hi all,

I am trying to read radolan file which is in ASCII format. I am using following versions.

python=3.9.13
wradlib version=1.16.2

import wradlib as wrl
import xarray as xr
import matplotlib.pyplot as pl
import warnings

warnings.filterwarnings("ignore")
try:
    get_ipython().magic("matplotlib inline")
except:
    pl.ion()
import numpy as np
src_path = "D:/Sandeep/Thesis/Data/Extracted/"
data, metadata = wrl.io.read_radolan_composite(src_path+"RW-20050601.tar.gz")

Error:

---------------------------------------------------------------------------
EOFError                                  Traceback (most recent call last)
Input In [8], in <cell line: 1>()
----> 1 data, metadata = wrl.io.read_radolan_composite(src_path+"RW-20050601.tar.gz")

File ~\anaconda3\lib\site-packages\wradlib\io\radolan.py:763, in read_radolan_composite(f, missing, loaddata, fillmissing)
    760 NODATA = missing
    762 # get _radolan_file class
--> 763 with _radolan_file(
    764     f, fillmissing=fillmissing, copy=True, ancillary=False
    765 ) as radfile:
    767     attrs = radfile.attrs
    769     if not loaddata:

File ~\anaconda3\lib\site-packages\wradlib\io\radolan.py:1016, in _radolan_file.__init__(self, filename, fillmissing, copy, ancillary)
   1014 self._fill = fillmissing
   1015 self._copy = copy
-> 1016 self._ancillary = self._get_ancillary(requested=ancillary)

File ~\anaconda3\lib\site-packages\wradlib\io\radolan.py:1190, in _radolan_file._get_ancillary(self, requested)
   1189 def _get_ancillary(self, requested=True):
-> 1190     if self.product in ["PG", "PC"]:
   1191         anc = ("nodatamask",)
   1192     elif self.product in ["RX", "EX", "WX"]:

File ~\anaconda3\lib\site-packages\wradlib\io\radolan.py:1029, in _radolan_file.product(self)
   1026 @property
   1027 def product(self):
   1028     if self._product is None:
-> 1029         self._product = self.attrs["producttype"]
   1030     return self._product

File ~\anaconda3\lib\site-packages\wradlib\io\radolan.py:1023, in _radolan_file.attrs(self)
   1020 if self._attrs is None:
   1021     # move file pointer to start
   1022     self.fp.seek(0)
-> 1023     self._attrs = self._read_attrs()
   1024 return self._attrs

File ~\anaconda3\lib\site-packages\wradlib\io\radolan.py:1062, in _radolan_file._read_attrs(self)
   1061 def _read_attrs(self):
-> 1062     header = read_radolan_header(self.fp)
   1063     return parse_dwd_composite_header(header)

File ~\anaconda3\lib\site-packages\wradlib\io\radolan.py:690, in read_radolan_header(fid)
    688 mychar = fid.read(1)
    689 if not mychar:
--> 690     raise EOFError("Unexpected EOF detected while reading " "RADOLAN header")
    691 if mychar == b"\x03":
    692     break

EOFError: Unexpected EOF detected while reading RADOLAN header

Hi Sandeep,

wradlib is only able to read the binary RADOLAN data files. wradlib cannot read the ASCII RADOLAN data files.

I’m sorry to not have a better answer for you. My suggestion would be to read the data using numpy/pandas CSV readers. If you get a working prototype, we might have the chance to put that into wradlib. I encourage you to open a feature request issue at the wradlib GitHub issue tracker.

Hi Kai,

Now I understand ASCII radolan data files are not readable using wradlib library. I have to consider using numpy or pandas for reading the data.

So here my goal is to analyse different precipitation types from 2005 - 2021 in the state of Brandenburg, Germany. If I can read the files using pandas, is it possible to achieve my goal without using wradlib or radproc libraries for ASCII radolan data files?

Thanks in advance!
Sandeep

Hi Sandeep,

If you can read the data using numpy/padas or other means, it depends on what your processing needs are. You might not need wradlib then. But nevertheless, it might still be a good idea to equip wradlib with that capability. So my suggestion would be: Please open a feature request here. I’ll check how to read that data and put it into wradlib. Deal?

Hi Kai,

I just posted the issue on github. Thank you for all the timely replies from your side.

Thanks
Sandeep

Here the Issue and Pullrequest for reference. Let’s iterate over there and present solution here, when finalized.

Issue: Reading ASCII radolan data files using wradlib · Issue #593 · wradlib/wradlib · GitHub
PullRequest: WIP: ENH: read RADOLAN ascii format by kmuehlbauer · Pull Request #594 · wradlib/wradlib · GitHub

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.