VAPOR3 3.9.4
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
VAPoR::NetCDFSimple Class Reference

NetCDFSimple API interface. More...

#include <NetCDFSimple.h>

Inheritance diagram for VAPoR::NetCDFSimple:
Wasp::MyBase

Classes

class  Variable
 NetCDFSimple API interface. More...
 

Public Member Functions

 NetCDFSimple ()
 
virtual ~NetCDFSimple ()
 
virtual int Initialize (string path)
 
virtual int OpenRead (const NetCDFSimple::Variable &variable)
 
int Read (const size_t start[], const size_t count[], double *data, int fd=0) const
 
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
 
virtual 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 Wasp::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 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 ()
 

Protected Member Functions

int _GetAtts (int ncid, int varid, std::vector< std::pair< string, std::vector< double > > > &flt_atts, std::vector< std::pair< string, std::vector< long > > > &int_atts, std::vector< std::pair< string, string > > &str_atts)
 
- Protected Member Functions inherited from Wasp::MyBase
void SetClassName (const string &name)
 

Protected Attributes

int _ncid
 
std::map< int, int > _ovr_table
 
string _path
 
std::vector< string > _dimnames
 
std::vector< size_t > _dims
 
std::vector< string > _unlimited_dimnames
 
std::vector< std::pair< string, std::vector< double > > > _flt_atts
 
std::vector< std::pair< string, std::vector< long > > > _int_atts
 
std::vector< std::pair< string, string > > _str_atts
 
std::vector< NetCDFSimple::Variable_variables
 

Friends

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

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
 

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

◆ NetCDFSimple()

VAPoR::NetCDFSimple::NetCDFSimple ( )

◆ ~NetCDFSimple()

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

Member Function Documentation

◆ _GetAtts()

int VAPoR::NetCDFSimple::_GetAtts ( int  ncid,
int  varid,
std::vector< std::pair< string, std::vector< double > > > &  flt_atts,
std::vector< std::pair< string, std::vector< long > > > &  int_atts,
std::vector< std::pair< string, string > > &  str_atts 
)
protected

◆ Close()

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

Close the currently opened variable

Parameters
[in]fdA currently opened file descriptor returned by OpenRead().
Return values
statusReturns a non-negative value on success

◆ DimId()

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()

◆ DimLen()

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()

◆ DimName()

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()

◆ GetAtt() [1/3]

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

◆ GetAtt() [2/3]

void VAPoR::NetCDFSimple::GetAtt ( string  name,
std::vector< long > &  values 
) const

◆ GetAtt() [3/3]

void VAPoR::NetCDFSimple::GetAtt ( string  name,
string &  values 
) const

◆ GetAttNames()

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()

◆ GetAttType()

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.

◆ GetDimensions()

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]

\params[out] names Vector of dimension names \params[out] dims Vector of dimension lengths

See also
Initialize()

◆ GetVariables()

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 196 of file NetCDFSimple.h.

◆ Initialize()

virtual int VAPoR::NetCDFSimple::Initialize ( string  path)
virtual

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

◆ IsNCTypeFloat()

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

◆ IsNCTypeInt()

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

◆ IsNCTypeText()

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

◆ OpenRead()

virtual int VAPoR::NetCDFSimple::OpenRead ( const NetCDFSimple::Variable variable)
virtual

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()

◆ Read() [1/4]

int VAPoR::NetCDFSimple::Read ( const size_t  start[],
const size_t  count[],
char *  data,
int  fd = 0 
) const

◆ Read() [2/4]

int VAPoR::NetCDFSimple::Read ( const size_t  start[],
const size_t  count[],
double *  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

◆ Read() [3/4]

int VAPoR::NetCDFSimple::Read ( const size_t  start[],
const size_t  count[],
float *  data,
int  fd = 0 
) const

◆ Read() [4/4]

int VAPoR::NetCDFSimple::Read ( const size_t  start[],
const size_t  count[],
int *  data,
int  fd = 0 
) const

Friends And Related Function Documentation

◆ operator<<

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

Member Data Documentation

◆ _dimnames

std::vector<string> VAPoR::NetCDFSimple::_dimnames
protected

Definition at line 334 of file NetCDFSimple.h.

◆ _dims

std::vector<size_t> VAPoR::NetCDFSimple::_dims
protected

Definition at line 335 of file NetCDFSimple.h.

◆ _flt_atts

std::vector<std::pair<string, std::vector<double> > > VAPoR::NetCDFSimple::_flt_atts
protected

Definition at line 337 of file NetCDFSimple.h.

◆ _int_atts

std::vector<std::pair<string, std::vector<long> > > VAPoR::NetCDFSimple::_int_atts
protected

Definition at line 338 of file NetCDFSimple.h.

◆ _ncid

int VAPoR::NetCDFSimple::_ncid
protected

Definition at line 331 of file NetCDFSimple.h.

◆ _ovr_table

std::map<int, int> VAPoR::NetCDFSimple::_ovr_table
protected

Definition at line 332 of file NetCDFSimple.h.

◆ _path

string VAPoR::NetCDFSimple::_path
protected

Definition at line 333 of file NetCDFSimple.h.

◆ _str_atts

std::vector<std::pair<string, string> > VAPoR::NetCDFSimple::_str_atts
protected

Definition at line 339 of file NetCDFSimple.h.

◆ _unlimited_dimnames

std::vector<string> VAPoR::NetCDFSimple::_unlimited_dimnames
protected

Definition at line 336 of file NetCDFSimple.h.

◆ _variables

std::vector<NetCDFSimple::Variable> VAPoR::NetCDFSimple::_variables
protected

Definition at line 340 of file NetCDFSimple.h.


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