VAPOR3 3.9.4
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:
Wasp::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.
 
virtual int DefVar (string name, int xtype, vector< string > dimnames)
 Define a variable.
 
virtual int InqVarDims (string name, vector< string > &dimnames, vector< size_t > &dims) const
 Learn the dimension names associated with a variable.
 
virtual int InqDims (vector< string > &dimnames, vector< size_t > &dims) const
 Learn the dimension names and lengths defined in a file.
 
virtual int InqDimlen (string name, size_t &len) const
 Learn the length of a named dimension.
 
int InqAttnames (string varname, std::vector< string > &attnames) const
 Learn the names of all the global or variable attributes.
 
int CopyAtt (string varname_in, string attname, NetCDFCpp &ncdf_out, string varname_out) const
 
virtual int PutAtt (string varname, string attname, int value) const
 Write an integer attribute.
 
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.
 
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.
 
virtual int InqAtt (string varname, string attname, nc_type &xtype, size_t &len) const
 Return information about a NetCDF attribute.
 
virtual int InqVartype (string varname, nc_type &xtype) const
 Find a variable's external representation type.
 
virtual int SetFill (int fillmode, int &old_modep)
 Set the fill value.
 
virtual int EndDef () const
 End the metadata definition section.
 
virtual int ReDef () const
 Put open netcdf dataset into define mode.
 
virtual int Close ()
 Close the currently opened file.
 
virtual int PutVara (string varname, vector< size_t > start, vector< size_t > count, const void *data)
 Write an array of values to a variable.
 
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.
 
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) const
 Read an array of values from a variable.
 
virtual int GetVara (string varname, vector< size_t > start, vector< size_t > count, float *data) const
 
virtual int GetVara (string varname, vector< size_t > start, vector< size_t > count, double *data) const
 
virtual int GetVara (string varname, vector< size_t > start, vector< size_t > count, int *data) const
 
virtual int GetVara (string varname, vector< size_t > start, vector< size_t > count, long *data) const
 
virtual int GetVara (string varname, vector< size_t > start, vector< size_t > count, unsigned char *data) const
 
virtual int GetVar (string varname, void *data) const
 Read an entire variable with one function call.
 
virtual int GetVar (string varname, float *data) const
 
virtual int GetVar (string varname, double *data) const
 
virtual int GetVar (string varname, int *data) const
 
virtual int GetVar (string varname, long *data) const
 
virtual int GetVar (string varname, unsigned char *data) const
 
virtual int CopyVar (string varname, NetCDFCpp &ncdf_out) const
 Copy a variable from one file to another.
 
virtual bool ValidFile (string path)
 
virtual bool InqDimDefined (string dimname)
 
virtual bool InqAttDefined (string varname, string attname)
 
virtual int InqVarnames (vector< string > &varnames) const
 
int GetNCID () const
 
- Public Member Functions inherited from Wasp::MyBase
 MyBase ()
 
const string & getClassName () const
 

Static Public Member Functions

static size_t SizeOf (int nctype)
 
- Static Public Member Functions inherited from Wasp::MyBase
static void SetErrMsg (const char *format,...)
 Record a formatted error message.
 
static void SetErrMsg (int errcode, const char *format,...)
 Record a formatted error message and an error code.
 
static const char * GetErrMsg ()
 
static void SetErrCode (int err_code)
 Record an error code.
 
static int GetErrCode ()
 Retrieve the current error code.
 
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.
 
static const char * GetDiagMsg ()
 
static void SetDiagMsgCB (DiagMsgCB_T cb)
 
static DiagMsgCB_T GetDiagMsgCB ()
 
static void SetDiagMsgFilePtr (FILE *fp)
 
static bool EnableErrMsg (bool enable)
 
static bool GetEnableErrMsg ()
 

Additional Inherited Members

- Public Types inherited from Wasp::MyBase
typedef void(* ErrMsgCB_T) (const char *msg, int err_code)
 
typedef void(* DiagMsgCB_T) (const char *msg)
 
- Static Public Attributes inherited from Wasp::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 Wasp::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 Wasp::MyBase::SetErrMsg().

Definition at line 44 of file NetCDFCpp.h.

Constructor & Destructor Documentation

◆ NetCDFCpp()

VAPoR::NetCDFCpp::NetCDFCpp ( )

◆ ~NetCDFCpp()

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

Member Function Documentation

◆ Close()

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

Close the currently opened file.

Reimplemented in VAPoR::WASP.

◆ CopyAtt()

int VAPoR::NetCDFCpp::CopyAtt ( string  varname_in,
string  attname,
NetCDFCpp ncdf_out,
string  varname_out 
) const

Copy global or variable attribute

This method copies an attribute from one open netCDF dataset to another. It can also be used to copy an attribute from one variable to another within the same netCDF.

Parameters
[in]varname_inName of source variable, empty if global
[in]attnameName of attribute to copy
[in]ncdf_outDestination NetCDF object
[in]varname_outName of destination variable, empty if global

◆ CopyVar()

virtual int VAPoR::NetCDFCpp::CopyVar ( string  varname,
NetCDFCpp ncdf_out 
) const
virtual

Copy a variable from one file to another.

◆ Create()

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

◆ DefDim()

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

Define a dimension.

Reimplemented in VAPoR::WASP.

◆ DefVar()

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

Define a variable.

Reimplemented in VAPoR::WASP.

◆ EndDef()

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

End the metadata definition section.

Reimplemented in VAPoR::WASP.

◆ GetAtt() [1/15]

virtual int VAPoR::NetCDFCpp::GetAtt ( string  varname,
string  attname,
char  values[],
size_t  n 
) const
virtual

◆ GetAtt() [2/15]

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

◆ GetAtt() [3/15]

virtual int VAPoR::NetCDFCpp::GetAtt ( string  varname,
string  attname,
double  values[],
size_t  n 
) const
virtual

◆ GetAtt() [4/15]

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

◆ GetAtt() [5/15]

virtual int VAPoR::NetCDFCpp::GetAtt ( string  varname,
string  attname,
float  values[],
size_t  n 
) const
virtual

◆ GetAtt() [6/15]

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

Read an integer attribute.

◆ GetAtt() [7/15]

virtual int VAPoR::NetCDFCpp::GetAtt ( string  varname,
string  attname,
int  values[],
size_t  n 
) const
virtual

◆ GetAtt() [8/15]

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

◆ GetAtt() [9/15]

virtual int VAPoR::NetCDFCpp::GetAtt ( string  varname,
string  attname,
size_t  values[],
size_t  n 
) const
virtual

◆ GetAtt() [10/15]

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

◆ GetAtt() [11/15]

virtual int VAPoR::NetCDFCpp::GetAtt ( string  varname,
string  attname,
vector< double > &  values 
) const
virtual

◆ GetAtt() [12/15]

virtual int VAPoR::NetCDFCpp::GetAtt ( string  varname,
string  attname,
vector< float > &  values 
) const
virtual

◆ GetAtt() [13/15]

virtual int VAPoR::NetCDFCpp::GetAtt ( string  varname,
string  attname,
vector< int > &  values 
) const
virtual

◆ GetAtt() [14/15]

virtual int VAPoR::NetCDFCpp::GetAtt ( string  varname,
string  attname,
vector< size_t > &  values 
) const
virtual

◆ GetAtt() [15/15]

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.

◆ GetNCID()

int VAPoR::NetCDFCpp::GetNCID ( ) const
inline

Return netCDF ID associated with this object

Definition at line 270 of file NetCDFCpp.h.

◆ GetVar() [1/6]

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

◆ GetVar() [2/6]

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

◆ GetVar() [3/6]

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

◆ GetVar() [4/6]

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

◆ GetVar() [5/6]

virtual int VAPoR::NetCDFCpp::GetVar ( string  varname,
unsigned char *  data 
) const
virtual

◆ GetVar() [6/6]

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

Read an entire variable with one function call.

◆ GetVara() [1/6]

virtual int VAPoR::NetCDFCpp::GetVara ( string  varname,
vector< size_t >  start,
vector< size_t >  count,
double *  data 
) const
virtual

◆ GetVara() [2/6]

virtual int VAPoR::NetCDFCpp::GetVara ( string  varname,
vector< size_t >  start,
vector< size_t >  count,
float *  data 
) const
virtual

◆ GetVara() [3/6]

virtual int VAPoR::NetCDFCpp::GetVara ( string  varname,
vector< size_t >  start,
vector< size_t >  count,
int *  data 
) const
virtual

◆ GetVara() [4/6]

virtual int VAPoR::NetCDFCpp::GetVara ( string  varname,
vector< size_t >  start,
vector< size_t >  count,
long *  data 
) const
virtual

◆ GetVara() [5/6]

virtual int VAPoR::NetCDFCpp::GetVara ( string  varname,
vector< size_t >  start,
vector< size_t >  count,
unsigned char *  data 
) const
virtual

◆ GetVara() [6/6]

virtual int VAPoR::NetCDFCpp::GetVara ( string  varname,
vector< size_t >  start,
vector< size_t >  count,
void *  data 
) const
virtual

Read an array of values from a variable.

◆ InqAtt()

virtual int VAPoR::NetCDFCpp::InqAtt ( string  varname,
string  attname,
nc_type &  xtype,
size_t &  len 
) const
virtual

Return information about a NetCDF attribute.

◆ InqAttDefined()

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

Returns true if the named attribute is defined

Parameters
[in]dimnameA NetCDF dimension name

◆ InqAttnames()

int VAPoR::NetCDFCpp::InqAttnames ( string  varname,
std::vector< string > &  attnames 
) const

Learn the names of all the global or variable attributes.

◆ InqDimDefined()

virtual bool VAPoR::NetCDFCpp::InqDimDefined ( string  dimname)
virtual

Returns true if the named dimension is defined

Parameters
[in]dimnameA NetCDF dimension name

◆ InqDimlen()

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

Learn the length of a named dimension.

◆ InqDims()

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

Learn the dimension names and lengths defined in a file.

◆ InqVarDims()

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.

◆ InqVarid()

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

Find the NetCDF ID of a variable.

◆ InqVarnames()

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.

◆ InqVartype()

virtual int VAPoR::NetCDFCpp::InqVartype ( string  varname,
nc_type &  xtype 
) const
virtual

Find a variable's external representation type.

◆ Open()

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.

◆ PutAtt() [1/15]

virtual int VAPoR::NetCDFCpp::PutAtt ( string  varname,
string  attname,
const char  values[],
size_t  n 
) const
virtual

◆ PutAtt() [2/15]

virtual int VAPoR::NetCDFCpp::PutAtt ( string  varname,
string  attname,
const double  values[],
size_t  n 
) const
virtual

◆ PutAtt() [3/15]

virtual int VAPoR::NetCDFCpp::PutAtt ( string  varname,
string  attname,
const float  values[],
size_t  n 
) const
virtual

◆ PutAtt() [4/15]

virtual int VAPoR::NetCDFCpp::PutAtt ( string  varname,
string  attname,
const int  values[],
size_t  n 
) const
virtual

◆ PutAtt() [5/15]

virtual int VAPoR::NetCDFCpp::PutAtt ( string  varname,
string  attname,
const size_t  values[],
size_t  n 
) const
virtual

◆ PutAtt() [6/15]

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

◆ PutAtt() [7/15]

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

◆ PutAtt() [8/15]

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

Write an integer attribute.

◆ PutAtt() [9/15]

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

◆ PutAtt() [10/15]

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

◆ PutAtt() [11/15]

virtual int VAPoR::NetCDFCpp::PutAtt ( string  varname,
string  attname,
vector< double >  values 
) const
virtual

◆ PutAtt() [12/15]

virtual int VAPoR::NetCDFCpp::PutAtt ( string  varname,
string  attname,
vector< float >  values 
) const
virtual

◆ PutAtt() [13/15]

virtual int VAPoR::NetCDFCpp::PutAtt ( string  varname,
string  attname,
vector< int >  values 
) const
virtual

◆ PutAtt() [14/15]

virtual int VAPoR::NetCDFCpp::PutAtt ( string  varname,
string  attname,
vector< size_t >  values 
) const
virtual

◆ PutAtt() [15/15]

virtual int VAPoR::NetCDFCpp::PutAtt ( string  varname,
string  attname,
vector< string >  values 
) const
virtual

◆ PutVar() [1/6]

virtual int VAPoR::NetCDFCpp::PutVar ( string  varname,
const double *  data 
)
virtual

◆ PutVar() [2/6]

virtual int VAPoR::NetCDFCpp::PutVar ( string  varname,
const float *  data 
)
virtual

◆ PutVar() [3/6]

virtual int VAPoR::NetCDFCpp::PutVar ( string  varname,
const int *  data 
)
virtual

◆ PutVar() [4/6]

virtual int VAPoR::NetCDFCpp::PutVar ( string  varname,
const long *  data 
)
virtual

◆ PutVar() [5/6]

virtual int VAPoR::NetCDFCpp::PutVar ( string  varname,
const unsigned char *  data 
)
virtual

◆ PutVar() [6/6]

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

Write an entire variable with one function call.

◆ PutVara() [1/6]

virtual int VAPoR::NetCDFCpp::PutVara ( string  varname,
vector< size_t >  start,
vector< size_t >  count,
const double *  data 
)
virtual

◆ PutVara() [2/6]

virtual int VAPoR::NetCDFCpp::PutVara ( string  varname,
vector< size_t >  start,
vector< size_t >  count,
const float *  data 
)
virtual

◆ PutVara() [3/6]

virtual int VAPoR::NetCDFCpp::PutVara ( string  varname,
vector< size_t >  start,
vector< size_t >  count,
const int *  data 
)
virtual

◆ PutVara() [4/6]

virtual int VAPoR::NetCDFCpp::PutVara ( string  varname,
vector< size_t >  start,
vector< size_t >  count,
const long *  data 
)
virtual

◆ PutVara() [5/6]

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

◆ PutVara() [6/6]

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.

◆ ReDef()

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

Put open netcdf dataset into define mode.

◆ SetFill()

virtual int VAPoR::NetCDFCpp::SetFill ( int  fillmode,
int &  old_modep 
)
virtual

Set the fill value.

Reimplemented in VAPoR::WASP.

◆ SizeOf()

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

Return the size in bytes of a NetCDF external data type

◆ ValidFile()

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: