MI - Fimex
Public Member Functions | List of all members
MetNoFimex::CDMExtractor Class Reference

#include <fimex/CDMExtractor.h>

Inheritance diagram for MetNoFimex::CDMExtractor:
MetNoFimex::CDMReader

Public Member Functions

 CDMExtractor (boost::shared_ptr< CDMReader > dataReader)
 
virtual ~CDMExtractor ()
 
virtual DataPtr getDataSlice (const std::string &varName, size_t unLimDimPos=0)
 data-reading function to be called from the CDMWriter More...
 
virtual DataPtr getDataSlice (const std::string &varName, const SliceBuilder &sb)
 data-reading function to be called from the CDMWriter More...
 
virtual void removeVariable (std::string varName)
 Remove a variable from the CDM. More...
 
virtual void selectVariables (std::set< std::string > variables, bool keepLogical=false)
 select only a set of variables More...
 
void reduceDimension (std::string dimName, const std::set< std::size_t > &slices)
 Reduce a dimension of the file. More...
 
virtual void reduceDimension (std::string dimName, size_t start, size_t length)
 Reduce a dimension of the file. More...
 
virtual void reduceDimensionStartEnd (std::string dimName, size_t start=0, long long end=0)
 Reduce a dimension of the file. More...
 
virtual void reduceAxes (const std::vector< CoordinateAxis::AxisType > &types, const std::string &aUnits, double startVal, double endVal)
 reduce the axes of a file with an explicit unit More...
 
virtual void reduceTime (const FimexTime &startTime, const FimexTime &endTime)
 reduce the time explicitly by a timestamp More...
 
virtual void reduceVerticalAxis (const std::string &units, double startVal, double endVal)
 reduce a vertical axis by value More...
 
virtual void reduceLatLonBoundingBox (double south, double north, double west, double east)
 reduce the horizontal layer to the latitude-longitude bounding box More...
 
virtual void changeDataType (std::string variable, CDMDataType datatype)
 change the datatype of the variable More...
 
- Public Member Functions inherited from MetNoFimex::CDMReader
 CDMReader ()
 
virtual ~CDMReader ()
 
virtual const CDMgetCDM () const
 
virtual CDMgetInternalCDM ()
 
virtual std::vector< std::size_t > getDims (std::string varName)
 Read the sizes of the dimensions belonging to a variable. More...
 
virtual std::vector< std::size_t > getDimsSlice (std::string varName)
 Read the sizes of the dimensions belonging to a variable slice. More...
 
virtual DataPtr getData (const std::string &varName)
 data-reading function to be called from the CDMWriter More...
 
virtual DataPtr getScaledDataSlice (const std::string &varName, size_t unLimDimPos)
 read and scale a dataslice More...
 
virtual DataPtr getScaledDataSliceInUnit (const std::string &varName, const std::string &unit, size_t unLimDimPos)
 read and scale a dataslice to a known unit More...
 
virtual DataPtr getScaledDataSlice (const std::string &varName, const SliceBuilder &sb)
 read and scale a dataslice More...
 
virtual DataPtr getScaledDataSliceInUnit (const std::string &varName, const std::string &unit, const SliceBuilder &sb)
 read and scale a dataslice to a set unit More...
 
virtual DataPtr getScaledData (const std::string &varName)
 read and scale the complete data More...
 
virtual DataPtr getScaledDataInUnit (const std::string &varName, const std::string &unit)
 read and scale the complete data to a set unit More...
 

Additional Inherited Members

- Protected Member Functions inherited from MetNoFimex::CDMReader
virtual DataPtr getDataSliceFromMemory (const CDMVariable &variable, size_t unLimDimPos=0)
 
void getScaleAndOffsetOf (const std::string &varName, double &scale, double &offset) const
 
- Protected Attributes inherited from MetNoFimex::CDMReader
boost::shared_ptr< CDMcdm_
 

Constructor & Destructor Documentation

MetNoFimex::CDMExtractor::CDMExtractor ( boost::shared_ptr< CDMReader dataReader)
virtual MetNoFimex::CDMExtractor::~CDMExtractor ( )
virtual

Member Function Documentation

virtual void MetNoFimex::CDMExtractor::changeDataType ( std::string  variable,
CDMDataType  datatype 
)
virtual

change the datatype of the variable

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

Parameters
variablename of the variable
datatypenew datatype
Exceptions
CDMExceptionif variable doesn't exist or conversion to datatype is not supported
virtual DataPtr MetNoFimex::CDMExtractor::getDataSlice ( const std::string varName,
size_t  unLimDimPos = 0 
)
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
varNamename of the variable to read
unLimDimPos(optional) if the variable contains a unlimited dimension (max one allowed) an slice of this position is returned
Exceptions
CDMExceptionon errors related to the CDM in combination with the underlying data-structure. It might also throw other (IO-)exceptions.

Implements MetNoFimex::CDMReader.

virtual DataPtr MetNoFimex::CDMExtractor::getDataSlice ( const std::string varName,
const SliceBuilder sb 
)
virtual

data-reading function to be called from the CDMWriter

Parameters
varNamename of the variable to read
sba SliceBuilder generated from this CDMReaders CDM
Exceptions
CDMExceptionon errors related to the CDM in combination with the underlying data-structure. It might also throw other (IO-)exceptions.
Warning
This method has a default implementation depending on getDataSlice(const std::string&, size_t), but should be implemented for performance reasons. If you want to fall back to the default implementation, remember to use 'using CDMReader::getDataSlice;'

Reimplemented from MetNoFimex::CDMReader.

virtual void MetNoFimex::CDMExtractor::reduceAxes ( const std::vector< CoordinateAxis::AxisType > &  types,
const std::string aUnits,
double  startVal,
double  endVal 
)
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
void MetNoFimex::CDMExtractor::reduceDimension ( std::string  dimName,
const std::set< std::size_t > &  slices 
)

Reduce a dimension of the file.

Parameters
dimNamedimension to change
slicesslices to pick from the original dimension
Exceptions
CDMExceptionif dimension doesn't exist or start+size outside range of the original dimension
virtual void MetNoFimex::CDMExtractor::reduceDimension ( std::string  dimName,
size_t  start,
size_t  length 
)
virtual

Reduce a dimension of the file.

Parameters
dimNamedimension to change
startstart-position corresponding to the original dimension
lengthsize of the new dimension
Exceptions
CDMExceptionif 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 long  end = 0 
)
virtual

Reduce a dimension of the file.

Parameters
dimNamedimension to change
startstart-position corresponding to the original dimension, defaults to 0
endend-position of dimension, 0 means full size, negative values start from end
Exceptions
CDMExceptionif dimension doesn't exist or start+size outside range of the original dimension
virtual void MetNoFimex::CDMExtractor::reduceLatLonBoundingBox ( double  south,
double  north,
double  west,
double  east 
)
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
southsouthernmost border in dec. degree, -90 < south < north < 90
northnorthernmost border in dec. degree, -90 < south < north < 90
westwesternmost border in dec. degree, -180 < west < east < 180
easteasternmost border in dec. degree, -180 < west < east < 180
virtual void MetNoFimex::CDMExtractor::reduceTime ( const FimexTime startTime,
const FimexTime endTime 
)
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 
)
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
unitsthe units of the start and end value. Only vertical axes with compatible units will be reduced.
startValthe lower value of the axis (included)
endValthe 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::removeVariable ( std::string  varName)
virtual

Remove a variable from the CDM.

Parameters
varNamename of the variable
Warning
ignores removal of non-existing variable
virtual void MetNoFimex::CDMExtractor::selectVariables ( std::set< std::string variables,
bool  keepLogical = false 
)
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 (if keepLogical is true)

Parameters
variableslist of variables-names
keepLogicalkeep logical auxiliary variables, i.e. coordinates or formula_terms
Warning
ignores selection of non-existing variable

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