Changeset 5600
- Timestamp:
- Nov 25, 2005, 4:45:06 PM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_rel8_b1/psModules/src/objects/pmPSFtry.c
r5255 r5600 183 183 184 184 // XXX this function wants aperture radius for pmSourcePhotometry 185 pmPSFtryMetric (try186 , RADIUS);185 pmPSFtryMetric_Alt (try 186 , RADIUS); 187 187 psLogMsg ("psphot.pspsf", 3, "try model %s, ap-fit: %f +/- %f, sky bias: %f\n", 188 188 modelName, try … … 277 277 // measure statistics only on upper 50% of points 278 278 // this would be easier if we could sort in reverse: 279 //280 // psVectorSort (tmp, tmp);281 // tmp->n = 0.5*tmp->n;282 // stats = psStatsAlloc (PS_STAT_SAMPLE_MEDIAN);283 // psVectorStats (stats, tmp, NULL, NULL, 0);284 // psTrace ("psphot.metricmodel", 4, "rfBin %d (%g): %d pts, %g\n", i, rfBin->data.F64[i], tmp->n, stats->sampleMedian);285 279 286 280 psVectorSort (tmp, tmp); … … 304 298 } 305 299 306 // linear fit to rfBin, daBin 307 psPolynomial1D *poly = psPolynomial1DAlloc(PS_POLYNOMIAL_ORD, 1); 308 309 // XXX EAM : this is the intended API (cycle 7? cycle 8?) 310 poly = psVectorFitPolynomial1D(poly, maskB, 1, daBin, NULL, rfBin); 311 312 // XXX EAM : replace this when the above version is implemented 313 // poly = psVectorFitPolynomial1DOrd(poly, maskB, rfBin, daBin, NULL); 300 // linear clipped fit to rfBin, daBin 301 psPolynomial1D *poly = psPolynomial1DAlloc(1, PS_POLYNOMIAL_ORD); 302 psStats *fitstat = psStatsAlloc (PS_STAT_SAMPLE_MEDIAN | PS_STAT_SAMPLE_STDEV); 303 poly = psVectorClipFitPolynomial1D (poly, fitstat, maskB, 1, daBin, NULL, rfBin); 314 304 315 305 psVector *daBinFit = psPolynomial1DEvalVector (poly, rfBin); … … 334 324 psFree (poly); 335 325 psFree (stats); 326 psFree (fitstat); 336 327 337 328 return true; 338 329 } 330 331 bool pmPSFtryMetric_Alt (pmPSFtry *try 332 , float RADIUS) 333 { 334 335 // the measured (aperture - fit) magnitudes (dA == try->metric) 336 // depend on both the true ap-fit (dAo) and the bias in the sky measurement: 337 // dA = dAo + dsky/flux 338 // where flux is the flux of the star 339 // we fit this trend to find the infinite flux aperture correction (dAo), 340 // the nominal sky bias (dsky), and the error on dAo 341 // the values of dA are contaminated by stars with close neighbors in the aperture 342 // we use an outlier rejection to avoid this bias 343 344 // rflux = ten(0.4*fitMag); 345 psVector *rflux = psVectorAlloc (try 346 ->sources->n, PS_TYPE_F64); 347 for (int i = 0; i < try 348 ->sources->n; i++) { 349 if (try 350 ->mask->data.U8[i] & PSFTRY_MASK_ALL) continue; 351 rflux->data.F64[i] = pow(10.0, 0.4*try 352 ->fitMag->data.F64[i]); 353 } 354 355 // XXX EAM : try 3hi/1lo sigma clipping on the rflux vs metric fit 356 psStats *stats = psStatsAlloc (PS_STAT_SAMPLE_MEDIAN | PS_STAT_SAMPLE_STDEV); 357 358 // XXX EAM 359 stats->min = 1.0; 360 stats->max = 3.0; 361 stats->clipIter = 3; 362 363 // linear clipped fit to rfBin, daBin 364 psPolynomial1D *poly = psPolynomial1DAlloc (1, PS_POLYNOMIAL_ORD); 365 poly = psVectorClipFitPolynomial1D (poly, stats, try 366 ->mask, PSFTRY_MASK_ALL, try 367 ->metric, NULL, rflux); 368 fprintf (stderr, "fit stats: %f +/- %f\n", stats->sampleMedian, stats->sampleStdev); 369 370 try 371 ->psf->ApResid = poly->coeff[0]; 372 try 373 ->psf->dApResid = stats->sampleStdev; 374 try 375 ->psf->skyBias = poly->coeff[1] / (M_PI * PS_SQR(RADIUS)); 376 377 FILE *f; 378 f = fopen ("apresid.dat", "w"); 379 if (f == NULL) 380 psAbort ("pmPSFtry", "can't open output file"); 381 382 for (int i = 0; i < try 383 ->sources->n; i++) { 384 fprintf (f, "%3d %8.4f %12.5e %8.4f %3d\n", i, try 385 ->fitMag->data.F64[i], rflux->data.F64[i], try 386 ->metric->data.F64[i], try 387 ->mask->data.U8[i]); 388 } 389 fclose (f); 390 391 psFree (rflux); 392 psFree (poly); 393 psFree (stats); 394 395 // psFree (daFit); 396 // psFree (daResid); 397 398 return true; 399 }
Note:
See TracChangeset
for help on using the changeset viewer.
