Changeset 5084 for trunk/psphot/src/pmPSFtry.c
- Timestamp:
- Sep 20, 2005, 6:48:16 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psphot/src/pmPSFtry.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/pmPSFtry.c
r5068 r5084 161 161 162 162 // XXX this function wants aperture radius for pmSourcePhotometry 163 pmPSFtryMetric (try, RADIUS);163 pmPSFtryMetric_Alt (try, RADIUS); 164 164 psLogMsg ("psphot.pspsf", 3, "try model %s, ap-fit: %f +/- %f, sky bias: %f\n", 165 165 modelName, try->psf->ApResid, try->psf->dApResid, try->psf->skyBias); … … 167 167 return (try); 168 168 } 169 170 169 171 170 bool pmPSFtryMetric (pmPSFtry *try, float RADIUS) { … … 195 194 } 196 195 fclose (f); 196 197 // XXX EAM : try 3hi/1lo sigma clipping on the rflux v dap fit 197 198 198 199 // find min and max of (1/flux): … … 297 298 return true; 298 299 } 300 301 bool pmPSFtryMetric_Alt (pmPSFtry *try, float RADIUS) { 302 303 // the measured (aperture - fit) magnitudes (dA == try->metric) 304 // depend on both the true ap-fit (dAo) and the bias in the sky measurement: 305 // dA = dAo + dsky/flux 306 // where flux is the flux of the star 307 // we fit this trend to find the infinite flux aperture correction (dAo), 308 // the nominal sky bias (dsky), and the error on dAo 309 // the values of dA are contaminated by stars with close neighbors in the aperture 310 // we use an outlier rejection to avoid this bias 311 312 // rflux = ten(0.4*fitMag); 313 psVector *rflux = psVectorAlloc (try->sources->n, PS_TYPE_F64); 314 for (int i = 0; i < try->sources->n; i++) { 315 if (try->mask->data.U8[i] & PSFTRY_MASK_ALL) continue; 316 rflux->data.F64[i] = pow(10.0, 0.4*try->fitMag->data.F64[i]); 317 } 318 319 // XXX EAM : try 3hi/1lo sigma clipping on the rflux vs metric fit 320 psStats *stats = psStatsAlloc (PS_STAT_SAMPLE_MEDIAN | PS_STAT_SAMPLE_STDEV); 321 322 // XXX EAM 323 stats->min = 1.0; 324 stats->max = 3.0; 325 stats->clipIter = 3; 326 327 // linear fit to rfBin, daBin 328 psPolynomial1D *poly = Polynomial1DAlloc_EAM (PS_POLYNOMIAL_ORD, 1); 329 330 // XXX EAM : this is the intended API (cycle 7? cycle 8?) 331 poly = VectorClipFitPolynomial1D_EAM (poly, stats, try->mask, PSFTRY_MASK_ALL, try->metric, NULL, rflux); 332 333 fprintf (stderr, "fit stats: %f +/- %f\n", stats->sampleMedian, stats->sampleStdev); 334 335 // these stats should come back from the fit above... 336 // psVector *daFit = Polynomial1DEvalVector_EAM (poly, rflux); 337 // psVector *daResid = (psVector *) psBinaryOp (NULL, (void *) try->metric, "-", (void *) daFit); 338 339 // stats = psStatsAlloc (PS_STAT_CLIPPED_STDEV); 340 // stats->clipIter = 3; 341 // stats->clipSigma = 3; 342 343 // stats = psVectorStats (stats, daResid, NULL, maskB, 1); 344 345 try->psf->ApResid = poly->coeff[0]; 346 try->psf->dApResid = stats->sampleStdev; 347 try->psf->skyBias = poly->coeff[1] / (M_PI * PS_SQR(RADIUS)); 348 349 FILE *f; 350 f = fopen ("apresid.dat", "w"); 351 if (f == NULL) psAbort ("pmPSFtry", "can't open output file"); 352 353 for (int i = 0; i < try->sources->n; i++) { 354 fprintf (f, "%3d %8.4f %12.5e %8.4f %3d\n", i, try->fitMag->data.F64[i], rflux->data.F64[i], try->metric->data.F64[i], try->mask->data.U8[i]); 355 } 356 fclose (f); 357 358 psFree (rflux); 359 psFree (poly); 360 psFree (stats); 361 362 // psFree (daFit); 363 // psFree (daResid); 364 365 return true; 366 }
Note:
See TracChangeset
for help on using the changeset viewer.
