casacore
|
Interpolate in one dimension. More...
#include <TabularCoordinate.h>
Public Types | |
enum | Method { nearestNeighbour, linear, cubic, spline } |
The different interpolation methods are enumerated here. More... | |
Public Types inherited from casacore::Function1D< Domain, Range > | |
typedef const Domain * | FunctionArg |
Public Types inherited from casacore::Function< T, U > | |
typedef FunctionTraits< T > ::ArgType | ArgType |
typedef const ArgType * | FunctionArg |
Public Member Functions | |
Interpolate1D () | |
The default constructor generates a useless object until the setData function has been called. More... | |
Interpolate1D (const SampledFunctional< Domain > &x, const SampledFunctional< Range > &y, const Bool sorted=False, const Bool uniq=False) | |
Construct an object with the specified data. More... | |
void | setData (const SampledFunctional< Domain > &x, const SampledFunctional< Range > &y, const Bool sorted=False, const Bool uniq=False) |
Define a new data set for the class to operate on. More... | |
Interpolate1D (const Interpolate1D< Domain, Range > &other) | |
The standard copy constructor, assignment operator and destructor. More... | |
Interpolate1D< Domain, Range > & | operator= (const Interpolate1D< Domain, Range > &other) |
~Interpolate1D () | |
virtual const String & | name () const |
Name of function. More... | |
virtual Range | eval (typename Function1D< Domain, Range >::FunctionArg x) const |
Interpolation is done using the () operator (see example above). More... | |
uInt | getMethod () const |
inquire/set the current interpolation method. More... | |
void | setMethod (uInt method) |
Vector< Domain > | getX () const |
Access the data set that interpolation is done over. More... | |
Vector< Range > | getY () const |
virtual Function< Domain, Range > * | clone () const |
A function to copy the Interpolate1D object. More... | |
Public Member Functions inherited from casacore::Function1D< Domain, Range > | |
Function1D () | |
Constructors. More... | |
Function1D (const uInt n) | |
Function1D (const Vector< Domain > &in) | |
Function1D (const FunctionParam< Domain > &other) | |
Function1D (const Function1D< W, X > &other) | |
virtual | ~Function1D () |
Destructor. More... | |
virtual uInt | ndim () const |
Returns the number of dimensions of function. More... | |
Public Member Functions inherited from casacore::Function< T, U > | |
Function () | |
Constructors. More... | |
Function (const uInt n) | |
Function (const Vector< T > &in) | |
Function (const FunctionParam< T > &other) | |
template<class W , class X > | |
Function (const Function< W, X > &other) | |
virtual | ~Function () |
Destructor. More... | |
uInt | nparameters () const |
Returns the number of parameters. More... | |
virtual U | eval (FunctionArg x) const =0 |
Evaluate the function object. More... | |
T & | operator[] (const uInt n) |
Manipulate the nth parameter (0-based) with no index check. More... | |
const T & | operator[] (const uInt n) const |
virtual U | operator() () const |
Evaluate this function object at x or at x, y . More... | |
virtual U | operator() (const ArgType &x) const |
virtual U | operator() (const Vector< ArgType > &x) const |
virtual U | operator() (FunctionArg x) const |
virtual U | operator() (const ArgType &x, const ArgType &y) const |
virtual U | operator() (const ArgType &x, const ArgType &y, const ArgType &z) const |
Bool & | mask (const uInt n) |
Manipulate the mask associated with the nth parameter (e.g. More... | |
const Bool & | mask (const uInt n) const |
const FunctionParam< T > & | parameters () const |
Return the parameter interface. More... | |
FunctionParam< T > & | parameters () |
const Vector< ArgType > & | argp () const |
Get arg_p and parset_p . More... | |
Bool | parsetp () const |
void | lockParam () |
Compiler cannot always find the correct 'const' version of parameter access. More... | |
void | unlockParam () |
virtual void | setMode (const RecordInterface &mode) |
get/set the function mode. More... | |
virtual void | getMode (RecordInterface &mode) const |
virtual Bool | hasMode () const |
return True if the implementing function supports a mode. More... | |
ostream & | print (ostream &os) const |
Print the function (i.e. More... | |
virtual Function< typename FunctionTraits< T >::DiffType > * | cloneAD () const |
virtual Function< typename FunctionTraits< T >::BaseType > * | cloneNonAD () const |
Public Member Functions inherited from casacore::Functional< FunctionTraits< T >::ArgType, U > | |
virtual | ~Functional () |
Destructor. More... | |
virtual U | operator() (const FunctionTraits< T >::ArgType &x) const =0 |
Map a Domain x into a Range y value. More... | |
Public Member Functions inherited from casacore::Functional< Vector< FunctionTraits< T >::ArgType >, U > | |
virtual | ~Functional () |
Destructor. More... | |
virtual U | operator() (const Vector< FunctionTraits< T >::ArgType > &x) const =0 |
Map a Domain x into a Range y value. More... | |
Private Member Functions | |
Range | polynomialInterpolation (const Domain x, uInt n, uInt offset) const |
A private function for doing polynomial interpolation. More... | |
Private Attributes | |
uInt | curMethod |
uInt | nElements |
Block< Domain > | xValues |
Block< Range > | yValues |
Block< Range > | y2Values |
Additional Inherited Members | |
Protected Attributes inherited from casacore::Function< T, U > | |
FunctionParam< T > | param_p |
The parameters and masks. More... | |
Vector< ArgType > | arg_p |
Aid for non-contiguous argument storage. More... | |
Bool | parset_p |
Indicate parameter written. More... | |
Bool | locked_p |
Indicate that parameters are expected to be locked from changing. More... | |
Interpolate in one dimension.
Public interface
The Interpolate1D class does interpolation in one dimension only.
This class will, given the abscissa and ordinates of a set of one dimensional data, interpolate on this data set giving the value at any specified ordinate. It will extrapolate if necessary, but this is will usually give a poor result. There is no requirement for the ordinates to be regularly spaced, or even sorted in any numerical order. However each abscissa should have a unique value.
Interpolation can be done using the following methods:
The restriction that each abcissus has a unique value can be lifted by setting the uniq=True
option in the appropriate functions. This imposes the following additional restrictions on interpolation.
The abscissa must be a SampledFunctional that returns a scalar value that can be ordered. ie. an uInt, Int, Float or Double (not Complex). The ordinate can be any data type that has addition, and subtraction defined as well as multiplication by a scalar. So the ordinate can be complex numbers, where the interpolation is done separately on the real and imaginary components, or an array, where the interpolation is done separately on an element by element basis.
This class will curently make an internal copy of the data supplied to it, and sort the data if it is not told it is already sorted, by using the sorted=True
flag.
This code fragment sets the interpolation method to cubic before interpolating on the supplied (x,y) vectors.
This class is motivated by the need to interpolate over the gain solutions obtained from calibrator observations, in order to get the gain at arbitrary times.
Definition at line 40 of file TabularCoordinate.h.
enum casacore::Interpolate1D::Method |
The different interpolation methods are enumerated here.
Enumerator | |
---|---|
nearestNeighbour |
Crude but sometimes useful. |
linear |
The most common method and the Default. |
cubic |
Fits a third order polynomial to 4 pts. |
spline |
Natural Cubic Splines. |
Definition at line 144 of file Interpolate1D.h.
casacore::Interpolate1D< Domain, Range >::Interpolate1D | ( | ) |
The default constructor generates a useless object until the setData function has been called.
casacore::Interpolate1D< Domain, Range >::Interpolate1D | ( | const SampledFunctional< Domain > & | x, |
const SampledFunctional< Range > & | y, | ||
const Bool | sorted = False , |
||
const Bool | uniq = False |
||
) |
Construct an object with the specified data.
casacore::Interpolate1D< Domain, Range >::Interpolate1D | ( | const Interpolate1D< Domain, Range > & | other | ) |
The standard copy constructor, assignment operator and destructor.
Internal data is copied in both cases (copy semantics)
casacore::Interpolate1D< Domain, Range >::~Interpolate1D | ( | ) |
|
virtual |
A function to copy the Interpolate1D object.
Implements casacore::Function< T, U >.
|
virtual |
Interpolation is done using the () operator (see example above).
Actual use is through the virtual eval()
function.
|
inline |
inquire/set the current interpolation method.
uInts are used as arguments instead of the Interpolate1D::Method enumerator due to compiler limitations. See the example above (or the demo code) for the recommended way to call these functions.
Definition at line 195 of file Interpolate1D.h.
Vector<Domain> casacore::Interpolate1D< Domain, Range >::getX | ( | ) | const |
Access the data set that interpolation is done over.
This will usually be sorted.
Vector<Range> casacore::Interpolate1D< Domain, Range >::getY | ( | ) | const |
|
inlinevirtual |
Name of function.
Reimplemented from casacore::Function< T, U >.
Definition at line 182 of file Interpolate1D.h.
Interpolate1D<Domain, Range>& casacore::Interpolate1D< Domain, Range >::operator= | ( | const Interpolate1D< Domain, Range > & | other | ) |
|
private |
A private function for doing polynomial interpolation.
void casacore::Interpolate1D< Domain, Range >::setData | ( | const SampledFunctional< Domain > & | x, |
const SampledFunctional< Range > & | y, | ||
const Bool | sorted = False , |
||
const Bool | uniq = False |
||
) |
Define a new data set for the class to operate on.
Equivalent in many aspects to creating a new object.
void casacore::Interpolate1D< Domain, Range >::setMethod | ( | uInt | method | ) |
|
private |
Definition at line 215 of file Interpolate1D.h.
Referenced by casacore::Interpolate1D< Double, Double >::getMethod().
|
private |
Definition at line 216 of file Interpolate1D.h.
|
private |
Definition at line 217 of file Interpolate1D.h.
|
private |
Definition at line 219 of file Interpolate1D.h.
|
private |
Definition at line 218 of file Interpolate1D.h.