Documentation for ncoct
Name
ncoct - an Octave netCDF interface
Synopsis
ncoct("open", fname)
ncoct("close", ncid)
ncoct("create", fname)
ncoct("putdim", ncid, dname, ddata)
ncoct("putvar", ncid, vname, rowid, colid, vdata)
ncoct("getvar", ncid, vname)
Description
ncoct is a Octave netCDF interface to be called from within Octave. Different functions are used by giving different first arguments. The functions currently available are:
string argument |
purpose of function |
"open" |
open a file with read access |
"close" |
close a file |
"create" |
create a file with read and write access |
"putdim" |
add a dimension |
"putvar" |
add a variable field |
"getvar" |
read a variable field |
If the wrong number or incorrect type of arguments are given, then ncoct should print a usage message to the standard error.
ncoct makes use of netCDF ids. netCDF ids are simply non-negative integers that are used to refer different parts of a netCDF dataset.
- ncoct("open", fname)
- Open a netCDF file. Where fname (a string) is the name of the file to be opened. The dataset is opened with read-only access, with accesses buffered and cached for efficiency. Returns the netCDF id of the opened file if successful.
- ncoct("close", ncid)
- Close a netCDF file. Where ncid (a real scalar) is the netCDF id of the file to be closed. After the dataset is closed, its netCDF id may be used for other files which are opened or created. Returns 0.0 if successful.
- ncoct("create", fname)
- Create a netCDF file. Where fname (a string) is the name of the file to create. Any existing file with the same name is overwritten. Accesses are buffered and cached for efficiency. Returns the netCDF id of the created file if successful.
- ncoct("putdim", ncid, dname, ddata)
- Add a dimension. Where:
- ncid (a real scalar) is the netCDF id of the file to add the dimension to
- dname (a string) is the name of the dimension to add. It must begin with an alphabetic character. Any other characters in the name must be alphanumeric or the underscore, "_". Dimension names are case sensitive.
- ddata is the real vector containing the data for the dimension
The index field for the dimension is stored as 64-bit doubles, and is given a valid_range attribute. Returns the netCDF id of the added dimension if successful.
- ncoct("putvar", ncid, vname, rowid, colid, vdata)
- Add a variable. Where:
- ncid (a real scalar) is the netCDF id of the file to add the variable to
- vname (a string) is the name of the variable to add. It must begin with an alphabetic character. Any other characters in the name must be alphanumeric or the underscore, "_". Like dimension names, variable names are case sensitive.
- rowid (a real scalar) is the netCDF id of the dimension for the variable's rows
- colid (a real scalar) is the netCDF id of the dimension for the variable's columns
- vdata is the real matrix containing the data for the variable
If vdata is a vector or a scalar, use a negative number to hold the place of the corresponding dimension id. The variable field is stored as 64-bit doubles in the netCDF file, and is given a valid_range attribute. Returns the netCDF id of the added variable if successful.
- ncoct("getvar", ncid, vname)
- Read a variable. Where:
- ncid (a real scalar) is the netCDF id of the file to get the variable from
- vname (a string) is the name of the variable to get
Returns the variable as an Octave value list if successful.
Notes
Tested with Octave version 2.0.16.92, and netCDF library version 3.5-beta3.
Compiled with: mkoctfile ncoct.cc -lnetcdf
Author
Beverly Davis
beverly@nmt.edu