VAPoR
0.1
|
NetCDFSimple API interface. More...
#include <NetCDFSimple.h>
Classes | |
class | Variable |
NetCDFSimple API interface. More... | |
Public Member Functions | |
NetCDFSimple () | |
virtual | ~NetCDFSimple () |
int | Initialize (string path) |
int | OpenRead (const NetCDFSimple::Variable &variable) |
int | Read (const size_t start[], const size_t count[], float *data, int fd=0) const |
int | Read (const size_t start[], const size_t count[], int *data, int fd=0) const |
int | Read (const size_t start[], const size_t count[], char *data, int fd=0) const |
int | Close (int fd=0) |
const std::vector< NetCDFSimple::Variable > & | GetVariables () const |
void | GetDimensions (std::vector< string > &names, std::vector< size_t > &dims) const |
string | DimName (int id) const |
size_t | DimLen (string name) const |
int | DimId (string name) const |
std::vector< string > | GetAttNames () const |
int | GetAttType (string name) const |
void | GetAtt (string name, std::vector< double > &values) const |
void | GetAtt (string name, std::vector< long > &values) const |
void | GetAtt (string name, string &values) const |
Public Member Functions inherited from VetsUtil::MyBase | |
MyBase () | |
const string & | getClassName () const |
Static Public Member Functions | |
static bool | IsNCTypeInt (int type) |
static bool | IsNCTypeFloat (int type) |
static bool | IsNCTypeText (int type) |
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) |
Friends | |
VDF_API friend std::ostream & | operator<< (std::ostream &o, const NetCDFSimple &nc) |
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) |
NetCDFSimple API interface.
This class presents a simplified interface for reading netCDF data files.
The specification of dimensions and coordinates in this class follows the netCDF API convention of ordering from slowest varying dimension to fastest varying dimension. For example, if 'dims' is a vector of dimensions, then dims[0] is the slowest varying dimension, dim[1] is the next slowest, and so on. This ordering is the opposite of the ordering used by most of the VAPoR API.
Definition at line 33 of file NetCDFSimple.h.
VAPoR::NetCDFSimple::NetCDFSimple | ( | ) |
|
virtual |
int VAPoR::NetCDFSimple::Close | ( | int | fd = 0 | ) |
Close the currently opened variable
[in] | fd | A currently opened file descriptor returned by OpenRead(). |
status | Returns a non-negative value on success |
int VAPoR::NetCDFSimple::DimId | ( | string | name | ) | const |
Return the netCDF dimension id for a named dimension
Returns the netCDF dimension id for the named dimension specified by name
[in] | name | a valid netCDF dimension name for the current file |
id | netCDF identifier for the dimension name . if name is invalid a negative int is returned. |
size_t VAPoR::NetCDFSimple::DimLen | ( | string | name | ) | const |
Return the dimension length of the named dimension
Returns the dimension length of the dimension named by name
. If name
is not recognized as a dimension name zero is returned.
[in] | name | a valid netCDF dimension name for the current file |
length | Length of the dimension named name , or 0 if name is unknown. |
string VAPoR::NetCDFSimple::DimName | ( | int | id | ) | const |
Return the name of the netCDF dimension with a given dimension id
Returns the name of dimension for the netCDF dimension id specified by id
[in] | id | a valid netCDF dimension ID for the current file |
name | Name of the dimension associated with the identifier id . if id is invalid an empty string is returned. |
void VAPoR::NetCDFSimple::GetAtt | ( | string | name, |
std::vector< double > & | values | ||
) | const |
Return global attribute values for attribute of type float
Return the values of the named global attribute converted to type float.
[in] | name | Name of the attribute |
[out] | values | A vector of attribute values |
void VAPoR::NetCDFSimple::GetAtt | ( | string | name, |
std::vector< long > & | values | ||
) | const |
void VAPoR::NetCDFSimple::GetAtt | ( | string | name, |
string & | values | ||
) | const |
std::vector<string> VAPoR::NetCDFSimple::GetAttNames | ( | ) | const |
Return global attribute names
This method returns a vector of all the global netCDF attributes defined in the file
vector | A list of global attribute names |
int VAPoR::NetCDFSimple::GetAttType | ( | string | name | ) | const |
Return the netCDF external data type for an attribute
Returns the nc_type of the named global attribute.
[in] | name | Name of the attribute |
If | an attribute named by name does not exist, a negative value is returned. |
void VAPoR::NetCDFSimple::GetDimensions | ( | std::vector< string > & | names, |
std::vector< size_t > & | dims | ||
) | const |
Return all dimensions and dimension names defined in the file
This method returns in names
a vector of all dimension names, and in dims
a vector of all dimension lengths. Thus, for example, the lenght of the dimension named by names[i] is given by dims[i]
[out] names Vector of dimension names [out] dims Vector of dimension lengths
|
inline |
Return a vector of the Variables contained in the file
This method returns a vector of Variable objects containing the metadata for each variable in the netCDF file
Definition at line 222 of file NetCDFSimple.h.
int VAPoR::NetCDFSimple::Initialize | ( | string | path | ) |
Initialize the class instance for a netCDF file
This method initializes (or reinitializes) a class instance with the name of a netCDF file
[in] | path | Path to the netCDF file |
status | A negative int is returned on failure |
|
static |
Determine if a NetCDF nc_type is a float
This static method returns true if type
is one of the NetCDF's nc_type: NC_FLOAT, or NC_DOUBLE. For all other values of type
false is returned.
[in] | type | A NetCDF external data type |
bool | True if type represents an floating point data type |
|
static |
Determine if a NetCDF nc_type is an int
This static method returns true if type
is one of the NetCDF's nc_type: NC_BYTE, NC_SHORT, NC_INT, NC_LONG, NC_UBYTE, NC_USHORT, NC_UINT, NC_INT64, or NC_UINT64. For all other values of type
false is returned.
[in] | type | A NetCDF external data type |
bool | True if type represents an integer data type |
|
static |
Determine if a NetCDF nc_type is an char
This static method returns true if type
is one of the NetCDF's nc_type: NC_CHAR. For all other values of type
false is returned.
[in] | type | A NetCDF external data type |
bool | True if type represents an char data type |
int VAPoR::NetCDFSimple::OpenRead | ( | const NetCDFSimple::Variable & | variable | ) |
Open the named variable for reading
This method prepares a netCDF variable for subsequent read operations by methods of this class. A small, non-negative integer for use in subsequent read operations is returned. The file descriptor returned by a successful call will be the lowest-numbered file descriptor not currently open for the process, starting with zero.
[in] | variable | A variable object returned by GetVariables() |
status | Returns a non-negative file descriptor on success |
int VAPoR::NetCDFSimple::Read | ( | const size_t | start[], |
const size_t | count[], | ||
float * | data, | ||
int | fd = 0 |
||
) | const |
Read an array of values from a variable
The method allows the readying of a hyperslab of data from the currently opened variable.
[in] | start | Start vector with one element for each dimension to specify a hyperslab |
[in] | count | Count vector with one element for each dimension to specify a Hyperslab |
[in] | fd | A currently opened file descriptor returned by OpenRead(). |
[out] | data | A pointer to an area of memory containing sufficent space to contain the copied hyperslab. |
status | A negative int is returned on failure |
int VAPoR::NetCDFSimple::Read | ( | const size_t | start[], |
const size_t | count[], | ||
int * | data, | ||
int | fd = 0 |
||
) | const |
int VAPoR::NetCDFSimple::Read | ( | const size_t | start[], |
const size_t | count[], | ||
char * | data, | ||
int | fd = 0 |
||
) | const |
|
friend |