MI - Fimex
|
Data structure of the Common Data Model. More...
#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 More... | |
CDMVariable & | getVariable (const std::string &varName) throw (CDMException) |
get a reference of a variable More... | |
const CDMVariable & | getVariable (const std::string &varName) const throw (CDMException) |
get a reference of a variable More... | |
bool | hasVariable (const std::string &varName) const |
test if variable exists More... | |
std::vector< std::string > | findVariables (const std::string &attrName, const std::string &attrValueRegExp) const |
search for variable with certain attribute-value More... | |
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 More... | |
bool | renameVariable (const std::string &oldName, const std::string &newName) |
rename a variable More... | |
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 More... | |
void | addDimension (const CDMDimension &dim) throw (CDMException) |
add a dimension to cdm More... | |
bool | hasDimension (const std::string &dimName) const |
CDMDimension & | getDimension (const std::string &dimName) throw (CDMException) |
get a reference to a dimension More... | |
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 More... | |
bool | renameDimension (const std::string &oldName, const std::string &newName) throw (CDMException) |
rename a dimension More... | |
bool | removeDimension (const std::string &name) throw (CDMException) |
remove a dimension More... | |
const CDMDimension * | getUnlimitedDim () const |
retrieve the unlimited dimension More... | |
bool | hasUnlimitedDim (const CDMVariable &var) const |
test if a variable contains the unlimited dim More... | |
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 More... | |
const DimVec & | getDimensions () const |
get the dimension More... | |
const VarVec & | getVariables () const |
get the variables More... | |
const StrAttrVecMap & | getAttributes () const |
get the attributes More... | |
std::vector< CDMAttribute > | getAttributes (const std::string &varName) const |
get the attributes of an variable More... | |
CDMAttribute & | getAttribute (const std::string &varName, const std::string &attrName) throw (CDMException) |
get an attribute More... | |
const CDMAttribute & | getAttribute (const std::string &varName, const std::string &attrName) const throw (CDMException) |
get a const. attribute More... | |
bool | getAttribute (const std::string &varName, const std::string &attrName, CDMAttribute &retAttribute) const |
get an attribute without throwing an error More... | |
double | getFillValue (const std::string &varName) const |
double | getValidMin (const std::string &varName) const |
double | getValidMax (const std::string &varName) const |
double | getAddOffset (const std::string &varName) const |
double | getScaleFactor (const std::string &varName) const |
std::string | getUnits (const std::string &varName) const |
void | generateProjectionCoordinates (boost::shared_ptr< const Projection > projection, const std::string &xDim, const std::string &yDim, const std::string &lonDim, const std::string &latDim) |
generate the projection coordinates (usually named "lat lon") More... | |
MIFI_DEPRECATED (bool getProjectionAndAxesUnits(std::string &projectionName, std::string &xAxis, std::string &yAxis, std::string &xAxisUnits, std::string &yAxisUnits) const throw(CDMException)) | |
generate the projection coordinates (usually named "lat lon") More... | |
MIFI_DEPRECATED (AttrVec getProjection(std::string varName) const) | |
get the projection attributes (as of CF-1.0) of a variable More... | |
boost::shared_ptr< const Projection > | getProjectionOf (std::string varName) const |
get the projection of a variable More... | |
std::string | getHorizontalXAxis (std::string varName) const |
get the x-(lon) axis of the variable More... | |
std::string | getHorizontalYAxis (std::string varName) const |
get the y-(lat) axis of the variable More... | |
bool | getLatitudeLongitude (std::string varName, std::string &latitude, std::string &longitude) const |
detect the latitude and longitude coordinates of the variable More... | |
std::string | getTimeAxis (std::string varName) const |
get the time axis of the variable More... | |
std::string | getVerticalAxis (std::string varName) const |
get the vertical axis of the variable More... | |
Static Public Member Functions | |
static const std::string & | globalAttributeNS () |
the namespace for global attributes More... | |
Data structure of the Common Data Model.
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 |
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::addDimension | ( | const CDMDimension & | dim | ) | |
throw | ( | CDMException | |||
) |
add a dimension to cdm
dim | the dimension |
CDMException | if dim-name 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::addVariable | ( | const CDMVariable & | var | ) | |
throw | ( | CDMException | |||
) |
add variable to cdm
var | the variable to add |
CDMException | if var.varName() already exists |
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 |
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 |
void MetNoFimex::CDM::generateProjectionCoordinates | ( | boost::shared_ptr< const Projection > | projection, |
const std::string & | xDim, | ||
const std::string & | yDim, | ||
const std::string & | lonDim, | ||
const std::string & | latDim | ||
) |
generate the projection coordinates (usually named "lat lon")
projection | 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 |
Referenced by globalAttributeNS().
double MetNoFimex::CDM::getAddOffset | ( | const std::string & | varName | ) | const |
find add_offset value for a variable
varName |
Referenced by globalAttributeNS().
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 |
Referenced by globalAttributeNS().
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 |
const StrAttrVecMap& MetNoFimex::CDM::getAttributes | ( | ) | const |
get the attributes
Referenced by globalAttributeNS().
std::vector<CDMAttribute> MetNoFimex::CDM::getAttributes | ( | const std::string & | varName | ) | const |
get the attributes of an variable
varName | name of variable |
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 | |||
) |
const DimVec& MetNoFimex::CDM::getDimensions | ( | ) | const |
get the dimension
Referenced by globalAttributeNS().
double MetNoFimex::CDM::getFillValue | ( | const std::string & | varName | ) | const |
get the fill value of an variable (_FillValue attribute)
Referenced by globalAttributeNS().
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 |
Referenced by globalAttributeNS().
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 |
Referenced by globalAttributeNS().
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 |
Referenced by globalAttributeNS().
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 |
Referenced by globalAttributeNS().
double MetNoFimex::CDM::getScaleFactor | ( | const std::string & | varName | ) | const |
find scale_factor value for a variable
varName |
Referenced by globalAttributeNS().
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 |
Referenced by globalAttributeNS().
std::string MetNoFimex::CDM::getUnits | ( | const std::string & | varName | ) | const |
const CDMDimension* MetNoFimex::CDM::getUnlimitedDim | ( | ) | const |
retrieve the unlimited dimension
double MetNoFimex::CDM::getValidMax | ( | const std::string & | varName | ) | const |
get the valid maximum value of an variable
Referenced by globalAttributeNS().
double MetNoFimex::CDM::getValidMin | ( | const std::string & | varName | ) | const |
get the valid minimum value of an variable
Referenced by globalAttributeNS().
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 getVariable(const std::string&)
varName | name of the variable |
CDMException | if varName doesn't exist |
const VarVec& MetNoFimex::CDM::getVariables | ( | ) | const |
get the variables
Referenced by globalAttributeNS().
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 |
Referenced by globalAttributeNS().
|
inlinestatic |
the namespace for global attributes
References generateProjectionCoordinates(), getAddOffset(), getAttribute(), getAttributes(), getDimensions(), getFillValue(), getHorizontalXAxis(), getHorizontalYAxis(), getLatitudeLongitude(), getProjectionOf(), getScaleFactor(), getTimeAxis(), getUnits(), getValidMax(), getValidMin(), getVariables(), getVerticalAxis(), and MIFI_DEPRECATED().
bool MetNoFimex::CDM::hasDimension | ( | const std::string & | dimName | ) | const |
check if the dimension exists
dimName | name of the dimension |
bool MetNoFimex::CDM::hasUnlimitedDim | ( | const CDMVariable & | var | ) | const |
test if a variable contains the unlimited dim
bool MetNoFimex::CDM::hasVariable | ( | const std::string & | varName | ) | const |
test if variable exists
varName | name of variable |
MetNoFimex::CDM::MIFI_DEPRECATED | ( | bool | getProjectionAndAxesUnitsstd::string &projectionName, std::string &xAxis, std::string &yAxis, std::string &xAxisUnits, std::string &yAxisUnits) const 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 in this CDM (not the data-reader)) |
yDim | the y dimension (the corresponding variable needs to contain data and units in this CDM (not the data-reader)) |
lonDim | name of the longitude variable |
latDim | name of the latitude variable |
CDMException | if any information is missing |
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 |
xAxisUnits | output of unit for x axis |
yAxisUnits | output of unit for y axis |
CDMException | if no projection with corresponding axes can be found |
Referenced by globalAttributeNS().
MetNoFimex::CDM::MIFI_DEPRECATED | ( | AttrVec getProjection(std::string varName) | const | ) |
get the projection attributes (as of CF-1.0) of a variable
varName | name of variable |
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 |
attrName | the CDMAttribute |
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 |
void MetNoFimex::CDM::removeVariable | ( | const std::string & | variableName | ) |
remove a variable and corresponding attributes
variableName | the variable to remove |
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::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::testDimensionInUse | ( | const std::string & | name | ) | const |
test if a dimension is actively in use
name | dimensionName |
void MetNoFimex::CDM::toXMLStream | ( | std::ostream & | os | ) | const |
print a xml representation to the stream