Changeset 14937
- Timestamp:
- Sep 20, 2007, 2:06:57 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/objects/pmPSFtry.c (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/objects/pmPSFtry.c
r14652 r14937 5 5 * @author EAM, IfA 6 6 * 7 * @version $Revision: 1.4 4$ $Name: not supported by cvs2svn $8 * @date $Date: 2007-0 8-24 00:11:02$7 * @version $Revision: 1.45 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2007-09-21 00:06:57 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 24 24 #include "pmResiduals.h" 25 25 #include "pmGrowthCurve.h" 26 #include "pmTrend2D.h" 26 27 #include "pmPSF.h" 27 28 #include "pmModel.h" … … 70 71 71 72 test->psf = pmPSFAlloc (type, poissonErrors, psfTrendMask); 72 test->metric = psVectorAlloc (sources->n, PS_TYPE_F 64);73 test->metricErr = psVectorAlloc (sources->n, PS_TYPE_F 64);74 test->fitMag = psVectorAlloc (sources->n, PS_TYPE_F 64);73 test->metric = psVectorAlloc (sources->n, PS_TYPE_F32); 74 test->metricErr = psVectorAlloc (sources->n, PS_TYPE_F32); 75 test->fitMag = psVectorAlloc (sources->n, PS_TYPE_F32); 75 76 test->mask = psVectorAlloc (sources->n, PS_TYPE_U8); 76 77 … … 79 80 test->sources->data[i] = pmSourceCopy (sources->data[i]); 80 81 test->mask->data.U8[i] = 0; 81 test->metric->data.F 64[i] = 0;82 test->metricErr->data.F 64[i] = 0;83 test->fitMag->data.F 64[i] = 0;82 test->metric->data.F32[i] = 0; 83 test->metricErr->data.F32[i] = 0; 84 test->fitMag->data.F32[i] = 0; 84 85 } 85 86 … … 183 184 } 184 185 185 psfTry->fitMag->data.F 64[i] = source->psfMag;186 psfTry->metric->data.F 64[i] = source->apMag - source->psfMag;187 psfTry->metricErr->data.F 64[i] = source->errMag;186 psfTry->fitMag->data.F32[i] = source->psfMag; 187 psfTry->metric->data.F32[i] = source->apMag - source->psfMag; 188 psfTry->metricErr->data.F32[i] = source->errMag; 188 189 Npsf ++; 189 190 } … … 195 196 // measure the chi-square trend as a function of flux (PAR[PM_PAR_I0]) 196 197 // this should be linear for Poisson errors and quadratic for constant sky errors 197 psVector *flux = psVectorAlloc (psfTry->sources->n, PS_TYPE_F 64);198 psVector *chisq = psVectorAlloc (psfTry->sources->n, PS_TYPE_F 64);198 psVector *flux = psVectorAlloc (psfTry->sources->n, PS_TYPE_F32); 199 psVector *chisq = psVectorAlloc (psfTry->sources->n, PS_TYPE_F32); 199 200 psVector *mask = psVectorAlloc (psfTry->sources->n, PS_TYPE_MASK); 200 201 … … 203 204 pmSource *source = psfTry->sources->data[i]; 204 205 if (source->modelPSF == NULL) { 205 flux->data.F 64[i] = 0.0;206 chisq->data.F 64[i] = 0.0;206 flux->data.F32[i] = 0.0; 207 chisq->data.F32[i] = 0.0; 207 208 mask->data.U8[i] = 0xff; 208 209 } else { 209 flux->data.F 64[i] = source->modelPSF->params->data.F32[PM_PAR_I0];210 chisq->data.F 64[i] = source->modelPSF->chisq / source->modelPSF->nDOF;210 flux->data.F32[i] = source->modelPSF->params->data.F32[PM_PAR_I0]; 211 chisq->data.F32[i] = source->modelPSF->chisq / source->modelPSF->nDOF; 211 212 mask->data.U8[i] = 0; 212 213 } … … 259 260 260 261 // r2rflux = radius^2 * ten(0.4*fitMag); 261 psVector *r2rflux = psVectorAlloc (psfTry->sources->n, PS_TYPE_F 64);262 psVector *r2rflux = psVectorAlloc (psfTry->sources->n, PS_TYPE_F32); 262 263 263 264 for (int i = 0; i < psfTry->sources->n; i++) { 264 265 if (psfTry->mask->data.U8[i] & PSFTRY_MASK_ALL) 265 266 continue; 266 r2rflux->data.F 64[i] = PS_SQR(RADIUS) * pow(10.0, 0.4*psfTry->fitMag->data.F64[i]);267 } 268 269 // XXX this analysis of the apResid statistics is only approximate. The fitted magnitudes270 // measure at this point (in the PSF fit) use Poisson errors, and are thus biased as a267 r2rflux->data.F32[i] = PS_SQR(RADIUS) * pow(10.0, 0.4*psfTry->fitMag->data.F32[i]); 268 } 269 270 // This analysis of the apResid statistics is only approximate. The fitted magnitudes 271 // measured at this point (in the PSF fit) use Poisson errors, and are thus biased as a 271 272 // function of magnitude. We re-measure the apResid statistics later in psphot using the 272 273 // linear, constant-error fitting. Do not reject outliers with excessive vigor here. … … 277 278 stats->clipIter = 3; 278 279 279 // XXX we used to include an asymmetric clipping in order to toss out contaminated stars.280 // test this on the very crowded field data.281 // stats->min = 1.0;282 // stats->max = 3.0;283 284 280 // fit ApTrend only to r2rflux, ignore x,y,flux variations for now 285 281 // linear clipped fit of ApResid to r2rflux … … 287 283 poly->mask[1] = 1; // fit only a constant offset (no SKYBIAS) 288 284 285 // XXX replace this with a psVectorStats call? since we are not fitting the trend 289 286 bool result = psVectorClipFitPolynomial1D (poly, stats, psfTry->mask, PSFTRY_MASK_ALL, psfTry->metric, psfTry->metricErr, r2rflux); 290 287 if (!result) { … … 312 309 fprintf (f, "%d %d, %f %f %f %f %f %f %f\n", 313 310 i, keep, x, y, 314 psfTry->fitMag->data.F 64[i],315 r2rflux->data.F 64[i],316 psfTry->metric->data.F 64[i],317 psfTry->metricErr->data.F 64[i],318 apfit->data.F 64[i]);311 psfTry->fitMag->data.F32[i], 312 r2rflux->data.F32[i], 313 psfTry->metric->data.F32[i], 314 psfTry->metricErr->data.F32[i], 315 apfit->data.F32[i]); 319 316 } 320 317 fclose (f); … … 322 319 } 323 320 324 pmPSFMaskApTrend (psfTry->psf->ApTrend, PM_PSF_APTREND_SKYBIAS); 325 psfTry->psf->ApTrend->coeff[0][0][0][0] = poly->coeff[0]; 326 psfTry->psf->ApTrend->coeff[0][0][1][0] = 0; 327 321 // XXX drop the skyBias value, or include above?? 328 322 psfTry->psf->skyBias = poly->coeff[1]; 329 323 psfTry->psf->ApResid = poly->coeff[0]; … … 356 350 357 351 // construct the fit vectors from the collection of objects 358 psVector *x = psVectorAlloc (psfTry->sources->n, PS_TYPE_F 64);359 psVector *y = psVectorAlloc (psfTry->sources->n, PS_TYPE_F 64);360 psVector *z = psVectorAlloc (psfTry->sources->n, PS_TYPE_F 64);352 psVector *x = psVectorAlloc (psfTry->sources->n, PS_TYPE_F32); 353 psVector *y = psVectorAlloc (psfTry->sources->n, PS_TYPE_F32); 354 psVector *z = psVectorAlloc (psfTry->sources->n, PS_TYPE_F32); 361 355 362 356 psVector *dz = NULL; 363 357 if (applyWeight) { 364 dz = psVectorAlloc (psfTry->sources->n, PS_TYPE_F 64);358 dz = psVectorAlloc (psfTry->sources->n, PS_TYPE_F32); 365 359 } 366 360 … … 371 365 continue; 372 366 373 // use F64 for polynomial fitting 374 x->data.F64[i] = source->modelEXT->params->data.F32[PM_PAR_XPOS]; 375 y->data.F64[i] = source->modelEXT->params->data.F32[PM_PAR_YPOS]; 367 x->data.F32[i] = source->modelEXT->params->data.F32[PM_PAR_XPOS]; 368 y->data.F32[i] = source->modelEXT->params->data.F32[PM_PAR_YPOS]; 376 369 377 370 // weight by the error on the source flux 378 371 if (dz) { 379 dz->data.F 64[i] = source->modelEXT->dparams->data.F32[PM_PAR_I0];372 dz->data.F32[i] = source->modelEXT->dparams->data.F32[PM_PAR_I0]; 380 373 } 381 374 } … … 397 390 398 391 // convert the measured source shape paramters to polarization terms 399 psVector *e0 = psVectorAlloc (psfTry->sources->n, PS_TYPE_F 64);400 psVector *e1 = psVectorAlloc (psfTry->sources->n, PS_TYPE_F 64);401 psVector *e2 = psVectorAlloc (psfTry->sources->n, PS_TYPE_F 64);392 psVector *e0 = psVectorAlloc (psfTry->sources->n, PS_TYPE_F32); 393 psVector *e1 = psVectorAlloc (psfTry->sources->n, PS_TYPE_F32); 394 psVector *e2 = psVectorAlloc (psfTry->sources->n, PS_TYPE_F32); 402 395 for (int i = 0; i < psfTry->sources->n; i++) { 403 396 pmSource *source = psfTry->sources->data[i]; … … 406 399 psEllipsePol pol = pmPSF_ModelToFit (source->modelEXT->params->data.F32); 407 400 408 e0->data.F 64[i] = pol.e0;409 e1->data.F 64[i] = pol.e1;410 e2->data.F 64[i] = pol.e2;401 e0->data.F32[i] = pol.e0; 402 e1->data.F32[i] = pol.e1; 403 e2->data.F32[i] = pol.e2; 411 404 } 412 405 … … 427 420 for (int i = 0; i < e0->n; i++) { 428 421 fprintf (f, "%f %f : %f %f %f : %d\n", 429 x->data.F 64[i], y->data.F64[i],430 e0->data.F 64[i], e1->data.F64[i], e2->data.F64[i], psfTry->mask->data.U8[i]);422 x->data.F32[i], y->data.F32[i], 423 e0->data.F32[i], e1->data.F32[i], e2->data.F32[i], psfTry->mask->data.U8[i]); 431 424 } 432 425 fclose (f); … … 457 450 if (source->modelEXT == NULL) 458 451 continue; 459 z->data.F 64[j] = source->modelEXT->params->data.F32[i];452 z->data.F32[j] = source->modelEXT->params->data.F32[i]; 460 453 } 461 454
Note:
See TracChangeset
for help on using the changeset viewer.
