- Timestamp:
- Mar 3, 2011, 3:11:09 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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)
Note:
See TracChangeset
for help on using the changeset viewer.
