# How to plot the pseudo RHI for Rainbow 5 by using vol data format

**URL:** <https://openradar.discourse.group/t/how-to-plot-the-pseudo-rhi-for-rainbow-5-by-using-vol-data-format/338>\
**Category:** General\
**Tags:** xradar, wradlib, py-art, data\
**Created:** [November 1, 2023, 6:18am UTC](https://openradar.discourse.group/t/how-to-plot-the-pseudo-rhi-for-rainbow-5-by-using-vol-data-format/338 "2023-11-01T06:18:27Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![nissa03](https://avatars.discourse-cdn.com/v4/letter/n/9d8465/32.png) [@nissa03](https://openradar.discourse.group/u/nissa03)\
**Post date:** [November 1, 2023, 6:18am UTC](https://openradar.discourse.group/t/how-to-plot-the-pseudo-rhi-for-rainbow-5-by-using-vol-data-format/338/1 "2023-11-01T06:18:27Z")

</div>

Hi, I’m just new here.

I want to plot RHI for radar data Rainbow 5, but all the data that I have is in the (.vol) format.  
I managed to plot the PPI but couldn’t for RHI. I tried to do with the pyart but it shows “TypeError: Unknown or unsupported file format: UNKNOWN”.

How can I plot the RHI/pseudo RHI for this radar data?  
Attached is the link to a sample of my radar data.  
[https://drive.google.com/drive/folders/11sX4jiZtmkBd66K6tXbG0LB96mI7ldH6?usp=drive\_link](https://drive.google.com/drive/folders/11sX4jiZtmkBd66K6tXbG0LB96mI7ldH6?usp=drive_link)

---

<div class="post-metadata">

**Author:** ![mgrover1](https://yyz2.discourse-cdn.com/free1/user_avatar/openradar.discourse.group/mgrover1/32/7_2.png) [@mgrover1](https://openradar.discourse.group/u/mgrover1)\
**Post date:** [November 1, 2023, 8:05pm UTC](https://openradar.discourse.group/t/how-to-plot-the-pseudo-rhi-for-rainbow-5-by-using-vol-data-format/338/2 "2023-11-01T20:05:09Z")

</div>

> [@nissa03](#):
>
> How can I plot the RHI/pseudo RHI for this radar data?  
> Attached is the link to a sample of my radar data.

Py-ART does not fully support rainbow files - I would suggest using xradar here.

[https://docs.openradarscience.org/projects/xradar/en/stable/notebooks/Rainbow.html](https://docs.openradarscience.org/projects/xradar/en/stable/notebooks/Rainbow.html)

There would not be out-of-the-box support for a pseudo rhi, this is something you would likely need to implement. Taking a look at the file you shared, it looks more like a PPI file than an RHI.

---

<div class="post-metadata">

**Author:** ![syedhamidali](https://yyz2.discourse-cdn.com/free1/user_avatar/openradar.discourse.group/syedhamidali/32/377_2.png) [@syedhamidali](https://openradar.discourse.group/u/syedhamidali)\
**Post date:** [November 1, 2023, 9:42pm UTC](https://openradar.discourse.group/t/how-to-plot-the-pseudo-rhi-for-rainbow-5-by-using-vol-data-format/338/3 "2023-11-01T21:42:00Z")

</div>

```auto
import os
import pyart
import xradar
import cmweather
import numpy as np
import xarray as xr
import cartopy.crs as ccrs
import matplotlib.pyplot as plt

import warnings
warnings.filterwarnings("ignore")

file1 = "2021110309550500dBZ.vol"

dtree = xradar.io.open_rainbow_datatree(file1)

# Fubction to add necessaey metadata, in order to export it to cfradial1 format
def correct_cfradial2(dtree):
    data = np.array('axis_z', dtype='|S32')
    attributes = {
        'standard_name': 'primary_axis_of_rotation',
        'options': 'axis_z, axis_y, axis_x'
    }
    # Create the xarray DataArray
    dtree['primary_axis'] = xr.DataArray(data, attrs=attributes, dims=())
    
    fixed_angles = []
    for grp in dtree.groups:
        if "sweep" in grp:
            fixed_angle = dtree[grp]['sweep_fixed_angle'].values
            fixed_angles.append(fixed_angle)
            dtree[grp]['sweep_mode'] = xr.DataArray(
                np.array(dtree[grp]['sweep_mode'], dtype='|S32'),
                attrs={'standard_name': 'scan_mode_for_sweep',
     'options': 'sector, coplane, rhi, vertical_pointing, idle, azimuth_surveillance, \
     elevation_surveillance, sunscan, pointing, calibration, manual_ppi, manual_rhi'})
    
    fixed_angles = np.array(fixed_angles, dtype=np.float32)
    sweep_groups = np.array([f'sweep_{i}' for i in range(fixed_angles.size)])
    dtree['sweep_fixed_angle'] = xr.DataArray(fixed_angles, dims=('sweep'))
    dtree['sweep_group_name'] = xr.DataArray(sweep_groups, dims=('sweep'))
    dtree['volume_number'] = xr.DataArray(np.array(0, dtype=np.int16),
                                      attrs={'standard_name':'data_volume_index_number'})
    dtree['instrument_type'] = xr.DataArray(np.array('radar', dtype='|S32'),
                                      attrs={'standard_name': 'type_of_instrument',
                                             'options': 'radar, lidar',
                                             'meta_group': 'instrument_parameters'}
                                       )
    dtree['platform_type'] = xr.DataArray(
        np.array('fixed', dtype='|S32'),
        attrs={'standard_name': 'platform_type',
    'options':'fixed, vehicle, ship, aircraft_fore, aircraft_aft, aircraft_tail, aircraft_belly,\
    aircraft_roof, aircraft_nose, satellite_orbit, satellite_geostat'})
    
    return dtree

# Apply Correction
dtree = correct_cfradial2(dtree)

# Export to Cfradial1
xradar.io.to_cfradial1(dtree, filename=None, calibs=True)

# Now Let's create PsedudoRHI using Pyart
radar = pyart.io.read_cfradial('cfrad1_None_20211103_095505.nc')
azi = 10 # Choose any azimuth from 0 to 360
pseudorhi = pyart.util.cross_section_ppi(radar, [azi])
display = pyart.graph.RadarDisplay(pseudorhi)
fig = plt.figure(figsize=[8, 3])
ax = plt.axes()
display.plot_rhi('DBZH', ax=ax, cmap="NWSRef")
ax.set_ylim(0, 20)
ax.set_xlim(0,130)
plt.show()

```

![image](https://global.discourse-cdn.com/free1/uploads/openradar/original/1X/db8bf07912f0d3f3db5cec181334f5aac4c9e0a0.png)

For the detailed Notebook, and how I created this animation, check this [Notebook](https://github.com/syedhamidali/test_scripts/blob/master/PPI_rainbow_KNisa.ipynb)

![knisa_vol](https://global.discourse-cdn.com/free1/uploads/openradar/original/1X/4ae740cb7172a741fd4fe47e555334c20e00af9c.gif)

---

<div class="post-metadata">

**Author:** ![syedhamidali](https://yyz2.discourse-cdn.com/free1/user_avatar/openradar.discourse.group/syedhamidali/32/377_2.png) [@syedhamidali](https://openradar.discourse.group/u/syedhamidali)\
**Post date:** [November 2, 2023, 2:48am UTC](https://openradar.discourse.group/t/how-to-plot-the-pseudo-rhi-for-rainbow-5-by-using-vol-data-format/338/4 "2023-11-02T02:48:38Z")

</div>

Hi @kmuehlbauer @mgrover1 ,  
This Rainbow file required the `correct_cfradial2(dtree)` function to be applied in order to export it to cfradial1 format and subsequently reading it with PyArt. I’m curious to know if the problem lies with the data or the Rainbow reader. What are your insights on this matter? Could it be possible that we missed adding the necessary metadata when reading the Rainbow file, or is it that the file itself lacks the essential metadata?

---

<div class="post-metadata">

**Author:** ![nissa03](https://avatars.discourse-cdn.com/v4/letter/n/9d8465/32.png) [@nissa03](https://openradar.discourse.group/u/nissa03)\
**Post date:** [November 2, 2023, 6:53am UTC](https://openradar.discourse.group/t/how-to-plot-the-pseudo-rhi-for-rainbow-5-by-using-vol-data-format/338/5 "2023-11-02T06:53:12Z")

</div>

Hi, I see  
Thank you!

---

<div class="post-metadata">

**Author:** ![nissa03](https://avatars.discourse-cdn.com/v4/letter/n/9d8465/32.png) [@nissa03](https://openradar.discourse.group/u/nissa03)\
**Post date:** [November 2, 2023, 7:04am UTC](https://openradar.discourse.group/t/how-to-plot-the-pseudo-rhi-for-rainbow-5-by-using-vol-data-format/338/6 "2023-11-02T07:04:39Z")

</div>

That’s amazing!  
I’d try and at the line

**# _Export to Cfradial1_**  
xradar.io.to\_cfradial1(dtree, filename=None, calibs=True)

it shows “AttributeError: module ‘[xradar.io](http://xradar.io)’ has no attribute ‘to\_cfradial1’”

How to fix this?

---

<div class="post-metadata">

**Author:** ![syedhamidali](https://yyz2.discourse-cdn.com/free1/user_avatar/openradar.discourse.group/syedhamidali/32/377_2.png) [@syedhamidali](https://openradar.discourse.group/u/syedhamidali)\
**Post date:** [November 2, 2023, 7:21am UTC](https://openradar.discourse.group/t/how-to-plot-the-pseudo-rhi-for-rainbow-5-by-using-vol-data-format/338/7 "2023-11-02T07:21:25Z")

</div>

You need to update it, you may use one of the following commands:

```auto
conda update xradar -c conda-forge

```

Or

```auto
mamba update xradar -c conda-forge

```

---

<div class="post-metadata">

**Author:** ![nissa03](https://avatars.discourse-cdn.com/v4/letter/n/9d8465/32.png) [@nissa03](https://openradar.discourse.group/u/nissa03)\
**Post date:** [November 2, 2023, 8:00am UTC](https://openradar.discourse.group/t/how-to-plot-the-pseudo-rhi-for-rainbow-5-by-using-vol-data-format/338/8 "2023-11-02T08:00:56Z")

</div>

Thank you so much!

It works!

 ![RHI_test](https://global.discourse-cdn.com/free1/uploads/openradar/original/1X/d10b3bc831805b05807e639cb6e341f5ee537a3a.png)

---

<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:** [November 2, 2023, 9:48am UTC](https://openradar.discourse.group/t/how-to-plot-the-pseudo-rhi-for-rainbow-5-by-using-vol-data-format/338/9 "2023-11-02T09:48:54Z")

</div>

@syedhamidali I think currently only a minimal set of those items are available via `.coords`. But I think they also do lack proper `attrs`. Please open an issue at xradar. Thanks!
