VAPOR3 3.9.4
|
Defines simple C++ wrapper for NetCDF. More...
#include <NetCDFCpp.h>
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 |
![]() | |
MyBase () | |
const string & | getClassName () const |
Static Public Member Functions | |
static size_t | SizeOf (int nctype) |
![]() | |
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 | |
![]() | |
typedef void(* | ErrMsgCB_T) (const char *msg, int err_code) |
typedef void(* | DiagMsgCB_T) (const char *msg) |
![]() | |
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 |
![]() | |
void | SetClassName (const string &name) |
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.
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.
VAPoR::NetCDFCpp::NetCDFCpp | ( | ) |
|
virtual |
|
virtual |
Close the currently opened file.
Reimplemented in VAPoR::WASP.
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.
[in] | varname_in | Name of source variable, empty if global |
[in] | attname | Name of attribute to copy |
[in] | ncdf_out | Destination NetCDF object |
[in] | varname_out | Name of destination variable, empty if global |
|
virtual |
Copy a variable from one file to another.
|
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 |
Define a dimension.
Reimplemented in VAPoR::WASP.
|
virtual |
Define a variable.
Reimplemented in VAPoR::WASP.
|
virtual |
End the metadata definition section.
Reimplemented in VAPoR::WASP.
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
Read an integer attribute.
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
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
.
|
inline |
Return netCDF ID associated with this object
Definition at line 270 of file NetCDFCpp.h.
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
Read an entire variable with one function call.
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
Read an array of values from a variable.
|
virtual |
Return information about a NetCDF attribute.
|
virtual |
Returns true if the named attribute is defined
[in] | dimname | A NetCDF dimension name |
int VAPoR::NetCDFCpp::InqAttnames | ( | string | varname, |
std::vector< string > & | attnames | ||
) | const |
Learn the names of all the global or variable attributes.
|
virtual |
Returns true if the named dimension is defined
[in] | dimname | A NetCDF dimension name |
|
virtual |
Learn the length of a named dimension.
|
virtual |
Learn the dimension names and lengths defined in a file.
|
virtual |
Learn the dimension names associated with a variable.
Reimplemented in VAPoR::WASP.
|
virtual |
Find the NetCDF ID of a variable.
|
virtual |
Learn the names of the user defined variables present
[out] | varnames | A vector containing the names of all of the variables defined in the presently opened NetCDF file. |
|
virtual |
Find a variable's external representation type.
|
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 |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
Write an integer attribute.
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
Write an entire variable with one function call.
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
Write an array of values to a variable.
|
virtual |
Put open netcdf dataset into define mode.
|
virtual |
Set the fill value.
Reimplemented in VAPoR::WASP.
|
static |
Return the size in bytes of a NetCDF external data type
|
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().