GNU Octave is MATLAB-like program that can read and visualize HDF5 file and OPeNDAP data source.
Download Octave. Octave can run on most UNIX (Linux/BSD/Mac) systems. Windows users can run Octave through Cygwin or MinGW.
Download M_Map, a mapping package for Octave.
The easiest way to install Octave is through package manager on your system. For example, on CentOS, issue the following command:
#yum install octave
OPeNDAP access requires netcdf package.
Run octave
first and enter the following command at the
Octave prompt:
octave:1>pkg install -forge -verbose netcdf
For M_Map package, extract the package under your current working directory to follow the examples that we provide here.
We provide two examples of accessing NASA HDF products.
By default, Octave can read HDF5 file without any additional package.
Open the sample NASA OMI L3 HDF-EOS5 file with load
command (Figure 1).
To load a dataset, just specify the path to the dataset with group names separated by dot (.) character as shown in Figure 2. Please replace space with '_'. Here, we assume that you can identify all groups and datasets inside the file with HDFView or h5dump.
To plot data on the map, you need to load the M_Map library at the beginning
and use the following functions that start with m_
as shown in Figure 3.
The rest of code is similar to other MATLAB comprehensive examples. The complete code is available here. The code will generate the plot in Figure 4.
In the above plot, we modified the colormap
to use white color for fill value. You may want to compare it with MATLAB plot from our comprehensive examples.
Octave can access OPeNDAP data source through NetCDF function calls. If you haven't installed NetCDF package for Octave, please read the Installation section and install the NetCDF package package first.
To open the sample NASA AIRS L3 HDF-EOS2 OPeNDAP data source
URL,
load the NetCDF package first and
call netcdf
function (Figure 5).
Unlike HDF5 access,
Octave can access both variables and attributes through NetCDF calls.
You can read attribute data using variable name and attribute
name in ncreadatt
function (Figure 6).
The rest of the code is similar to HDF5 example above. The complete code is available here. The code will generate the plot in Figure 7.
Please note that you can modify the OPeNDAP example to make it work with a local NetCDF file. For example, you can convert the sample NASA AIRS L3 HDF-EOS2 file into a NetCDF-3 file with the h4tonccf tool. Then, you can load the converted file as illustrated in Figure 8.
The rest of the code is almost identical to OPeNDAP example above. The complete code is available here. The plot in Figure 9. shows that you can get the same plot through the NetCDF conversion.