Loading...
Searching...
No Matches
casacore::Gaussian3D< T > Class Template Reference
scimath package (libcasa_scimath) » Functionals_module

More...

`#include <Gaussian3D.h>`

## Public Member Functions

| Gaussian3D ()
| A functional for a rotated, 3D Gaussian.
| Gaussian3D (T height, const Vector< T > &center, const Vector< T > &width, T theta, T phi)
| Gaussian3D (T &height, T &xCenter, T &yCenter, T &zCenter, T &xWidth, T &yWidth, T &zWidth, T &theta, T &phi)
| Gaussian3D (const Gaussian3D< T > &other)
| Copy constructor.
template<class W>
| Gaussian3D (const Gaussian3D< W > &other)
virtual | ~Gaussian3D ()
| Destructor.
Gaussian3D< T > & | operator= (const Gaussian3D< T > &other)
| Assignment operator.
virtual T | eval (typename Function< T >::FunctionArg x) const
| Evaluate the Gaussian at x.
virtual Function< T > * | clone () const
| Return a copy of this object from the heap.
virtual Function< typename FunctionTraits< T >::DiffType > * | cloneAD () const
virtual Function< typename FunctionTraits< T >::BaseType > * | cloneNonAD () const
Public Member Functions inherited from casacore::Gaussian3DParam< T >
| Gaussian3DParam ()
| Constructs the three dimensional Gaussians.
Gaussian3DParam< T > & | operator= (const Gaussian3DParam< T > &other)
| Copy assignment.
virtual | ~Gaussian3DParam ()
| Destructor.
virtual const String & | name () const
| Give name of function.
virtual uInt | ndim () const
| Return dimensionality.
T | height () const
| Get or set the peak height of the Gaussian.
void | setHeight (const T &height)
T | flux () const
| Get or set the total flux of the Gaussian.
void | setFlux (const T &flux)
Vector< T > | center () const
| Get or cet the center coordinates of the Gaussian.
void | setCenter (const Vector< T > &center)
T | xCenter () const
void | setXcenter (const T &xcenter)
T | yCenter () const
void | setYcenter (const T &ycenter)
T | zCenter () const
void | setZcenter (const T &zcenter)
Vector< T > | width () const
| Get or set the sigma-width of the Gaussian.
void | setWidth (const Vector< T > &width)
void | setXwidth (const T &xwidth)
T | xWidth () const
void | setYwidth (const T &ywidth)
T | yWidth () const
void | setZwidth (const T &zwidth)
T | zWidth () const
T | theta () const
| Get or set the rotation angles of the Gaussian.
void | settheta (const T &sT)
T | phi () const
void | setphi (const T &sP)
Public Member Functions inherited from casacore::Function< T, U >
| Function ()
| Constructors.
| 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.
uInt | nparameters () const
| Returns the number of parameters.
virtual U | eval (FunctionArg x) const =0
| Evaluate the function object.
T & | operator[] (const uInt n)
| Manipulate the nth parameter (0-based) with no index check.
const T & | operator[] (const uInt n) const
virtual U | operator() () const
| Evaluate this function object at xor at x, y.
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.
const Bool & | mask (const uInt n) const
const FunctionParam< T > & | parameters () const
| Return the parameter interface.
FunctionParam< T > & | parameters ()
const Vector< ArgType > & | argp () const
| Get arg_p and parset_p.
Bool | parsetp () const
void | lockParam ()
| Compiler cannot always find the correct 'const' version of parameter access.
void | unlockParam ()
virtual void | setMode (const RecordInterface &mode)
| get/set the function mode.
virtual void | getMode (RecordInterface &mode) const
virtual Bool | hasMode () const
| return True if the implementing function supports a mode.
ostream & | print (ostream &os) const
| Print the function (i.e.
Public Member Functions inherited from casacore::Functional< FunctionTraits< T >::ArgType, T >
virtual | ~Functional ()
| Destructor.
virtual T | operator() (const FunctionTraits< T >::ArgType &x) const=0
| Map a Domain x into a Range y value.
Public Member Functions inherited from casacore::Functional< Vector< FunctionTraits< T >::ArgType >, T >
virtual | ~Functional ()
| Destructor.
virtual T | operator() (const Vector< FunctionTraits< T >::ArgType > &x) const=0
| Map a Domain x into a Range y value.

## Private Member Functions

T | sq (T v) const
| AutoDiff does not have a square() function, so one is provided here.

## Additional Inherited Members

Public Types inherited from casacore::Gaussian3DParam< T >
enum |
| Parameter handling for the functional for 3D Gaussian Class. More...
Public Types inherited from casacore::Function< T, U >
typedef FunctionTraits< T >::ArgType | ArgType
typedef const ArgType * | FunctionArg
Protected Member Functions inherited from casacore::Gaussian3DParam< T >
void | settrigvals () const
Protected Attributes inherited from casacore::Gaussian3DParam< T >
T | fwhm2int
T | stoT_p
T | stoP_p
T | cosT_p
T | sinT_p
T | cosP_p
T | sinP_p
T | cosTcosP_p
T | cosTsinP_p
T | sinTcosP_p
T | sinTsinP_p
Protected Attributes inherited from casacore::Function< T, U >
FunctionParam< T > | param_p
| The parameters and masks.
Vector< ArgType > | arg_p
| Aid for non-contiguous argument storage.
Bool | parset_p
| Indicate parameter written.
Bool | locked_p
| Indicate that parameters are expected to be locked from changing.

## Detailed Description

template<class T>
class casacore::Gaussian3D< T >

A three dimensional Gaussian class.

### Intended use:

Public interface

### Review Status

Test programs:
  tGaussian3D

### Prerequisite

- Gaussian3DParam
- Function

### Etymology

A Gaussian3D functional is designed exclusively for calculating a Gaussian (or Normal) distribution in three dimensions. Other classes exist for calculating these functions in one (Gaussian1D), two (Gaussian2D), and N (GaussianND) dimensions.

### Synopsis

A Gaussian3D is described by a height, center, and width, and position angles. Its fundamental operation is evaluating itself at some (x,y,z) coordinate. Its parameters (height, center and width, position angles) may be changed at run time.

The width of the Gaussian is now specified in terms of the full width at half maximum (FWHM), like the 2D and 1D Gaussian functional classes.

The three axis values refer to the x, y, and z axes, and unlike with the 2D Gaussian any of the three axes may be the longest; instead, the position angles are restricted. The first position angle, theta, is the longitudinal angle, referring to the rotation (counterclockwise) around the z-axis. The second, phi, is the latidudinal angle, referring to the rotation around the theta-rotated y axis. The domain of both angles is -pi/4 < A < pi/4, although the angles are not constrained when fitting and can be set outside the domain by setting the parameters directly using Functional operator[]. (Note that the use of theta and phi corresponds to the mathematics convention for these angles, not the physics convention.)

The parameter interface (see Gaussian3DParam class), is used to provide an interface to the Fitting classes.

There are 9 parameters that are used to describe the Gaussian:

1. The height of the Gaussian. This is identical to the value returned using the height member function.
2. The center of the Gaussian in the x direction. This is identical to the value returned using the xCenter member function.
3. The center of the Gaussian in the y direction. This is identical to the value returned using the yCenter member function.
4. The center of the Gaussian in the z direction. This is identical to the value returned using the zCenter member function.
5. The width of the Gaussian along the x-axis.
6. The width of the Gaussian along the y-axis.
7. The width of the Gaussian along the z-axis.
8. The longitudinal position angle, theta (in radians)
9. The latitudinal position angle, phi (also in radians).

An enumeration for the parameter index is provided, enabling the setting and reading of parameters with the [] operator. The mask() methods can be used to check and set the parameter masks.

### Example

Gaussian3D<Double> g(9.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0);
Vector<Double> x(3);
x(0) = 1.0; x(1) = 0.5; x(2) = 0.0
cout << "g(" << x(0) << "," << x(1) << "," << x(2) << ")=" << g(x) << endl;
casacore::Gaussian3D::Gaussian3D
Gaussian3D()
A functional for a rotated, 3D Gaussian.
casacore::Vector
Definition Vector.h:82

### Motivation

The GaussianND class does not contain explicit derivatives and was insufficient for fitting 3D Gaussians to data.

### Template Type Argument Requirements (T)

- T should have standard numerical operators and exp() function. Current implementation only tested for real types.
- To obtain derivatives, the derivatives should be defined.

### Thrown Exceptions

- Assertion in debug mode if attempt is made to set a negative width
- AipsError if incorrect parameter number specified.
- Assertion in debug mode if operator(Vector<>) with empty Vector

### To Do

- Optimize derivative calculations for faster fitting?

Definition at line 141 of file Gaussian3D.h.

## Constructor & Destructor Documentation

## Gaussian3D() [1/5]

template<class T>

casacore::Gaussian3D< T >::Gaussian3D | ( |  | ) |

A functional for a rotated, 3D Gaussian.

Similar to Gaussian2D, but the xWidth, yWidth, and zWidth parameters are not adjusted for FWHM; they are identical to the parameters used in the function.

Constructs the three-dimensional Gaussians. Defaults: height = 1, center = {0,0,0}, width = {1,1,1}, theta = phi = 0. The center and width vectors must have three elements.

Referenced by cloneAD(), cloneNonAD(), Gaussian3D(), Gaussian3D(), and operator=().

## Gaussian3D() [2/5]

template<class T>

casacore::Gaussian3D< T >::Gaussian3D | ( | T | height,
|  | const Vector< T > & | center,
|  | const Vector< T > & | width,
|  | T | theta,
|  | T | phi )

References casacore::Gaussian3DParam< T >::center(), casacore::Gaussian3DParam< T >::height(), casacore::Gaussian3DParam< T >::phi(), casacore::Gaussian3DParam< T >::theta(), and casacore::Gaussian3DParam< T >::width().

## Gaussian3D() [3/5]

template<class T>

casacore::Gaussian3D< T >::Gaussian3D | ( | T & | height,
|  | T & | xCenter,
|  | T & | yCenter,
|  | T & | zCenter,
|  | T & | xWidth,
|  | T & | yWidth,
|  | T & | zWidth,
|  | T & | theta,
|  | T & | phi )

References casacore::Gaussian3DParam< T >::height(), casacore::Gaussian3DParam< T >::phi(), casacore::Gaussian3DParam< T >::theta(), casacore::Gaussian3DParam< T >::xCenter(), casacore::Gaussian3DParam< T >::xWidth(), casacore::Gaussian3DParam< T >::yCenter(), casacore::Gaussian3DParam< T >::yWidth(), casacore::Gaussian3DParam< T >::zCenter(), and casacore::Gaussian3DParam< T >::zWidth().

## Gaussian3D() [4/5]

template<class T>

casacore::Gaussian3D< T >::Gaussian3D | ( | const Gaussian3D< T > & | other | ) |

Copy constructor.

References Gaussian3D().

## Gaussian3D() [5/5]

template<class T>
template<class W>

casacore::Gaussian3D< T >::Gaussian3D | ( | const Gaussian3D< W > & | other | ) |

inline

Definition at line 163 of file Gaussian3D.h.

References Gaussian3D(), and casacore::Gaussian3DParam< T >::Gaussian3DParam().

## ~Gaussian3D()

template<class T>

virtual casacore::Gaussian3D< T >::~Gaussian3D | ( |  | ) |

virtual

Destructor.

## Member Function Documentation

## clone()

template<class T>

virtual Function< T > * casacore::Gaussian3D< T >::clone | ( |  | ) | const

virtual

Return a copy of this object from the heap.

The caller is responsible for deleting this pointer.

Implements casacore::Function< T, U >.

## cloneAD()

template<class T>

virtual Function< typename FunctionTraits< T >::DiffType > * casacore::Gaussian3D< T >::cloneAD | ( |  | ) | const

inline virtual

Reimplemented from casacore::Function< T, U >.

Definition at line 179 of file Gaussian3D.h.

References Gaussian3D().

## cloneNonAD()

template<class T>

virtual Function< typename FunctionTraits< T >::BaseType > * casacore::Gaussian3D< T >::cloneNonAD | ( |  | ) | const

inline virtual

Reimplemented from casacore::Function< T, U >.

Definition at line 181 of file Gaussian3D.h.

References Gaussian3D().

## eval()

template<class T>

virtual T casacore::Gaussian3D< T >::eval | ( | typename Function< T >::FunctionArg | x | ) | const

virtual

Evaluate the Gaussian at x.

## operator=()

template<class T>

Gaussian3D< T > & casacore::Gaussian3D< T >::operator= | ( | const Gaussian3D< T > & | other | ) |

Assignment operator.

References Gaussian3D().

## sq()

template<class T>

T casacore::Gaussian3D< T >::sq | ( | T | v | ) | const

private

AutoDiff does not have a square() function, so one is provided here.

References casacore::Gaussian3DParam< T >::AX, casacore::Gaussian3DParam< T >::AY, casacore::Gaussian3DParam< T >::AZ, casacore::Gaussian3DParam< T >::cosP_p, casacore::Gaussian3DParam< T >::cosT_p, casacore::Gaussian3DParam< T >::cosTcosP_p, casacore::Gaussian3DParam< T >::cosTsinP_p, casacore::Gaussian3DParam< T >::CX, casacore::Gaussian3DParam< T >::CY, casacore::Gaussian3DParam< T >::CZ, casacore::Gaussian3DParam< T >::fwhm2int, casacore::Gaussian3DParam< T >::Gaussian3DParam(), casacore::Gaussian3DParam< T >::H, casacore::Function< T, U >::param_p, casacore::Gaussian3DParam< T >::PHI, casacore::Gaussian3DParam< T >::settrigvals(), casacore::Gaussian3DParam< T >::sinP_p, casacore::Gaussian3DParam< T >::sinT_p, casacore::Gaussian3DParam< T >::sinTcosP_p, casacore::Gaussian3DParam< T >::sinTsinP_p, casacore::Gaussian3DParam< T >::stoP_p, casacore::Gaussian3DParam< T >::stoT_p, and casacore::Gaussian3DParam< T >::THETA.

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

- scimath/Functionals/Gaussian3D.h