hydrobricks
Loading...
Searching...
No Matches
FileNetcdf Class Reference
Inheritance diagram for FileNetcdf:

Public Member Functions

bool OpenReadOnly (const string &path)
 
bool Create (const string &path)
 
void Close ()
 
int GetVariableCount () const
 
int GetVarId (const string &varName) const
 
string GetVarName (int varId) const
 
vecInt GetVarDimIds (int varId, int dimCount) const
 
int DefDim (const string &dimName, int length)
 
int GetDimId (const string &dimName) const
 
int GetDimLen (const string &dimName) const
 
int DefVarInt (const string &varName, vecInt dimIds, int dimCount=1, bool compress=false)
 
int DefVarFloat (const string &varName, vecInt dimIds, int dimCount=1, bool compress=false)
 
int DefVarDouble (const string &varName, vecInt dimIds, int dimCount=1, bool compress=false)
 
vecInt GetVarInt1D (const string &varName, int size) const
 
vecFloat GetVarFloat1D (const string &varName, int size) const
 
vecDouble GetVarDouble1D (const string &varName, int size) const
 
axxd GetVarDouble2D (int varId, int rows, int cols) const
 
void PutVar (int varId, const vecInt &values)
 
void PutVar (int varId, const vecFloat &values)
 
void PutVar (int varId, const vecDouble &values)
 
void PutVar (int varId, const axd &values)
 
void PutVar (int varId, const vecAxd &values)
 
void PutVar (int varId, const vecAxxd &values)
 
bool HasVar (const string &varName) const
 
bool HasAtt (const string &attName, const string &varName="") const
 
vecStr GetAttString1D (const string &attName, const string &varName="") const
 
void PutAttString (const string &attName, const vecStr &values, int varId=NC_GLOBAL)
 
string GetAttText (const string &attName, const string &varName="") const
 
void PutAttText (const string &attName, const string &value, int varId=NC_GLOBAL)
 

Protected Attributes

int _ncId
 

Member Function Documentation

◆ Close()

void FileNetcdf::Close ( )

Close the NetCDF file. Not mandatory as the file is closed in the destructor if still opened.

◆ Create()

bool FileNetcdf::Create ( const string & path)

Create a NetCDF file at the given path.

Parameters
pathPath of the file to be created.
Returns
True if successful, false otherwise.

◆ DefDim()

int FileNetcdf::DefDim ( const string & dimName,
int length )

Define a new dimension.

Parameters
dimNameName of the new dimension.
lengthLength of the new dimension.
Returns
The new dimension id.

◆ DefVarDouble()

int FileNetcdf::DefVarDouble ( const string & varName,
vecInt dimIds,
int dimCount = 1,
bool compress = false )

Define a new double variable.

Parameters
varNameName of the new variable.
dimIdsThe corresponding dimension ids.
dimCountThe number of corresponding dimensions.
compressOption to compress the variable values (default: false).
Returns
The new variable id.

◆ DefVarFloat()

int FileNetcdf::DefVarFloat ( const string & varName,
vecInt dimIds,
int dimCount = 1,
bool compress = false )

Define a new float variable.

Parameters
varNameName of the new variable.
dimIdsThe corresponding dimension ids.
dimCountThe number of corresponding dimensions.
compressOption to compress the variable values (default: false).
Returns
The new variable id.

◆ DefVarInt()

int FileNetcdf::DefVarInt ( const string & varName,
vecInt dimIds,
int dimCount = 1,
bool compress = false )

Define a new integer variable.

Parameters
varNameName of the new variable.
dimIdsThe corresponding dimension ids.
dimCountThe number of corresponding dimensions.
compressOption to compress the variable values (default: false).
Returns
The new variable id.

◆ GetAttString1D()

vecStr FileNetcdf::GetAttString1D ( const string & attName,
const string & varName = "" ) const

Get a string vector stored as an attribute.

Parameters
attNameThe attribute name.
varNameThe variable name. If empty, search in the global attributes.
Returns
A string vector containing the data.

◆ GetAttText()

string FileNetcdf::GetAttText ( const string & attName,
const string & varName = "" ) const

Get a text attribute.

Parameters
attNameThe name of the attribute.
varNameThe name of the variable (empty for global attribute).
Returns
The value of the attribute.

◆ GetDimId()

int FileNetcdf::GetDimId ( const string & dimName) const

Get a dimension ID.

Parameters
dimNameThe dimension name of interest.
Returns
The id of the requested dimension.

◆ GetDimLen()

int FileNetcdf::GetDimLen ( const string & dimName) const

Get a dimension length.

Parameters
dimNameThe name of the dimension.
Returns
The length of the dimension.

◆ GetVarDimIds()

vecInt FileNetcdf::GetVarDimIds ( int varId,
int dimCount ) const

Get the dimension ids of the provided variable.

Parameters
varIdThe id of the variable of interest.
dimCountThe number of dimensions of the variable.
Returns
A vector of the dimension ids.

◆ GetVarDouble1D()

vecDouble FileNetcdf::GetVarDouble1D ( const string & varName,
int size ) const

Get the values of a 1D double variable. The whole vector retrieved at once.

Parameters
varNameThe name of the variable of interest.
sizeThe size of the data vector.
Returns
A vector containing the data.

◆ GetVarDouble2D()

axxd FileNetcdf::GetVarDouble2D ( int varId,
int rows,
int cols ) const

Get values of a 2D double variable. The whole array retrieved at once.

Parameters
varIdThe id of the variable of interest.
rowsThe number of rows of the data array.
colsThe number of columns of the data array.
Returns
An array containing the data.

◆ GetVarFloat1D()

vecFloat FileNetcdf::GetVarFloat1D ( const string & varName,
int size ) const

Get the values of a 1D float variable. The whole vector retrieved at once.

Parameters
varNameThe name of the variable of interest.
sizeThe size of the data vector.
Returns
A vector containing the data.

◆ GetVariableCount()

int FileNetcdf::GetVariableCount ( ) const

Get the number of variables in the file.

Returns
the number of variables.

◆ GetVarId()

int FileNetcdf::GetVarId ( const string & varName) const

Get the variable id corresponding to the provided name.

Parameters
varNameThe name of the variable of interest.
Returns
The id of the requested variable.

◆ GetVarInt1D()

vecInt FileNetcdf::GetVarInt1D ( const string & varName,
int size ) const

Get the values of a 1D integer variable. The whole vector retrieved at once.

Parameters
varNameThe name of the variable of interest.
sizeThe size of the data vector.
Returns
A vector containing the data.

◆ GetVarName()

string FileNetcdf::GetVarName ( int varId) const

Get the variable name corresponding to the provided id.

Parameters
varIdThe id of the variable of interest.
Returns
The name of the requested variable.

◆ HasAtt()

bool FileNetcdf::HasAtt ( const string & attName,
const string & varName = "" ) const

Check if an attribute exists.

Parameters
attNameThe attribute name.
varNameThe variable name. If empty, search in the global attributes.
Returns
True if the attribute exists, false otherwise.

◆ HasVar()

bool FileNetcdf::HasVar ( const string & varName) const

Check if a variable exists.

Parameters
varNameThe variable name.
Returns
True if the attribute exists, false otherwise.

◆ OpenReadOnly()

bool FileNetcdf::OpenReadOnly ( const string & path)

Open a NetCDF file as read only.

Parameters
pathPath of the existing file.
Returns
True if successful, false otherwise

◆ PutAttString()

void FileNetcdf::PutAttString ( const string & attName,
const vecStr & values,
int varId = NC_GLOBAL )

Store a string vector as an attribute.

Parameters
attNameThe attribute name.
valuesA string vector containing the data.
varIdThe variable id. If empty, search in the global attributes.

◆ PutAttText()

void FileNetcdf::PutAttText ( const string & attName,
const string & value,
int varId = NC_GLOBAL )

Store a string as an attribute.

Parameters
attNameThe attribute name.
valueThe string to store.
varIdThe variable id. If empty, search in the global attributes.

◆ PutVar() [1/6]

void FileNetcdf::PutVar ( int varId,
const axd & values )

Set the variable values from a 1D array of doubles.

Parameters
varIdThe id of the variable of interest.
valuesThe data to store.

◆ PutVar() [2/6]

void FileNetcdf::PutVar ( int varId,
const vecAxd & values )

Set the variable values from a vector of 1D arrays of doubles.

Parameters
varIdThe id of the variable of interest.
valuesThe data to store.

◆ PutVar() [3/6]

void FileNetcdf::PutVar ( int varId,
const vecAxxd & values )

Set the variable values from a vector of 2D arrays of doubles.

Parameters
varIdThe id of the variable of interest.
valuesThe data to store.

◆ PutVar() [4/6]

void FileNetcdf::PutVar ( int varId,
const vecDouble & values )

Set the variable values from a vector of doubles.

Parameters
varIdThe id of the variable of interest.
valuesThe data to store.

◆ PutVar() [5/6]

void FileNetcdf::PutVar ( int varId,
const vecFloat & values )

Set the variable values from a vector of floats.

Parameters
varIdThe id of the variable of interest.
valuesThe data to store.

◆ PutVar() [6/6]

void FileNetcdf::PutVar ( int varId,
const vecInt & values )

Set the variable values from a vector of integers.

Parameters
varIdThe id of the variable of interest.
valuesThe data to store.

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