LRAUV  revA
NetCdfWriter Class Reference

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

#include <NetCdfWriter.h>

Inheritance diagram for NetCdfWriter:
Collaboration diagram for NetCdfWriter:

Public Types

typedef FastMap< const Str, NetCdfGroup * > NetCdfGroups
 
- 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
 

Public Member Functions

virtual ~NetCdfWriter ()
 Destructor. More...
 
bool isOk () const
 Indicates intialization success. More...
 
const NetCdfAttaddGlobalAtt (const Str &name, const Str &value)
 
const NetCdfAttaddGlobalAtt (const Str &name, const unsigned char value)
 
const NetCdfAttaddGlobalAtt (const Str &name, const short value)
 
const NetCdfAttaddGlobalAtt (const Str &name, const int value)
 
const NetCdfAttaddGlobalAtt (const Str &name, const float value)
 
const NetCdfAttaddGlobalAtt (const Str &name, const double value)
 
const NetCdfDim * addDim (const Str &name, const unsigned int dimSize)
 
NetCdfVaraddVar (const Str &name, const NetCdfType netCdfType, const NetCdfDim *dimTime=NULL, const NetCdfDim *dimM=NULL, const NetCdfDim *dimN=NULL, const NetCdfDim *dimO=NULL)
 
NetCdfVaraddStaticVar (const Str &name, const NetCdfType netCdfType, const NetCdfDim *dim=NULL)
 
const NetCdfAttaddVarAtt (NetCdfVar *netCdfVar, const Str &name, const Str &value)
 
const NetCdfAttaddVarAtt (NetCdfVar *netCdfVar, const Str &name, unsigned char value)
 
const NetCdfAttaddVarAtt (NetCdfVar *netCdfVar, const Str &name, const int value)
 
const NetCdfAttaddVarAtt (NetCdfVar *netCdfVar, const Str &name, const float value)
 
const NetCdfAttaddVarAtt (NetCdfVar *netCdfVar, const Str &name, const double value)
 
void setAttValue (const NetCdfAtt *netCdfAtt, const Str &value)
 
void setAttValue (const NetCdfAtt *netCdfAtt, const unsigned char value)
 
void setAttValue (const NetCdfAtt *netCdfAtt, const int value)
 
void setAttValue (const NetCdfAtt *netCdfAtt, const float value)
 
void setAttValue (const NetCdfAtt *netCdfAtt, const double value)
 
NetCdfGroupaddGroup (const Str &name)
 
NetCdfGroupfindGroup (const Str &name)
 
bool initialize ()
 Opens a NetCdfWriter for a file Returns true if no error. More...
 
bool writeRecord (Timestamp &timestamp)
 Write all the variables. More...
 
bool writeVarRecord (NetCdfVar *netCdfVar, const ElementURI *uri=NULL)
 Just write the specified variable. More...
 
bool finalize ()
 Set the number of records in the file header 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 NetCdfWriterNewNetCdfWriter (const char *fileName, bool version4, const char *trajectoryName="LRAUVTrajectory")
 Returns an newNetCdfWriter of a NetCdfWriter for a file. More...
 

Protected Member Functions

 NetCdfWriter (const char *filename, bool version4, const char *trajectoryName)
 Protected Constructor. More...
 
 NetCdfWriter (const char *name, int parentNcId)
 Protected group Constructor. More...
 
const NetCdfAttaddAtt (NetCdfAtts &atts, int varId, const Str &name, const Str &value)
 
const NetCdfAttaddAtt (NetCdfAtts &atts, int varId, const Str &name, const unsigned char value)
 
const NetCdfAttaddAtt (NetCdfAtts &atts, int varId, const Str &name, const short value)
 
const NetCdfAttaddAtt (NetCdfAtts &atts, int varId, const Str &name, const int value)
 
const NetCdfAttaddAtt (NetCdfAtts &atts, int varId, const Str &name, const float value)
 
const NetCdfAttaddAtt (NetCdfAtts &atts, int varId, const Str &name, const double value)
 
int putValue (NetCdfVar *netCdfVar, size_t index[], double value)
 Used by writeVarRecord to put a value in the variable. 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_
 
Str filename_
 
unsigned int numRecs_
 
bool initialized_
 
bool finalized_
 
const char * trajectoryName_
 
bool version4_
 
const NetCdfDim * trajectoryLenDim_
 
NetCdfVartrajectoryVar_
 
const NetCdfDim * timeDim_
 
NetCdfVartimeVar_
 
unsigned long long currentLocation_
 
NetCdfGroups groups_
 
- Protected Attributes inherited from NetCdf
int status_
 
int ncId_
 
NetCdfDimArray dimArray_
 
NetCdfDims dims_
 
NetCdfAtts gatts_
 
NetCdfVarArray varArray_
 
NetCdfVars vars_
 

Private Member Functions

 NetCdfWriter (const NetCdfWriter &old)
 

Additional Inherited Members

- 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 writer with a minimal feature set.

It is intended for writing a set of record variables to a file, sequentially as time increases. (No provision for large, multidimensional arrays, etc.)

Member Typedef Documentation

Constructor & Destructor Documentation

NetCdfWriter::~NetCdfWriter ( )
virtual

Destructor.

References FastMap< S, T >::clear(), finalize(), and groups_.

NetCdfWriter::NetCdfWriter ( const char *  filename,
bool  version4,
const char *  trajectoryName 
)
protected
NetCdfWriter::NetCdfWriter ( const char *  name,
int  parentNcId 
)
protected

Protected group Constructor.

References NetCdf::ncId_, ok_, and NetCdf::status_.

NetCdfWriter::NetCdfWriter ( const NetCdfWriter old)
private

Member Function Documentation

const NetCdf::NetCdfAtt * NetCdfWriter::addAtt ( NetCdfAtts atts,
int  varId,
const Str name,
const unsigned char  value 
)
protected
const NetCdf::NetCdfDim * NetCdfWriter::addDim ( const Str name,
const unsigned int  dimSize 
)
const NetCdf::NetCdfAtt * NetCdfWriter::addGlobalAtt ( const Str name,
const Str value 
)
const NetCdf::NetCdfAtt * NetCdfWriter::addGlobalAtt ( const Str name,
const unsigned char  value 
)

References addAtt(), and NetCdf::gatts_.

const NetCdf::NetCdfAtt * NetCdfWriter::addGlobalAtt ( const Str name,
const short  value 
)

References addAtt(), and NetCdf::gatts_.

const NetCdf::NetCdfAtt * NetCdfWriter::addGlobalAtt ( const Str name,
const int  value 
)

References addAtt(), and NetCdf::gatts_.

const NetCdf::NetCdfAtt * NetCdfWriter::addGlobalAtt ( const Str name,
const float  value 
)

References addAtt(), and NetCdf::gatts_.

const NetCdf::NetCdfAtt * NetCdfWriter::addGlobalAtt ( const Str name,
const double  value 
)

References addAtt(), and NetCdf::gatts_.

NetCdfGroup * NetCdfWriter::addGroup ( const Str name)
const NetCdf::NetCdfAtt * NetCdfWriter::addVarAtt ( NetCdfVar netCdfVar,
const Str name,
const Str value 
)
const NetCdf::NetCdfAtt * NetCdfWriter::addVarAtt ( NetCdfVar netCdfVar,
const Str name,
unsigned char  value 
)
const NetCdf::NetCdfAtt * NetCdfWriter::addVarAtt ( NetCdfVar netCdfVar,
const Str name,
const int  value 
)
const NetCdf::NetCdfAtt * NetCdfWriter::addVarAtt ( NetCdfVar netCdfVar,
const Str name,
const float  value 
)
const NetCdf::NetCdfAtt * NetCdfWriter::addVarAtt ( NetCdfVar netCdfVar,
const Str name,
const double  value 
)
bool NetCdfWriter::finalize ( )

Set the number of records in the file header Returns true if no error.

References finalized_, NetCdf::ncId_, ok_, and NetCdf::status_.

Referenced by NetCdfLogWriter::writeFooter(), NetCdfTableLogWriter::writeFooter(), and ~NetCdfWriter().

NetCdfGroup * NetCdfWriter::findGroup ( const Str name)

References FastMap< S, T >::get(), and groups_.

Referenced by addGroup().

bool NetCdfWriter::isOk ( ) const
inline

Indicates intialization success.

References ok_.

Referenced by NewNetCdfWriter().

NetCdfWriter * NetCdfWriter::NewNetCdfWriter ( const char *  fileName,
bool  version4,
const char *  trajectoryName = "LRAUVTrajectory" 
)
static

Returns an newNetCdfWriter of a NetCdfWriter for a file.

References isOk(), NetCdfWriter(), and NetCdf::status().

int NetCdfWriter::putValue ( NetCdfVar netCdfVar,
size_t  index[],
double  value 
)
protected
void NetCdfWriter::setAttValue ( const NetCdfAtt netCdfAtt,
const Str value 
)
void NetCdfWriter::setAttValue ( const NetCdfAtt netCdfAtt,
const unsigned char  value 
)
void NetCdfWriter::setAttValue ( const NetCdfAtt netCdfAtt,
const int  value 
)
void NetCdfWriter::setAttValue ( const NetCdfAtt netCdfAtt,
const float  value 
)
void NetCdfWriter::setAttValue ( const NetCdfAtt netCdfAtt,
const double  value 
)

Member Data Documentation

unsigned long long NetCdfWriter::currentLocation_
protected
Str NetCdfWriter::filename_
protected
bool NetCdfWriter::finalized_
protected

Referenced by finalize().

NetCdfGroups NetCdfWriter::groups_
protected
bool NetCdfWriter::initialized_
protected

Referenced by initialize().

unsigned int NetCdfWriter::numRecs_
protected

Referenced by writeRecord().

const NetCdfDim* NetCdfWriter::timeDim_
protected

Referenced by addVar(), and NetCdfWriter().

NetCdfVar* NetCdfWriter::timeVar_
protected

Referenced by NetCdfWriter(), and writeRecord().

const NetCdfDim* NetCdfWriter::trajectoryLenDim_
protected

Referenced by NetCdfWriter().

const char* NetCdfWriter::trajectoryName_
protected

Referenced by initialize().

NetCdfVar* NetCdfWriter::trajectoryVar_
protected

Referenced by initialize(), and NetCdfWriter().

bool NetCdfWriter::version4_
protected

Referenced by addVar().


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