# MI - Fimex: MetNoFimex::CDMExtractor Class Reference

# MetNoFimex::CDMExtractor Class Reference

`#include <CDMExtractor.h>`

Inheritance diagram for MetNoFimex::CDMExtractor:

List of all members.

## Public Member Functions

| CDMExtractor (boost::shared_ptr< CDMReader > dataReader)
virtual | ~CDMExtractor ()
virtual boost::shared_ptr< Data > | getDataSlice (const std::string &varName, size_t unLimDimPos=0) throw (CDMException)
| data-reading function to be called from the CDMWriter
virtual void | removeVariable (std::string variable)
| Remove a variable from the CDM.
virtual void | selectVariables (std::set< std::string > variables)
| select only a set of variables
virtual void | reduceDimension (std::string dimName, size_t start, size_t length) throw (CDMException)
| Reduce a dimension of the file.
virtual void | reduceDimensionStartEnd (std::string dimName, size_t start=0, long end=0) throw (CDMException)
| Reduce a dimension of the file.
virtual void | reduceAxes (const std::vector< CoordinateAxis::AxisType > &types, const std::string &aUnits, double startVal, double endVal) throw (CDMException)
| reduce the axes of a file with an explicit unit
virtual void | reduceTime (const FimexTime &startTime, const FimexTime &endTime) throw (CDMException)
| reduce the time explicitly by a timestamp
virtual void | reduceVerticalAxis (const std::string &units, double startVal, double endVal) throw (CDMException)
| reduce a vertical axis by value
virtual void | reduceLatLonBoundingBox (double south, double north, double west, double east) throw (CDMException)
| reduce the horizontal layer to the latitude-longitude bounding box
virtual void | changeDataType (std::string variable, CDMDataType datatype) throw (CDMException)
| change the datatype of the variable

## Constructor & Destructor Documentation

MetNoFimex::CDMExtractor::CDMExtractor | ( | boost::shared_ptr< CDMReader > | dataReader | ) |

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

## Member Function Documentation

virtual boost::shared_ptr<Data> MetNoFimex::CDMExtractor::getDataSlice | ( | const std::string & | varName,
|  | size_t | unLimDimPos = `0` |
| ) |  |  | throw (CDMException)`[virtual]`

data-reading function to be called from the CDMWriter

This methods needs to be implemented by the CDMReader. It should provide the data for each variable, either by reading from disk, converting from another CDMReader or reading from an in-memory data-section.

This function should retrieve the whole data for a dataset without unlimited dimension if the unLimDimPos == 0.

Parameters:

  | varName | name of the variable to read
  | unLimDimPos | (optional) if the variable contains a unlimited dimension (max one allowed) an slice of this position is returned

Implements MetNoFimex::CDMReader.

virtual void MetNoFimex::CDMExtractor::removeVariable | ( | std::string | variable | ) | `[virtual]`

Remove a variable from the CDM.

Parameters:

  | varName | name of the variable

Warning:
  ignores removal of non-existing variable

virtual void MetNoFimex::CDMExtractor::selectVariables | ( | std::set< std::string > | variables | ) | `[virtual]`

select only a set of variables

This function will remove all variables except the ones selected plus eventually some auxiliary variables needed by the selected variables (not decided yet)

Parameters:

  | variables | list of variables-names

Warning:
  ignores selection of non-existing variable

virtual void MetNoFimex::CDMExtractor::reduceDimension | ( | std::string | dimName,
|  | size_t | start,
|  | size_t | length |
| ) |  |  | throw (CDMException)`[virtual]`

Reduce a dimension of the file.

Parameters:

  | name | dimension to change
  | start | start-position corresponding to the original dimension
  | size | size of the new dimension

Exceptions:

  | CDMException | if dimension doesn't exist or start+size outside range of the original dimension

virtual void MetNoFimex::CDMExtractor::reduceDimensionStartEnd | ( | std::string | dimName,
|  | size_t | start = `0`,
|  | long | end = `0` |
| ) |  |  | throw (CDMException)`[virtual]`

Reduce a dimension of the file.

Parameters:

  | name | dimension to change
  | start | start-position corresponding to the original dimension, defaults to 0
  | end | end-position of dimension, 0 means full size, negative values start from end

Exceptions:

  | CDMException | if dimension doesn't exist or start+size outside range of the original dimension

virtual void MetNoFimex::CDMExtractor::reduceAxes | ( | const std::vector< CoordinateAxis::AxisType > & | types,
|  | const std::string & | aUnits,
|  | double | startVal,
|  | double | endVal |
| ) |  |  | throw (CDMException)`[virtual]`

reduce the axes of a file with an explicit unit

In contrast to reduceDimension, this method allows the usage of absolute values, not positions on the dimension. It will try to detect the reduction of dimensions as needed.

Warning:
  reduceAxes requires the times to be monotonic

  reduceAxes requires the file to come with a known convention, e.g. CF, see listCoordinateSystems()

  reduceAxes is not able to reduce multi-dimensional axes-dimensions, e.g. time(time, station), yet

virtual void MetNoFimex::CDMExtractor::reduceTime | ( | const FimexTime & | startTime,
|  | const FimexTime & | endTime |
| ) |  |  | throw (CDMException)`[virtual]`

reduce the time explicitly by a timestamp

In contrast to reduceDimension, this method allows the usage of absolute times. It will try to detect the reduction of dimensions as needed

This is implemented using reduceAxes() and the TimeAxis type.

Warning:
  see warnings in reduceAxes()

virtual void MetNoFimex::CDMExtractor::reduceVerticalAxis | ( | const std::string & | units,
|  | double | startVal,
|  | double | endVal |
| ) |  |  | throw (CDMException)`[virtual]`

reduce a vertical axis by value

In contrast to reduceDimension, this method allows the usage of vertical axes values having a compatible unit to units. It will try to detect the reduction of dimensions as needed.

Parameters:

  | units | the units of the start and end value. Only vertical axes with compatible units will be reduced.
  | startVal | the lower value of the axis (included)
  | endVal | the upper value of the axis (included)

This is implemented using reduceAxes() and the axis types: pressure, height, geoZ.

Warning:
  see warnings in reduceAxes()

virtual void MetNoFimex::CDMExtractor::reduceLatLonBoundingBox | ( | double | south,
|  | double | north,
|  | double | west,
|  | double | east |
| ) |  |  | throw (CDMException)`[virtual]`

reduce the horizontal layer to the latitude-longitude bounding box

This method will try to reduce the horizontal layer to the given latitude/longitude bounding box. It requires the original data to have a simple geospatial gridded CoordinateSystem, i.e. CoordinateSystem::isSimpleSpatialGridded() and a projection mapping to lat/lon

Parameters:

  | south | southernmost border in dec. degree, -90 < south < north < 90
  | north | northernmost border in dec. degree, -90 < south < north < 90
  | west | westernmost border in dec. degree, -180 < west < east < 180
  | east | easternmost border in dec. degree, -180 < west < east < 180

virtual void MetNoFimex::CDMExtractor::changeDataType | ( | std::string | variable,
|  | CDMDataType | datatype |
| ) |  |  | throw (CDMException)`[virtual]`

change the datatype of the variable

a change of the variable will also change the datatype of the _FillValue attribute

Parameters:

  | variable | name of the variable
  | datatype | new datatype

Exceptions:

  | CDMException | if variable doesn't exist or conversion to datatype is not supported

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

- include/fimex/CDMExtractor.h