VAPoR  0.1
Classes | Public Member Functions | Static Public Member Functions | Friends | List of all members
VAPoR::NetCDFSimple Class Reference

NetCDFSimple API interface. More...

#include <NetCDFSimple.h>

Inheritance diagram for VAPoR::NetCDFSimple:
VetsUtil::MyBase

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)
 

Detailed Description

NetCDFSimple API interface.

Author
John Clyne
Version
$Revision$
Date
$Date$

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.

Constructor & Destructor Documentation

VAPoR::NetCDFSimple::NetCDFSimple ( )
virtual VAPoR::NetCDFSimple::~NetCDFSimple ( )
virtual

Member Function Documentation

int VAPoR::NetCDFSimple::Close ( int  fd = 0)

Close the currently opened variable

Parameters
[in]fdA currently opened file descriptor returned by OpenRead().
Return values
statusReturns 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

Parameters
[in]namea valid netCDF dimension name for the current file
Return values
idnetCDF identifier for the dimension name. if name is invalid a negative int is returned.
See also
Initialize()
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.

Parameters
[in]namea valid netCDF dimension name for the current file
Return values
lengthLength of the dimension named name, or 0 if name is unknown.
See also
Initialize()
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

Parameters
[in]ida valid netCDF dimension ID for the current file
Return values
nameName of the dimension associated with the identifier id. if id is invalid an empty string is returned.
See also
Initialize()
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.

Note
Attributes of type int are cast to float
All attributes with floating point representation of any precision are returned by this method. Attributes that do not have floating point internal representations can not be returned
Parameters
[in]nameName of the attribute
[out]valuesA 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

Return values
vectorA list of global attribute names
See also
Initialize()
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.

Parameters
[in]nameName of the attribute
Return values
Ifan 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

See also
Initialize()
const std::vector<NetCDFSimple::Variable>& VAPoR::NetCDFSimple::GetVariables ( ) const
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

See also
Initialize(), NetCDFSimple::Variable

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

Parameters
[in]pathPath to the netCDF file
Return values
statusA negative int is returned on failure
static bool VAPoR::NetCDFSimple::IsNCTypeFloat ( int  type)
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.

Parameters
[in]typeA NetCDF external data type
Return values
boolTrue if type represents an floating point data type
static bool VAPoR::NetCDFSimple::IsNCTypeInt ( int  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.

Parameters
[in]typeA NetCDF external data type
Return values
boolTrue if type represents an integer data type
static bool VAPoR::NetCDFSimple::IsNCTypeText ( int  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.

Parameters
[in]typeA NetCDF external data type
Return values
boolTrue 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.

Parameters
[in]variableA variable object returned by GetVariables()
Return values
statusReturns a non-negative file descriptor on success
See also
Read(), GetVariables()
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.

Parameters
[in]startStart vector with one element for each dimension to specify a hyperslab
[in]countCount vector with one element for each dimension to specify a Hyperslab
[in]fdA currently opened file descriptor returned by OpenRead().
[out]dataA pointer to an area of memory containing sufficent space to contain the copied hyperslab.
Return values
statusA negative int is returned on failure
See also
OpenRead()
NetCDF documentation for nc_get_vara
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

Friends And Related Function Documentation

VDF_API friend std::ostream& operator<< ( std::ostream &  o,
const NetCDFSimple nc 
)
friend

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