Changeset 15000 for trunk/psphot/src/psphotApResid.c
- Timestamp:
- Sep 24, 2007, 11:27:58 AM (19 years ago)
- File:
-
- 1 edited
-
trunk/psphot/src/psphotApResid.c (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psphotApResid.c
r14965 r15000 1 1 # include "psphotInternal.h" 2 2 3 # define SKIPSTAR(MSG) { psTrace ("psphot", 3, "invalid : %s", MSG); continue; } 3 4 // measure the aperture residual statistics and 2D variations 4 5 bool psphotApResid (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf, psMaskType maskVal, psMaskType mark) … … 63 64 model = source->modelPSF; 64 65 65 if (source->type != PM_SOURCE_TYPE_STAR) continue;66 if (source->mode & PM_SOURCE_MODE_SATSTAR) continue;67 if (source->mode & PM_SOURCE_MODE_BLEND) continue;68 if (source->mode & PM_SOURCE_MODE_FAIL) continue;69 if (source->mode & PM_SOURCE_MODE_POOR) continue;66 if (source->type != PM_SOURCE_TYPE_STAR) SKIPSTAR ("NOT STAR"); 67 if (source->mode & PM_SOURCE_MODE_SATSTAR) SKIPSTAR ("SATSTAR"); 68 if (source->mode & PM_SOURCE_MODE_BLEND) SKIPSTAR ("BLEND"); 69 if (source->mode & PM_SOURCE_MODE_FAIL) SKIPSTAR ("FAIL STAR"); 70 if (source->mode & PM_SOURCE_MODE_POOR) SKIPSTAR ("POOR STAR"); 70 71 71 72 // get growth-corrected, apTrend-uncorrected magnitudes in scaled apertures … … 73 74 if (!pmSourceMagnitudes (source, psf, photMode, maskVal, mark)) { 74 75 Nskip ++; 76 psTrace ("psphot", 3, "skip : bad source mag"); 75 77 continue; 76 78 } 77 79 78 if (!isfinite(source->apMag) || !isfinite(source-> apMag)) {80 if (!isfinite(source->apMag) || !isfinite(source->psfMag)) { 79 81 Nfail ++; 82 psTrace ("psphot", 3, "fail : nan mags : %f %f", source->apMag, source->psfMag); 80 83 continue; 81 84 } … … 87 90 if ((MAX_AP_OFFSET > 0) && (fabs(dap) > MAX_AP_OFFSET)) { 88 91 Nfail ++; 92 psTrace ("psphot", 3, "fail : bad dap %f %f", dap, MAX_AP_OFFSET); 89 93 continue; 90 94 } … … 99 103 dMag->data.F32[Npsf] = model->dparams->data.F32[PM_PAR_I0] / model->params->data.F32[PM_PAR_I0]; 100 104 105 psVectorExtend (mag, 100, 1); 101 106 psVectorExtend (mask, 100, 1); 102 107 psVectorExtend (xPos, 100, 1); … … 146 151 } 147 152 153 // XXX catch error condition 148 154 psphotApResidTrend (readout, psf, Npsf, entryMin, &errorScale, &errorFloor, mask, xPos, yPos, apResid, dMag); 149 155 … … 152 158 psVector *apResidRes = (psVector *) psBinaryOp (NULL, (void *) apResid, "-", (void *) apResidFit); 153 159 psVector *dMagSys = (psVector *) psBinaryOp (NULL, (void *) dMag, "*", (void *) psScalarAlloc(errorScale, PS_TYPE_F32)); 154 155 psphotSaveImage (NULL, psf->ApTrend->map->map, "apresid.map.fits");156 160 157 161 if (psTraceGetLevel("psphot") >= 5) { … … 170 174 float xc = 0.5*readout->image->numCols + readout->image->col0 + 0.5; 171 175 float yc = 0.5*readout->image->numRows + readout->image->row0 + 0.5; 176 172 177 psf->ApResid = pmTrend2DEval (psf->ApTrend, xc, yc); // ap-fit at chip center 173 178 psf->dApResid = errorFloor; … … 206 211 */ 207 212 208 bool psphotMagErrorScale (float *errorScale, float *errorFloor, psVector *dMag, psVector *dap, int nGroup) {213 bool psphotMagErrorScale (float *errorScale, float *errorFloor, psVector *dMag, psVector *dap, psVector *mask, int nGroup) { 209 214 210 215 psStats *statsS = psStatsAlloc (PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV); … … 225 230 psVector *dMSubset = psVectorAllocEmpty (nGroup, PS_TYPE_F32); 226 231 psVector *dASubset = psVectorAllocEmpty (nGroup, PS_TYPE_F32); 232 psVector *mkSubset = psVectorAllocEmpty (nGroup, PS_TYPE_U8); 227 233 228 234 int n = 0; … … 233 239 dMSubset->data.F32[j] = dMag->data.F32[N]; 234 240 dASubset->data.F32[j] = dap->data.F32[N]; 241 mkSubset->data.U8[j] = mask->data.U8[N]; 235 242 } 236 243 dMSubset->n = j; 237 244 dASubset->n = j; 245 mkSubset->n = j; 238 246 239 247 psStatsInit (statsS); 240 248 psStatsInit (statsM); 241 249 242 psVectorStats (statsS, dASubset, NULL, NULL, 0xff);243 psVectorStats (statsM, dMSubset, NULL, NULL, 0xff);250 psVectorStats (statsS, dASubset, NULL, mkSubset, 0xff); 251 psVectorStats (statsM, dMSubset, NULL, mkSubset, 0xff); 244 252 245 253 dSo->data.F32[i] = statsS->robustStdev; … … 250 258 psFree (dMSubset); 251 259 psFree (dASubset); 260 psFree (mkSubset); 252 261 253 262 psStats *stats = psStatsAlloc (PS_STAT_SAMPLE_MEDIAN); … … 286 295 } 287 296 297 // the mask marks the values not used to calculate the ApTrend 298 psVectorInit (mask, 0); 299 288 300 // XXX stats structure for use by ApTrend : make parameters user setable 289 301 psStats *stats = psStatsAlloc (PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV); … … 305 317 // XXX this is a bit arbitrary, but it forces ~3 stars from the bright bin per spatial bin 306 318 int nGroup = PS_MAX (3*Nx*Ny, 10); 307 psphotMagErrorScale (errorScale, errorFloor, dMag, apResidRes, nGroup);319 psphotMagErrorScale (errorScale, errorFloor, dMag, apResidRes, mask, nGroup); 308 320 309 321 psLogMsg ("psphot.apresid", PS_LOG_INFO, "result of %d x %d grid (%d stars per bin)\n", Nx, Ny, nGroup);
Note:
See TracChangeset
for help on using the changeset viewer.
