3.3 Low-level functions

3.3.1 netcdf.abort

: netcdf.abort(ncid)

Aborts all changes since the last time the dataset entered in define mode.

3.3.2 netcdf.close

: netcdf.close(ncid)

Close the NetCDF file with the id ncid.

3.3.3 netcdf.copyAtt

: netcdf.copyAtt (ncid,varid,name,ncid_out,varid_out)

Copies the attribute named old_name of the variable varid in the data set ncid to the variable varid_out in the data set ncid_out. To copy a global attribute use netcdf.getConstant("global") for varid or varid_out.

See also: netcdf.getAtt,netcdf.getConstant.

3.3.4 netcdf.create

: ncid = netcdf.create(filename,mode)

Creates the file named filename in the mode mode which can have the following values: "clobber" (overwrite existing files), "noclobber" (prevent to overwrite existing files) "64bit_offset" (use the 64bit-offset format), "netcdf4" (use the NetCDF4, i.e. HDF5 format) or "share" (concurrent reading of the dataset). mode can also be the numeric value return by netcdf.getConstant. In the later-case it can be combined with a bitwise-or.

Example

 mode = bitor(netcdf.getConstant("classic_model"), ...
 netcdf.getConstant("netcdf4"));
 ncid = netcdf.create("test.nc",mode);

3.3.5 netcdf.defDim

: dimid = netcdf.defDim(ncid,name,len)

Define the dimension with the name name and the length len in the dataset ncid. The id of the dimension is returned.

3.3.6 netcdf.defGrp

: new_ncid = netcdf.defGrp(ncid,name)

Define a group in a NetCDF file.

See also: netcdf.inqGrps.

3.3.7 netcdf.defVar

: varid = netcdf.defVar(ncid,name,xtype,dimids)

Defines a variable with the name name in the dataset ncid. xtype can be "byte", "ubyte", "short", "ushort", "int", "uint", "int64", "uint64", "float", "double", "char" or the corresponding number as returned by netcdf.getConstant. The parameter dimids define the ids of the dimension. For scalar this parameter is the empty array ([]). The variable id is returned.

3.3.8 netcdf.defVarChunking

: netcdf.defVarChunking (ncid,varid,storage,chunkSizes)

Define the chunking settings of NetCDF variable varid. If storage is the string "chunked", the variable is stored by chunk of the size chunkSizes. If storage is the string "contiguous", the variable is stored in a contiguous way.

3.3.9 netcdf.defVarDeflate

: netcdf.defVarDeflate (ncid,varid,shuffle,deflate,deflate_level)

Define the compression settings NetCDF variable varid. If deflate is true, then the variable is compressed. The compression level deflate_level is an integer between 0 (no compression) and 9 (maximum compression).

3.3.10 netcdf.defVarFill

: netcdf.defVarFill(ncid,varid,no_fill,fillvalue)

Define the fill-value settings of the NetCDF variable varid. If no_fill is false, then the values between no-contiguous writes are filled with the value fill_value. This is disabled by setting no_fill to true.

3.3.11 netcdf.defVarFletcher32

: netcdf.defVarFletcher32(ncid,varid,checksum)

Defines the checksum settings of the variable with the id varid in the data set ncid. If checksum is the string "FLETCHER32", then fletcher32 checksums will be turned on for this variable. If checksum is "NOCHECKSUM", then checksums will be disabled.

3.3.12 netcdf.defVlen

: varid = netcdf.defVlen(ncid,typename,basetype)

Defines a NC_VLEN variable length array type with the type name typename and a base datatype of basetype in the dataset ncid. basetype can be "byte", "ubyte", "short", "ushort", "int", "uint", "int64", "uint64", "float", "double", "char" or the corresponding number as returned by netcdf.getConstant. The new data type id is returned.

3.3.13 netcdf.delAtt

: netcdf.delAtt(ncid,varid,name)

Deletes the attribute named name of the variable varid in the data set ncid. To delete a global attribute use netcdf.getConstant("global") for varid.

See also: netcdf.defAtt,netcdf.getConstant.

3.3.14 netcdf.endDef

: netcdf.endDef (ncid)

Leaves define-mode of NetCDF file ncid.

3.3.15 netcdf.getAtt

: data = netcdf.getAtt (ncid,varid,name)

Get the value of a NetCDF attribute. This function returns the value of the attribute called name of the variable varid in the NetCDF file ncid. For global attributes varid can be netcdf.getConstant("global").

See also: netcdf.putAtt.

3.3.16 netcdf.getChunkCache

: [size, nelems, preemption] = netcdf.getChunkCache()

Gets the default chunk cache settings in the HDF5 library.

3.3.17 netcdf.getConstant

: value = netcdf.getConstant(name)

Returns the value of a NetCDF constant called name.

See also: netcdf.getConstantNames.

3.3.18 netcdf.getConstantNames

: value = netcdf.getConstantNames()

Returns a list of all constant names.

3.3.19 netcdf.getVar

: data = netcdf.getVar (ncid,varid)
: data = netcdf.getVar (ncid,varid,start)
: data = netcdf.getVar (ncid,varid,start,count)
: data = netcdf.getVar (ncid,varid,start,count,stride)

Get the data from a NetCDF variable. The data data is loaded from the variable varid of the NetCDF file ncid. start is the start index of each dimension (0-based and defaults to a vector of zeros), count is the number of elements of to be written along each dimension (default all elements) and stride is the sampling interval.

3.3.20 netcdf.inq

: [ndims,nvars,ngatts,unlimdimid] = netcdf.inq(ncid)

Return the number of dimension (ndims), the number of variables (nvars), the number of global attributes (ngatts) and the id of the unlimited dimension (unlimdimid). If no unlimited dimension is declared -1 is returned. For NetCDF4 files, one should use the function netcdf.inqUnlimDims as multiple unlimite dimension exists.

3.3.21 netcdf.inqAtt

: [xtype,len] = netcdf.inqAtt(ncid,varid,name)

Get attribute type and length.

See also: netcdf.inqAttName.

3.3.22 netcdf.inqAttID

: attnum = netcdf.inqAttID(ncid,varid,attname)

Return the attribute id attnum of the attribute named attname of the variable varid in the dataset ncid. For global attributes varid can be netcdf.getConstant("global").

See also: netcdf.inqAttName.

3.3.23 netcdf.inqAttName

: name = netcdf.inqAttName (ncid,varid,attnum)

Get the name of a NetCDF attribute. This function returns the name of the attribute with the id attnum of the variable varid in the NetCDF file ncid. For global attributes varid can be netcdf.getConstant("global").

See also: netcdf.inqAttName.

3.3.24 netcdf.inqDim

: [name,length] = netcdf.inqDim(ncid,dimid)

Returns the name and length of a NetCDF dimension.

See also: netcdf.inqDimID.

3.3.25 netcdf.inqDimID

: dimid = netcdf.inqDimID(ncid,dimname)

Return the id of a NetCDF dimension.

See also: netcdf.inqDim.

3.3.26 netcdf.inqDimIDs

: dimids = netcdf.inqDimID(ncid)
: dimids = netcdf.inqDimID(ncid,include_parents)

Return the dimension ids defined in a NetCDF file. If include_parents is 1, the dimension ids of the parent group are also returned. Per default this is not the case (include_parents is 0).

See also: netcdf.inqDim.

3.3.27 netcdf.inqFormat

: format = netcdf.inqFormat(ncid)

Return the NetCDF format of the dataset ncid. Format might be one of the following "FORMAT_CLASSIC", "FORMAT_64BIT", "FORMAT_NETCDF4" or "FORMAT_NETCDF4_CLASSIC"

3.3.28 netcdf.inqGrpFullNcid

: grp_ncid = netcdf.inqGrpFullNcid(ncid,name)

Return the group id based on the full group name.

See also: netcdf.inqGrpName.

3.3.29 netcdf.inqGrpName

: name = netcdf.inqGrpName(ncid)

Return group name in a NetCDF file.

See also: netcdf.inqGrps.

3.3.30 netcdf.inqGrpNameFull

: name = netcdf.inqGrpNameFull(ncid)

Return full name of group in NetCDF file.

See also: netcdf.inqGrpName.

3.3.31 netcdf.inqGrpParent

: parent_ncid = netcdf.inqGrpParent(ncid)

Return id of the parent group

See also: netcdf.inqGrpName.

3.3.32 netcdf.inqGrps

: ncids = netcdf.inqGrps(ncid)

Return all groups ids in a NetCDF file.

See also: netcdf.inqGrps.

3.3.33 netcdf.inqLibVers

: vers = netcdf.inqLibVers()

Returns the version of the NetCDF library.

3.3.34 netcdf.inqNcid

: grp_ncid = netcdf.inqNcid(ncid,name)

Return group id based on its name

See also: netcdf.inqGrpFullNcid.

3.3.35 netcdf.inqUnlimDims

: unlimdimids = netcdf.inqUnlimDims(ncid)

Return the id of all unlimited dimensions of the NetCDF file ncid.

3.3.36 netcdf.inqUserType

: [typename, bytesize, basetypeid, numfields, classid] = netcdf.inqUserType(ncid,typeid)

Provide information on a user defined type typeid in the dataset ncid.

The function returns the typename, bytesize, base type id, number of fields and class identifier of the type.

3.3.37 netcdf.inqVar

: [name,nctype,dimids,nattr] = netcdf.inqVar (ncid,varid)

Inquires information about a NetCDF variable. This functions returns the name, the NetCDF type nctype, an array of dimension ids dimids and the number of attributes nattr of the NetCDF variable. nctype in an integer corresponding NetCDF constants.

See also: netcdf.inqVarID,netcdf.getConstant.

3.3.38 netcdf.inqVarChunking

: [storage,chunkSizes] = netcdf.inqVarChunking (ncid,varid)

Determines the chunking settings of NetCDF variable varid. If storage is the string "chunked", the variable is stored by chunk of the size chunkSizes. If storage is the string "contiguous", the variable is stored in a contiguous way.

3.3.39 netcdf.inqVarDeflate

: [shuffle,deflate,deflate_level] = netcdf.inqVarDeflate (ncid,varid)

Determines the compression settings NetCDF variable varid. If deflate is true, then the variable is compressed. The compression level deflate_level is an integer between 0 (no compression) and 9 (maximum compression).

3.3.40 netcdf.inqVarFill

: [no_fill,fillvalue] = netcdf.inqVarFill(ncid,varid)

Determines the fill-value settings of the NetCDF variable varid. If no_fill is false, then the values between no-contiguous writes are filled with the value fill_value. This is disabled by setting no_fill to true.

3.3.41 netcdf.inqVarFletcher32

: checksum = netcdf.inqVarFletcher32(ncid,varid)

Determines the checksum settings of the variable with the id varid in the data set ncid. If fletcher32 checksums is turned on for this variable, then checksum is the string "FLETCHER32". Otherwise it is the string "NOCHECKSUM".

3.3.42 netcdf.inqVarID

: varid = netcdf.inqVarID (ncid,name)

Return the id of a variable based on its name.

See also: netcdf.defVar,netcdf.inqVarIDs.

3.3.43 netcdf.inqVarIDs

: varids = netcdf.inqVarID (ncid)

Return all variable ids. This functions returns all variable ids in a NetCDF file or NetCDF group.

See also: netcdf.inqVarID.

3.3.44 netcdf.inqVlen

: [typename, bytesize, basetypeid] = netcdf.inqVlen(ncid,typeid)

Provide information on a NC_VLEN variable length array type typeid in the dataset ncid.

The function returns the typename, bytesize, and base type id.

3.3.45 netcdf.open

: ncid = netcdf.open(filename,mode)

Opens the file named filename in the mode mode.

3.3.46 netcdf.putAtt

: netcdf.putAtt (ncid,varid,name,data)

Defines a NetCDF attribute. This function defines the attribute called name of the variable varid in the NetCDF file ncid. The value of the attribute will be data. For global attributes varid can be netcdf.getConstant("global").

See also: netcdf.getAtt.

3.3.47 netcdf.putVar

: netcdf.putVar (ncid,varid,data)
: netcdf.putVar (ncid,varid,start,data)
: netcdf.putVar (ncid,varid,start,count,data)
: netcdf.putVar (ncid,varid,start,count,stride,data)

Put data in a NetCDF variable. The data data is stored in the variable varid of the NetCDF file ncid. start is the start index of each dimension (0-based and defaults to a vector of zeros), count is the number of elements of to be written along each dimension (default all elements) and stride is the sampling interval.

3.3.48 netcdf.reDef

: netcdf.reDef (ncid)

Enter define-mode of NetCDF file ncid.

3.3.49 netcdf.renameAtt

: netcdf.renameAtt(ncid,varid,old_name,new_name)

Renames the attribute named old_name of the variable varid in the data set ncid. new_name is the new name of the attribute. To rename a global attribute use netcdf.getConstant("global") for varid.

See also: netcdf.copyAtt,netcdf.getConstant.

3.3.50 netcdf.renameDim

: netcdf.renameDim(ncid,dimid,name)

Renames the dimension with the id dimid in the data set ncid. name is the new name of the dimension.

3.3.51 netcdf.renameVar

: netcdf.renameVar(ncid,varid,name)

Renames the variable with the id varid in the data set ncid. name is the new name of the variable.

3.3.52 netcdf.setChunkCache

: netcdf.setChunkCache(size, nelems, preemption)

Sets the default chunk cache settings in the HDF5 library. The settings applies to all files which are subsequently opened or created.

3.3.53 netcdf.setDefaultFormat

: old_format = netcdf.setDefaultFormat(format)

Sets the default format of the NetCDF library and returns the previous default format (as a numeric value). format can be "format_classic", "format_64bit", "format_netcdf4" or "format_netcdf4_classic".

3.3.54 netcdf.setFill

: old_mode = netcdf.setFill(ncid,fillmode)

Change the fill mode (fillmode) of the data set ncid. The previous value of the fill mode is returned. fillmode can be either "fill" or "nofill".

3.3.55 netcdf.sync

: netcdf.sync(ncid)

Writes all changes to the disk and leaves the file open.