VAPoR  3.0.0
Public Member Functions | Static Public Member Functions | List of all members
VAPoR::NetCDFCpp Class Reference

Defines simple C++ wrapper for NetCDF. More...

#include <NetCDFCpp.h>

Inheritance diagram for VAPoR::NetCDFCpp:
VetsUtil::MyBase VAPoR::WASP

Public Member Functions

 NetCDFCpp ()
 
virtual ~NetCDFCpp ()
 
virtual int Create (string path, int cmode, size_t initialsz, size_t &bufrsizehintp)
 
virtual int Open (string path, int mode)
 
virtual int DefDim (string name, size_t len) const
 Define a dimension. More...
 
virtual int DefVar (string name, int xtype, vector< string > dimnames)
 Define a variable. More...
 
virtual int InqVarDims (string name, vector< string > &dimnames, vector< size_t > &dims) const
 Learn the dimension names associated with a variable. More...
 
virtual int InqDimlen (string name, size_t &len) const
 Learn the length of a named dimension. More...
 
virtual int PutAtt (string varname, string attname, int value) const
 Write an integer attribute. More...
 
virtual int PutAtt (string varname, string attname, vector< int > values) const
 
virtual int PutAtt (string varname, string attname, const int values[], size_t n) const
 
virtual int GetAtt (string varname, string attname, int &value) const
 Read an integer attribute. More...
 
virtual int GetAtt (string varname, string attname, vector< int > &values) const
 
virtual int GetAtt (string varname, string attname, int values[], size_t n) const
 
virtual int PutAtt (string varname, string attname, size_t value) const
 
virtual int PutAtt (string varname, string attname, vector< size_t > values) const
 
virtual int PutAtt (string varname, string attname, const size_t values[], size_t n) const
 
virtual int GetAtt (string varname, string attname, size_t &value) const
 
virtual int GetAtt (string varname, string attname, vector< size_t > &values) const
 
virtual int GetAtt (string varname, string attname, size_t values[], size_t n) const
 
virtual int PutAtt (string varname, string attname, float value) const
 
virtual int PutAtt (string varname, string attname, vector< float > values) const
 
virtual int PutAtt (string varname, string attname, const float values[], size_t n) const
 
virtual int GetAtt (string varname, string attname, float &value) const
 
virtual int GetAtt (string varname, string attname, vector< float > &values) const
 
virtual int GetAtt (string varname, string attname, float values[], size_t n) const
 
virtual int PutAtt (string varname, string attname, double value) const
 
virtual int PutAtt (string varname, string attname, vector< double > values) const
 
virtual int PutAtt (string varname, string attname, const double values[], size_t n) const
 
virtual int GetAtt (string varname, string attname, double &value) const
 
virtual int GetAtt (string varname, string attname, vector< double > &values) const
 
virtual int GetAtt (string varname, string attname, double values[], size_t n) const
 
virtual int PutAtt (string varname, string attname, string value) const
 
virtual int PutAtt (string varname, string attname, vector< string > values) const
 
virtual int PutAtt (string varname, string attname, const char values[], size_t n) const
 
virtual int GetAtt (string varname, string attname, string &value) const
 
virtual int GetAtt (string varname, string attname, char values[], size_t n) const
 
virtual int GetAtt (string varname, string attname, vector< string > &values) const
 
virtual int InqVarid (string varname, int &varid) const
 Find the NetCDF ID of a variable. More...
 
virtual int InqAtt (string varname, string attname, nc_type &xtype, size_t &len) const
 Return information about a NetCDF attribute. More...
 
virtual int InqVartype (string varname, nc_type &xtype) const
 Find a variable's external representation type. More...
 
virtual int SetFill (int fillmode, int &old_modep)
 Set the fill value. More...
 
virtual int EndDef () const
 End the metadata definition section. More...
 
virtual int Close ()
 Close the currently opened file. More...
 
virtual int PutVara (string varname, vector< size_t > start, vector< size_t > count, const void *data)
 Write an array of values to a variable. More...
 
virtual int PutVara (string varname, vector< size_t > start, vector< size_t > count, const float *data)
 
virtual int PutVara (string varname, vector< size_t > start, vector< size_t > count, const double *data)
 
virtual int PutVara (string varname, vector< size_t > start, vector< size_t > count, const int *data)
 
virtual int PutVara (string varname, vector< size_t > start, vector< size_t > count, const long *data)
 
virtual int PutVara (string varname, vector< size_t > start, vector< size_t > count, const unsigned char *data)
 
virtual int PutVar (string varname, const void *data)
 Write an entire variable with one function call. More...
 
virtual int PutVar (string varname, const float *data)
 
virtual int PutVar (string varname, const double *data)
 
virtual int PutVar (string varname, const int *data)
 
virtual int PutVar (string varname, const long *data)
 
virtual int PutVar (string varname, const unsigned char *data)
 
virtual int GetVara (string varname, vector< size_t > start, vector< size_t > count, void *data)
 Read an array of values from a variable. More...
 
virtual int GetVara (string varname, vector< size_t > start, vector< size_t > count, float *data)
 
virtual int GetVara (string varname, vector< size_t > start, vector< size_t > count, double *data)
 
virtual int GetVara (string varname, vector< size_t > start, vector< size_t > count, int *data)
 
virtual int GetVara (string varname, vector< size_t > start, vector< size_t > count, long *data)
 
virtual int GetVara (string varname, vector< size_t > start, vector< size_t > count, unsigned char *data)
 
virtual int GetVar (string varname, void *data)
 Read an entire variable with one function call. More...
 
virtual int GetVar (string varname, float *data)
 
virtual int GetVar (string varname, double *data)
 
virtual int GetVar (string varname, int *data)
 
virtual int GetVar (string varname, long *data)
 
virtual int GetVar (string varname, unsigned char *data)
 
virtual bool ValidFile (string path)
 
virtual bool InqDimDefined (string dimname)
 
virtual bool InqAttDefined (string varname, string attname)
 
virtual int InqVarnames (vector< string > &varnames) const
 
- Public Member Functions inherited from VetsUtil::MyBase
 MyBase ()
 
const string & getClassName () const
 

Static Public Member Functions

static size_t SizeOf (int nctype)
 
- Static Public Member Functions inherited from VetsUtil::MyBase
static void SetErrMsg (const char *format,...)
 Record a formatted error message. More...
 
static void SetErrMsg (int errcode, const char *format,...)
 Record a formatted error message and an error code. More...
 
static const char * GetErrMsg ()
 
static void SetErrCode (int err_code)
 Record an error code. More...
 
static int GetErrCode ()
 Retrieve the current error code. More...
 
static void SetErrMsgCB (ErrMsgCB_T cb)
 
static ErrMsgCB_T GetErrMsgCB ()
 
static void SetErrMsgFilePtr (FILE *fp)
 
static const FILE * SetErrMsgFilePtr ()
 
static void SetDiagMsg (const char *format,...)
 Record a formatted diagnostic message. More...
 
static const char * GetDiagMsg ()
 
static void SetDiagMsgCB (DiagMsgCB_T cb)
 
static DiagMsgCB_T GetDiagMsgCB ()
 
static void SetDiagMsgFilePtr (FILE *fp)
 
static bool EnableErrMsg (bool enable)
 

Additional Inherited Members

- Public Types inherited from VetsUtil::MyBase
typedef void(* ErrMsgCB_T) (const char *msg, int err_code)
 
typedef void(* DiagMsgCB_T) (const char *msg)
 
- Static Public Attributes inherited from VetsUtil::MyBase
static char * ErrMsg
 
static int ErrCode
 
static int ErrMsgSize
 
static FILE * ErrMsgFilePtr
 
static ErrMsgCB_T ErrMsgCB
 
static char * DiagMsg
 
static int DiagMsgSize
 
static FILE * DiagMsgFilePtr
 
static DiagMsgCB_T DiagMsgCB
 
static bool Enabled
 
- Protected Member Functions inherited from VetsUtil::MyBase
void SetClassName (const string &name)
 

Detailed Description

Defines simple C++ wrapper for NetCDF.

This class provdies a simple object-oriented wrapper for the NetCDF API C language binding. In most cases the member functions provided by this class are identical or near identical to the NetCDF API functions of the same name. Only when significant differences exist between the NetCDF native functions and the member functions provided herein is anything other than brief documention provided.

The ordering of dimension and coordinate parameters specified as arrays or STL vectors follows that of NetCDF: The first element is the slowest varying dimension, the second element is the next slowest, and so on.

Note
This ordering is the opposite of that used by the VAPoR::VDC class.

One particular difference of note: the various identifiers used by NetCDF (e.g. variable id, dimesion id, etc) are not exposed by the NetCDFCpp class methods. These objects are instead referred to by their ascii string names. Moreover, as the file access methods Open() and Create() do not return a NetCDF file identifier, only a single NetCDF file may be opened at a time (multiple NetCDF files may be opened, if needed, by instantiating multiple NetCDFCpp objects).

Unless otherwise noted the return value of any member function that returns an integer may be interpreted as status. A negative value indicates an error. Upon error an error message will be logged via VetsUtil::MyBase::SetErrMsg().

Definition at line 43 of file NetCDFCpp.h.

Constructor & Destructor Documentation

VAPoR::NetCDFCpp::NetCDFCpp ( )
virtual VAPoR::NetCDFCpp::~NetCDFCpp ( )
virtual

Member Function Documentation

virtual int VAPoR::NetCDFCpp::Close ( )
virtual

Close the currently opened file.

Reimplemented in VAPoR::WASP.

virtual int VAPoR::NetCDFCpp::Create ( string  path,
int  cmode,
size_t  initialsz,
size_t &  bufrsizehintp 
)
virtual

Create a new NetCDF file

Create an new NetCDF file named by 'path'. Any currently opened NetCDF files are closed prior to attempting to create the named file

virtual int VAPoR::NetCDFCpp::DefDim ( string  name,
size_t  len 
) const
virtual

Define a dimension.

Reimplemented in VAPoR::WASP.

virtual int VAPoR::NetCDFCpp::DefVar ( string  name,
int  xtype,
vector< string >  dimnames 
)
virtual

Define a variable.

Reimplemented in VAPoR::WASP.

Referenced by VAPoR::WASP::DefVar().

virtual int VAPoR::NetCDFCpp::EndDef ( ) const
virtual

End the metadata definition section.

Reimplemented in VAPoR::WASP.

virtual int VAPoR::NetCDFCpp::GetAtt ( string  varname,
string  attname,
int &  value 
) const
virtual

Read an integer attribute.

virtual int VAPoR::NetCDFCpp::GetAtt ( string  varname,
string  attname,
vector< int > &  values 
) const
virtual
virtual int VAPoR::NetCDFCpp::GetAtt ( string  varname,
string  attname,
int  values[],
size_t  n 
) const
virtual
virtual int VAPoR::NetCDFCpp::GetAtt ( string  varname,
string  attname,
size_t &  value 
) const
virtual
virtual int VAPoR::NetCDFCpp::GetAtt ( string  varname,
string  attname,
vector< size_t > &  values 
) const
virtual
virtual int VAPoR::NetCDFCpp::GetAtt ( string  varname,
string  attname,
size_t  values[],
size_t  n 
) const
virtual
virtual int VAPoR::NetCDFCpp::GetAtt ( string  varname,
string  attname,
float &  value 
) const
virtual
virtual int VAPoR::NetCDFCpp::GetAtt ( string  varname,
string  attname,
vector< float > &  values 
) const
virtual
virtual int VAPoR::NetCDFCpp::GetAtt ( string  varname,
string  attname,
float  values[],
size_t  n 
) const
virtual
virtual int VAPoR::NetCDFCpp::GetAtt ( string  varname,
string  attname,
double &  value 
) const
virtual
virtual int VAPoR::NetCDFCpp::GetAtt ( string  varname,
string  attname,
vector< double > &  values 
) const
virtual
virtual int VAPoR::NetCDFCpp::GetAtt ( string  varname,
string  attname,
double  values[],
size_t  n 
) const
virtual
virtual int VAPoR::NetCDFCpp::GetAtt ( string  varname,
string  attname,
string &  value 
) const
virtual
virtual int VAPoR::NetCDFCpp::GetAtt ( string  varname,
string  attname,
char  values[],
size_t  n 
) const
virtual
virtual int VAPoR::NetCDFCpp::GetAtt ( string  varname,
string  attname,
vector< string > &  values 
) const
virtual

Return a text attribute as a vector of strings

This method attempts to return the value of the named text attribute as a vector of words. The value of the attribute named by attname is tokenized (parsed) using white space as a delimeter. The extracted tokens are returned in the order of occurence in the vector values.

virtual int VAPoR::NetCDFCpp::GetVar ( string  varname,
void *  data 
)
virtual

Read an entire variable with one function call.

virtual int VAPoR::NetCDFCpp::GetVar ( string  varname,
float *  data 
)
virtual
virtual int VAPoR::NetCDFCpp::GetVar ( string  varname,
double *  data 
)
virtual
virtual int VAPoR::NetCDFCpp::GetVar ( string  varname,
int *  data 
)
virtual
virtual int VAPoR::NetCDFCpp::GetVar ( string  varname,
long *  data 
)
virtual
virtual int VAPoR::NetCDFCpp::GetVar ( string  varname,
unsigned char *  data 
)
virtual
virtual int VAPoR::NetCDFCpp::GetVara ( string  varname,
vector< size_t >  start,
vector< size_t >  count,
void *  data 
)
virtual

Read an array of values from a variable.

virtual int VAPoR::NetCDFCpp::GetVara ( string  varname,
vector< size_t >  start,
vector< size_t >  count,
float *  data 
)
virtual
virtual int VAPoR::NetCDFCpp::GetVara ( string  varname,
vector< size_t >  start,
vector< size_t >  count,
double *  data 
)
virtual
virtual int VAPoR::NetCDFCpp::GetVara ( string  varname,
vector< size_t >  start,
vector< size_t >  count,
int *  data 
)
virtual
virtual int VAPoR::NetCDFCpp::GetVara ( string  varname,
vector< size_t >  start,
vector< size_t >  count,
long *  data 
)
virtual
virtual int VAPoR::NetCDFCpp::GetVara ( string  varname,
vector< size_t >  start,
vector< size_t >  count,
unsigned char *  data 
)
virtual
virtual int VAPoR::NetCDFCpp::InqAtt ( string  varname,
string  attname,
nc_type &  xtype,
size_t &  len 
) const
virtual

Return information about a NetCDF attribute.

virtual bool VAPoR::NetCDFCpp::InqAttDefined ( string  varname,
string  attname 
)
virtual

Returns true if the named attribute is defined

Parameters
[in]dimnameA NetCDF dimension name
virtual bool VAPoR::NetCDFCpp::InqDimDefined ( string  dimname)
virtual

Returns true if the named dimension is defined

Parameters
[in]dimnameA NetCDF dimension name
virtual int VAPoR::NetCDFCpp::InqDimlen ( string  name,
size_t &  len 
) const
virtual

Learn the length of a named dimension.

virtual int VAPoR::NetCDFCpp::InqVarDims ( string  name,
vector< string > &  dimnames,
vector< size_t > &  dims 
) const
virtual

Learn the dimension names associated with a variable.

Reimplemented in VAPoR::WASP.

virtual int VAPoR::NetCDFCpp::InqVarid ( string  varname,
int &  varid 
) const
virtual

Find the NetCDF ID of a variable.

virtual int VAPoR::NetCDFCpp::InqVarnames ( vector< string > &  varnames) const
virtual

Learn the names of the user defined variables present

Parameters
[out]varnamesA vector containing the names of all of the variables defined in the presently opened NetCDF file.
virtual int VAPoR::NetCDFCpp::InqVartype ( string  varname,
nc_type &  xtype 
) const
virtual

Find a variable's external representation type.

virtual int VAPoR::NetCDFCpp::Open ( string  path,
int  mode 
)
virtual

Open an existing NetCDF file

Open an existing named file. Any currently opened NetCDF files are closed prior to attempting to open the named file

Reimplemented in VAPoR::WASP.

virtual int VAPoR::NetCDFCpp::PutAtt ( string  varname,
string  attname,
int  value 
) const
virtual

Write an integer attribute.

virtual int VAPoR::NetCDFCpp::PutAtt ( string  varname,
string  attname,
vector< int >  values 
) const
virtual
virtual int VAPoR::NetCDFCpp::PutAtt ( string  varname,
string  attname,
const int  values[],
size_t  n 
) const
virtual
virtual int VAPoR::NetCDFCpp::PutAtt ( string  varname,
string  attname,
size_t  value 
) const
virtual
virtual int VAPoR::NetCDFCpp::PutAtt ( string  varname,
string  attname,
vector< size_t >  values 
) const
virtual
virtual int VAPoR::NetCDFCpp::PutAtt ( string  varname,
string  attname,
const size_t  values[],
size_t  n 
) const
virtual
virtual int VAPoR::NetCDFCpp::PutAtt ( string  varname,
string  attname,
float  value 
) const
virtual
virtual int VAPoR::NetCDFCpp::PutAtt ( string  varname,
string  attname,
vector< float >  values 
) const
virtual
virtual int VAPoR::NetCDFCpp::PutAtt ( string  varname,
string  attname,
const float  values[],
size_t  n 
) const
virtual
virtual int VAPoR::NetCDFCpp::PutAtt ( string  varname,
string  attname,
double  value 
) const
virtual
virtual int VAPoR::NetCDFCpp::PutAtt ( string  varname,
string  attname,
vector< double >  values 
) const
virtual
virtual int VAPoR::NetCDFCpp::PutAtt ( string  varname,
string  attname,
const double  values[],
size_t  n 
) const
virtual
virtual int VAPoR::NetCDFCpp::PutAtt ( string  varname,
string  attname,
string  value 
) const
virtual
virtual int VAPoR::NetCDFCpp::PutAtt ( string  varname,
string  attname,
vector< string >  values 
) const
virtual
virtual int VAPoR::NetCDFCpp::PutAtt ( string  varname,
string  attname,
const char  values[],
size_t  n 
) const
virtual
virtual int VAPoR::NetCDFCpp::PutVar ( string  varname,
const void *  data 
)
virtual

Write an entire variable with one function call.

virtual int VAPoR::NetCDFCpp::PutVar ( string  varname,
const float *  data 
)
virtual
virtual int VAPoR::NetCDFCpp::PutVar ( string  varname,
const double *  data 
)
virtual
virtual int VAPoR::NetCDFCpp::PutVar ( string  varname,
const int *  data 
)
virtual
virtual int VAPoR::NetCDFCpp::PutVar ( string  varname,
const long *  data 
)
virtual
virtual int VAPoR::NetCDFCpp::PutVar ( string  varname,
const unsigned char *  data 
)
virtual
virtual int VAPoR::NetCDFCpp::PutVara ( string  varname,
vector< size_t >  start,
vector< size_t >  count,
const void *  data 
)
virtual

Write an array of values to a variable.

virtual int VAPoR::NetCDFCpp::PutVara ( string  varname,
vector< size_t >  start,
vector< size_t >  count,
const float *  data 
)
virtual
virtual int VAPoR::NetCDFCpp::PutVara ( string  varname,
vector< size_t >  start,
vector< size_t >  count,
const double *  data 
)
virtual
virtual int VAPoR::NetCDFCpp::PutVara ( string  varname,
vector< size_t >  start,
vector< size_t >  count,
const int *  data 
)
virtual
virtual int VAPoR::NetCDFCpp::PutVara ( string  varname,
vector< size_t >  start,
vector< size_t >  count,
const long *  data 
)
virtual
virtual int VAPoR::NetCDFCpp::PutVara ( string  varname,
vector< size_t >  start,
vector< size_t >  count,
const unsigned char *  data 
)
virtual
virtual int VAPoR::NetCDFCpp::SetFill ( int  fillmode,
int &  old_modep 
)
virtual

Set the fill value.

Reimplemented in VAPoR::WASP.

static size_t VAPoR::NetCDFCpp::SizeOf ( int  nctype)
static

Return the size in bytes of a NetCDF external data type

virtual bool VAPoR::NetCDFCpp::ValidFile ( string  path)
virtual

Return true if file exists and is a valid NetCDF file

Returns true if both the file specified by path exists, and it can be opened with nc_open().


The documentation for this class was generated from the following file: