LRAUV  revA
NetCdfReader Class Reference

A very compact, very simple netCDF reader with a minimal feature set. More...

#include <NetCdfReader.h>

Inheritance diagram for NetCdfReader:
Collaboration diagram for NetCdfReader:

Public Member Functions

virtual ~NetCdfReader ()
 Destructor. More...
 
bool isOk () const
 Indicates intialization success. More...
 
bool read (void *assignTo, const NetCdfType assignType, const NetCdfVar &var, const size_t indices[])
 Reads the value of the variable at the indices as the indicated type Returns true if no error. More...
 
bool read1D (void *assignTo, const NetCdfType assignType, const NetCdfVar &var, const unsigned long index1)
 Reads the value of the variable at the 1D index as the specified type Returns true if no error. More...
 
bool read2D (void *assignTo, const NetCdfType assignType, const NetCdfVar &var, const unsigned long index1, const unsigned long index2)
 Reads the value of the variable at the 2D index as the specified type Returns true if no error. More...
 
bool read3D (void *assignTo, const NetCdfType assignType, const NetCdfVar &var, const unsigned long index1, const unsigned long index2, const unsigned long index3)
 Reads the value of the variable at the 3D index as the specified type Returns true if no error. More...
 
bool read4D (void *assignTo, const NetCdfType assignType, const NetCdfVar &var, const unsigned long index1, const unsigned long index2, const unsigned long index3, const unsigned long index4)
 Reads the value of the variable at the 4D index as the specified type Returns true if no error. More...
 
bool read1DArray (void *assignTo, const NetCdfType assignType, const NetCdfVar &var, const unsigned long index1a, const unsigned long index1b)
 Reads a 1D range of the variable between a pair of indices (a <= index <= b) into an existing 1D array of the specified type Returns true if no error. More...
 
bool read2DArray (void *assignTo, const NetCdfType assignType, const NetCdfVar &var, const unsigned long index1a, const unsigned long index1b, const unsigned long index2a, const unsigned long index2b)
 Reads a 2D range of the variable between 2 pairs of indices (a <= index <= b) into an existing 2D array of the specified type Returns true if no error. More...
 
bool read3DArray (void *assignTo, const NetCdfType assignType, const NetCdfVar &var, const unsigned long index1a, const unsigned long index1b, const unsigned long index2a, const unsigned long index2b, const unsigned long index3a, const unsigned long index3b)
 Reads a 3D range of the variable between 3 pairs of indices (a <= index <= b) into an existing 3D array of the specified type Returns true if no error. More...
 
bool read4DArray (void *assignTo, const NetCdfType assignType, const NetCdfVar &var, const unsigned long index1a, const unsigned long index1b, const unsigned long index2a, const unsigned long index2b, const unsigned long index3a, const unsigned long index3b, const unsigned long index4a, const unsigned long index4b)
 Reads a 4D range of the variable between 4 pairs of indices (a <= index <= b) into an existing 3D array of the specified type Returns true if no error. More...
 
bool readStr (Str &assignTo, const NetCdfAtt &att)
 Reads the value of the attribute as a Str Returns true if no error. More...
 
- Public Member Functions inherited from NetCdf
virtual ~NetCdf ()
 Destructor. More...
 
const NetCdfDimArraygetDimArray ()
 Returns the dimensions. More...
 
const NetCdfAttsgetGlobalAtts ()
 Returns the global attributes. More...
 
const NetCdfVarsgetVars ()
 Returns the variables. More...
 
NetCdfDimfindDim (const Str &name)
 Finds a dimension by name Returns NULL if error. More...
 
NetCdfAttfindAtt (const Str &name)
 Finds a global attribute by name NetCdfAtt* invalidValue_;. More...
 
NetCdfVarfindVar (const Str &name)
 Finds a variable by name Returns NULL if error. More...
 
NetCdfAttfindAtt (NetCdfVar &var, const Str &name)
 Finds a variable's attribute by name Returns NULL if error. More...
 
const char * status ()
 

Static Public Member Functions

static NetCdfReaderNewNetCdfReader (const char *fileName)
 Returns an newNetCdfReader of a NetCdfReader for a file. More...
 

Protected Member Functions

 NetCdfReader (const char *fileName)
 Protected Constructor. More...
 
bool initialize (const char *fileName)
 Opens a NetCdfReader for a file Returns true if no error. More...
 
- Protected Member Functions inherited from NetCdf
 NetCdf ()
 Protected constructor. More...
 
NetCdfDimfindDim (NetCdfDims &dims, const Str &name)
 Finds a dimension by name in the set of NetCdfDims Returns NULL if error. More...
 
NetCdfAttfindAtt (NetCdfAtts &atts, const Str &name)
 Finds a global attribute by name in the set of NetCdfAtts Returns NULL if error. More...
 
NetCdfVarfindVar (NetCdfVars &vars, const Str &name)
 Finds a variable by name in the set of NetCdfVars Returns NULL if error. More...
 

Protected Attributes

bool ok_
 
- Protected Attributes inherited from NetCdf
int status_
 
int ncId_
 
NetCdfDimArray dimArray_
 
NetCdfDims dims_
 
NetCdfAtts gatts_
 
NetCdfVarArray varArray_
 
NetCdfVars vars_
 

Additional Inherited Members

- Public Types inherited from NetCdf
enum  NetCdfType {
  NC_ABSENT_TYPE = 0, NC_BYTE_TYPE = NC_BYTE, NC_CHAR_TYPE = NC_CHAR, NC_SHORT_TYPE = NC_SHORT,
  NC_INT_TYPE = NC_INT, NC_FLOAT_TYPE = NC_FLOAT, NC_DOUBLE_TYPE = NC_DOUBLE, NC_UBYTE_TYPE = NC_UBYTE,
  NC_USHORT_TYPE = NC_USHORT, NC_UINT_TYPE = NC_UINT, NC_INT64_TYPE = NC_INT64, NC_UINT64_TYPE = NC_UINT64,
  NC_STRING_TYPE = NC_STRING
}
 
typedef FastMap< const Str, NetCdfDim * > NetCdfDims
 
typedef FlexArray< NetCdfDim * > NetCdfDimArray
 
typedef FastMap< const Str, NetCdfAtt * > NetCdfAtts
 
typedef FastMap< const Str, NetCdfVar * > NetCdfVars
 
typedef FlexArray< NetCdfVar * > NetCdfVarArray
 
- Static Public Attributes inherited from NetCdf
static unsigned int NetCdfTypeSize_ [NC_DOUBLE_TYPE+1] = {0, 1, 1, 2, 4, 4, 8 }
 

Detailed Description

A very compact, very simple netCDF reader with a minimal feature set.

Constructor & Destructor Documentation

NetCdfReader::~NetCdfReader ( )
virtual

Destructor.

References NetCdf::ncId_.

NetCdfReader::NetCdfReader ( const char *  fileName)
protected

Protected Constructor.

References initialize(), and ok_.

Referenced by NewNetCdfReader().

Member Function Documentation

bool NetCdfReader::isOk ( ) const
inline

Indicates intialization success.

References ok_.

Referenced by NewNetCdfReader().

bool NetCdfReader::read ( void *  assignTo,
const NetCdfType  assignType,
const NetCdfVar var,
const size_t  indices[] 
)
bool NetCdfReader::read1D ( void *  assignTo,
const NetCdfType  assignType,
const NetCdfVar var,
const unsigned long  index1 
)

Reads the value of the variable at the 1D index as the specified type Returns true if no error.

Reads the value of the variable at the 1D index as the indicated type Returns true if no error.

References read().

Referenced by read1DArray(), and read2D().

bool NetCdfReader::read1DArray ( void *  assignTo,
const NetCdfType  assignType,
const NetCdfVar var,
const unsigned long  index1a,
const unsigned long  index1b 
)

Reads a 1D range of the variable between a pair of indices (a <= index <= b) into an existing 1D array of the specified type Returns true if no error.

Reads a 1D range of the variable between a pair of indices (a <= index <= b) into an existing 1D array of the indicated type Returns true if no error.

References NetCdf::NetCdfTypeSize_, and read1D().

Referenced by EnvSimulator::configureSensors().

bool NetCdfReader::read2D ( void *  assignTo,
const NetCdfType  assignType,
const NetCdfVar var,
const unsigned long  index1,
const unsigned long  index2 
)

Reads the value of the variable at the 2D index as the specified type Returns true if no error.

Reads the value of the variable at the 2D index as the indicated type Returns true if no error.

References NetCdf::NetCdfVar::nDims_, read(), and read1D().

Referenced by read2DArray(), and read3D().

bool NetCdfReader::read2DArray ( void *  assignTo,
const NetCdfType  assignType,
const NetCdfVar var,
const unsigned long  index1a,
const unsigned long  index1b,
const unsigned long  index2a,
const unsigned long  index2b 
)

Reads a 2D range of the variable between 2 pairs of indices (a <= index <= b) into an existing 2D array of the specified type Returns true if no error.

Reads a 2D range of the variable between 2 pairs of indices (a <= index <= b) into an existing 2D array of the indicated type Returns true if no error.

References NetCdf::NetCdfTypeSize_, and read2D().

Referenced by NetCdfReader_Test::testReadFloatVar2DRange().

bool NetCdfReader::read3D ( void *  assignTo,
const NetCdfType  assignType,
const NetCdfVar var,
const unsigned long  index1,
const unsigned long  index2,
const unsigned long  index3 
)

Reads the value of the variable at the 3D index as the specified type Returns true if no error.

Reads the value of the variable at the 3D index as the indicated type Returns true if no error.

References NetCdf::NetCdfVar::nDims_, read(), and read2D().

Referenced by read3DArray(), and read4D().

bool NetCdfReader::read3DArray ( void *  assignTo,
const NetCdfType  assignType,
const NetCdfVar var,
const unsigned long  index1a,
const unsigned long  index1b,
const unsigned long  index2a,
const unsigned long  index2b,
const unsigned long  index3a,
const unsigned long  index3b 
)

Reads a 3D range of the variable between 3 pairs of indices (a <= index <= b) into an existing 3D array of the specified type Returns true if no error.

Reads a 3D range of the variable between 3 pairs of indices (a <= index <= b) into an existing 3D array of the indicated type Returns true if no error.

References NetCdf::NetCdfTypeSize_, and read3D().

bool NetCdfReader::read4D ( void *  assignTo,
const NetCdfType  assignType,
const NetCdfVar var,
const unsigned long  index1,
const unsigned long  index2,
const unsigned long  index3,
const unsigned long  index4 
)

Reads the value of the variable at the 4D index as the specified type Returns true if no error.

Reads the value of the variable at the 4D index as the indicated type Returns true if no error.

References NetCdf::NetCdfVar::nDims_, read(), and read3D().

Referenced by read4DArray().

bool NetCdfReader::read4DArray ( void *  assignTo,
const NetCdfType  assignType,
const NetCdfVar var,
const unsigned long  index1a,
const unsigned long  index1b,
const unsigned long  index2a,
const unsigned long  index2b,
const unsigned long  index3a,
const unsigned long  index3b,
const unsigned long  index4a,
const unsigned long  index4b 
)

Reads a 4D range of the variable between 4 pairs of indices (a <= index <= b) into an existing 3D array of the specified type Returns true if no error.

Reads a 4D range of the variable between 4 pairs of indices (a <= index <= b) into an existing 4D array of the indicated type Returns true if no error.

References NetCdf::NetCdfTypeSize_, and read4D().

Referenced by EnvSimulator::interpolate().

bool NetCdfReader::readStr ( Str assignTo,
const NetCdfAtt att 
)

Reads the value of the attribute as a Str Returns true if no error.

References Str::cStr(), NetCdf::NetCdfAtt::name_, NetCdf::ncId_, NetCdf::NetCdfAtt::nelems_, NetCdf::status_, and NetCdf::NetCdfAtt::varId_.

Member Data Documentation

bool NetCdfReader::ok_
protected

Referenced by initialize(), isOk(), and NetCdfReader().


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