- Timestamp:
- Mar 3, 2011, 3:11:09 PM (15 years ago)
- Location:
- branches/eam_branches/ipp-20110213/psModules/src/objects
- Files:
-
- 10 edited
-
pmModel.c (modified) (1 diff)
-
pmModel.h (modified) (1 diff)
-
pmPCMdata.c (modified) (2 diffs)
-
pmPCMdata.h (modified) (1 diff)
-
pmSourceFitModel.c (modified) (1 diff)
-
pmSourceFitPCM.c (modified) (2 diffs)
-
pmSourceFitSet.c (modified) (6 diffs)
-
pmSourceOutputs.c (modified) (1 diff)
-
pmSourcePhotometry.c (modified) (3 diffs)
-
pmSourcePhotometry.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20110213/psModules/src/objects/pmModel.c
r30705 r30784 67 67 tmp->chisqNorm = NAN; 68 68 tmp->nDOF = 0; 69 tmp->nPar = 0; 69 70 tmp->nPix = 0; 70 71 tmp->nIter = 0; -
branches/eam_branches/ipp-20110213/psModules/src/objects/pmModel.h
r30705 r30784 39 39 float magErr; ///< integrated model magnitude error 40 40 int nPix; ///< number of pixels used for fit 41 int nDOF; ///< number of degrees of freedom 41 int nPar; ///< number of parameters in fit 42 int nDOF; ///< number of degrees of freedom (nDOF = nPix - nPar) 42 43 int nIter; ///< number of iterations to reach min 43 44 pmModelStatus flags; ///< model status flags -
branches/eam_branches/ipp-20110213/psModules/src/objects/pmPCMdata.c
r30763 r30784 254 254 255 255 pcm->nPix = nPix; 256 pcm->nDOF = nPix - nParams - 1; 256 pcm->nPar = nParams; 257 pcm->nDOF = nPix - nParams; 257 258 258 259 return pcm; … … 341 342 return false; 342 343 } 344 pcm->nPar = nParams; 343 345 pcm->nDOF = pcm->nPix - nParams; 344 346 -
branches/eam_branches/ipp-20110213/psModules/src/objects/pmPCMdata.h
r30621 r30784 33 33 psMinConstraint *constraint; 34 34 int nPix; 35 int nPar; 35 36 int nDOF; 36 37 } pmPCMdata; -
branches/eam_branches/ipp-20110213/psModules/src/objects/pmSourceFitModel.c
r30763 r30784 236 236 model->covar = psMemIncrRefCounter(covar); 237 237 } 238 model->nIter = myMin->iter; 239 model->nPar = nParams; 240 238 241 psTrace ("psModules.objects", 4, "niter: %d, chisq: %f", myMin->iter, myMin->value); 239 242 240 243 // save the resulting chisq, nDOF, nIter 244 // NOTE: if (!options->poissonErrors) chisq will be wrong : recalculate 241 245 if (options->poissonErrors) { 242 246 model->chisq = myMin->value; 243 247 model->nPix = y->n; 244 model->nDOF = y->n - nParams;248 model->nDOF = y->n - model->nPar; 245 249 model->chisqNorm = model->chisq / model->nDOF; 246 250 } else { 247 pmSourceChisq (model, source->pixels, source->maskObj, source->variance, maskVal, options->covarFactor, nParams); 248 } 249 model->nIter = myMin->iter; 251 pmSourceChisqUnsubtracted (source, model, maskVal); 252 } 250 253 251 254 // set the model success or failure status -
branches/eam_branches/ipp-20110213/psModules/src/objects/pmSourceFitPCM.c
r30763 r30784 84 84 } 85 85 } 86 pcm->modelConv->nIter = myMin->iter; 87 pcm->modelConv->nPar = pcm->nPar; 86 88 87 89 // save the resulting chisq, nDOF, nIter … … 92 94 pcm->modelConv->chisqNorm = pcm->modelConv->chisq / pcm->modelConv->nDOF; 93 95 } else { 94 pmSourceChisq (pcm->modelConv, source->pixels, source->maskObj, source->variance, maskVal, fitOptions->covarFactor, pcm->nPix - pcm->nDOF - 1); 96 // xxx this is wrong because it does not convolve with the psf 97 pmSourceChisqUnsubtracted (source, pcm->modelConv, maskVal); 95 98 } 96 pcm->modelConv->nIter = myMin->iter;97 99 98 100 // set the model success or failure status -
branches/eam_branches/ipp-20110213/psModules/src/objects/pmSourceFitSet.c
r30763 r30784 335 335 psTrace ("psModules.objects", 4, " src %d", i); 336 336 337 model->nIter = myMin->iter; 338 // model->nPar is set by pmSourceFitSetMasks 339 337 340 // save the resulting chisq, nDOF, nIter 338 341 // these are not unique for any one source … … 340 343 model->chisq = myMin->value; 341 344 model->nPix = nPix; 342 model->nDOF = nPix - model-> params->n;345 model->nDOF = nPix - model->nPar; 343 346 model->chisqNorm = model->chisq / model->nDOF; 344 347 } else { 345 pmSourceChisq (model, source->pixels, source->maskObj, source->variance, maskVal, options->covarFactor, model->params->n);348 pmSourceChisqUnsubtracted (source, model, maskVal); 346 349 } 347 model->nIter = myMin->iter;348 350 349 351 // set the model success or failure status … … 399 401 for (int i = 0; i < set->paramSet->n; i++) { 400 402 psVector *paramOne = set->paramSet->data[i]; 403 pmModel *modelOne = set->modelSet->data[i]; 401 404 402 405 switch (mode) { … … 406 409 if (j == PM_PAR_I0) continue; 407 410 constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[n + j] = 1; 411 modelOne->nPar = 1; 408 412 } 409 413 break; … … 415 419 if (j == PM_PAR_I0) continue; 416 420 constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[n + j] = 1; 421 modelOne->nPar = 3; 417 422 } 418 423 break; … … 420 425 // EXT model fits all params (except sky) 421 426 constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[n + PM_PAR_SKY] = 1; 427 modelOne->nPar = paramOne->n - 1; 422 428 break; 423 429 default: -
branches/eam_branches/ipp-20110213/psModules/src/objects/pmSourceOutputs.c
r30763 r30784 72 72 } 73 73 74 *nImageOverlap = 1;74 *nImageOverlap = psMetadataLookupS32 (&status2, header, "NINPUTS"); 75 75 return true; 76 76 -
branches/eam_branches/ipp-20110213/psModules/src/objects/pmSourcePhotometry.c
r30772 r30784 741 741 # endif 742 742 743 // determine chisq, etc for linear normalization-only fit744 bool pmSourceChisq (pmModel *model, psImage *image, psImage *mask, psImage *variance, psImageMaskType maskVal , const float covarFactor, int nParams)743 // determine chisq, nPix, nDOF, chisqNorm : model->nPar must be set 744 bool pmSourceChisq (pmModel *model, psImage *image, psImage *mask, psImage *variance, psImageMaskType maskVal) 745 745 { 746 746 PS_ASSERT_PTR_NON_NULL(model, false); … … 757 757 if (variance->data.F32[j][i] <= 0) 758 758 continue; 759 // dC += PS_SQR (image->data.F32[j][i]) / (covarFactor * variance->data.F32[j][i]);760 759 dC += PS_SQR (image->data.F32[j][i]) / variance->data.F32[j][i]; 761 760 Npix ++; 762 761 } 763 762 } 764 765 763 model->nPix = Npix; 766 model->nDOF = Npix - nParams - 1;764 model->nDOF = Npix - model->nPar; 767 765 model->chisq = dC; 768 766 model->chisqNorm = dC / model->nDOF; … … 771 769 } 772 770 771 772 // return source aperture magnitude 773 bool pmSourceChisqUnsubtracted (pmSource *source, pmModel *model, psImageMaskType maskVal) 774 { 775 PS_ASSERT_PTR_NON_NULL(source, false); 776 PS_ASSERT_PTR_NON_NULL(model, false); 777 778 float dC = 0.0; 779 int Npix = 0; 780 781 // the model function returns the source flux at a position 782 psVector *coord = psVectorAlloc(2, PS_TYPE_F32); 783 784 psVector *params = model->params; 785 psImage *image = source->pixels; 786 psImage *mask = source->maskObj; 787 psImage *variance = source->variance; 788 789 int dX = image->col0; 790 int dY = image->row0; 791 792 for (int iy = 0; iy < image->numRows; iy++) { 793 for (int ix = 0; ix < image->numCols; ix++) { 794 795 // skip pixels which are masked 796 if (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] & maskVal) continue; 797 798 if (variance->data.F32[iy][ix] <= 0) continue; 799 800 coord->data.F32[0] = (psF32) ix + dX + 0.5; 801 coord->data.F32[1] = (psF32) iy + dY + 0.5; 802 803 // for the full model, add all points 804 float value = model->modelFunc (NULL, params, coord); 805 806 // fprintf (stderr, "%d, %d : %f, %f : %f - %f : %f\n", 807 // ix, iy, coord->data.F32[0], coord->data.F32[1], image->data.F32[iy][ix], value, dC); 808 809 dC += PS_SQR (image->data.F32[iy][ix] - value) / variance->data.F32[iy][ix]; 810 Npix ++; 811 } 812 } 813 model->nPix = Npix; 814 model->nDOF = Npix - model->nPar; 815 model->chisq = dC; 816 model->chisqNorm = dC / model->nDOF; 817 818 psFree (coord); 819 return (true); 820 } 773 821 774 822 double pmSourceModelWeight(const pmSource *Mi, int term, const bool unweighted_sum, const float covarFactor, psImageMaskType maskVal) -
branches/eam_branches/ipp-20110213/psModules/src/objects/pmSourcePhotometry.h
r30772 r30784 69 69 bool pmSourcePixelWeight (pmSource *source, pmModel *model, psImage *mask, psImageMaskType maskVal, float radius); 70 70 71 bool pmSourceChisq (pmModel *model, psImage *image, psImage *mask, psImage *weight, psImageMaskType maskVal, const float covarFactor, int nParams); 71 bool pmSourceChisq (pmModel *model, psImage *image, psImage *mask, psImage *weight, psImageMaskType maskVal); 72 bool pmSourceChisqUnsubtracted (pmSource *source, pmModel *model, psImageMaskType maskVal); 72 73 73 74 bool pmSourceMeasureDiffStats (pmSource *source, psImageMaskType maskVal, psImageMaskType markVal);
Note:
See TracChangeset
for help on using the changeset viewer.
