#include <fimex/CDM.h>
Public Types | |
typedef std::vector< CDMAttribute > | AttrVec |
typedef std::map< std::string, AttrVec > | StrAttrVecMap |
typedef std::vector< CDMDimension > | DimVec |
typedef std::vector< CDMVariable > | VarVec |
Public Member Functions | |
CDM () | |
CDM (const CDM &rhs) | |
virtual | ~CDM () |
CDM & | operator= (const CDM &rhs) |
void | addVariable (const CDMVariable &var) throw (CDMException) |
add variable to cdm | |
CDMVariable & | getVariable (const std::string &varName) throw (CDMException) |
get a reference of a variable | |
const CDMVariable & | getVariable (const std::string &varName) const throw (CDMException) |
get a reference of a variable | |
bool | hasVariable (const std::string &varName) const |
test if variable exists | |
std::vector< std::string > | findVariables (const std::string &attrName, const std::string &attrValueRegExp) const |
search for variable with certain attribute-value | |
std::vector< std::string > | findVariables (const std::map< std::string, std::string > &findAttributes, const std::vector< std::string > &findDimensions) const |
search for variable with attribute-values and dimensions | |
bool | renameVariable (const std::string &oldName, const std::string &newName) |
rename a variable | |
bool | checkVariableAttribute (const std::string &varName, const std::string &attribute, const boost::regex &attrValue) const |
void | removeVariable (const std::string &variableName) |
remove a variable and corresponding attributes | |
void | addDimension (const CDMDimension &dim) throw (CDMException) |
add a dimension to cdm | |
bool | hasDimension (const std::string &dimName) const |
CDMDimension & | getDimension (const std::string &dimName) throw (CDMException) |
get a reference to a dimension | |
const CDMDimension & | getDimension (const std::string &dimName) const throw (CDMException) |
bool | testDimensionInUse (const std::string &name) const |
test if a dimension is actively in use | |
bool | renameDimension (const std::string &oldName, const std::string &newName) throw (CDMException) |
rename a dimension | |
bool | removeDimension (const std::string &name) throw (CDMException) |
remove a dimension | |
const CDMDimension * | getUnlimitedDim () const |
retrieve the unlimited dimension | |
bool | hasUnlimitedDim (const CDMVariable &var) const |
test if a variable contains the unlimited dim | |
void | addAttribute (const std::string &varName, const CDMAttribute &attr) throw (CDMException) |
void | addOrReplaceAttribute (const std::string &varName, const CDMAttribute &attr) throw (CDMException) |
void | removeAttribute (const std::string &varName, const std::string &attrName) |
void | toXMLStream (std::ostream &os) const |
print a xml representation to the stream | |
const DimVec & | getDimensions () const |
get the dimension | |
const VarVec & | getVariables () const |
get the variables | |
const StrAttrVecMap & | getAttributes () const |
get the attributes | |
std::vector< CDMAttribute > | getAttributes (const std::string &varName) const |
get the attributes of an variable | |
CDMAttribute & | getAttribute (const std::string &varName, const std::string &attrName) throw (CDMException) |
get an attribute | |
const CDMAttribute & | getAttribute (const std::string &varName, const std::string &attrName) const throw (CDMException) |
get a const. attribute | |
bool | getAttribute (const std::string &varName, const std::string &attrName, CDMAttribute &retAttribute) const |
get an attribute without throwing an error | |
double | getFillValue (const std::string &varName) const |
std::string | getUnits (const std::string &varName) const |
void | generateProjectionCoordinates (const std::string &projectionVariable, const std::string &xDim, const std::string &yDim, const std::string &lonDim, const std::string &latDim) throw (CDMException) |
generate the projection coordinates (usually named "lat lon") | |
DEPRECATED (bool getProjectionAndAxesUnits(std::string &projectionName, std::string &xAxis, std::string &yAxis, std::string &xAxisUnits, std::string &yAxisUnits) const throw(CDMException)) | |
extract the names of the projection-variable and the corresponding projection-axes | |
DEPRECATED (AttrVec getProjection(std::string varName) const) | |
get the projection attributes (as of CF-1.0) of a variable | |
boost::shared_ptr< const Projection > | getProjectionOf (std::string varName) const |
get the projection of a variable | |
std::string | getHorizontalXAxis (std::string varName) const |
get the x-(lon) axis of the variable | |
std::string | getHorizontalYAxis (std::string varName) const |
get the y-(lat) axis of the variable | |
bool | getLatitudeLongitude (std::string varName, std::string &latitude, std::string &longitude) const |
detect the latitude and longitude coordinates of the variable | |
std::string | getTimeAxis (std::string varName) const |
get the time axis of the variable | |
std::string | getVerticalAxis (std::string varName) const |
get the vertical axis of the variable | |
Static Public Member Functions | |
static const std::string & | globalAttributeNS () |
the namespace for global attributes |
This class implements the data-structure of the Common Data Model version 1 http://www.unidata.ucar.edu/software/netcdf-java/CDM.html
MetNoFimex::CDM::CDM | ( | ) |
MetNoFimex::CDM::CDM | ( | const CDM & | rhs | ) |
virtual MetNoFimex::CDM::~CDM | ( | ) | [virtual] |
void MetNoFimex::CDM::addVariable | ( | const CDMVariable & | var | ) | throw (CDMException) |
add variable to cdm
var | the variable to add |
CDMException | if var.varName() already exists |
CDMVariable& MetNoFimex::CDM::getVariable | ( | const std::string & | varName | ) | throw (CDMException) |
get a reference of a variable
varName | name of the variable |
CDMException | if varName doesn't exist |
const CDMVariable& MetNoFimex::CDM::getVariable | ( | const std::string & | varName | ) | const throw (CDMException) |
get a reference of a variable
this is a constant version of CDMVariable::getVariable}
varName | name of the variable |
CDMException | if varName doesn't exist |
bool MetNoFimex::CDM::hasVariable | ( | const std::string & | varName | ) | const |
test if variable exists
varName | name of variable |
std::vector<std::string> MetNoFimex::CDM::findVariables | ( | const std::string & | attrName, | |
const std::string & | attrValueRegExp | |||
) | const |
search for variable with certain attribute-value
attrName | name of the attribute | |
attrValueRegExp | regular expression the 'string'-value needs to match |
std::vector<std::string> MetNoFimex::CDM::findVariables | ( | const std::map< std::string, std::string > & | findAttributes, | |
const std::vector< std::string > & | findDimensions | |||
) | const |
search for variable with attribute-values and dimensions
And AND search for attributes and dimensions.
findAttributes | map with (attribute => string-value regExp) pairs | |
findDimensions | vector with dimensions contained in variable |
bool MetNoFimex::CDM::renameVariable | ( | const std::string & | oldName, | |
const std::string & | newName | |||
) |
rename a variable
oldName | the old name of the variable | |
newName | the new name of the variable |
bool MetNoFimex::CDM::checkVariableAttribute | ( | const std::string & | varName, | |
const std::string & | attribute, | |||
const boost::regex & | attrValue | |||
) | const |
check if a variable contains a attributes with a matching string-value
varName | variable | |
attribute | the attribute name | |
attrValue | the regexp the string-value of the attribute will match against |
void MetNoFimex::CDM::removeVariable | ( | const std::string & | variableName | ) |
remove a variable and corresponding attributes
variableName | the variable to remove |
void MetNoFimex::CDM::addDimension | ( | const CDMDimension & | dim | ) | throw (CDMException) |
add a dimension to cdm
dim | the dimension |
CDMException | if dim-name already exists |
bool MetNoFimex::CDM::hasDimension | ( | const std::string & | dimName | ) | const |
check if the dimension exists
dimName | name of the dimension |
CDMDimension& MetNoFimex::CDM::getDimension | ( | const std::string & | dimName | ) | throw (CDMException) |
get a reference to a dimension
dimName | name of the dimension |
CDMException | if dimension doesn't exist |
const CDMDimension& MetNoFimex::CDM::getDimension | ( | const std::string & | dimName | ) | const throw (CDMException) |
bool MetNoFimex::CDM::testDimensionInUse | ( | const std::string & | name | ) | const |
test if a dimension is actively in use
name | dimensionName |
bool MetNoFimex::CDM::renameDimension | ( | const std::string & | oldName, | |
const std::string & | newName | |||
) | throw (CDMException) |
rename a dimension
Rename a dimension.
CDMException | if newName already in use in a variable but for a different dimension |
bool MetNoFimex::CDM::removeDimension | ( | const std::string & | name | ) | throw (CDMException) |
remove a dimension
Remove a dimension, if it is not in use by a variable.
CDMException | if dimension in us in a variable |
const CDMDimension* MetNoFimex::CDM::getUnlimitedDim | ( | ) | const |
retrieve the unlimited dimension
bool MetNoFimex::CDM::hasUnlimitedDim | ( | const CDMVariable & | var | ) | const |
test if a variable contains the unlimited dim
void MetNoFimex::CDM::addAttribute | ( | const std::string & | varName, | |
const CDMAttribute & | attr | |||
) | throw (CDMException) |
add an attribute to cdm
varName | name of the variablt the attribute belongs to | |
attr | the CDMAttribute |
CDMException | if varName doesn't exist, or attr.getName() already exists |
void MetNoFimex::CDM::addOrReplaceAttribute | ( | const std::string & | varName, | |
const CDMAttribute & | attr | |||
) | throw (CDMException) |
add or replace an attribute of the cdm
varName | name of variable the attribute belongs to | |
attr | the CDMAttribute |
CDMException | if vaName doesn't exist |
void MetNoFimex::CDM::removeAttribute | ( | const std::string & | varName, | |
const std::string & | attrName | |||
) |
remove an attribute from the cdm
varName | name of variable the attribute belongs to | |
attr | the CDMAttribute |
void MetNoFimex::CDM::toXMLStream | ( | std::ostream & | os | ) | const |
print a xml representation to the stream
static const std::string& MetNoFimex::CDM::globalAttributeNS | ( | ) | [inline, static] |
the namespace for global attributes
const DimVec& MetNoFimex::CDM::getDimensions | ( | ) | const |
get the dimension
const VarVec& MetNoFimex::CDM::getVariables | ( | ) | const |
get the variables
const StrAttrVecMap& MetNoFimex::CDM::getAttributes | ( | ) | const |
get the attributes
std::vector<CDMAttribute> MetNoFimex::CDM::getAttributes | ( | const std::string & | varName | ) | const |
get the attributes of an variable
varName | name of variable |
CDMAttribute& MetNoFimex::CDM::getAttribute | ( | const std::string & | varName, | |
const std::string & | attrName | |||
) | throw (CDMException) |
get an attribute
varName | name of variable | |
attrName | name of attribute |
CDMException | if varName attrName combination doesn't exists |
const CDMAttribute& MetNoFimex::CDM::getAttribute | ( | const std::string & | varName, | |
const std::string & | attrName | |||
) | const throw (CDMException) |
get a const. attribute
varName | name of variable | |
attrName | name of attribute |
CDMException | if varName attrName combination doesn't exists |
bool MetNoFimex::CDM::getAttribute | ( | const std::string & | varName, | |
const std::string & | attrName, | |||
CDMAttribute & | retAttribute | |||
) | const |
get an attribute without throwing an error
This method will search for an attribute in the cdm. It will return true on success and return the attribute.
varName | name of variable | |
attrName | name of attribute | |
retAttribute | returns the attribute if found |
double MetNoFimex::CDM::getFillValue | ( | const std::string & | varName | ) | const |
get the fill value of an variable (_FillValue attribute)
std::string MetNoFimex::CDM::getUnits | ( | const std::string & | varName | ) | const |
get the value of the "units" attribute
void MetNoFimex::CDM::generateProjectionCoordinates | ( | const std::string & | projectionVariable, | |
const std::string & | xDim, | |||
const std::string & | yDim, | |||
const std::string & | lonDim, | |||
const std::string & | latDim | |||
) | throw (CDMException) |
generate the projection coordinates (usually named "lat lon")
projectionVariable | the variable containing the projection information | |
xDim | the x dimension (the corresponding variable needs to contain data and units) | |
yDim | the y dimension (the corresponding variable needs to contain data and units) | |
lonDim | name of the longitude variable | |
latDim | name of the latitude variable |
CDMException | if any information is missing |
MetNoFimex::CDM::DEPRECATED | ( | bool | getProjectionAndAxesUnitsstd::string &projectionName, std::string &xAxis, std::string &yAxis, std::string &xAxisUnits, std::string &yAxisUnits) const throw(CDMException | ) |
extract the names of the projection-variable and the corresponding projection-axes
projectionName | output of the projection variables name | |
xAxis | output of the spatial x axis | |
yAxis | output of the spation y axis | |
xAxisUnit | output of unit for x axis | |
yAxisUnit | output of unit for y axis |
CDMException | if no projection with corresponding axes can be found |
MetNoFimex::CDM::DEPRECATED | ( | AttrVec getProjection(std::string varName) | const | ) |
get the projection attributes (as of CF-1.0) of a variable
varName | name of variable |
boost::shared_ptr<const Projection> MetNoFimex::CDM::getProjectionOf | ( | std::string | varName | ) | const |
get the projection of a variable
This is the same as using the CoordinateSystem::getProjection().
varName | name of variable |
std::string MetNoFimex::CDM::getHorizontalXAxis | ( | std::string | varName | ) | const |
get the x-(lon) axis of the variable
This is the same as using the CoordinateSystem::getGeoXAxis().
varName | name of variable |
std::string MetNoFimex::CDM::getHorizontalYAxis | ( | std::string | varName | ) | const |
get the y-(lat) axis of the variable
This is the same as using the CoordinateSystem::getGeoYAxis().
varName | name of variable |
bool MetNoFimex::CDM::getLatitudeLongitude | ( | std::string | varName, | |
std::string & | latitude, | |||
std::string & | longitude | |||
) | const |
detect the latitude and longitude coordinates of the variable
This is the same as using the CoordinateSystem::findAxisOfType() with CoordinateAxis::Lon and CoordinateAxis::Lat.
varName | name of variable | |
latitude | return value of the latitude | |
longitude | return value of the longitude |
std::string MetNoFimex::CDM::getTimeAxis | ( | std::string | varName | ) | const |
get the time axis of the variable
This is the same as using the CoordinateSystem::getTimeAxis().
varName | name of variable |
std::string MetNoFimex::CDM::getVerticalAxis | ( | std::string | varName | ) | const |
get the vertical axis of the variable
This is the same as using the CoordinateSystem::getGeoZAxis().
varName | name of variable |