mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
mx::math::fit::fitMoffat1D< _realT > Class Template Reference

template<typename _realT>
class mx::math::fit::fitMoffat1D< _realT >

Class to manage fitting a 1D Moffat to data via the levmarInterface.

Fits The Moffat Function to a 1-dimensional array of data.

This class allows for treating any of the parameters as fixed.

Template Parameters
fitterTa type meeting the requirements specified in levmarInterface.

Definition at line 304 of file fitMoffat.hpp.

#include <math/fit/fitMoffat.hpp>

+ Inheritance diagram for mx::math::fit::fitMoffat1D< _realT >:

Public Member Functions

void setFixed (bool I0, bool I, bool x0, bool alpha, bool beta)
 Set whether each parameter is fixed. More...
 
void setGuess (realT I0, realT I, realT x0, realT alpha, realT beta)
 Set the initial guess for a symmetric Moffat. More...
 
void setArray (realT *data, int nx)
 Set the data aray. More...
 
void setArray (realT *data, realT *coords, int nx)
 Set the data aray and the coordinates. More...
 
realT I0 ()
 Get the current value of I0, the constant. More...
 
realT I ()
 Get the current value of I, the peak scaling. More...
 
realT x0 ()
 Get the center x-. More...
 
realT alpha ()
 Return the width parameter. More...
 
realT beta ()
 Return the shape parameter. More...
 
realT fwhm ()
 Return the full-width at half maximum. More...
 
- Public Member Functions inherited from mx::math::fit::levmarInterface< moffat1D_fitter< _realT > >
 levmarInterface ()
 Default constructor. More...
 
 levmarInterface (realT *i_p, realT *i_x, int i_m, int i_n, void *i_adata)
 Setup constructor. More...
 
 ~levmarInterface ()
 Destructor. More...
 
void nParams (int i_m)
 Set number of parameters, but don't allocate. More...
 
int nParams ()
 Get the current number of parameters. More...
 
void allocate_params ()
 Allocate parameters array based on previous call to nParams. More...
 
void allocate_params (int i_m)
 Set number of parameters and allocate. More...
 
void point_params (realT *i_p)
 Point the parameter pointer at an externally allocated array. More...
 
void point_params (realT *i_p, int i_m)
 Point the parameter pointer at an externally allocated array. More...
 
void set_params (realT *i_p)
 Copy parameters to the parameter array. More...
 
realT * get_params ()
 Get current pointer array address. More...
 
void set_itmax (int i_itmax)
 Set the maximum number of iterations. More...
 
int get_itmax ()
 Get the maximum number of iterations. More...
 
void allocate_work ()
 Allocate the work and covar matrices. More...
 
void set_opts (int n, realT val)
 Set one of the minimization options to val. More...
 
void set_opts_default (int n=-1)
 Set one or all of the minimization options to the default. More...
 
realT get_opts (int n)
 Get the current value of an option. More...
 
int fit ()
 Perform the fit. More...
 
realT get_initial_norm ()
 Returns the L2-norm before minimization occurs. More...
 
realT get_final_norm ()
 Returns the L2-norm at the end of the minimization. More...
 
int get_iterations ()
 Get the number of iterations taken during the minimization. More...
 
int get_reason_code ()
 Get a code specifying the reason minimization terminated. More...
 
std::string get_reason_string ()
 Get the descriptive string describing the reason minimization terminated. More...
 
int get_fevals ()
 Get the number of function evaluations during the minimization. More...
 
int get_jevals ()
 Get the number of jacobian evaluations during the minimization. More...
 
int get_nlinsys ()
 Get the number of linear system solutions during the minimization. More...
 
double get_deltaT ()
 Get the elapsed time of the fit. More...
 
iosT & dumpParameters (iosT &ios)
 Output current parameters to a stream. More...
 
std::ostream & dumpParameters ()
 Dump the parameter vector to stdout. More...
 
iosT & dumpReport (iosT &ios, bool dumpParams=true)
 Output current parameters to a stream. More...
 
std::ostream & dumpReport (bool dumpParams=true)
 Dump a status report to stdout. More...
 

Additional Inherited Members

- Public Attributes inherited from mx::math::fit::levmarInterface< moffat1D_fitter< _realT > >
realT * x
 I: measurement vector. NULL implies a zero vector. More...
 
int n
 I: measurement vector dimension. More...
 
realT opts [LM_OPTS_SZ]
 Options passed to the minimization routines. See set_opts for details. More...
 
realT info [LM_INFO_SZ]
 Information regarding the minimization. More...
 
double deltaT
 Elapsed time of the fitting procedure. More...
 
realT * work
 Working memory passed to the levmar routines. More...
 
int work_sz
 The current size of the work array. More...
 
realT * covar
 Covariance matrix corresponding to LS solution; mxm. More...
 
int covar_sz
 The current size of the covar array. More...
 
bool getCovar
 Controls whether the covar array is allocated. More...
 
void * adata
 Pointer to possibly additional data, passed uninterpreted to func & jacf. More...
 
- Protected Attributes inherited from mx::math::fit::levmarInterface< moffat1D_fitter< _realT > >
realT * p
 Parameter array. On input is the initial estimates. On output has the estimated solution. More...
 
realT * init_p
 Parameter array on input, saved for comparison. More...
 
int m
 Parameter vector dimension (i.e. number of unknowns) More...
 
bool own_p
 Flag indicating whether the p array is owned by this object (for de-allocation). More...
 
int itmax
 Maximum number of iterations, default is 100. More...
 

Member Function Documentation

◆ alpha()

template<typename _realT >
realT mx::math::fit::fitMoffat1D< _realT >::alpha ( )
inline

Return the width parameter.

Returns
the current value of alpha

Definition at line 419 of file fitMoffat.hpp.

Referenced by mx::math::fit::fitMoffat1D< _realT >::fwhm(), mx::math::fit::fitMoffat1D< _realT >::setFixed(), and mx::math::fit::fitMoffat1D< _realT >::setGuess().

◆ beta()

template<typename _realT >
realT mx::math::fit::fitMoffat1D< _realT >::beta ( )
inline

Return the shape parameter.

Returns
the current value of beta

Definition at line 428 of file fitMoffat.hpp.

Referenced by mx::math::fit::fitMoffat1D< _realT >::fwhm(), mx::math::fit::fitMoffat1D< _realT >::setFixed(), and mx::math::fit::fitMoffat1D< _realT >::setGuess().

◆ fwhm()

template<typename _realT >
realT mx::math::fit::fitMoffat1D< _realT >::fwhm ( )
inline

Return the full-width at half maximum.

Returns
the FWHM calculated from alpha and beta

Definition at line 437 of file fitMoffat.hpp.

References mx::math::fit::fitMoffat1D< _realT >::alpha(), mx::math::fit::fitMoffat1D< _realT >::beta(), and mx::math::func::moffatFWHM().

◆ I()

template<typename _realT >
realT mx::math::fit::fitMoffat1D< _realT >::I ( )
inline

Get the current value of I, the peak scaling.

Returns
the current value of I

Definition at line 401 of file fitMoffat.hpp.

Referenced by mx::math::fit::fitMoffat1D< _realT >::setFixed(), and mx::math::fit::fitMoffat1D< _realT >::setGuess().

◆ I0()

template<typename _realT >
realT mx::math::fit::fitMoffat1D< _realT >::I0 ( )
inline

Get the current value of I0, the constant.

Returns
the current value of I0

Definition at line 392 of file fitMoffat.hpp.

Referenced by mx::math::fit::fitMoffat1D< _realT >::setFixed(), and mx::math::fit::fitMoffat1D< _realT >::setGuess().

◆ setArray() [1/2]

template<typename _realT >
void mx::math::fit::fitMoffat1D< _realT >::setArray ( realT *  data,
int  nx 
)
inline

Set the data aray.

Parameters
[in]datapointer to an nx sized array of the y-values to be fit
[in]nxthe number of pixels in the x direction of the data array

Definition at line 363 of file fitMoffat.hpp.

References mx::math::fit::array2FitMoffat1D< realT >::data, mx::math::fit::levmarInterface< moffat1D_fitter< _realT > >::n, and mx::math::fit::array2FitMoffat1D< realT >::nx.

◆ setArray() [2/2]

template<typename _realT >
void mx::math::fit::fitMoffat1D< _realT >::setArray ( realT *  data,
realT *  coords,
int  nx 
)
inline

Set the data aray and the coordinates.

Parameters
[in]datapointer to an nx sized array of the y-values to be fit
[in]coordspoint to an nx sized array of the x-values of the data
[in]nxthe number of pixels in the x direction of the data array

Definition at line 375 of file fitMoffat.hpp.

References mx::math::fit::array2FitMoffat1D< realT >::coords, mx::math::fit::array2FitMoffat1D< realT >::data, mx::math::fit::levmarInterface< moffat1D_fitter< _realT > >::n, and mx::math::fit::array2FitMoffat1D< realT >::nx.

◆ setFixed()

template<typename _realT >
void mx::math::fit::fitMoffat1D< _realT >::setFixed ( bool  I0,
bool  I,
bool  x0,
bool  alpha,
bool  beta 
)
inline

Set whether each parameter is fixed.

Sets the parameter indices appropriately.

Parameters
[in]I0if true, then I0 will be not be part of the fit
[in]Iif true, then I will be not be part of the fit
[in]x0if true, then x0 will be not be part of the fit
[in]alphaif true, then alpha will be not be part of the fit
[in]betaif true, then beta will be not be part of the fit

Definition at line 336 of file fitMoffat.hpp.

References mx::math::fit::levmarInterface< moffat1D_fitter< _realT > >::allocate_params(), mx::math::fit::fitMoffat1D< _realT >::alpha(), mx::math::fit::fitMoffat1D< _realT >::beta(), mx::math::fit::fitMoffat1D< _realT >::I(), mx::math::fit::fitMoffat1D< _realT >::I0(), mx::math::fit::array2FitMoffat1D< realT >::setFixed(), and mx::math::fit::fitMoffat1D< _realT >::x0().

◆ setGuess()

template<typename _realT >
void mx::math::fit::fitMoffat1D< _realT >::setGuess ( realT  I0,
realT  I,
realT  x0,
realT  alpha,
realT  beta 
)
inline

Set the initial guess for a symmetric Moffat.

Parameters
[in]I0the constant background level
[in]Ithe peak scaling
[in]x0the center x-coordinate
[in]alphathe width parameter
[in]betathe shape parameter

Definition at line 348 of file fitMoffat.hpp.

References mx::math::fit::fitMoffat1D< _realT >::alpha(), mx::math::fit::fitMoffat1D< _realT >::beta(), mx::math::fit::fitMoffat1D< _realT >::I(), mx::math::fit::fitMoffat1D< _realT >::I0(), and mx::math::fit::fitMoffat1D< _realT >::x0().

◆ x0()

template<typename _realT >
realT mx::math::fit::fitMoffat1D< _realT >::x0 ( )
inline

Get the center x-.

Returns
the current value of x0

Definition at line 410 of file fitMoffat.hpp.

Referenced by mx::math::fit::fitMoffat1D< _realT >::setFixed(), and mx::math::fit::fitMoffat1D< _realT >::setGuess().


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