Changeset 13086
- Timestamp:
- Apr 30, 2007, 3:51:22 PM (19 years ago)
- Location:
- trunk/psphot/src
- Files:
-
- 4 edited
-
Makefile.am (modified) (1 diff)
-
psphot.h (modified) (1 diff)
-
psphotReadout.c (modified) (1 diff)
-
psphotSourceSize.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/Makefile.am
r13035 r13086 56 56 psphotMosaicSubimage.c \ 57 57 psphotMakeResiduals.c \ 58 psphotSourceSize.c \ 58 59 psphotAddNoise.c 59 60 -
trunk/psphot/src/psphot.h
r13052 r13086 108 108 bool psphotSetState (pmSource *source, bool curState); 109 109 bool psphotDeblendSatstars (psArray *sources, psMetadata *recipe); 110 bool psphotSourceSize (pmReadout *readout, psArray *sources, psMetadata *recipe); 110 111 111 112 bool psphotMakeResiduals (psArray *sources, psMetadata *recipe, pmPSF *psf); -
trunk/psphot/src/psphotReadout.c
r13035 r13086 128 128 psphotFitSourcesLinear (readout, sources, recipe, psf, FALSE); 129 129 if (dump) psphotSaveImage (NULL, readout->image, "image.v1.fits"); 130 131 // XXX test the CR/EXT measurement 132 psphotSourceSize (readout, sources, recipe); 133 130 134 if (!strcasecmp (breakPt, "ENSEMBLE")) { 131 135 goto finish; -
trunk/psphot/src/psphotSourceSize.c
r13081 r13086 1 1 # include "psphotInternal.h" 2 # include <gsl/gsl_sf_gamma.h> 2 3 3 // we need to call this function after sources have been fitted to the PSF 4 // model and subtracted. this function examines the 9 pixels in the 3x3 square containing the peak 5 // and compares the observed flux to the model. For the 4 pixel lines which contain the peak, we 6 // calculate the value 4 // we need to call this function after sources have been fitted to the PSF model and 5 // subtracted. this function examines the 9 pixels in the 3x3 square containing the peak and 6 // compares the observed flux to the model. 7 7 8 /* 9 * 10 * 11 * 12 * 13 * 14 */ 8 bool psphotSourceSize (pmReadout *readout, psArray *sources, psMetadata *recipe) { 15 9 16 bool psphotSourceSize (pmReadout *readout, psArray *sources, psMetadata *recipe, bool add) { 10 FILE *f = fopen ("srcsize.dat", "w"); 17 11 18 12 // loop over all source … … 23 17 if (!(source->mode & PM_SOURCE_MODE_SUBTRACTED)) continue; 24 18 25 psF32 * resid = source->pixels->data.F32;26 psF32 * weight = source->weight->data.F32;27 psU8 * mask = source->maskObj->data.U8;19 psF32 **resid = source->pixels->data.F32; 20 psF32 **weight = source->weight->data.F32; 21 psU8 **mask = source->maskObj->data.U8; 28 22 29 int xPeak = source->peak->xf - source->pixels->col0 ;30 int yPeak = source->peak->yf - source->pixels->row0 ;23 int xPeak = source->peak->xf - source->pixels->col0 + 0.5; 24 int yPeak = source->peak->yf - source->pixels->row0 + 0.5; 31 25 32 // XXX need to deal with edge peaks... 26 // XXX for now, just skip any sources with masked pixels 27 bool keep = true; 28 for (int iy = -1; (iy <= +1) && keep; iy++) { 29 for (int ix = -1; (ix <= +1) && keep; ix++) { 30 if (mask[yPeak+iy][xPeak+ix]) { keep &= false; } 31 } 32 } 33 if (!keep) continue; 34 35 // XXX need to deal with edge peaks... and mask 33 36 float cX = 2*resid[yPeak][xPeak] - resid[yPeak+0][xPeak-1] - resid[yPeak+0][xPeak+1]; 34 37 float cY = 2*resid[yPeak][xPeak] - resid[yPeak+1][xPeak+0] - resid[yPeak+1][xPeak+0]; … … 36 39 float cR = 2*resid[yPeak][xPeak] - resid[yPeak+1][xPeak-1] - resid[yPeak-1][xPeak+1]; 37 40 38 float dcX = 2*weight[yPeak][xPeak] - weight[yPeak+0][xPeak-1] - weight[yPeak+0][xPeak+1]; 39 float dcY = 2*weight[yPeak][xPeak] - weight[yPeak+1][xPeak+0] - weight[yPeak+1][xPeak+0]; 40 float dcL = 2*weight[yPeak][xPeak] - weight[yPeak-1][xPeak-1] - weight[yPeak+1][xPeak+1]; 41 float dcR = 2*weight[yPeak][xPeak] - weight[yPeak+1][xPeak-1] - weight[yPeak-1][xPeak+1]; 41 float dcX = 4*weight[yPeak][xPeak] + weight[yPeak+0][xPeak-1] + weight[yPeak+0][xPeak+1]; 42 float dcY = 4*weight[yPeak][xPeak] + weight[yPeak+1][xPeak+0] + weight[yPeak+1][xPeak+0]; 43 float dcL = 4*weight[yPeak][xPeak] + weight[yPeak-1][xPeak-1] + weight[yPeak+1][xPeak+1]; 44 float dcR = 4*weight[yPeak][xPeak] + weight[yPeak+1][xPeak-1] + weight[yPeak-1][xPeak+1]; 45 46 float nX = cX / sqrt(dcX); 47 float nY = cY / sqrt(dcY); 48 float nL = cL / sqrt(dcL); 49 float nR = cR / sqrt(dcR); 50 51 float chisq = PS_SQR (nX) + PS_SQR (nY) + PS_SQR (nX) + PS_SQR (nR); 52 53 // P(chisq > chisq_obs; Ndof) = gamma_Q (Ndof/2, chisq/2) 54 // Ndof = 4 ? (four measurements, no free parameters) 55 float Ppsf = gsl_sf_gamma_inc_Q (2, 0.5*chisq); 56 57 float fCR = 0.0; 58 float fEXT = 0.0; 59 int nCR = 0; 60 int nEXT = 0; 61 if (nX > 0.0) { 62 fCR += nX; 63 nCR ++; 64 } else { 65 fEXT += nX; 66 nEXT ++; 67 } 68 if (nY > 0.0) { 69 fCR += nY; 70 nCR ++; 71 } else { 72 fEXT += nY; 73 nEXT ++; 74 } 75 if (nL > 0.0) { 76 fCR += nL; 77 nCR ++; 78 } else { 79 fEXT += nL; 80 nEXT ++; 81 } 82 if (nR > 0.0) { 83 fCR += nR; 84 nCR ++; 85 } else { 86 fEXT += nR; 87 nEXT ++; 88 } 89 fCR = (nCR > 0) ? fCR / nCR : 0.0; 90 fEXT = (nEXT > 0) ? fEXT / nEXT : 0.0; 42 91 43 92 // XXX plot this as a function of flux / magnitude? 44 93 // XXX overlay outliers on an image? 45 94 46 // some possible classes: 47 // all 4 curvatures are highly negative : CR 48 // all 4 curvatures are highly positive : EXT 95 fprintf (f, "%f %f %f %f %f %f %f\n", source->peak->xf, source->peak->yf, source->peak->flux, 96 chisq, Ppsf, fCR, fEXT); 97 } 98 fclose (f); 99 return true; 100 } 49 101 50 // at least 2 are significantly negative, none are significantly positive : CR51 // at least 2 are significantly positive, none are significantly negative : EXT52 102 53 // any are significantly negative, some may be significantly positive : CR 54 // any are significantly positive, none may be significantly positive : EXT 103 // some possible classes: 104 // all 4 curvatures are highly negative : CR 105 // all 4 curvatures are highly positive : EXT 106 107 // at least 2 are significantly negative, none are significantly positive : CR 108 // at least 2 are significantly positive, none are significantly negative : EXT 109 110 // any are significantly negative, some may be significantly positive : CR 111 // any are significantly positive, none may be significantly positive : EXT 55 112 56 /* Nn Np No57 4 0 0 CR_158 3 1 0 CR_159 3 0 1 CR_160 2 2 0 CR_261 2 1 1 CR_262 2 0 2 CR_263 1 3 0 CR_364 1 2 1 CR_365 1 1 2 CR_366 1 0 3 CR_367 0 4 0 EXT68 0 3 1 EXT69 0 2 2 EXT70 0 1 3 PSF71 0 0 4 PSF72 */113 /* Nn Np No 114 4 0 0 CR_1 115 3 1 0 CR_1 116 3 0 1 CR_1 117 2 2 0 CR_2 118 2 1 1 CR_2 119 2 0 2 CR_2 120 1 3 0 CR_3 121 1 2 1 CR_3 122 1 1 2 CR_3 123 1 0 3 CR_3 124 0 4 0 EXT 125 0 3 1 EXT 126 0 2 2 EXT 127 0 1 3 PSF 128 0 0 4 PSF 129 */ 73 130 74 /* I can write the formal probability that the 4 measurements are consistent with a PSF 75 * based on how large the error values are (Nsigma -> erf -> P(Nsigma)). 76 * I should examine this value as a function of flux and also examine the distribution of 77 * the probabilities for the PSF sources. 78 */ 131 /* Alternatively, write a f(CR) = Sum(nX,etc if >0) */ 132 133 134 /* I can write the formal probability that the 4 measurements are consistent with a PSF 135 * based on how large the error values are (Nsigma -> erf -> P(Nsigma)). 136 * I should examine this value as a function of flux and also examine the distribution of 137 * the probabilities for the PSF sources. 138 */ 139
Note:
See TracChangeset
for help on using the changeset viewer.
