Skip to main content

6.2) NetCDF Files


A commonly used file format for storing environmental science data is the NetCDF (Network Common Data Format). NetCDF is a self-describing scientific data access interface and library.

IDL has many built-in routines for dealing with NetCDF files. They all begin with the prefix "NCDF_". There are too many to list them all here but you can find the in the IDL help pages.For now, we will just cover opening a NetCDF file and extracting a variable for which we already know the name. For example, to read the variable called "Pressure" from the file "filename.nc" into an IDL variable called "pres", use the following code:

ncid = NCDF_OPEN('filename.nc')
varid = NCDF_VARID(ncid, 'Pressure')
NCDF_VARGET, ncid, varid, pres
NCDF_CLOSE, ncid
; NetCDF Commands