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

#include <CDMInterpolator.h>

Inheritance diagram for MetNoFimex::CDMInterpolator:
MetNoFimex::CDMReader

Public Member Functions

 CDMInterpolator (boost::shared_ptr< CDMReader > dataReader)
 
virtual ~CDMInterpolator ()
 
virtual DataPtr getDataSlice (const std::string &varName, size_t unLimDimPos=0)
 retrieve data from the underlying dataReader and interpolate the values due to the current projection More...
 
virtual DataPtr getDataSlice (const std::string &varName, const SliceBuilder &sb)
 retrieve data from the underlying dataReader and interpolate the values due to the current projection More...
 
virtual void changeProjection (int method, const std::string &proj_input, const std::vector< double > &out_x_axis, const std::vector< double > &out_y_axis, const std::string &out_x_axis_unit, const std::string &out_y_axis_unit, CDMDataType out_x_axis_type, CDMDataType out_y_axis_type)
 change the (main) projection of the dataReaders cdm to this new projection More...
 
 MIFI_DEPRECATED (virtual void changeProjection(int method, const std::string &proj_input, const std::vector< double > &out_x_axis, const std::vector< double > &out_y_axis, const std::string &out_x_axis_unit, const std::string &out_y_axis_unit))
 change the (main) projection of the dataReaders cdm to this new projection More...
 
virtual void changeProjection (int method, const std::string &proj_input, const std::string &out_x_axis, const std::string &out_y_axis, const std::string &out_x_axis_unit, const std::string &out_y_axis_unit, const std::string &out_x_axis_type="double", const std::string &out_y_axis_type="double")
 change the (main) projection of the dataReaders cdm to this new projection More...
 
virtual void changeProjection (int method, const std::string &netcdf_template_file)
 change the (main) projection of the dataReaders cdm to this new projection More...
 
virtual void changeProjection (int method, const std::vector< double > &lonVals, const std::vector< double > &latVals)
 extract/interpolate a list of lat/lon points More...
 
virtual void changeProjectionToCrossSections (int method, const std::vector< CrossSectionDefinition > &crossSections)
 
virtual void setLatitudeName (const std::string &latName)
 
virtual const std::stringgetLatitudeName () const
 
virtual void setLongitudeName (const std::string &lonName)
 
virtual const std::stringgetLongitudeName () const
 
virtual double getMaxDistanceOfInterest (const std::vector< double > &out_y_axis, const std::vector< double > &out_x_axis, bool isMetric) const
 
virtual void setDistanceOfInterest (double dist)
 
virtual void addPreprocess (boost::shared_ptr< InterpolatorProcess2d > process)
 
virtual void addPostprocess (boost::shared_ptr< InterpolatorProcess2d > process)
 
- 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_
 

Detailed Description

This class is responsible for horizontal reprojections and selection of latitude longitude points.

Vectors in the direction of x/y axes are automatically reprojected if:

Constructor & Destructor Documentation

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

Member Function Documentation

virtual void MetNoFimex::CDMInterpolator::addPostprocess ( boost::shared_ptr< InterpolatorProcess2d process)
virtual

add a process to the internal list of postprocesses, run after interpolation

Warning
this function is not completely thought through and might change
virtual void MetNoFimex::CDMInterpolator::addPreprocess ( boost::shared_ptr< InterpolatorProcess2d process)
virtual

add a process to the internal list of preprocesses, run on fields before interpolation

Warning
this function is not completely thought through and might change
virtual void MetNoFimex::CDMInterpolator::changeProjection ( int  method,
const std::string proj_input,
const std::vector< double > &  out_x_axis,
const std::vector< double > &  out_y_axis,
const std::string out_x_axis_unit,
const std::string out_y_axis_unit,
CDMDataType  out_x_axis_type,
CDMDataType  out_y_axis_type 
)
virtual

change the (main) projection of the dataReaders cdm to this new projection

Parameters
methodInterpolation method
proj_inputinput-string for proj4, used as output projection
out_x_axisvalues of the output x-axis
out_y_axisvalues of the output y-axis
out_x_axis_unitunit of the output x-axis
out_y_axis_unitunit of the output y-axis
out_x_axis_typetype of CDM_TYPE (DOUBLE, FLOAT, ...) of x-axis
out_y_axis_typetype of CDM_TYPE (DOUBLE, FLOAT, ...) of y-axis
virtual void MetNoFimex::CDMInterpolator::changeProjection ( int  method,
const std::string proj_input,
const std::string out_x_axis,
const std::string out_y_axis,
const std::string out_x_axis_unit,
const std::string out_y_axis_unit,
const std::string out_x_axis_type = "double",
const std::string out_y_axis_type = "double" 
)
virtual

change the (main) projection of the dataReaders cdm to this new projection

Parameters
methodInterpolation method
proj_inputinput-string for proj4, used as output projection
out_x_axisconfig-string for x_axis, either '1,2,...,5' or 'auto' or 'auto,distance=3.5'
out_y_axisconfig-string for y_axis, either '1,2,...,5' or 'auto' or 'auto,distance=3.5'
out_x_axis_unitunit of the output x-axis
out_y_axis_unitunit of the output y-axis
out_x_axis_typetype (double, float, int, short) of x-axis
out_y_axis_typetype of MIFI_TYPE (double, float, int, short) of y-axis
virtual void MetNoFimex::CDMInterpolator::changeProjection ( int  method,
const std::string netcdf_template_file 
)
virtual

change the (main) projection of the dataReaders cdm to this new projection

Interpolate/extract latitude/longitude values from regularly gridded input to latitude/longitude values given from a netcdf CF-template . The template must at least contain the information given in this example:

netcdf template4interpolation {
dimensions:
	x = 4 ;
	y = 1 ;
variables:
	int x(x) ;
		x:standard_name = "projection_x_coordinate" ;
		x:units = "m" ; // meters in a unspecified coordinate system
	int y(y) ;
		y:standard_name = "projection_y_coordinate" ;
		y:units = "m" ; // meters in a unspecified coordinate system
	float latitude(y, x) ;
		latitude:standard_name = "latitude" ;
		latitude:units = "degrees_north" ;
	float longitude(y, x) ;
		longitude:standard_name = "longitude" ;
		longitude:units = "degrees_east" ;
	float referenceVariable(y, x) ;
		referenceVariable:coordinates = "longitude latitude" ;

// global attributes:
		:Conventions = "CF-1.4" ;
data:
 x =  0, 1, 2, 3; // just a list
 y = 0;           // just a list 
 latitude =  60, 60, 60.1, 45.4;
 longitude = 10,  9,  9,   17;
// no data required for 'referenceVariable'
}
Parameters
methodInterpolation method, only nearestneighbor, bilinear and bicubic supported
netcdf_template_fileinput-string for netcf template filename
virtual void MetNoFimex::CDMInterpolator::changeProjection ( int  method,
const std::vector< double > &  lonVals,
const std::vector< double > &  latVals 
)
virtual

extract/interpolate a list of lat/lon points

Parameters
methodInterpolation method, only nearestneighbor, bilinear and bicubic supported
lonValslongitude values in degree
latValslatitude values in degree (lonVals.size() == latVals.size())
virtual void MetNoFimex::CDMInterpolator::changeProjectionToCrossSections ( int  method,
const std::vector< CrossSectionDefinition > &  crossSections 
)
virtual

Change the projection to latitude-longitude points defined by the points in the CrossSections. In between the CrossSection points, latitude/longitude points will be added on a straight line (in the original projection plane). The distance of the points will be in the magnitude of the grid-distance.

In addition, the cross-section names and the cross-section position in the output-latitude/longitude will be added to the resulting file.

Parameters
methodone of the MIFI_INTERPOL_* methods defined in mifi_constants.h
crossSections
virtual DataPtr MetNoFimex::CDMInterpolator::getDataSlice ( const std::string varName,
size_t  unLimDimPos = 0 
)
virtual

retrieve data from the underlying dataReader and interpolate the values due to the current projection

Implements MetNoFimex::CDMReader.

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

retrieve data from the underlying dataReader and interpolate the values due to the current projection

Reimplemented from MetNoFimex::CDMReader.

virtual const std::string& MetNoFimex::CDMInterpolator::getLatitudeName ( ) const
virtual
Returns
the name used for latitude in the automatic coordinate generation
virtual const std::string& MetNoFimex::CDMInterpolator::getLongitudeName ( ) const
virtual
Returns
the name used for longitude in the automatic coordinate generation
virtual double MetNoFimex::CDMInterpolator::getMaxDistanceOfInterest ( const std::vector< double > &  out_y_axis,
const std::vector< double > &  out_x_axis,
bool  isMetric 
) const
virtual

get the maximum distance allowed between the center of two cells to still influence each others

Parameters
out_x_axisthe available new x-axis (in meter or radian)
out_y_axisthe available new y-axis (in meter or radian)
isMetricindicate if y-axis is already given in m, or is in degree
Returns
the maximum distance (in m) between adjacent points, or the value given with setDistanceOfInterest()
MetNoFimex::CDMInterpolator::MIFI_DEPRECATED ( virtual void   changeProjectionint method, const std::string &proj_input, const std::vector< double > &out_x_axis, const std::vector< double > &out_y_axis, const std::string &out_x_axis_unit, const std::string &out_y_axis_unit)

change the (main) projection of the dataReaders cdm to this new projection

Parameters
methodInterpolation method
proj_inputinput-string for proj4, used as output projection
out_x_axisvalues of the output x-axis
out_y_axisvalues of the output y-axis
out_x_axis_unitunit of the output x-axis
out_y_axis_unitunit of the output y-axis
Deprecated:
use version changeProjection(int method, const std::string& proj_input, const std::vector<double>& out_x_axis, const std::vector<double>& out_y_axis, const std::string& out_x_axis_unit, const std::string& out_y_axis_unit)
virtual void MetNoFimex::CDMInterpolator::setDistanceOfInterest ( double  dist)
virtual

set the distance of interest, usually the radius of input-points + ~1/2 cell-size of output Negative values invalidate the distance. To have effect, this function must be set before calling changeProjection()

Parameters
distdistance in meter
virtual void MetNoFimex::CDMInterpolator::setLatitudeName ( const std::string latName)
virtual

set the name for the automatically generated latitude coordinate axis. This must be set before changeProjection is called.

Parameters
latNamename for latitude
virtual void MetNoFimex::CDMInterpolator::setLongitudeName ( const std::string lonName)
virtual

set the name for the automatically generated longitude coordinate axis. This must be set before changeProjection is called.

Parameters
lonNamename for longitude

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