netCDF: http://www.unidata.ucar.edu/software/netcdf/docs/index.html
netCDF includes libraries for implementing creating, reading and writing netCDF (.nc) files, as well as some handy command-line utilities. One in particular ncdump
, as its name implies, is able to display or dump the entire contents of a netCDF file as ascii, but its main utility is to display the headers of a netCDF file, including a description of the variables contained in the file, as well as the dimensions (latitude, longitude, time, etc.) of the data.
In addition to ncdump
, there are two sets of command line utilities, CDO
and NCO
(Climate Data Operators, and netCDF Operators, respectively), that can efficiently perfor many tasks, like regridding or concatenation individual .nc
files:
To set up the netCDF command-line utilities in Windows,
download and install the netCDF-C library and utilites from
http://www.unidata.ucar.edu/software/netcdf/docs/winbin.html (e.g. netCDF4.6.3-NC4-DAP-64.exe)
Install as usual by clicking on the file; the destination folder will likely be c:\Program Files\netCDF 4.6.3\
When prompted, select “Add netCDF to the system PATH for all users”
Check to make sure the PATH
environment variable has been set: Control Panel > All Control Panel Items > System > Advanced System Settings > Environment Variables > System Variables Pane, Click on Path, and add the following if not present: c:\Program Files\netCDF 4.6.3\;c:\Program Files\netCDF 4.6.3\bin\;c:\Program Files\netCDF 4.6.3\lib\
create a .bat
(batch) file named ncd.bat
in the netCDF folder created in the second step, with the following contents:
c:\Program Files\netCDF 4.6.3\bin\ncdump -c %1
rem netCDF_4.6.3
pause
Then, double-clicking on a .nc file, or in a command window, typing ncd ncfile.nc
(where ncfile.nc
is a netCDF file), should produce a listing of the headers and dimension variables in a netCDF file.
netCDF, CDO and NCO (plus another useful utility, ncview) can most easily be installed via Homebrew:
http://brew.sh/index.html
brew tap homebrew/science
brew install netcdf
brew install moffat/sciencebits/cdo
brew install nco
Make a text file simply named ncd
, with following contents, and place in the folder /usr/local/bin/
#! /bin/bash
pwd
/usr/local/Cellar/netcdf/4.6.3/bin/ncdump -c $1
(Note that the folder path may need to be adjusted; at the time of this writing the current version of netCDF on Homebrew was 4.6.3
. The approprate path can be found by typing locate ncdump
at the command prompt, which should yield a reply like /usr/local/Cellar/netcdf/4.6.3/bin/ncdump
)
Make the file executable by opening a Terminal window in /usr/local/bin/
and typing:
chmod +x ncd
Then opening a Terminal window in the folder with the netCDF file in it and typing ncd ncfile.nc
(where “ncfile.nc
” is the name of the netCDF file) should should produce a listing of the headers and dimension variables in a netCDF file.
Note that ncdump
(as opposed to ncd
) can also be used directly in a command/Terminal window. Typing ncdump -ct ncfile.nc
produces a standard listing of the headers, but prints the Time variable in human-interpretable form.