- Timestamp:
- Aug 22, 2007, 2:55:49 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20070817/psModules/src/objects/models/pmModel_GAUSS.c
r14544 r14612 28 28 # define PM_MODEL_FIT_STATUS pmModelFitStatus_GAUSS 29 29 30 // the model is a function of the pixel coordinate (pixcoord[0,1] = x,y) 30 31 psF32 PM_MODEL_FUNC(psVector *deriv, 31 32 const psVector *params, … … 39 40 psF32 py = Y / PAR[PM_PAR_SYY]; 40 41 psF32 z = PS_SQR(px) + PS_SQR(py) + PAR[PM_PAR_SXY]*X*Y; 42 assert (z >= 0.0); 43 41 44 psF32 r = exp(-z); 42 45 psF32 q = PAR[PM_PAR_I0]*r; … … 62 65 # define AR_MAX 20.0 63 66 # define AR_RATIO 0.99 67 64 68 bool PM_MODEL_LIMITS (psMinConstraintMode mode, int nParam, float *params, float *beta) 65 69 { … … 94 98 break; 95 99 case PM_PAR_SXX: 96 beta_lim = 0.5;100 beta_lim = 2.0; 97 101 break; 98 102 case PM_PAR_SYY: 99 beta_lim = 0.5;103 beta_lim = 2.0; 100 104 break; 101 105 case PM_PAR_SXY: … … 186 190 187 191 // make an initial guess for parameters 188 bool PM_MODEL_GUESS (void *inModel, void *inSource) 189 { 190 pmModel *model = inModel; 191 pmSource *source = inSource; 192 192 bool PM_MODEL_GUESS (pmModel *model, pmSource *source) 193 { 193 194 pmMoments *moments = source->moments; 194 195 psF32 *PAR = model->params->data.F32; … … 259 260 260 261 // construct the PSF model from the FLT model and the psf 261 bool PM_MODEL_FROM_PSF (void *inModelPSF, void *inModelFLT, void *inPSF) 262 { 263 pmModel *modelPSF = inModelPSF; 264 pmModel *modelFLT = inModelFLT; 265 pmPSF *psf = inPSF; 266 262 bool PM_MODEL_FROM_PSF (pmModel *modelPSF, pmModel *modelFLT, pmPSF *psf) 263 { 267 264 psF32 *out = modelPSF->params->data.F32; 268 265 psF32 *in = modelFLT->params->data.F32; 269 266 270 267 // we require these two parameters to exist 271 assert (psf->params _NEW->n > PM_PAR_YPOS);272 assert (psf->params _NEW->n > PM_PAR_XPOS);268 assert (psf->params->n > PM_PAR_YPOS); 269 assert (psf->params->n > PM_PAR_XPOS); 273 270 274 271 // supply the model-fitted parameters, or copy from the input 275 for (int i = 0; i < psf->params _NEW->n; i++) {276 if (psf->params _NEW->data[i] == NULL) {272 for (int i = 0; i < psf->params->n; i++) { 273 if (psf->params->data[i] == NULL) { 277 274 out[i] = in[i]; 278 275 } else { 279 psPolynomial2D *poly = psf->params _NEW->data[i];276 psPolynomial2D *poly = psf->params->data[i]; 280 277 out[i] = psPolynomial2DEval(poly, in[PM_PAR_XPOS], in[PM_PAR_YPOS]); 281 278 } … … 296 293 // apply the model limits here: this truncates excessive extrapolation 297 294 // XXX do we need to do this still? should we put in asserts to test? 298 for (int i = 0; i < psf->params _NEW->n; i++) {295 for (int i = 0; i < psf->params->n; i++) { 299 296 // apply the limits to all components or just the psf-model parameters? 300 if (psf->params _NEW->data[i] == NULL)297 if (psf->params->data[i] == NULL) 301 298 continue; 302 299 … … 315 312 // construct the PSF model from the FLT model and the psf 316 313 // XXX is this sufficiently general do be a global function, not a pmModelClass function? 317 bool PM_MODEL_PARAMS_FROM_PSF (void *inModel, void *inPSF, float Xo, float Yo, float Io) 318 { 319 pmModel *model = inModel; 320 pmPSF *psf = inPSF; 321 314 bool PM_MODEL_PARAMS_FROM_PSF (pmModel *model, pmPSF *psf, float Xo, float Yo, float Io) 315 { 322 316 psF32 *PAR = model->params->data.F32; 323 317 324 318 // we require these two parameters to exist 325 assert (psf->params _NEW->n > PM_PAR_YPOS);326 assert (psf->params _NEW->n > PM_PAR_XPOS);319 assert (psf->params->n > PM_PAR_YPOS); 320 assert (psf->params->n > PM_PAR_XPOS); 327 321 328 322 PAR[PM_PAR_SKY] = 0.0; … … 332 326 333 327 // supply the model-fitted parameters, or copy from the input 334 for (int i = 0; i < psf->params _NEW->n; i++) {328 for (int i = 0; i < psf->params->n; i++) { 335 329 if (i == PM_PAR_SKY) continue; 336 psPolynomial2D *poly = psf->params_NEW->data[i]; 330 if (i == PM_PAR_I0) continue; 331 if (i == PM_PAR_XPOS) continue; 332 if (i == PM_PAR_YPOS) continue; 333 psPolynomial2D *poly = psf->params->data[i]; 337 334 assert (poly); 338 335 PAR[i] = psPolynomial2DEval(poly, Xo, Yo); … … 349 346 // apply the model limits here: this truncates excessive extrapolation 350 347 // XXX do we need to do this still? should we put in asserts to test? 351 for (int i = 0; i < psf->params _NEW->n; i++) {348 for (int i = 0; i < psf->params->n; i++) { 352 349 // apply the limits to all components or just the psf-model parameters? 353 if (psf->params _NEW->data[i] == NULL)350 if (psf->params->data[i] == NULL) 354 351 continue; 355 352 … … 368 365 // this test is invalid if the parameters are derived 369 366 // from the PSF model 370 bool PM_MODEL_FIT_STATUS (void *inModel) 371 { 372 pmModel *model = inModel; 373 367 bool PM_MODEL_FIT_STATUS (pmModel *model) 368 { 374 369 psF32 dP; 375 370 bool status;
Note:
See TracChangeset
for help on using the changeset viewer.
