NetCDF4 C++ API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
netcdf Namespace Reference

Classes

class  NcAtt
 Represents a netCDF attribute. More...
 
class  NcByte
 Represents a netCDF atomic Byte type. More...
 
class  NcChar
 Represents a netCDF atomic Char type. More...
 
class  NcCompoundType
 Represents a netCDF compound type. More...
 
class  NcDim
 Represents a netCDF dimension. More...
 
class  NcDouble
 Represents a netCDF atomic Double type. More...
 
class  NcEnumType
 Represents a netCDF enum type. More...
 
class  NcException
 Handles the C++ API exceptions. More...
 
class  NcFile
 Manages the opening, creating, and closing of netCDF files.
Represents the netCDF root group. More...
 
class  NcFileReg
 Manages a registry of NcFile objects. More...
 
class  NcFloat
 Represents a netCDF atomic Float type. More...
 
class  NcGroup
 Represents a netCDF group. More...
 
class  NcGroupAtt
 Represents a netCDF group attribute. More...
 
class  NcInt
 Represents a netCDF atomic Int type. More...
 
class  NcInt64
 Represents a netCDF atomic Int64 type. More...
 
class  NcItem
 Base class for NcAtt, NcVar, NcDim, NcGroup. More...
 
class  NcLimits
 Class containing NetCDF limiting values. More...
 
class  NcMPI
 Manages data related to the MPI implementation. More...
 
class  NcOpaqueType
 Represents a netCDF opaque type. More...
 
class  NcShort
 Represents a netCDF atomic Short type. More...
 
class  NcString
 Represents a netCDF atomic String type. More...
 
class  NcType
 Base class for all netCDF data types. More...
 
class  NcNullType
 
class  NcTypeUserDef
 Defines a non-atomic, user-defined NetCDF4 type. More...
 
class  NcTypeV4
 Class associated with netCDF version 4 data types. More...
 
class  NcUbyte
 Represents a netCDF atomic Ubyte type. More...
 
class  NcUint
 Represents a netCDF atomic Uint type. More...
 
class  NcUint64
 Represents a netCDF atomic Uint64 type. More...
 
class  NcUshort
 Represents a netCDF atomic Ushort type. More...
 
class  NcVar
 Represents a netCDF variable. More...
 
class  NcNullVar
 
class  NcVarAtt
 Represents a netCDF variable attribute. More...
 
class  NcVersion
 Class which returns the version of the NetCDF4 C++ API. More...
 
class  NcVlenType
 Represents a netCDF VLEN type. More...
 
class  MetadataCFGlobal
 Class managing global metadata that conform to netCDF CF conventions. A typical set of attributes are known. More...
 
class  MetadataCFVariable
 Class managing variable metadata that conform to netCDF CF conventions. A typical set of attributes are known. More...
 
class  NcFileMetaCF
 Class for read/write CF-convention netCDF global metadata (aka attributes). A typical set of attributes are known. More...
 
class  NcVarMetaCF
 Class for read/write CF-convention metadata for a netCDF variable. A typical set of attributes are known. More...
 
class  NcIndexedGridBase
 Class providing an interface to a NetCDF file containing a indexed (packed) latitude/longitude grid. More...
 
class  NcLatLonRecordBase
 Class providing an interface to a NetCDF file containing a record-based latitude/longitude data. More...
 
class  NcSimpleGridBase
 Class providing an interface to a NetCDF file containing a simple latitude/longitude grid. More...
 
class  NcSpatial
 Types and constants for spatial data. More...
 
class  NcTimeSeriesBase
 Class providing an interface to a NetCDF file containing time-series dimension and variables. More...
 
class  NcUtil
 Utility functions for the NetCDF4 C++ API. More...
 

Typedefs

typedef TEH::GL::Singleton
< NcFileReg
NcFileRegSingleton
 
typedef std::vector< signed char > TVecByte
 
typedef std::vector< unsigned
char > 
TVecUbyte
 
typedef std::vector< char > TVecChar
 
typedef std::vector< short > TVecShort
 
typedef std::vector< unsigned
short > 
TVecUshort
 
typedef std::vector< int > TVecInt
 
typedef std::vector< unsigned int > TVecUint
 
typedef std::vector< float > TVecFloat
 
typedef std::vector< double > TVecDouble
 
typedef std::vector< long long > TVecInt64
 
typedef std::vector< unsigned
long long > 
TVecUint64
 
typedef std::vector< std::string > TVecString
 
typedef std::vector< std::size_t > TVecIndex
 
typedef std::vector< ptrdiff_t > TVecStride
 

Functions

void NcCheckThrowMsg (int const retCode, char const *const file, int const line)
 
void NcCheckEdgeArrays (int const groupID, int const varID, std::vector< std::size_t > const &start, std::vector< std::size_t > const &count)
 
void NcCheck (int const retCode, char const *const file, int const line)
 
std::string const & GetFileModeStr (NcFile::FileMode const fileMode)
 Get a string matching the file mode. More...
 
std::string const & GetFileFormatStr (NcFile::FileFormat const fileFormat)
 Get a string matching the file format. More...
 
char ** MakeCStringArray (int const numStrings, short const size)
 Allocates array and copies strings. More...
 
char ** ToCStringArray (std::vector< std::string > const &strVec)
 
void FreeCStringArray (char **&cStrArray, std::size_t const numStrings)
 
bool IsRecordVariable (int const groupID, int const varID)
 
std::size_t GetTotalSize (NcVar const &var)
 Get total number of elements of data from the dimensions of a variable. throws error if netcdf error. returns zero if has no sizes > 0. Unlimited dimensions are counted only if > zero. More...
 
std::size_t GetTotalSize (int const groupID, int const varID)
 
std::size_t GetTotalSize (int const groupID, int const varID, std::vector< std::size_t > const &count)
 
void GetTypeName (NcGroup const &group,NcType::ncType const typeID,std::string &name)
 Gets the netCDF name of existing type object from the type ID. More...
 
NcGroup GetGroup (NcFile const &ncFile, int const groupID)
 Get item info from netCDF ID numbers. More...
 
std::string GetVarName (int const groupID, int const varID)
 
NcVar GetVar (NcFile const &ncFile, int const groupID, int const varID)
 
void GetNcDims (int const groupID, int const varID, std::vector< NcDim > &ncDims)
 Get the dimensions for a variable as vector of NcDim objects. More...
 
std::size_t GetDimSize (int const groupID,int const varID,int const dimIndex)
 Get the size of a variable's dimension. More...
 
bool IsAtomicType (NcType::ncType const typeClass)
 true if is a netCDF atomic type More...
 
bool IsUserDefinedType (NcType::ncType const typeClass)
 true if is a netCDF user-defined type More...
 
template<class TNCT >
TNCT::value_type * MakeCArray (TNCT const &ncType, int const size, typename TNCT::value_type const initValue=0)
 Create an empty C-ptr array from the NcType object and size. More...
 
template<class TSrc , class TDest >
void ToVector (TSrc const srcBegin, TSrc const srcEnd, std::vector< TDest > &dest)
 Copy a C-ptr array to a std::vector. More...
 
template<class TSrc , class TDest >
void ToVector (TSrc const srcBegin, std::vector< TDest > &dest, std::size_t const count)
 Copy a C-ptr array to a std::vector. More...
 
template<class T >
T * FromVector (std::vector< T > const &src)
 Create a C-array from a std::vector. More...
 
void operator<< (NcFileMetaCF &metaFile,MetadataCFGlobal const &meta)
 Add metadata to netCDF global attributes. More...
 
void operator>> (NcFileMetaCF &metaFile,MetadataCFGlobal &meta)
 Read metadata from netCDF global attributes. More...
 
std::ostream & operator<< (std::ostream &os,MetadataCFGlobal const &meta)
 Write global file metadata to stream. More...
 
void UpdateHistory (MetadataCFGlobal &meta,std::string const &newHistory,char const separator=MetadataCFGlobal::defaultSeparator)
 Append update with datestamp to history attribute. More...
 
template<typename TNumeric >
void operator<< (NcVarMetaCF &metaVar, MetadataCFVariable< TNumeric > const &meta)
 Add metadata to netCDF variable attributes. More...
 
template<typename TNumeric >
void operator>> (NcVarMetaCF &metaVar, MetadataCFVariable< TNumeric > &meta)
 Read metadata from netCDF variable attributes. More...
 
template<typename TNumeric >
std::ostream & operator<< (std::ostream &os, MetadataCFVariable< TNumeric > const &meta)
 Write variable metadata to stream. More...
 
std::string & SetExtension (std::string &ncFileName)
 Set the file name extension to "nc" as is the netCDF convention. More...
 
void GetNcFiles (std::string const &path, std::vector< std::string > &fileNames)
 Get all the netCDF file names in the path. More...
 
bool FileExists (std::string const &ncFileName,bool const isPath=false)
 Return true if file exists, else false. More...
 
bool IsGridded (NcFile &nc)
 
bool IsGriddedIndexed (NcFile &nc)
 
bool IsTimeSeries (NcFile &nc)
 
NcSpatial::GridDim GetGridDimensions (NcFile &nc)
 

Variables

NcByte ncByte
 
NcChar ncChar
 
NcDouble ncDouble
 
NcFloat ncFloat
 
NcInt ncInt
 
NcInt64 ncInt64
 
NcShort ncShort
 
NcString ncString
 
NcNullType nullType
 global null type More...
 
NcType NullType
 
NcUbyte ncUbyte
 
NcUint ncUint
 
NcUint64 ncUint64
 
NcUshort ncUshort
 
NcNullVar nullVar
 global null variable More...
 

Detailed Description

Todo:
record dimension - allow to be fixed

Typedef Documentation

typedef TEH::GL::Singleton<NcFileReg> netcdf::NcFileRegSingleton
typedef std::vector< signed char > netcdf::TVecByte
typedef std::vector< char > netcdf::TVecChar
typedef std::vector< double > netcdf::TVecDouble
typedef std::vector< float > netcdf::TVecFloat
typedef std::vector< std::size_t > netcdf::TVecIndex
typedef std::vector< int > netcdf::TVecInt
typedef std::vector< long long > netcdf::TVecInt64
typedef std::vector< short > netcdf::TVecShort
typedef std::vector< ptrdiff_t > netcdf::TVecStride
typedef std::vector< std::string > netcdf::TVecString
typedef std::vector< unsigned char > netcdf::TVecUbyte
typedef std::vector< unsigned int > netcdf::TVecUint
typedef std::vector< unsigned long long > netcdf::TVecUint64
typedef std::vector< unsigned short > netcdf::TVecUshort

Function Documentation

bool netcdf::FileExists ( std::string const &  ncFileName,
bool const  isPath = false 
)

if true, fileName is a path

Parameters
ncFileNamefile name or path to find
Examples:
Test_NcFileUtils.cpp.
void netcdf::FreeCStringArray ( char **&  cStrArray,
std::size_t const  numStrings 
)
Examples:
Test_NcChar.cpp.
template<class T >
T* netcdf::FromVector ( std::vector< T > const &  src)

< atomic data type

Parameters
srcreturns ownership of C array data source
std::size_t netcdf::GetDimSize ( int const  groupID,
int const  varID,
int const  dimIndex 
)

which dimension to query (zero-based)

Parameters
groupIDgroup ID
varIDvariable ID
std::string const & netcdf::GetFileFormatStr ( NcFile::FileFormat const  fileFormat)
std::string const & netcdf::GetFileModeStr ( NcFile::FileMode const  fileMode)
NcSpatial::GridDim netcdf::GetGridDimensions ( NcFile &  nc)
NcGroup netcdf::GetGroup ( NcFile const &  ncFile,
int const  groupID 
)
void netcdf::GetNcDims ( int const  groupID,
int const  varID,
std::vector< NcDim > &  ncDims 
)
void netcdf::GetNcFiles ( std::string const &  path,
std::vector< std::string > &  fileNames 
)

netCDF file names found

Parameters
pathpath to search
fileNamesnetCDF file names found
Examples:
Test_NcFileUtils.cpp.
std::size_t netcdf::GetTotalSize ( NcVar const &  var)
std::size_t netcdf::GetTotalSize ( int const  groupID,
int const  varID 
)
std::size_t netcdf::GetTotalSize ( int const  groupID,
int const  varID,
std::vector< std::size_t > const &  count 
)
void netcdf::GetTypeName ( NcGroup const &  group,
NcType::ncType const  typeID,
std::string &  name 
)

returned name

Parameters
groupNcGroup or NcFile
typeIDnc_CHAR, etc.
NcVar netcdf::GetVar ( NcFile const &  ncFile,
int const  groupID,
int const  varID 
)
std::string netcdf::GetVarName ( int const  groupID,
int const  varID 
)
bool netcdf::IsAtomicType ( NcType::ncType const  typeClass)
inline
bool netcdf::IsGridded ( NcFile &  nc)
bool netcdf::IsGriddedIndexed ( NcFile &  nc)
bool netcdf::IsRecordVariable ( int const  groupID,
int const  varID 
)
bool netcdf::IsTimeSeries ( NcFile &  nc)
bool netcdf::IsUserDefinedType ( NcType::ncType const  typeClass)
inline
template<class TNCT >
TNCT::value_type* netcdf::MakeCArray ( TNCT const &  ncType,
int const  size,
typename TNCT::value_type const  initValue = 0 
)
Examples:
Test_NcChar.cpp.
char ** netcdf::MakeCStringArray ( int const  numStrings,
short const  size 
)
void netcdf::NcCheck ( int const  retCode,
char const *const  file,
int const  line 
)
inline

Function checks error code and if necessary throws an exception.

Parameters
retCodeInteger value returned by netCDF C-routines.
fileThe name of the file from which this call originates.
lineThe line number in the file from which this call originates.
void netcdf::NcCheckEdgeArrays ( int const  groupID,
int const  varID,
std::vector< std::size_t > const &  start,
std::vector< std::size_t > const &  count 
)
Parameters
groupIDreturns true if ok
varIDgroup or file ID
startvariable ID
countstart indices
void netcdf::NcCheckThrowMsg ( int const  retCode,
char const *const  file,
int const  line 
)
void netcdf::operator<< ( NcFileMetaCF &  metaFile,
MetadataCFGlobal const &  meta 
)

global file metadata

Parameters
metaFilenetCDF file metadata
template<typename TNumeric >
void netcdf::operator<< ( NcVarMetaCF &  metaVar,
MetadataCFVariable< TNumeric > const &  meta 
)
Parameters
metaVarnetCDF variable
metavariable metadata
std::ostream & netcdf::operator<< ( std::ostream &  os,
MetadataCFGlobal const &  meta 
)

global file metadata

Parameters
osoutput stream
template<typename TNumeric >
std::ostream& netcdf::operator<< ( std::ostream &  os,
MetadataCFVariable< TNumeric > const &  meta 
)
Parameters
osoutput stream
metavariable metadata
void netcdf::operator>> ( NcFileMetaCF &  metaFile,
MetadataCFGlobal &  meta 
)

global file metadata

Parameters
metaFilenetCDF file metadata
template<typename TNumeric >
void netcdf::operator>> ( NcVarMetaCF &  metaVar,
MetadataCFVariable< TNumeric > &  meta 
)
Parameters
metaVarnetCDF variable
metavariable metadata
std::string & netcdf::SetExtension ( std::string &  ncFileName)
char ** netcdf::ToCStringArray ( std::vector< std::string > const &  strVec)
template<class TSrc , class TDest >
void netcdf::ToVector ( TSrc const  srcBegin,
TSrc const  srcEnd,
std::vector< TDest > &  dest 
)

< atomic data types

Parameters
srcBeginCopies to std::vector C array source begin ptr
srcEndC array source begin ptr + length
destvector to receive values
Examples:
Test_NcChar.cpp.
template<class TSrc , class TDest >
void netcdf::ToVector ( TSrc const  srcBegin,
std::vector< TDest > &  dest,
std::size_t const  count 
)

< atomic data types

Parameters
srcBeginCopies to std::vector C array source begin ptr
destvector to receive values
countnumber of elements (ignored if zero)
void netcdf::UpdateHistory ( MetadataCFGlobal &  meta,
std::string const &  newHistory,
char const  separator 
)
Parameters
metametadata with history item
newHistorynew history to append
separatorseparator for history items

Variable Documentation

NcByte netcdf::ncByte

A global instance of the NcByte class within the netCDF namespace.

Examples:
Test_AttVectors.cpp.
NcChar netcdf::ncChar

A global instance of the NcChar class within the netCDF namespace.

Examples:
Test_AttVectors.cpp, and Test_NcChar.cpp.
NcDouble netcdf::ncDouble

A global instance of the NcDouble class within the netCDF namespace.

Examples:
Test_AttVectors.cpp.
NcFloat netcdf::ncFloat

A global instance of the NcFloat class within the netCDF namespace.

Examples:
Test_AttVectors.cpp, and Test_CreateFileNc3.cpp.
NcInt netcdf::ncInt

A global instance of the NcInt class within the netCDF namespace.

Examples:
Test_AttVectors.cpp, and Test_Parallel.cpp.
NcInt64 netcdf::ncInt64

A global instance of the NcInt64 class within the netCDF namespace.

Examples:
Test_AttVectors.cpp.
NcShort netcdf::ncShort

A global instance of the NcShort class within the netCDF namespace.

Examples:
Test_AttVectors.cpp.
NcString netcdf::ncString

A global instance of the NcString class within the netCDF namespace.

Examples:
Test_AttVectors.cpp, and Test_NcString.cpp.
NcUbyte netcdf::ncUbyte

A global instance of the NcUbyte class within the netCDF namespace.

Examples:
Test_AttVectors.cpp.
NcUint netcdf::ncUint

A global instance of the NcUint class within the netCDF namespace.

Examples:
Test_AttVectors.cpp.
NcUint64 netcdf::ncUint64

A global instance of the NcUint64 class within the netCDF namespace.

Examples:
Test_AttVectors.cpp.
NcUshort netcdf::ncUshort
Examples:
Test_AttVectors.cpp.
NcNullType netcdf::nullType
NcType netcdf::NullType
NcNullVar netcdf::nullVar