Although NCO is mainly for NetCDF files, NetCDF-4 uses HDF5 as storage format and some NASA MEaSUREs products use NetCDF-4. In addition, the H4CF Conversion Toolkit can benefit from NCO in editing the converted NetCDF files. The NASA HDF files served by CF-enabled OPeNDAP handlers can be manipulated easily with NCO. Thus, we highlight some basic and useful usage on how to access NetCDF files using NCO.
One of the basic usage is to dump the contents of NetCDF files in ASCII output. Although ncdump
can do the similar job, the ncks
in NCO prints data in one datum per line, with all dimension subscripts and coordinate values. This makes users to easily search for the data you want. To dump the file contents of an NetCDF file, use ncks
as shown in Figure 1.
h4tonccf
tool in H4CF Conversion Toolkit.
The same command works for some NASA files served by CF-option enabled OPeNDAP hdf4 handler and hdf5 handler as shown in Figure 2.
The ncks
operator in the previous section can also save the contents of remote OPeNDAP resource that follows the CF-conventions in a local NetCDF file.
One nice thing about NCO is that you can edit an attribute easily with the ncatted
operator. This is particularly useful for NASA products that do not follow the CF conventions in naming attributes and their values. For example, our sample file opendap.nc (size:175M) from the previous section does not have "units" attribute for "TotO3_A" variable. If you want to add "units" attribute with value "DU" for "TotO3_A" variable, use ncatted
as shown in Figure 4.
Finally, you can convert NetCDF-3 into NetCDF-4 file. Since the NetCDF-4 uses HDF5 for its storage format, the converted file becomes an HDF5 file that any HDF5 tool like HDFView can easily access it. Use the ncks
operator as shown in Figure 5.