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 GetVarsNb ()
 
int GetVarId (const string &varName)
 
string GetVarName (int varId)
 
vecInt GetVarDimIds (int varId, int dimNb)
 
int DefDim (const string &dimName, int length)
 
int GetDimId (const string &dimName)
 
int GetDimLen (const string &dimName)
 
int DefVarInt (const string &varName, vecInt dimIds, int dimsNb=1, bool compress=false)
 
int DefVarFloat (const string &varName, vecInt dimIds, int dimsNb=1, bool compress=false)
 
int DefVarDouble (const string &varName, vecInt dimIds, int dimsNb=1, bool compress=false)
 
vecInt GetVarInt1D (const string &varName, int size)
 
vecFloat GetVarFloat1D (const string &varName, int size)
 
vecDouble GetVarDouble1D (const string &varName, int size)
 
axxd GetVarDouble2D (int varId, int rows, int cols)
 
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)
 
bool HasAtt (const string &attName, const string &varName="")
 
vecStr GetAttString1D (const string &attName, const string &varName="")
 
void PutAttString (const string &attName, const vecStr &values, int varId=NC_GLOBAL)
 
string GetAttText (const string &attName, const string &varName="")
 
void PutAttText (const string &attName, const string &value, int varId=NC_GLOBAL)
 

Protected Attributes

int m_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  dimsNb = 1,
bool  compress = false 
)

Define a new double variable.

Parameters
varNameName of the new variable.
dimIdsThe corresponding dimension ids.
dimsNbThe 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  dimsNb = 1,
bool  compress = false 
)

Define a new float variable.

Parameters
varNameName of the new variable.
dimIdsThe corresponding dimension ids.
dimsNbThe 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  dimsNb = 1,
bool  compress = false 
)

Define a new integer variable.

Parameters
varNameName of the new variable.
dimIdsThe corresponding dimension ids.
dimsNbThe 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 = "" 
)

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 = "" 
)

Get a string stored as an attribute.

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

◆ GetDimId()

int FileNetcdf::GetDimId ( const string &  dimName)

Get the dimension id corresponding to the provided name.

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

◆ GetDimLen()

int FileNetcdf::GetDimLen ( const string &  dimName)

Get the length of a dimension.

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

◆ GetVarDimIds()

vecInt FileNetcdf::GetVarDimIds ( int  varId,
int  dimNb 
)

Get the dimension ids of the provided variable.

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

◆ GetVarDouble1D()

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

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 
)

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 
)

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.

◆ GetVarId()

int FileNetcdf::GetVarId ( const string &  varName)

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 
)

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)

Get the variable name corresponding to the provided id.

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

◆ GetVarsNb()

int FileNetcdf::GetVarsNb ( )

Get the number of variables in the file.

Returns
The number of variables in the file.

◆ HasAtt()

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

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)

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: