MI - Fimex
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
MetNoFimex::CDMReader Class Referenceabstract

Basic interface for CDM reading and manipulation classes. More...

#include <fimex/CDMReader.h>

Inheritance diagram for MetNoFimex::CDMReader:
MetNoFimex::C_CDMReader MetNoFimex::CDMBorderSmoothing MetNoFimex::CDMExtractor MetNoFimex::CDMInterpolator MetNoFimex::CDMMerger MetNoFimex::CDMOverlay MetNoFimex::CDMPressureConversions MetNoFimex::CDMProcessor MetNoFimex::CDMQualityExtractor MetNoFimex::CDMReaderWriter MetNoFimex::CDMTimeInterpolator MetNoFimex::CDMVerticalInterpolator MetNoFimex::GribCDMReader MetNoFimex::MetGmCDMReader MetNoFimex::NcmlCDMReader MetNoFimex::WdbCDMReader

Public Member Functions

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

Protected Member Functions

virtual DataPtr getDataSliceFromMemory (const CDMVariable &variable, size_t unLimDimPos=0)
 
void getScaleAndOffsetOf (const std::string &varName, double &scale, double &offset) const
 

Protected Attributes

boost::shared_ptr< CDMcdm_
 

Detailed Description

Basic interface for CDM reading and manipulation classes.

The CDMReader is the basic interface for reading and manipulation of the cdm datastructure. The CDMWriter will work with an implementation of the CDMReader and read the included data in the cdm or the data provided through the implementation of the CDMReader#getDataSlice

See also
FeltCDMReader

Constructor & Destructor Documentation

MetNoFimex::CDMReader::CDMReader ( )
virtual MetNoFimex::CDMReader::~CDMReader ( )
inlinevirtual

Member Function Documentation

virtual const CDM& MetNoFimex::CDMReader::getCDM ( ) const
virtual

Retrieve the cdm structure of this reader.

Referenced by ~CDMReader().

virtual DataPtr MetNoFimex::CDMReader::getData ( const std::string varName)
virtual

data-reading function to be called from the CDMWriter

The getData function is a convenient function to retrieve all data from a file. It is implemented using getDataSlice. It should be used with care, since a complete variable might be bigger than available memory.

Parameters
varNamename of the variable to read
Exceptions
CDMExceptionon errors related to the CDM in combination with the underlying data-structure. It might also throw other (IO-)exceptions.

Referenced by ~CDMReader().

virtual DataPtr MetNoFimex::CDMReader::getDataSlice ( const std::string varName,
size_t  unLimDimPos 
)
pure 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.

Implemented in MetNoFimex::CDMInterpolator, MetNoFimex::NcmlCDMReader, MetNoFimex::WdbCDMReader, MetNoFimex::CDMProcessor, MetNoFimex::CDMVerticalInterpolator, MetNoFimex::CDMQualityExtractor, MetNoFimex::CDMExtractor, MetNoFimex::GribCDMReader, MetNoFimex::CDMPressureConversions, MetNoFimex::MetGmCDMReader, MetNoFimex::NetCDF_CDMReader, MetNoFimex::CDMTimeInterpolator, and MetNoFimex::C_CDMReader.

Referenced by MetNoFimex::CDMPressureConversions::~CDMPressureConversions(), MetNoFimex::CDMQualityExtractor::~CDMQualityExtractor(), and ~CDMReader().

virtual DataPtr MetNoFimex::CDMReader::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 in MetNoFimex::CDMInterpolator, MetNoFimex::NcmlCDMReader, MetNoFimex::WdbCDMReader, MetNoFimex::CDMExtractor, MetNoFimex::GribCDMReader, and MetNoFimex::NetCDF_CDMReader.

virtual DataPtr MetNoFimex::CDMReader::getDataSliceFromMemory ( const CDMVariable variable,
size_t  unLimDimPos = 0 
)
protectedvirtual

Read the data from the variable.hasData() and select the correct unLimDimPos. This function should be used internally from getDataSlice.

Parameters
variablethe variable to read data from
unLimDimPos(optional) the unlimited position
virtual std::vector<std::size_t> MetNoFimex::CDMReader::getDims ( std::string  varName)
virtual

Read the sizes of the dimensions belonging to a variable.

Read the dimension-sizes of a variable. This can be used to set the index of the Data as received with on of the getData() functions, e.g.

DataPtr d = reader->getData("my_var");
if (d.size() != 0) {
d.setDims(reader->getDims("my_var"));
}
Parameters
varNamethe variables name
Returns
a vector with the dimension sizes usable with MetNoFimex::Index

Referenced by ~CDMReader().

virtual std::vector<std::size_t> MetNoFimex::CDMReader::getDimsSlice ( std::string  varName)
virtual

Read the sizes of the dimensions belonging to a variable slice.

Read the dimension-sizes of a variable. This can be used to set the index of the Data as received with on of the getData() functions, e.g.

DataPtr d = reader->getScaledDataSliceInUnit("my_var", "m", 3);
if (d.size() != 0) {
d.setDims(reader->getDimsSlice("my_var"));
}

When using getDataSlice with a MetNoFimex::SliceBuilder, use SliceBuilder::getDimensionSizes().

Parameters
varNamethe variables name
Returns
a vector with the dimension sizes usable with MetNoFimex::Index

Referenced by ~CDMReader().

virtual CDM& MetNoFimex::CDMReader::getInternalCDM ( )
virtual

Retrieve the cdm structure of this reader, non-constant.

Only in rare cases, this might be required.

Referenced by ~CDMReader().

void MetNoFimex::CDMReader::getScaleAndOffsetOf ( const std::string varName,
double &  scale,
double &  offset 
) const
protected
virtual DataPtr MetNoFimex::CDMReader::getScaledData ( const std::string varName)
virtual

read and scale the complete data

This function uses getData internally. It tries to read "scale_factor" "add_offset" and "_FillValue" and apply the scaling to the read data. Output-datatype will be double, output _FillValue will be MIFI_UNDEFINED_D.

Parameters
varNamename of the variable to read
Exceptions
CDMExceptionon errors related to the CDM in combination with the underlying data-structure. It might also throw other (IO-)exceptions.

Referenced by ~CDMReader().

virtual DataPtr MetNoFimex::CDMReader::getScaledDataInUnit ( const std::string varName,
const std::string unit 
)
virtual

read and scale the complete data to a set unit

This function uses getData internally. It tries to read "scale_factor" "add_offset" and "_FillValue" and apply the scaling to the read data. Output-datatype will be double, output _FillValue will be MIFI_UNDEFINED_D. The data will be converted to match unit.

Parameters
varNamename of the variable to read
unitthe unit-string to convert the data to
Exceptions
CDMExceptionon errors related to the CDM in combination with the underlying data-structure. It might also throw other (IO-)exceptions.

Referenced by ~CDMReader().

virtual DataPtr MetNoFimex::CDMReader::getScaledDataSlice ( const std::string varName,
size_t  unLimDimPos 
)
virtual

read and scale a dataslice

This function uses getDataSlice internally. It tries to read "scale_factor" "add_offset" and "_FillValue" and apply the scaling to the read data. Output-datatype will be double, output _FillValue will be MIFI_UNDEFINED_D

Parameters
varNamename of the variable to read
unLimDimPos(optional) if the variable contains a unlimited dimension (max one allowed) a 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.

Referenced by ~CDMReader().

virtual DataPtr MetNoFimex::CDMReader::getScaledDataSlice ( const std::string varName,
const SliceBuilder sb 
)
virtual

read and scale a dataslice

Parameters
varNamename of the variable to read
sbSliceBuilder to restrict the data
Exceptions
CDMExceptionon errors related to the CDM in combination with the underlying data-structure. It might also throw other (IO-)exceptions.
See also
getScaledDataSlice(varName, unLimDimPos)
virtual DataPtr MetNoFimex::CDMReader::getScaledDataSliceInUnit ( const std::string varName,
const std::string unit,
size_t  unLimDimPos 
)
virtual

read and scale a dataslice to a known unit

This function uses getDataSlice internally. It tries to read "scale_factor" "add_offset" and "_FillValue" and apply the scaling to the read data. Output-datatype will be double, output _FillValue will be MIFI_UNDEFINED_D. The data will be converted to match unit.

Parameters
varNamename of the variable to read
unitunit-string
unLimDimPos(optional) if the variable contains a unlimited dimension (max one allowed) a 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.

Referenced by ~CDMReader().

virtual DataPtr MetNoFimex::CDMReader::getScaledDataSliceInUnit ( const std::string varName,
const std::string unit,
const SliceBuilder sb 
)
virtual

read and scale a dataslice to a set unit

Parameters
varNamename of the variable to read
unitunit string to scale to
sbSliceBuilder to restrict the data
Exceptions
CDMExceptionon errors related to the CDM in combination with the underlying data-structure. It might also throw other (IO-)exceptions.
See also
getScaledDataSlice(varName, unLimDimPos)

Member Data Documentation

boost::shared_ptr<CDM> MetNoFimex::CDMReader::cdm_
protected

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