Error in reading of rainbow vol file format

550 views
Skip to first unread message

omidfarmoha...@gmail.com

unread,
Apr 17, 2016, 8:19:27 AM4/17/16
to wradlib-users
Hi maik
I could  install wradlib whit conda software in windows 7.
But i have a problem in reading rainbow vol file. When i write this : >>data, metadata = wradlib.io.read_rainbow("e:/ 2.vol , loaddata =true")
I see this Error in reading of raw data : 
  Error in io.py : 1590 line ,and in 1546 line in reading of rainbow  vol format file !!

please help me.Thanks a lot.

mohammad
 

Maik Heistermann

unread,
Apr 18, 2016, 3:44:48 AM4/18/16
to wradlib-users
Dear Mohammad,

from a quick view it appears that the call of read_rainbow is invalid: Only the path should be set in quotation marks (because it is a string). However, you set the entire function call in quotation marks which makes it invalid.

I would also recommend not to use whitespaces in file paths (as in your example "e:/ 2.vol").

Good luck,
Maik 

omidfarmoha...@gmail.com

unread,
Apr 19, 2016, 11:35:11 PM4/19/16
to wradlib-users

Hi dear Maik
thank a lot for your answer.but i writhe this line just the same as wradlib document for reading rainbow file.
 

sorry i don,t  understand your answre.if you mind writhe it whit a example. 
 
  
whit respect mohammad
 

Maik Heistermann

unread,
Apr 20, 2016, 2:38:19 AM4/20/16
to wradlib-users
Dear Mohammad,

you might want to have a look at the library reference here:

http://wradlib.org/wradlib-docs/latest/generated/wradlib.io.read_Rainbow.html#wradlib.io.read_Rainbow

There are, in fact, four issues in one line: (i) the function itself (read_Rainbow instead of read_rainbow), (ii) passing the arguments (only path as string), (iii) assigning the return value (a dictionary) to a variable (only one variable: a dictionary containing metadata and data - in case loaddata=True), (iv) the boolean variable True should be written with a capital letter.

So you call should look something like:

import wradlib
outdict
= wradlib.io.read_Rainbow("e:/ 2.vol", loaddata=True)

But you should also check whether your path ("e:/ 2.vol") really contains a white space.

If you seek for more background in Python, I highly recommend the scipy lecture notes available here:

http://www.scipy-lectures.org/

In case it does not work out, please send us the complete error message returned by Python.

Good luck,
Maik

omidfarmoha...@gmail.com

unread,
Apr 20, 2016, 8:08:07 AM4/20/16
to wradlib-users


sincerely yours maik
I try your recommendation and inform result   

omidfarmoha...@gmail.com

unread,
Apr 20, 2016, 8:56:53 AM4/20/16
to wradlib-users
Hi again maik
I do your recommendation but see this error:

 Python 2.7.11 |Anaconda 4.0.0 (64-bit)| (default, Feb 16 2016, 09:58:36) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
>>> import wradlib
>>> outdict = wradlib.io.read_Rainbow("e:/2.vol", loaddata=True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Anaconda2\lib\site-packages\wradlib\io.py", line 1590, in read_Rainbow
    rbdict = get_RB_header(filename)
  File "C:\Anaconda2\lib\site-packages\wradlib\io.py", line 1562, in get_RB_header
    return xmltodict.parse(header)
  File "C:\Anaconda2\lib\site-packages\wradlib\util.py", line 179, in __getattr__
    'for further instructions.')
AttributeError: Module "xmltodict" is not installed.

You tried to access function/module/attribute "parse"
from module "xmltodict".
This module is optional right now in wradlib.
You need to separately install this dependency.
for further instructions.
>>> 

I send you a sample of my radar raw data file (2.vol)  and the error massages .

Please  show my mistakes.

thank you


2.vol
aks errr.png

Maik Heistermann

unread,
Apr 20, 2016, 10:38:12 AM4/20/16
to wradlib-users
Dear Mohammad,

this means you still need to install another package: xmltodict. It is specifically required by read_Rainbow.

Just open a system console and then:

> activate wradlib
[wradlib] > pip install xmltodict

Then try open a new Python console in order to test your script.

Best,
Maik 

omidfarmoha...@gmail.com

unread,
Apr 23, 2016, 6:35:03 AM4/23/16
to wradlib-users
Hi Maik
Thanks alot for helping me.
I could open rainbow vol file.
But in Runing "load_rainbow_example.py" I see several errors :(please help me. What is my mistake that i see this errors)
 
>>> import wradlib
>>> import wradlib as wrl
>>> import matplotlib.pyplot as pl
>>> import numpy as np
>>> import os
>>> def ex_load_rainbow():
...
  File "<stdin>", line 2
   
    ^
IndentationError: expected an indented block
>>>      rbdict = wradlib.io.read_Rainbow("e:/2.vol")
  File "<stdin>", line 1
    rbdict = wradlib.io.read_Rainbow("e:/2.vol")
    ^
IndentationError: unexpected indent
>>>     azi = rbdict['volume']['scan']['slice']['slicedata']['rayinfo']['data']
  File "<stdin>", line 1
    azi = rbdict['volume']['scan']['slice']['slicedata']['rayinfo']['data']
    ^
IndentationError: unexpected indent
>>>     azidepth = float(rbdict['volume']['scan']['slice']['slicedata']['rayinfo']['@depth'])
  File "<stdin>", line 1
    azidepth = float(rbdict['volume']['scan']['slice']['slicedata']['rayinfo']['@depth'])
    ^
IndentationError: unexpected indent
>>>     azirange = float(rbdict['volume']['scan']['slice']['slicedata']['rayinfo']['@rays'])
  File "<stdin>", line 1
    azirange = float(rbdict['volume']['scan']['slice']['slicedata']['rayinfo']['@rays'])
    ^
IndentationError: unexpected indent
>>>     azires = float(rbdict['volume']['scan']['slice']['anglestep'])
  File "<stdin>", line 1
    azires = float(rbdict['volume']['scan']['slice']['anglestep'])
    ^
IndentationError: unexpected indent
>>>     azi =  (azi * azirange / 2**azidepth) * azires
  File "<stdin>", line 1
    azi =  (azi * azirange / 2**azidepth) * azires
    ^
IndentationError: unexpected indent
>>>
>>>     stoprange = float(rbdict['volume']['scan']['slice']['stoprange'])
  File "<stdin>", line 1
    stoprange = float(rbdict['volume']['scan']['slice']['stoprange'])
    ^
IndentationError: unexpected indent
>>>     rangestep = float(rbdict['volume']['scan']['slice']['rangestep'])
  File "<stdin>", line 1
    rangestep = float(rbdict['volume']['scan']['slice']['rangestep'])
    ^
IndentationError: unexpected indent
>>>     r = np.arange(0, stoprange, rangestep)
  File "<stdin>", line 1
    r = np.arange(0, stoprange, rangestep)
    ^
IndentationError: unexpected indent
>>>
>>>     data = rbdict['volume']['scan']['slice']['slicedata']['rawdata']['data']
  File "<stdin>", line 1
    data = rbdict['volume']['scan']['slice']['slicedata']['rawdata']['data']
    ^
IndentationError: unexpected indent
>>>     datadepth = float(rbdict['volume']['scan']['slice']['slicedata']['rawdata']['@depth'])
  File "<stdin>", line 1
    datadepth = float(rbdict['volume']['scan']['slice']['slicedata']['rawdata']['@depth'])
    ^
IndentationError: unexpected indent
>>>     datamin = float(rbdict['volume']['scan']['slice']['slicedata']['rawdata']['@min'])
  File "<stdin>", line 1
    datamin = float(rbdict['volume']['scan']['slice']['slicedata']['rawdata']['@min'])
    ^
IndentationError: unexpected indent
>>>     datamax = float(rbdict['volume']['scan']['slice']['slicedata']['rawdata']['@max'])
  File "<stdin>", line 1
    datamax = float(rbdict['volume']['scan']['slice']['slicedata']['rawdata']['@max'])
    ^
IndentationError: unexpected indent
>>>     data = datamin + data * (datamax - datamin) / 2 ** datadepth
  File "<stdin>", line 1
    data = datamin + data * (datamax - datamin) / 2 ** datadepth
    ^
IndentationError: unexpected indent
>>>
>>>     unit = rbdict['volume']['scan']['slice']['slicedata']['rawdata']['@type']
  File "<stdin>", line 1
    unit = rbdict['volume']['scan']['slice']['slicedata']['rawdata']['@type']
    ^
IndentationError: unexpected indent
>>>     time = rbdict['volume']['scan']['slice']['slicedata']['@time']
  File "<stdin>", line 1
    time = rbdict['volume']['scan']['slice']['slicedata']['@time']
    ^
IndentationError: unexpected indent
>>>     date = rbdict['volume']['scan']['slice']['slicedata']['@date']
  File "<stdin>", line 1
    date = rbdict['volume']['scan']['slice']['slicedata']['@date']
    ^
IndentationError: unexpected indent
>>>     lon = rbdict['volume']['sensorinfo']['lon']
  File "<stdin>", line 1
    lon = rbdict['volume']['sensorinfo']['lon']
    ^
IndentationError: unexpected indent
>>>     lat = rbdict['volume']['sensorinfo']['lat']
  File "<stdin>", line 1
    lat = rbdict['volume']['sensorinfo']['lat']
    ^
IndentationError: unexpected indent
>>>     sensortype = rbdict['volume']['sensorinfo']['@type']
  File "<stdin>", line 1
    sensortype = rbdict['volume']['sensorinfo']['@type']
    ^
IndentationError: unexpected indent
>>>     sensorname = rbdict['volume']['sensorinfo']['@name']
  File "<stdin>", line 1
    sensorname = rbdict['volume']['sensorinfo']['@name']
    ^
IndentationError: unexpected indent
>>>
>>>     cgax, caax, paax, pm = wrl.vis.plot_cg_ppi(data, r=r, az=azi)
  File "<stdin>", line 1
    cgax, caax, paax, pm = wrl.vis.plot_cg_ppi(data, r=r, az=azi)
    ^
IndentationError: unexpected indent
>>>
>>>     title = sensortype + ' ' + sensorname + ' ' + date + ' ' + time + '\n' + lon + 'E ' + lat + 'N'
  File "<stdin>", line 1
    title = sensortype + ' ' + sensorname + ' ' + date + ' ' + time + '\n' + lon + 'E ' + lat + 'N'
    ^
IndentationError: unexpected indent
>>>     t = pl.title(title, fontsize=12)
  File "<stdin>", line 1
    t = pl.title(title, fontsize=12)
    ^
IndentationError: unexpected indent
>>>     t.set_y(1.1)
  File "<stdin>", line 1
    t.set_y(1.1)
    ^
IndentationError: unexpected indent
>>>     cbar = pl.gcf().colorbar(pm, pad=0.075)
  File "<stdin>", line 1
    cbar = pl.gcf().colorbar(pm, pad=0.075)
    ^
IndentationError: unexpected indent
>>>     caax.set_xlabel('x_range [km]')
  File "<stdin>", line 1
    caax.set_xlabel('x_range [km]')
    ^
IndentationError: unexpected indent
>>>     caax.set_ylabel('y_range [km]')
  File "<stdin>", line 1
    caax.set_ylabel('y_range [km]')
    ^
IndentationError: unexpected indent
>>>     pl.text(1.0, 1.05, 'azimuth', transform=caax.transAxes, va='bottom',
  File "<stdin>", line 1
    pl.text(1.0, 1.05, 'azimuth', transform=caax.transAxes, va='bottom',
    ^
IndentationError: unexpected indent
>>>             ha='right')
  File "<stdin>", line 1
    ha='right')
    ^
IndentationError: unexpected indent
>>>     cbar.set_label('reflectivity [' + unit + ']')
  File "<stdin>", line 1
    cbar.set_label('reflectivity [' + unit + ']')
    ^
IndentationError: unexpected indent
>>>     pl.tight_layout()
  File "<stdin>", line 1
    pl.tight_layout()
    ^
IndentationError: unexpected indent
>>>     pl.show()
  File "<stdin>", line 1
    pl.show()
    ^
IndentationError: unexpected indent
>>>
>>>
>>> if __name__ == '__main__':
...     ex_load_rainbow()
...


Thanks a lot.(mohammad)
 
load_rainbow_example.py
2.vol

Maik Heistermann

unread,
Apr 26, 2016, 7:24:07 AM4/26/16
to wradlib-users
Dear Mohammad,

you should not execute a Python script line by line if it contains indented code blocks. If you want to test the functionality of the script, just run it by

$ python name_of_my_script
.py

from any system console that is opened within the same directory as your script. Otherwise, I recommend to use an integrated development environment for testing and developing Python code, such as Spyder or PyCharm and many many more.

Best,
Maik

omidfarmoha...@gmail.com

unread,
Apr 29, 2016, 6:06:22 AM4/29/16
to wradlib-users


Hello maik.
First able,I am gratitude for  your big helps .
I have three question :

1. when i run "trafo" dictionary , the python gives  error such first attach  file( error in line 79: return 10.**(x/10.) ), please see first attach file .what is the problem?

2.when i open Rainbow Raw data, i see little numerical data and most of reflective data only shown by dots like this:( [10 25 ....... 104 151 44 ] ,How i can see actual data? if you mind send me document or explanation about the nature of "[slice] or [rayinfo] or [depth] or  [sliceedata],[ raw data]. ...?
3.what is the mathematical relation between "azi, anglestep, azi range "? 

I am sorry and apologize for many questions.
Thank you 
mohammad 
 

Untitled.png
2.png

omidfarmoha...@gmail.com

unread,
May 4, 2016, 10:14:55 AM5/4/16
to wradlib-users
Hi maik plese ,please please help me and reply my three question.

Thank you.

omidfarmoha...@gmail.com

unread,
May 7, 2016, 7:16:02 AM5/7/16
to wradlib-users


Drear Maik  answer my questions . 

Thank you.

Maik Heistermann

unread,
May 9, 2016, 2:56:35 AM5/9/16
to wradlib-users
Dear Mohammad,

we are answering user requests based on available resources, and I would kindly like to ask you to refrain from sending "insisting" messages to the forum. This might also be annoying for other users subscribed to this forum.

As to your questions:

1. wradlib.trafo.idecibel requires a float or a numpy array of floats. You need to extract the array of reflectivities from the data dictionary by using the corresponding key. You have to find out yourself which key this might be. You can get an overview of keys by

>>> print data.keys()

If you found the right key (let's say, e.g.: refl), you access the value array by data["refl"] and your function call would be wradlib.trafo.idecibel(data["refl"])

2. Printing large arrays to the Python console will not work. Python will only show the beginning and the end of the array. Everything inbetween will be shown as "...". In order to inspect arrays, you can use slicing (see e.g. http://www.scipy-lectures.org/intro/numpy/array_object.html), or you can write the array to a text file (see e.g. http://www.scipy-lectures.org/intro/numpy/advanced_operations.html#loading-data-files).

Again, I would like to encourage you to use available web resources related to basic Python programming. This forum's main purpose is to answer questions that are specifically related to wradlib.

Kind regards,
Maik 

omidfarmoha...@gmail.com

unread,
May 12, 2016, 8:00:28 AM5/12/16
to wradlib-users


Sorry Dear maik, excuse me.
Thanks a lot for your best Guidance. 

omidfarmoha...@gmail.com

unread,
May 21, 2016, 12:45:51 AM5/21/16
to wradlib-users
Hi dear maik.
(problem in data transformatiom to dBZ) 
when i am using "trafo" modulea ,data be transformed, but when i plot transformed Data the screen is empty .
Wath is the problem?
please see attach files.
thanks alot.

>>> import wradlib as wr
>>> f=wr.io.read_Rainbow("d:/11.vol")
>>> data = f['volume']['scan']['slice'][0]['slicedata']['rawdata']['data']
>>> cgax, caax, paax, pm = wr.vis.plot_cg_ppi(data)
C:\Anaconda2\lib\site-packages\matplotlib\projections\polar.py:157: RuntimeWarning: invalid value encountered in remainder
  theta %= 2 * np.pi
>>> s =wr.trafo.idecibel(data)
>>> cgax, caax, paax, pm = wr.vis.plot_cg_ppi(s)
111111.png
2222.png

Maik Heistermann

unread,
May 23, 2016, 2:53:17 AM5/23/16
to wradlib-users
Dear Mohammad,

you said the problem is transforming the data to dBZ...but calling trafo.idecibel actually does the opposite: transforming from dBZ to Z.

In any case, the
problem with the plot remains... and I do not have a good answer, yet. An empty plot typically indicates that the array contains invalid values (such as np.nan). But your plot of data appears to be ok, so I do not see any reason why the transformation should produce invalid values... but you should check anyways. There are several ways to do this, e.g.

>>> import numpy as np
>>> np.all(np.isfinite(s))


This should return False in case there is at least one "invalid" value in s. You might also want to check whether masking invald values will produce the desired plot (though this will not help you to understand what caused the invalid value):

>>> wr.vis.plot_cg_ppi( np.ma.masked_invalid(s) )

Or you can check other properties like

>>> print "Min in data: %.1f, Max in data: %.1f, Min in s: %.1f, Max in s: %.1f" % ( data.min(), data.max(), s.min(), s.max() )

in order to understand what is happening.

By the way: the plot looks a bit weird with showing a semi circle. Of course, you might have such a scan strategy, but It'll be uncommon. For adequately utilizing vis.plot_cg_ppi (or vis.plot_ppi), you should pass the other function arguments that describe the scan (such as range and azimuth arrays). Please see the library reference for details. The scan strategy should become apparent by inspecting the metadata of your rainbow file.

Best,
Maik

omidfarmoha...@gmail.com

unread,
May 27, 2016, 1:32:04 AM5/27/16
to wradlib-users
Hi maik
Thank a lot for your best guides.
 I have a problem with georefrance modul:

>>> import wradlib as a
>>> import numpy as np
>>> d= a.io.read_Rainbow('d:/8.vol')
>>> data = d['volume']['scan']['slice'][0]['slicedata']['rawdata']['data']
>>> radar_location = (47.8744, 8.005, 1517)
>>> elevation = 0.5
>>> azimuths = np.arange(0,360)
>>> ranges = np.arange(0, 128000., 1000.)
>>> polargrid = np.meshgrid(ranges, azimuths)
>>> lon, lat, alt = a.georef.polar2lonlatalt_n(polargrid[0], polargrid[1], elevation, radar_location)
>>> gk3 = a.georef.epsg_to_osr(31467)
>>>  x, y = a.georef.reproject(lon, lat, projection_target=gk3)

  File "<stdin>", line 1
    x, y = a.georef.reproject(lon, lat, projection_target=gk3)
    ^
IndentationError: unexpected indent
>>>  x, y = a.georef.project(lat, lon, gk3)

  File "<stdin>", line 1
    x, y = a.georef.project(lat, lon, gk3)
    ^
IndentationError: unexpected indent

>>> gk3 =a.georef.create_projstr("gk", zone=3)

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'create_projstr'



what is the problem?
mohammad

55555.png

Maik Heistermann

unread,
May 27, 2016, 3:31:24 AM5/27/16
to wradlib-users
Dear Mohammad,

the IndentationError occurs becasue you have a leading whitespace in your line. You need to remove that.

Regarding your use of georef.project and georef.create_projstr: these functions have been deprecated for quite some time, and are not part of wradlib anymore. Please use - as you already did - georef.reproject and georef.epsg_to_osr or georef.create_osr or georef.proj4_to_osr.

See the library reference for more details.

Best,
Maik
Reply all
Reply to author
Forward
0 new messages