31 #include "../func/moffat.hpp"
33 #include "../../improc/eigenImage.hpp"
45 template<
typename realT>
79 else m_I0_idx = idx++;
85 else m_x0_idx = idx++;
87 if(alpha) m_alpha_idx = -1;
88 else m_alpha_idx = idx++;
90 if(beta) m_beta_idx = -1;
91 else m_beta_idx = idx++;
148 realT x0( realT * p )
174 realT alpha( realT * p )
176 if( m_alpha_idx < 0 )
182 return p[m_alpha_idx];
186 void alpha( realT * p,
190 if( m_alpha_idx < 0 )
196 p[m_alpha_idx] = nalpha;
201 realT beta( realT * p )
209 return p[m_beta_idx];
213 void beta( realT * p,
223 p[m_beta_idx] = nbeta;
255 template<
typename _realT>
258 typedef _realT realT;
260 static const int nparams = 6;
262 static void func(realT *p, realT *hx,
int m,
int n,
void *adata)
266 size_t idx_mat, idx_dat;
270 realT I0 = arr->I0(p);
272 realT x0 = arr->x0(p);
273 realT alpha = arr->alpha(p);
274 realT beta = arr->beta(p);
278 for(
int i=0; i<arr->
nx; ++i)
280 hx[i] = func::moffat<realT>(arr->
coords[i],I0,I, x0, alpha, beta) - arr->
data[i];
285 for(
int i=0; i<arr->
nx; ++i)
287 hx[i] = func::moffat<realT>(i,I0,I, x0, alpha, beta) - arr->
data[i];
303 template<
typename _realT>
309 typedef _realT realT;
358 arr.alpha(this->p,
alpha);
359 arr.beta(this->p,
beta);
394 return arr.I0( this->p );
403 return arr.I( this->p );
412 return arr.x0( this->p );
421 return arr.alpha( this->p );
430 return arr.beta( this->p );
445 template<
typename realT>
446 struct array2FitMoffat;
449 template<
typename _realT>
450 struct moffat2D_sym_fitter;
462 template<
typename fitterT>
468 typedef typename fitterT::realT realT;
519 arr.alpha(this->p,
alpha);
520 arr.beta(this->p,
beta);
543 return arr.I0( this->p );
552 return arr.I( this->p );
561 return arr.x0( this->p );
570 return arr.y0( this->p );
579 return arr.alpha( this->p );
588 return arr.beta( this->p );
607 template<
typename realT>
643 if(I0) m_I0_idx = -1;
644 else m_I0_idx = idx++;
647 else m_I_idx = idx++;
649 if(x0) m_x0_idx = -1;
650 else m_x0_idx = idx++;
652 if(y0) m_y0_idx = -1;
653 else m_y0_idx = idx++;
655 if(alpha) m_alpha_idx = -1;
656 else m_alpha_idx = idx++;
658 if(beta) m_beta_idx = -1;
659 else m_beta_idx = idx++;
664 realT I0( realT * p )
716 realT x0( realT * p )
742 realT y0( realT * p )
769 realT alpha( realT * p )
771 if( m_alpha_idx < 0 )
777 return p[m_alpha_idx];
781 void alpha( realT * p,
785 if( m_alpha_idx < 0 )
791 p[m_alpha_idx] = nalpha;
796 realT beta( realT * p )
804 return p[m_beta_idx];
808 void beta( realT * p,
818 p[m_beta_idx] = nbeta;
834 template<
typename _realT>
837 typedef _realT realT;
839 static const int nparams = 6;
841 static void func(realT *p, realT *hx,
int m,
int n,
void *adata)
845 size_t idx_mat, idx_dat;
849 realT I0 = arr->I0(p);
851 realT x0 = arr->x0(p);
852 realT y0 = arr->y0(p);
853 realT alpha = arr->alpha(p);
854 realT beta = arr->beta(p);
856 for(
int i=0; i<arr->
nx; ++i)
858 for(
int j=0; j<arr->
ny; ++j)
860 idx_mat = i+j*arr->
nx;
862 hx[idx_dat] = func::moffat2D<realT>(i,j,I0,I, x0, y0, alpha, beta) - arr->
data[idx_mat];
874 template<
typename realT>
Class to manage fitting a 1D Moffat to data via the levmarInterface.
realT beta()
Return the shape parameter.
void setGuess(realT I0, realT I, realT x0, realT alpha, realT beta)
Set the initial guess for a symmetric Moffat.
void setArray(realT *data, realT *coords, int nx)
Set the data aray and the coordinates.
void setArray(realT *data, int nx)
Set the data aray.
realT x0()
Get the center x-.
realT alpha()
Return the width parameter.
realT I0()
Get the current value of I0, the constant.
realT fwhm()
Return the full-width at half maximum.
realT I()
Get the current value of I, the peak scaling.
void setFixed(bool I0, bool I, bool x0, bool alpha, bool beta)
Set whether each parameter is fixed.
Class to manage fitting a 2D Moffat to data via the levmarInterface.
realT y0()
Get the center y-coordinate.
void setFixed(bool I0, bool I, bool x0, bool y0, bool alpha, bool beta)
Set whether each parameter is fixed.
void setArray(realT *data, int nx, int ny)
Set the data aray.
realT I()
Get the current value of I, the peak scaling.
realT I0()
Get the current value of I0, the constant.
realT beta()
Return the shape parameter.
realT x0()
Get the center x-.
void setGuess(realT I0, realT I, realT x0, realT y0, realT alpha, realT beta)
Set the initial guess for a symmetric Moffat.
realT fwhm()
Return the full-width at half maximum.
realT alpha()
Return the width parameter.
A templatized interface to the levmar package.
void allocate_params()
Allocate parameters array based on previous call to nParams.
int n
I: measurement vector dimension.
void * adata
Pointer to possibly additional data, passed uninterpreted to func & jacf.
realT moffatFWHM(realT alpha, realT beta)
Compute the full-width at half-maximum of a Moffat profile.
A c++ interface to the templatized levmar minimization routines..
Wrapper for a native array to pass to levmarInterface, with Moffat details.
realT * data
Pointer to the array of y values.
void setFixed(bool I0, bool I, bool x0, bool alpha, bool beta)
Set whether each parameter is fixed.
size_t nx
X dimension of the array.
realT * coords
Pointer to the array of x values (optional)
Wrapper for a native array to pass to levmarInterface, with Moffat details.
void setFixed(bool I0, bool I, bool x0, bool y0, bool alpha, bool beta)
Set whether each parameter is fixed.
size_t nx
X dimension of the array.
size_t ny
Y dimension of the array.
realT * data
Pointer to the array.
levmarInterface fitter structure for the 1D Moffat.
levmarInterface fitter structure for the symmetric Moffat.