How to Read and Visualize HDF-EOS5 MLS data Using IDL

IDLexternal (Interactive Data Language) is a programming language for scientific analysis and visualization. IDL provides APIs for reading and writing several file formats including HDF5external . This page presents a few examples on how to read and visualize HDF-EOS5 MLS data via IDL.

IDL provides a set of functions for handling HDF5 files. Since each of them is equivalent to an HDF5 C API, those who are familiar with the HDF5 library can easily learn how to handle HDF5 files in IDL. For example, H5F_OPEN, H5D_OPEN and H5D_READ are equivalent to H5Fopen, H5Dopen and H5Dread, respectively.

MLS swath data

HDF-EOS5 MLS L2 data is special in that it has n points of vertical profiles. The location of each point stored in 1-D lat/lon arrays that have n dimension size.

To access a dataset in an HDF5 file, first open the enclosing HDF-EOS5 MLS file using H5F_OPEN. Then, using the descriptor returned by that API, open the dataset.

Since MLS holds the data values inside the L2gpValue dataset, you need to open and read it along with Latitude, Longitude, and Pressure dataset as shown in example(Figure 1).

Figure 1 Accessing MLS datasets
file_name = 'MLS-Aura_L2GP-CO_v02-23-c02_2008d277.he5'
file_id = H5F_OPEN(file_name)
dataset_id_lat= H5D_OPEN(file_id, '/HDFEOS/SWATHS/CO/Geolocation Fields/Latitude')
lat = H5D_Read(dataset_id_lat)
H5D_CLOSE, dataset_id_lat
dataset_id_lon= H5D_OPEN(file_id, '/HDFEOS/SWATHS/CO/Geolocation Fields/Longitude')
lon = H5D_Read(dataset_id_lon)
H5D_CLOSE, dataset_id_lon
dataset_id_lev= H5D_OPEN(file_id, '/HDFEOS/SWATHS/CO/Geolocation Fields/Pressure')
lev = H5D_Read(dataset_id_lev)
H5D_CLOSE, dataset_id_lev
dataset_id_val= H5D_OPEN(file_id, '/HDFEOS/SWATHS/CO/Data Fields/L2gpValue')
val = H5D_Read(dataset_id_val)
H5D_CLOSE, dataset_id_val

Once all datasets are read, you pick one location. As shown in Figure 2, we pick the location at array index 0 in this example. The la0 and lo0 hold the values of latitude and longitude on that location. The * in val[*,0] retrieves all data values on different levels stored in lev at location 0. Finally, we re-scales data values and levels to generate a easy-to-read graph.

Figure 2 Reading datasests in MLS
la0 = lat[0]
lo0 = lon[0]
x = val[*,0]
z = alog10(lev)
a = 10000000 * x
plot, a, z, xtitle='CO (1.0e-07 vmr)', ytitle='Pressure (log hPa)', title='lat:' + STRTRIM(la0) + 'lon:' + STRTRIM(lo0),xrange=[-5, 5]
The plot command draws a vertical profile graph from the L2gpValue dataset.

After finishing processing all datasets, one needs to close the file using H5F_CLOSE(Figure 3).

Figure 3 Closing MLS file
H5F_CLOSE, file_id

See the complete code here. Download the sample file. Run the code as follows:

Figure 5 shows the result.


Last modified: 06/02/2017
About Us | Contact Info | Archive Info | Disclaimer
Sponsored by Subcontract number 4400528183 under Raytheon Contract number NNG15HZ39C, funded by NASA / Maintained by The HDF Group