h5py is a Python interface to the HDF5 library. It covers most HDF5 APIs.
Although user can download, build, and install h5py from source, it is not recommended. Instead, please download Miniconda and install it first. Installing Miniconda is straightforward if you follow this instruction.
Once you can run Miniconda successfully, use conda install h5py
from Miniconda's Python shell.
If you're a Docker user, please try our Docker images of Anaconda through Docker Hub that include all the required Python modules (e.g., basemap) to visualize HDF-EOS data.
h5py greatly simplifies the complexity of HDF5 C APIs by providing easy-to-use high level APIs. Yet, it's powerful enough to do almost anything you can do from HDF5 C APIs.
If you have installed h5py successfully, you can read and visualize NASA HDF5 and netCDF-4 data products. First, please make sure that you have installed basemap, matplotlib, and numpy modules and import them before h5py as shown in Figure 1. For example, if Python fails to load basemap module, you can install one using conda install basemap
.
Next, open the sample NASA HDF5 file and read datasets and attributes as shown in Figure 2. You can replace FILE_NAME
if you want to visualize a different file of the same OMI L3 version 2 product. You can replace DATAFIELD_NAME
if you want to visualize a different dataset in the HDF5 file. You can examine the available datasets using f.keys()
.
Finally, plot the data on map using the functions in basemap and matplotlib packages as shown in Figure 3.
The complete code, which includes lat/lon calculation, is here. Use right mouse button and select Save Link As to download the code. If you execute the code (e.g., python OMI_L3_ColumnAmountO3.py
) on the directory where the sample file exists, you will get the image as shown in Figure 4.
Generally speaking, each NASA HDF5 data product requires a different technique for reading and visualizing dataset properly. We provide comprehensive h5py examples here to help you access NASA data easily.
There is a GUI tool that can generate h5py code for HDF5 data creation. Such GUI tool is called HDF Product Designer and it allows you to edit HDF5 contents (group, dataset, attributes) visually and generates h5py code that matches your HDF5 content (Figure 5). Please click here to learn more about HDF Product Designer.