Enumerations | |
enum | Dimensions { firstdimension =mio::MeteoGrids::lastparam+10 , NONE =firstdimension , TIME , LATITUDE , LONGITUDE , NORTHING , EASTING , STATION , STATSTRLEN , DATESTRLEN , ZREF , UREF , lastdimension =UREF } |
This enum expands the parameters given in mio::MeteoGrids::Parameters and adds parameters used as dimensions in NetCDF files. More... | |
Functions | |
std::vector< std::string > | initDimensionNames () |
Set the names of the dimensions. More... | |
const std::vector< std::string > | dimnames (initDimensionNames()) |
void | open_file (const std::string &filename, const int &omode, int &ncid) |
void | create_file (const std::string &filename, const int &cmode, int &ncid) |
void | add_attribute (const int &ncid, const int &varid, const std::string &attr_name, const double &attr_value, const int &data_type) |
Add an attribute to the file pointed to by ncid. More... | |
void | add_attribute (const int &ncid, const int &varid, const std::string &attr_name, const double &attr_value) |
Add an attribute to the file pointed to by ncid. More... | |
void | add_attribute (const int &ncid, const int &varid, const std::string &attr_name, const float &attr_value) |
void | add_attribute (const int &ncid, const int &varid, const std::string &attr_name, const int &attr_value) |
void | add_attribute (const int &ncid, const int &varid, const std::string &attr_name, const std::string &attr_value) |
void | writeACDDAttributes (const int &ncid, const mio::ACDD &acdd) |
Add all the ACDD attributes contained in the acdd object to the file pointed to by ncid. More... | |
bool | check_attribute (const int &ncid, const int &varid, const std::string &attr_name) |
Check if a variable has a given attribute. More... | |
void | overload_attributes (ncpp::nc_variable &var) |
Add attributes to non-standard variables. More... | |
void | create_variable (const int &ncid, ncpp::nc_variable &var) |
Write a pre-defined set of attributes for the given variable. More... | |
void | file_redef (const std::string &filename, const int &ncid) |
Re-open the file in "definition" mode. More... | |
void | end_definitions (const std::string &filename, const int &ncid) |
void | close_file (const std::string &filename, const int &ncid) |
void | read_data (const int &ncid, const nc_variable &var, const size_t &pos, const size_t &nrows, const size_t &ncols, const size_t &pos_i, const size_t &row_i, const size_t &col_i, double *data) |
Read 2D gridded data at the provided time position for a specific variable. More... | |
void | read_data_point (const int &ncid, const nc_variable &var, const size_t &row, const size_t &col, const size_t &row_i, const size_t &col_i, double *data) |
Read grid point in 2D gridded data for non time dependent data. More... | |
void | read_data_point (const int &ncid, const nc_variable &var, const size_t &pos, const size_t &row, const size_t &col, const size_t &pos_i, const size_t &row_i, const size_t &col_i, double *data) |
Read grid point in 2D gridded data at the provided time position for a specific variable. More... | |
void | read_data (const int &ncid, const nc_variable &var, double *data) |
Read all the data for a specific variable. More... | |
void | read_data (const int &ncid, const nc_variable &var, int *data) |
Read all the data for a specific variable. More... | |
void | readVariableMetadata (const int &ncid, ncpp::nc_variable &var, const bool &readTimeTransform, const double &TZ) |
Read a pre-defined set of attributes for the given variable, from the provided file. More... | |
void | write_data (const int &ncid, const nc_variable &var, const size_t &pos, const size_t &nrows, const size_t &ncols, const double *const data) |
Write 2D gridded data at the provided time position for a specific variable. More... | |
void | write_1Ddata (const int &ncid, const nc_variable &var, const std::vector< double > &data, const bool &isUnlimited) |
Write a vector of data for a given 1D variable. More... | |
void | write_1Ddata (const int &ncid, const nc_variable &var, const std::vector< std::string > &data, const int &strMaxLen) |
Write a vector of strings for a given 1D variable. More... | |
void | getAttribute (const int &ncid, const nc_variable &var, const std::string &attr_name, std::string &attr_value) |
Read a given attribute from a variable (if not found, an empty string is returned) More... | |
void | getAttribute (const int &ncid, const nc_variable &var, const std::string &attr_name, double &attr_value) |
Read a given attribute from a variable (if not found, attr_value is left unchanged) More... | |
void | getGlobalAttribute (const int &ncid, const std::string &attr_name, std::string &attr_value) |
Read a given global attribute (if not found, an empty string is returned) More... | |
void | getGlobalAttribute (const int &ncid, const std::string &attr_name, int &attr_value) |
void | getTimeTransform (const std::string &time_units, const double &i_TZ, double &o_time_offset, double &o_time_divisor) |
Parse a time unit specification. More... | |
void | createDimension (const int &ncid, ncpp::nc_dimension &dimension, const size_t &length) |
Create a new dimension. More... | |
void | fill2DGrid (mio::Grid2DObject &grid, const double data[], const double &nodata, const bool &normal_Xorder, const bool &normal_Yorder) |
Fill a Grid2DObject with 2D gridded data as read from a NetCDF file. More... | |
std::string | getParameterName (const size_t ¶m) |
Given a parameter index, return its associated name. More... | |
std::string | getParameterDescription (const size_t ¶m) |
std::string | getParameterUnits (const size_t ¶m) |
size_t | getParameterIndex (const std::string ¶m) |
Given a parameter name, return its associated index. More... | |
std::string | generateHistoryAttribute () |
Build a CF-1 history string (date of creation, creator, software version) More... | |
void | createDimension (const int &ncid, nc_dimension &dimension, const size_t &length) |
enum ncpp::Dimensions |
This enum expands the parameters given in mio::MeteoGrids::Parameters and adds parameters used as dimensions in NetCDF files.
Enumerator | |
---|---|
firstdimension | |
NONE | |
TIME | |
LATITUDE | |
LONGITUDE | |
NORTHING | |
EASTING | |
STATION | |
STATSTRLEN | |
DATESTRLEN | |
ZREF | |
UREF | |
lastdimension |
void ncpp::add_attribute | ( | const int & | ncid, |
const int & | varid, | ||
const std::string & | attr_name, | ||
const double & | attr_value | ||
) |
Add an attribute to the file pointed to by ncid.
In the target NetCDF file, the attribute will have the same type as the provided attribute value argument provided in this call
[in] | ncid | file ID |
[in] | varid | ID of the variable this attribute belongs to |
[in] | attr_name | name of the attribute |
[in] | attr_value | value of the attribute |
void ncpp::add_attribute | ( | const int & | ncid, |
const int & | varid, | ||
const std::string & | attr_name, | ||
const double & | attr_value, | ||
const int & | data_type | ||
) |
Add an attribute to the file pointed to by ncid.
The provided attribute value will be casted to the data type that is provided as argument.
[in] | ncid | file ID |
[in] | varid | ID of the variable this attribute belongs to |
[in] | attr_name | name of the attribute |
[in] | attr_value | value of the attribute (represented as a double) |
[in] | data_type | data type to cast the value to (according to NetCDF's external data types) |
void ncpp::add_attribute | ( | const int & | ncid, |
const int & | varid, | ||
const std::string & | attr_name, | ||
const float & | attr_value | ||
) |
void ncpp::add_attribute | ( | const int & | ncid, |
const int & | varid, | ||
const std::string & | attr_name, | ||
const int & | attr_value | ||
) |
void ncpp::add_attribute | ( | const int & | ncid, |
const int & | varid, | ||
const std::string & | attr_name, | ||
const std::string & | attr_value | ||
) |
bool ncpp::check_attribute | ( | const int & | ncid, |
const int & | varid, | ||
const std::string & | attr_name | ||
) |
Check if a variable has a given attribute.
[in] | ncid | file ID |
[in] | varid | ID of the variable those attributes should be checked |
[in] | attr_name | name of the attribute to check |
void ncpp::close_file | ( | const std::string & | filename, |
const int & | ncid | ||
) |
void ncpp::create_file | ( | const std::string & | filename, |
const int & | cmode, | ||
int & | ncid | ||
) |
void ncpp::create_variable | ( | const int & | ncid, |
ncpp::nc_variable & | var | ||
) |
Write a pre-defined set of attributes for the given variable.
Please note that during this call, a variable will be created, therefore the nc_variable structure will get a positive varid. If the variable already exists, it will return without doing anything.
[in] | ncid | file ID |
[in,out] | var | variable whose attributes should be set. |
void ncpp::createDimension | ( | const int & | ncid, |
nc_dimension & | dimension, | ||
const size_t & | length | ||
) |
void ncpp::createDimension | ( | const int & | ncid, |
ncpp::nc_dimension & | dimension, | ||
const size_t & | length | ||
) |
Create a new dimension.
If the requested dimension already exists, nothing is done
[in] | ncid | file ID |
[in] | dimension | dimension to create |
[in] | length | length to set for this dimension (for the unlimited dimension, this will be ignored) |
const std::vector< std::string > ncpp::dimnames | ( | initDimensionNames() | ) |
void ncpp::end_definitions | ( | const std::string & | filename, |
const int & | ncid | ||
) |
void ncpp::file_redef | ( | const std::string & | filename, |
const int & | ncid | ||
) |
Re-open the file in "definition" mode.
[in] | filename | filename to use when reporting errors |
[in] | ncid | file ID |
void ncpp::fill2DGrid | ( | mio::Grid2DObject & | grid, |
const double | data[], | ||
const double & | nodata, | ||
const bool & | normal_Xorder, | ||
const bool & | normal_Yorder | ||
) |
Fill a Grid2DObject with 2D gridded data as read from a NetCDF file.
The provided Grid2DObject must have been properly initialized before (ie proper Nx, Ny). Grids whose llcorner/urcorner have been reversed are properly handled by providing the normal_Xorder and/or normal_Yorder booleans (as well as any combination).
[out] | grid | grid to populate |
[in] | data | serialized data, as read from the NetCDF file |
[in] | nodata | value that indicates nodata |
[in] | normal_Xorder | set to false if the X coordinate is reversed |
[in] | normal_Yorder | set to false if the Y coordinate is reversed |
std::string ncpp::generateHistoryAttribute | ( | ) |
Build a CF-1 history string (date of creation, creator, software version)
void ncpp::getAttribute | ( | const int & | ncid, |
const nc_variable & | var, | ||
const std::string & | attr_name, | ||
double & | attr_value | ||
) |
Read a given attribute from a variable (if not found, attr_value is left unchanged)
[in] | ncid | file ID |
[in] | var | variable properties |
[in] | attr_name | attribute name |
[out] | attr_value | attribute value as read |
void ncpp::getAttribute | ( | const int & | ncid, |
const nc_variable & | var, | ||
const std::string & | attr_name, | ||
std::string & | attr_value | ||
) |
Read a given attribute from a variable (if not found, an empty string is returned)
[in] | ncid | file ID |
[in] | var | variable properties |
[in] | attr_name | attribute name |
[out] | attr_value | attribute value as read |
void ncpp::getGlobalAttribute | ( | const int & | ncid, |
const std::string & | attr_name, | ||
int & | attr_value | ||
) |
void ncpp::getGlobalAttribute | ( | const int & | ncid, |
const std::string & | attr_name, | ||
std::string & | attr_value | ||
) |
Read a given global attribute (if not found, an empty string is returned)
[in] | ncid | file ID |
[in] | attr_name | attribute name |
[out] | attr_value | attribute value as read |
std::string ncpp::getParameterDescription | ( | const size_t & | param | ) |
size_t ncpp::getParameterIndex | ( | const std::string & | param | ) |
Given a parameter name, return its associated index.
Since the MeteoGrids::Parameters have been extended inncpp, this method had to be redefined.
[in] | param | parameter name to get the index for |
std::string ncpp::getParameterName | ( | const size_t & | param | ) |
Given a parameter index, return its associated name.
Since the MeteoGrids::Parameters have been extended inncpp, this method had to be redefined.
[in] | param | parameter index to get the name for |
std::string ncpp::getParameterUnits | ( | const size_t & | param | ) |
void ncpp::getTimeTransform | ( | const std::string & | time_units, |
const double & | i_TZ, | ||
double & | o_time_offset, | ||
double & | o_time_divisor | ||
) |
Parse a time unit specification.
Time is often defined as a number of intervals (hours, seconds, etc) from a reference date. This call parses such as specification string and return the necessary offset and multiplier compared to julian date.
[in] | time_units | time specification string |
[in] | i_TZ | timezone to use to interpret the reference date |
[out] | o_time_offset | offset to apply to convert the packed values to julian date |
[out] | o_time_divisor | multiplier to apply to convert the packed values to julian date |
|
inline |
Set the names of the dimensions.
void ncpp::open_file | ( | const std::string & | filename, |
const int & | omode, | ||
int & | ncid | ||
) |
|
inline |
Add attributes to non-standard variables.
[in,out] | var | variable whose attributes should be set. |
void ncpp::read_data | ( | const int & | ncid, |
const nc_variable & | var, | ||
const size_t & | pos, | ||
const size_t & | nrows, | ||
const size_t & | ncols, | ||
const size_t & | pos_i, | ||
const size_t & | row_i, | ||
const size_t & | col_i, | ||
double * | data | ||
) |
Read 2D gridded data at the provided time position for a specific variable.
[in] | ncid | file ID |
[in] | var | variable to read |
[in] | pos | time index in the file |
[in] | nrows | number of rows |
[in] | ncols | number of columns |
[in] | pos_i | dimension index of time |
[in] | row_i | dimension index of the rows |
[in] | col_i | dimension index of the columns |
[out] | data | data extracted from the file |
void ncpp::read_data | ( | const int & | ncid, |
const nc_variable & | var, | ||
double * | data | ||
) |
Read all the data for a specific variable.
[in] | ncid | file ID |
[in] | var | variable to read |
[out] | data | data extracted from the file |
void ncpp::read_data | ( | const int & | ncid, |
const nc_variable & | var, | ||
int * | data | ||
) |
Read all the data for a specific variable.
[in] | ncid | file ID |
[in] | var | variable to read |
[out] | data | data extracted from the file |
void ncpp::read_data_point | ( | const int & | ncid, |
const nc_variable & | var, | ||
const size_t & | pos, | ||
const size_t & | row, | ||
const size_t & | col, | ||
const size_t & | pos_i, | ||
const size_t & | row_i, | ||
const size_t & | col_i, | ||
double * | data | ||
) |
Read grid point in 2D gridded data at the provided time position for a specific variable.
[in] | ncid | file ID |
[in] | var | variable to read |
[in] | pos | time index in the file |
[in] | row | row index to read |
[in] | col | column index to read |
[in] | pos_i | dimension index of time |
[in] | row_i | dimension index of the rows |
[in] | col_i | dimension index of the columns |
[out] | data | data extracted from the file |
void ncpp::read_data_point | ( | const int & | ncid, |
const nc_variable & | var, | ||
const size_t & | row, | ||
const size_t & | col, | ||
const size_t & | row_i, | ||
const size_t & | col_i, | ||
double * | data | ||
) |
Read grid point in 2D gridded data for non time dependent data.
[in] | ncid | file ID |
[in] | var | variable to read |
[in] | row | row index to read |
[in] | col | column index to read |
[in] | row_i | dimension index of the rows |
[in] | col_i | dimension index of the columns |
[out] | data | data extracted from the file |
void ncpp::readVariableMetadata | ( | const int & | ncid, |
ncpp::nc_variable & | var, | ||
const bool & | readTimeTransform, | ||
const double & | TZ | ||
) |
Read a pre-defined set of attributes for the given variable, from the provided file.
Please note that during this call, the nc_variable structure will get a positive varid. If any of the predefined set of attribute does not exist, it will be silently skipped. The attributes structure of the variable var will then be populated by what has been read.
[in] | ncid | file ID |
[in,out] | var | variable whose attributes should be read. |
[in] | readTimeTransform | should the time-parsing arguments (offset and scale from a reference date and units) be read? default=false |
[in] | TZ | timezone to use when/if reading a date |
void ncpp::write_1Ddata | ( | const int & | ncid, |
const nc_variable & | var, | ||
const std::vector< double > & | data, | ||
const bool & | isUnlimited | ||
) |
Write a vector of data for a given 1D variable.
[in] | ncid | file ID |
[in] | var | variable to write out |
[in] | data | vector that has to be written |
[in] | isUnlimited | Is the variable the associated variable of an unlimited dimension? (default: false) |
void ncpp::write_1Ddata | ( | const int & | ncid, |
const nc_variable & | var, | ||
const std::vector< std::string > & | data, | ||
const int & | strMaxLen | ||
) |
Write a vector of strings for a given 1D variable.
[in] | ncid | file ID |
[in] | var | variable properties |
[in] | data | vector that has to be written |
[in] | strMaxLen | maximum length of the strings in the vector (this MUST have been defined as a dimension before) |
void ncpp::write_data | ( | const int & | ncid, |
const nc_variable & | var, | ||
const size_t & | pos, | ||
const size_t & | nrows, | ||
const size_t & | ncols, | ||
const double *const | data | ||
) |
Write 2D gridded data at the provided time position for a specific variable.
[in] | ncid | file ID |
[in] | var | variable to write out |
[in] | nrows | number of rows |
[in] | ncols | number of columns |
[in] | pos | time index in the file (IOUtils::npos for a variable that is not time dependent) |
[in] | data | data to write to the file |
void ncpp::writeACDDAttributes | ( | const int & | ncid, |
const mio::ACDD & | acdd | ||
) |
Add all the ACDD attributes contained in the acdd object to the file pointed to by ncid.
[in] | ncid | file ID |
[in] | acdd | ACDD object containing all ACDD attributes (only those that have a value will be written) |