XArray : HDF File Error : IOError: [Errno -51] NetCDF: Unknown file format

1,826 views
Skip to first unread message

sav...@umbc.edu

unread,
Sep 24, 2018, 11:56:30 AM9/24/18
to xarray
Hello,

I came across the XArray and its functionalities and wanted to ticker around with NASA MODIS Climatic files in .hdf file format.
However, whenever I attempted to read the file, I ran into an error of

IOError: [Errno -51] NetCDF: Unknown file format: '/content/MYD03.A2002185.0000.061.2017362174430.hdf'

Note that I ran the program in various environments like :
1. Locally on my machine
2. On Google Colab

Moreover, still ran into the same error. I even tried changing the file extension to .h4 as per one of the post suggestion in this group about HDF files, still no luck.
Kindly provide me with some assistance on this issue.

xr.open_dataset('MYD03.A2002185.0000.061.2017362174430.h4', engine='pynio')
foo1
= xr.open_mfdataset('MYD03.A2002185.0000.061.2017362174430.hdf')
foo
= xr.DataArray('MYD03.A2002185.0000.061.2017362174430.hdf')


Forgive me for my lack of knowledge since I am still new to this topic and subject.

When I use the netCDF python library and the Function Dataset, I get this as its output:**Please view the attached Jupyter Notebook for reference.

Kindly Help.

Thank you.


SamVersionOfSavioCode1.ipynb

Chelle Gentemann

unread,
Sep 24, 2018, 6:14:19 PM9/24/18
to xar...@googlegroups.com

Hi.  I have a work around, but perhaps someone else has a better solution.
I work with AMSRE files which are in HDF EOS format, a specialized HDF4.
HDFEOSVersion = "HDFEOS_V2.17";

Your MODIS files are
HDFEOSVersion = "HDFEOS_V2.19

So, I think my workaround, while not elegant may work for you.

1) convert HDFEOS to netcdf4 using h4tonccf_nc4.exe which you can get here: http://hdfeos.org/software/h4cflib/previous_releases/1.1/windows/
I've attached my python routine that basically goes through my directories and processes all the files to netcdf
2) read in using ds=xr.open_dataset(filename)

Good luck!  A bit frustrating that the large data centers can't update all their old HDF data into netcdf4....
Chelle






--
You received this message because you are subscribed to the Google Groups "xarray" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xarray+un...@googlegroups.com.
To post to this group, send email to xar...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/xarray/c0f66c2a-ee33-440c-bdeb-1e188bdd46c3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
-----------------
Dr. Chelle L. Gentemann
Senior Scientist, Earth & Space Research
cgent...@esr.org; 707-363-9215  (email preferred)
skype id: chelle.gentemann
-----------------
amsre_l2a_hdf4_eos_to_netcdf_converter.ipynb
Reply all
Reply to author
Forward
0 new messages