# MI - Fimex: MetNoFimex::CDM Class Reference

# MetNoFimex::CDM Class Reference

Data structure of the Common Data Model. More...

`#include <fimex/CDM.h>`

List of all members.

## 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

## Detailed Description

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

## Member Typedef Documentation

typedef std::vector<CDMAttribute> MetNoFimex::CDM::AttrVec

typedef std::map<std::string, AttrVec> MetNoFimex::CDM::StrAttrVecMap

typedef std::vector<CDMDimension> MetNoFimex::CDM::DimVec

typedef std::vector<CDMVariable> MetNoFimex::CDM::VarVec

## Constructor & Destructor Documentation

MetNoFimex::CDM::CDM | ( |  | ) |

MetNoFimex::CDM::CDM | ( | const CDM & | rhs | ) |

virtual MetNoFimex::CDM::~CDM | ( |  | ) | `[virtual]`

## Member Function Documentation

CDM& MetNoFimex::CDM::operator= | ( | const CDM & | rhs | ) |

void MetNoFimex::CDM::addVariable | ( | const CDMVariable & | var | ) | throw (CDMException)

add variable to cdm

Parameters:

  | var | the variable to add

Exceptions:

  | CDMException | if var.varName() already exists

CDMVariable& MetNoFimex::CDM::getVariable | ( | const std::string & | varName | ) | throw (CDMException)

get a reference of a variable

Parameters:

  | varName | name of the variable

Exceptions:

  | 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}

Parameters:

  | varName | name of the variable

Exceptions:

  | CDMException | if varName doesn't exist

bool MetNoFimex::CDM::hasVariable | ( | const std::string & | varName | ) | const

test if variable exists

Parameters:

  | 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

Parameters:

  | attrName | name of the attribute
  | attrValueRegExp | regular expression the 'string'-value needs to match

Returns:
  variable names of the variable with attributes matching

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.

Parameters:

  | findAttributes | map with (attribute => string-value regExp) pairs
  | findDimensions | vector with dimensions contained in variable

Returns:
  variable names of the variable with attributes matching the request and containing all dimensions

bool MetNoFimex::CDM::renameVariable | ( | const std::string & | oldName,
|  | const std::string & | newName |
| ) |  |  |

rename a variable

Parameters:

  | oldName | the old name of the variable
  | newName | the new name of the variable

Returns:
  1 on success (oldName exists), 0 on failure

Warning:
  this will not change the spatialVectorCounterPart of all other variables

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

Parameters:

  | 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

Parameters:

  | variableName | the variable to remove

void MetNoFimex::CDM::addDimension | ( | const CDMDimension & | dim | ) | throw (CDMException)

add a dimension to cdm

Parameters:

  | dim | the dimension

Exceptions:

  | CDMException | if dim-name already exists

bool MetNoFimex::CDM::hasDimension | ( | const std::string & | dimName | ) | const

check if the dimension exists

Parameters:

  | dimName | name of the dimension

CDMDimension& MetNoFimex::CDM::getDimension | ( | const std::string & | dimName | ) | throw (CDMException)

get a reference to a dimension

Parameters:

  | dimName | name of the dimension

Exceptions:

  | 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

Parameters:

  | name | dimensionName

bool MetNoFimex::CDM::renameDimension | ( | const std::string & | oldName,
|  | const std::string & | newName |
| ) |  |  | throw (CDMException)

rename a dimension

Rename a dimension.

Returns:
  false if the original name does not exist.

Exceptions:

  | 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.

Returns:
  true if dimension existed, false otherwise

Exceptions:

  | CDMException | if dimension in us in a variable

const CDMDimension* MetNoFimex::CDM::getUnlimitedDim | ( |  | ) | const

retrieve the unlimited dimension

Returns:
  unLimDim pointer with the unlimited dimension, the pointer will be deleted with the CDM

bool MetNoFimex::CDM::hasUnlimitedDim | ( | const CDMVariable & | var | ) | const

test if a variable contains the unlimited dim

Returns:
  true/false

void MetNoFimex::CDM::addAttribute | ( | const std::string & | varName,
|  | const CDMAttribute & | attr |
| ) |  |  | throw (CDMException)

add an attribute to cdm

Parameters:

  | varName | name of the variablt the attribute belongs to
  | attr | the CDMAttribute

Exceptions:

  | 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

Parameters:

  | varName | name of variable the attribute belongs to
  | attr | the CDMAttribute

Exceptions:

  | CDMException | if vaName doesn't exist

void MetNoFimex::CDM::removeAttribute | ( | const std::string & | varName,
|  | const std::string & | attrName |
| ) |  |  |

remove an attribute from the cdm

Parameters:

  | 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

Returns:
  map of type <variableName <attributeName, attribute>>

std::vector<CDMAttribute> MetNoFimex::CDM::getAttributes | ( | const std::string & | varName | ) | const

get the attributes of an variable

Parameters:

  | varName | name of variable

CDMAttribute& MetNoFimex::CDM::getAttribute | ( | const std::string & | varName,
|  | const std::string & | attrName |
| ) |  |  | throw (CDMException)

get an attribute

Parameters:

  | varName | name of variable
  | attrName | name of attribute

Exceptions:

  | 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

Parameters:

  | varName | name of variable
  | attrName | name of attribute

Exceptions:

  | 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.

Parameters:

  | varName | name of variable
  | attrName | name of attribute
  | retAttribute | returns the attribute if found

Returns:
  true when attribute has been found and set

double MetNoFimex::CDM::getFillValue | ( | const std::string & | varName | ) | const

get the fill value of an variable (_FillValue attribute)

Returns:
  value of _FillValue attribute, or MIFI_UNDEFINED_F

std::string MetNoFimex::CDM::getUnits | ( | const std::string & | varName | ) | const

get the value of the "units" attribute

Returns:
  unitsString or ""

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

Parameters:

  | 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

Exceptions:

  | 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

Parameters:

  | 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

Returns:
  true if unique result, false (and print warning) if results are not unique

Exceptions:

  | 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

Parameters:

  | varName | name of variable

Returns:
  vector of attributes of the projection, an empty vector if no projection found

Deprecated:
  use the getProjectionOf() method

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().

Parameters:

  | varName | name of variable

Returns:
  projection

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().

Parameters:

  | varName | name of variable

Returns:
  name of x-axis dimension (or "" if not defined)

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().

Parameters:

  | varName | name of variable

Returns:
  name of y-axis dimension (or "" if not defined)

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.

Parameters:

  | varName | name of variable
  | latitude | return value of the latitude
  | longitude | return value of the longitude

Returns:
  true if latitude and longitude have been found

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().

Parameters:

  | varName | name of variable

Returns:
  name of time dimension (or "" if not defined)

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().

Parameters:

  | varName | name of variable

Returns:
  name of vertical dimension (or "" if not defined)

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

- include/fimex/CDM.h