31 #include "../func/airyPattern.hpp"
40 template<
typename realT>
43 template<
typename _realT>
44 struct airy2D_obs_fitter;
46 template<
typename _realT>
47 struct airy2D_obs_fitter_ps;
70 template<
typename fitterT>
76 typedef typename fitterT::realT realT;
78 static const int nparams = fitterT::nparams;
104 static_assert( nparams==4 ,
"fitAiry2D: Wrong setGuess called for platescale and/or cen-obs variable.");
120 static_assert( nparams==5 ,
"fitAiry2D: Wrong setGuess called for only platescale variable.");
138 static_assert( nparams==6 ,
"fitAiry2D: Wrong setGuess called for cen-obs not variable.");
148 void setArray(realT *data,
int nx,
int ny)
158 void cenObs( realT co )
224 template<
typename realT>
242 template<
typename _realT>
245 typedef _realT realT;
247 static const int nparams = 4;
249 static void func(realT *p, realT *hx,
int m,
int n,
void *adata)
253 size_t idx_mat, idx_dat;
266 for(
int i=0;i<arr->
nx; i++)
268 for(
int j=0;j<arr->
ny;j++)
270 idx_mat = i+j*arr->
nx;
272 r = sqrt( pow( i-p[2],2) + pow(j-p[3],2));
274 hx[idx_dat] =
func::airyPattern(
static_cast<realT
>(i),
static_cast<realT
>(j), p[0], p[1], p[2], p[3], arr->
ps, arr->
cenObs) - arr->
data[idx_mat];
292 template<
typename _realT>
295 typedef _realT realT;
297 static const int nparams = 5;
299 static void func(realT *p, realT *hx,
int m,
int n,
void *adata)
303 size_t idx_mat, idx_dat;
317 for(
int i=0;i<arr->
nx; i++)
319 for(
int j=0;j<arr->
ny;j++)
321 idx_mat = i+j*arr->
nx;
323 r = sqrt( pow( i-p[2],2) + pow(j-p[3],2));
325 hx[idx_dat] =
func::airyPattern(
static_cast<realT
>(i),
static_cast<realT
>(j), p[0], p[1], p[2], p[3], p[4], arr->
cenObs) - arr->
data[idx_mat];
342 template<
typename _realT>
345 typedef _realT realT;
347 static const int nparams = 6;
349 static void func(realT *p, realT *hx,
int m,
int n,
void *adata)
353 size_t idx_mat, idx_dat;
368 for(
int i=0;i<arr->
nx; ++i)
370 for(
int j=0;j<arr->
ny; ++j)
372 idx_mat = i+j*arr->
nx;
376 hx[idx_dat] =
func::airyPattern(
static_cast<realT
>(i),
static_cast<realT
>(j), p[0], p[1], p[2], p[3], p[4], p[5]) - arr->
data[idx_mat];
391 template<
typename realT>
397 template<
typename realT>
403 template<
typename realT>
Class to manage fitting a 2D Airy pattern to data via the levmarInterface.
void setGuess(realT A0, realT A, realT x0, realT y0, realT ps)
Set the initial guess when platescale is variable, and central obscuration is fixed.
void setGuess(realT A0, realT A, realT x0, realT y0)
Set the initial guess when platescale and central obscuration are fixed.
void setGuess(realT A0, realT A, realT x0, realT y0, realT ps, realT co)
Set the initial guess when central-obscuration is variable.
A templatized interface to the levmar package.
int fit()
Perform the fit.
void allocate_params()
Allocate parameters array based on previous call to nParams.
realT * p
Parameter array. On input is the initial estimates. On output has the estimated solution.
int n
I: measurement vector dimension.
void * adata
Pointer to possibly additional data, passed uninterpreted to func & jacf.
realT airyPattern(realT x)
The classical Airy pattern.
A c++ interface to the templatized levmar minimization routines..
levmarInterface fitter structure for the obstructed Airy pattern, including fitting platescale and ce...
levmarInterface fitter structure for the obstructed Airy pattern, including platescale.
levmarInterface fitter structure for the centrally obscured Airy pattern.
Wrapper for a native array to pass to levmarInterface, with Airy details.
size_t ny
Y dimension of the array.
realT * data
Pointer to the array.
realT cenObs
is the ratio of the circular central obscuration diameter to the diameter.
realT ps
the platescale in
size_t nx
X dimension of the array.