Changeset 20084
- Timestamp:
- Oct 12, 2008, 4:05:31 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/psphot/src/psphotEvalPSF.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psphotEvalPSF.c
r16820 r20084 1 1 # include "psphotInternal.h" 2 2 3 // given a pmSource which has been fitted using modelPSF, evaluate the 4 // resulting fit: did the fit succeed? is this object PSF-like? is this object5 // extended? return status is TRUE for a valid PSF, FALSE otherwise.3 // given a pmSource which has been fitted using modelPSF, evaluate the resulting fit: did 4 // the fit succeed? is this object saturated? return status is TRUE for a successful PSF 5 // fit, FALSE otherwise. 6 6 7 // identify objects consistent with PSF shape/magnitude distribution 8 // we expect dparams[PM_PAR_SXX],dparams[PM_PAR_SXX] to have a scatter of: 9 // sigma_x / (S/N) 10 11 // any objects which is consistent with the PSF should have 12 // abs(dparams[PM_PAR_SXX]) < N * dsxLine(mag) & abs(dparams[PM_PAR_SYY]) < N * dsyLine(mag) 13 // this includes a minimum buffer (DS) for the brighter objects 14 15 // EAM : 2006.10.20 : I have re-defined params[PM_PAR_SXX] : it is now sqrt(2)*sigma_x, not 1/sigma_x 16 17 // saturated stars should fall outside (larger), but have peaks above SATURATION 18 // extended sources should be larger, cosmic rays smaller 19 // we also reject objects with S/N too low or ChiSquare to high 20 21 // floor for DS value 22 // XXX EAM : add to configuration? 7 // NOTE : 2008.10.12 EAM : This function used to make a measurement of the consistency of 8 // the source shape with the PSF. This feature has been superceded with the 9 // much-better-defined psphotSourceSize.c function 23 10 24 11 static float SATURATION; 25 12 static float PSF_MIN_SN; 26 static float PSF_MIN_DS;27 13 static float PSF_MAX_CHI; 28 static float PSF_SHAPE_NSIGMA;29 static float PSF_DSX_MEAN;30 static float PSF_DSY_MEAN;31 static float PSF_DSX_STDEV;32 static float PSF_DSY_STDEV;33 14 34 15 bool psphotInitLimitsPSF (psMetadata *recipe, pmReadout *readout) { … … 41 22 PSF_MIN_SN = psMetadataLookupF32 (&status, recipe, "PSF_MIN_SN"); 42 23 PSF_MAX_CHI = psMetadataLookupF32 (&status, recipe, "PSF_MAX_CHI"); 43 PSF_SHAPE_NSIGMA = psMetadataLookupF32 (&status, recipe, "PSF_SHAPE_NSIGMA");44 PSF_MIN_DS = psMetadataLookupF32 (&status, recipe, "PSF_MIN_DS");45 if (!status) PSF_MIN_DS = 0.01;46 47 PSF_DSX_MEAN = psMetadataLookupF32 (&status, recipe, "DSX_MEAN");48 PSF_DSY_MEAN = psMetadataLookupF32 (&status, recipe, "DSY_MEAN");49 PSF_DSX_STDEV = psMetadataLookupF32 (&status, recipe, "DSX_STDV");50 PSF_DSY_STDEV = psMetadataLookupF32 (&status, recipe, "DSY_STDV");51 24 52 25 return true; … … 58 31 59 32 int keep; 60 float dSX, dSY, SX, SY, SN; 61 float nSx, nSy, Chi; 33 float SN, Chi; 62 34 63 35 // do we actually have a valid PSF model? … … 122 94 123 95 SN = model->params->data.F32[PM_PAR_I0]/model->dparams->data.F32[PM_PAR_I0]; 124 SX = model->params->data.F32[PM_PAR_SXX];125 SY = model->params->data.F32[PM_PAR_SYY];126 dSX = model->dparams->data.F32[PM_PAR_SXX];127 dSY = model->dparams->data.F32[PM_PAR_SYY];128 96 Chi = model->chisqNorm / model->nDOF; 129 130 // swing of sigma_x,y in sigmas131 nSx = (dSX - PSF_DSX_MEAN) / (PSF_DSX_STDEV * PS_MAX (PSF_MIN_DS, (SX / SN)));132 nSy = (dSY - PSF_DSY_MEAN) / (PSF_DSY_STDEV * PS_MAX (PSF_MIN_DS, (SY / SN)));133 97 134 98 // assign PM_SOURCE_MODE_GOODSTAR to bright objects within PSF region of dparams[] 135 99 keep = TRUE; 136 // keep &= (fabs(nSx) < PSF_SHAPE_NSIGMA);137 // keep &= (fabs(nSy) < PSF_SHAPE_NSIGMA);138 100 keep &= (SN > PSF_MIN_SN); 139 101 keep &= (Chi < PSF_MAX_CHI); 140 102 141 103 if (source->mode & PM_SOURCE_MODE_SATSTAR) { 142 psTrace ("psphot", 5, "satstar fit results: %f, %f %d : %f %f : %f %f : %f %f\n", 143 model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS], keep, 144 dSX, nSx, dSY, nSy, SN, Chi); 104 psTrace ("psphot", 5, "satstar fit results: %f, %f %d : SN: %f Chisq: %f\n", 105 model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS], keep, SN, Chi); 145 106 } 146 107 147 108 if (keep) { 148 109 if (source->mode & PM_SOURCE_MODE_PSFSTAR) { 149 psTrace ("psphot", 7, "PSFSTAR kept (%f, %f : %f %f : %f %f : %f%f)\n",150 model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS], dSX, nSx, dSY, nSy,SN, Chi);110 psTrace ("psphot", 7, "PSFSTAR kept (%f, %f : SN: %f Chisq: %f)\n", 111 model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS], SN, Chi); 151 112 } 152 113 return true; … … 155 116 // this source is not a star, warn if it was a PSFSTAR 156 117 if (source->mode & PM_SOURCE_MODE_PSFSTAR) { 157 psTrace ("psphot", 5, "PSFSTAR demoted based on fit quality (%f, %f : %f %f : %f %f : %f%f)\n",158 model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS], dSX, nSx, dSY, nSy,SN, Chi);118 psTrace ("psphot", 5, "PSFSTAR demoted based on fit quality (%f, %f : SN: %f Chisq: %f)\n", 119 model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS], SN, Chi); 159 120 } else { 160 psTrace ("psphot", 5, "fails PSF fit (%f, %f : %f %f : %f %f : %f %f)\n", 161 model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS], dSX, nSx, dSY, nSy, SN, Chi); 162 } 163 164 // object appears to be small, suspected defect. this is a weak indication for a defect: a 165 // large positive or negative swing can also come from the bright sources for which we are 166 // more sensitive to the wings than for the faint sources. 167 // XXX allow -NSIGMA and +NSIGMA to have different values? 168 if ((nSx <= -PSF_SHAPE_NSIGMA) || (nSy <= -PSF_SHAPE_NSIGMA)) { 169 source->type = PM_SOURCE_TYPE_DEFECT; 170 return false; 171 } 172 173 // object appears to be large, suspected extended source 174 if ((nSx >= PSF_SHAPE_NSIGMA) || (nSy >= PSF_SHAPE_NSIGMA)) { 175 source->type = PM_SOURCE_TYPE_EXTENDED; 176 return false; 121 psTrace ("psphot", 5, "fails PSF fit (%f, %f : SN: %f Chisq: %f)\n", 122 model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS], SN, Chi); 177 123 } 178 124 … … 224 170 225 171 // if the object has a fitted peak below 0, the fit did not converge cleanly 226 if (model->params->data.F32[PM_PAR_I0] <= 0 ) {172 if (model->params->data.F32[PM_PAR_I0] <= 0.02) { 227 173 source->mode |= PM_SOURCE_MODE_FAIL; 228 174 return false;
Note:
See TracChangeset
for help on using the changeset viewer.
