Opening hdf4 with pyart


I have NASA APR-2 data in an hdf4 file. I was hoping to use pyart.graph.AirborneRadarDisplay.plot_rhi to plot the data. However, says that pyart hdf4 is an unsupported format. Is there a way to get around this issue? I can read the data into python using pyhdf.


Hi Hannah,

I used the APR alot in my MS/PhD, and stuck with hdf4/hdf5 libraries to load the data. I used it for OLYMPEX and GCPEX, so your milage may vary if using a different campaign. But here is some old code I have available online: DRpy/ at 391775ec5038a6759252051412705eb667044e0a · dopplerchase/DRpy · GitHub

[ugh I know its ugly… :(]

In that .py file you should see a class called APR (starts on line 1990).

I think the basic usage was:

from gpmdpr import APR
apr = APR(‘PATH/TO/FILE’, campaign=‘gcpex’)

then it would load all the data into an xarray dataset for you


There is an old notebook here: DRpy/Example_APR.ipynb at 391775ec5038a6759252051412705eb667044e0a · dopplerchase/DRpy · GitHub

but you can’t install this old version of DRpy (I had a major refactor where I dropped APR support). If that code doesnt work I can probably go digging on the Illinois computer cluster for my other code.


1 Like

@hvagasky As suggested over at Py-ART Github I’d try to use recent rasterio/rioxarray for hdf4 data. For hdf5 data, xarray is able to read files based on that format either with netcdf4 or h5netcdf backend.

import xarray

# might work with recent rasterio/rioxarray
xds = xarray.open_dataset(hdf4_filename, engine="rasterio") 

# should all work for hdf5-files
xds = xarray.open_dataset(hdf5_filename) 
xds = xarray.open_dataset(hdf5_filename, engine="netcdf4")  
xds = xarray.open_dataset(hdf5_filename, engine="h5netcdf") 

It would be great if you could share a data file, so we can fully answer that question.

BTW: Welcome to openradar-discourse @hvagasky and @dopplerchase!

1 Like

Thanks for the suggestions. It was an older file, so it was challenging. I was able to use pyhdf.SD to open the file and figured out how to maneuver within it.