Basic interface for CDM reading and manipulation classes.
More...
#include <fimex/CDMReader.h>
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
MetNoFimex::CDMReader::CDMReader |
( |
| ) |
|
virtual MetNoFimex::CDMReader::~CDMReader |
( |
| ) |
|
|
inlinevirtual |
virtual const CDM& MetNoFimex::CDMReader::getCDM |
( |
| ) |
const |
|
virtual |
Retrieve the cdm structure of this reader.
Referenced by ~CDMReader().
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
-
varName | name of the variable to read |
- Exceptions
-
CDMException | on 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
-
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 |
- Exceptions
-
CDMException | on 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::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
-
variable | the variable to read data from |
unLimDimPos | (optional) the unlimited position |
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
-
varName | the variables name |
- Returns
- a vector with the dimension sizes usable with MetNoFimex::Index
Referenced by ~CDMReader().
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
-
varName | the 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 |
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
-
varName | name of the variable to read |
- Exceptions
-
CDMException | on errors related to the CDM in combination with the underlying data-structure. It might also throw other (IO-)exceptions. |
Referenced by ~CDMReader().
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
-
varName | name of the variable to read |
unit | the unit-string to convert the data to |
- Exceptions
-
CDMException | on 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
-
varName | name 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
-
CDMException | on errors related to the CDM in combination with the underlying data-structure. It might also throw other (IO-)exceptions. |
Referenced by ~CDMReader().
read and scale a dataslice
- Parameters
-
varName | name of the variable to read |
sb | SliceBuilder to restrict the data |
- Exceptions
-
CDMException | on errors related to the CDM in combination with the underlying data-structure. It might also throw other (IO-)exceptions. |
- See also
- getScaledDataSlice(varName, unLimDimPos)
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
-
varName | name of the variable to read |
unit | unit-string |
unLimDimPos | (optional) if the variable contains a unlimited dimension (max one allowed) a slice of this position is returned |
- Exceptions
-
CDMException | on errors related to the CDM in combination with the underlying data-structure. It might also throw other (IO-)exceptions. |
Referenced by ~CDMReader().
read and scale a dataslice to a set unit
- Parameters
-
varName | name of the variable to read |
unit | unit string to scale to |
sb | SliceBuilder to restrict the data |
- Exceptions
-
CDMException | on errors related to the CDM in combination with the underlying data-structure. It might also throw other (IO-)exceptions. |
- See also
- getScaledDataSlice(varName, unLimDimPos)
boost::shared_ptr<CDM> MetNoFimex::CDMReader::cdm_ |
|
protected |
The documentation for this class was generated from the following file: