Changeset 5844 for trunk/psModules/src/objects/pmPSFtry.c
- Timestamp:
- Dec 23, 2005, 3:24:38 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/objects/pmPSFtry.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/objects/pmPSFtry.c
r5765 r5844 5 5 * @author EAM, IfA 6 6 * 7 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $8 * @date $Date: 2005-12- 12 21:14:38$7 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2005-12-24 01:24:32 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 176 176 177 177 // XXX this function wants aperture radius for pmSourcePhotometry 178 pmPSFtryMetric (psfTry, RADIUS);178 pmPSFtryMetric_Alt (psfTry, RADIUS); 179 179 psLogMsg ("psphot.pspsf", 3, "try model %s, ap-fit: %f +/- %f, sky bias: %f\n", 180 180 modelName, … … 288 288 289 289 // linear fit to rfBin, daBin 290 psPolynomial1D *poly = psPolynomial1DAlloc(PS_POLYNOMIAL_ORD, 1); 290 psPolynomial1D *poly = psPolynomial1DAlloc(1, PS_POLYNOMIAL_ORD); 291 psStats *fitstat = psStatsAlloc (PS_STAT_SAMPLE_MEDIAN | PS_STAT_SAMPLE_STDEV); 292 poly = psVectorClipFitPolynomial1D (poly, fitstat, maskB, 1, daBin, NULL, rfBin); 291 293 292 294 // XXX EAM : this is the intended API (cycle 7? cycle 8?) 293 poly = psVectorFitPolynomial1D(poly, maskB, 1, daBin, NULL, rfBin);295 // poly = psVectorFitPolynomial1D(poly, maskB, 1, daBin, NULL, rfBin); 294 296 295 297 // XXX EAM : replace this when the above version is implemented … … 314 316 psFree (poly); 315 317 psFree (stats); 318 psFree (fitstat); 316 319 317 320 return true; 318 321 } 322 323 bool pmPSFtryMetric_Alt (pmPSFtry *try 324 , float RADIUS) 325 { 326 327 // the measured (aperture - fit) magnitudes (dA == try->metric) 328 // depend on both the true ap-fit (dAo) and the bias in the sky measurement: 329 // dA = dAo + dsky/flux 330 // where flux is the flux of the star 331 // we fit this trend to find the infinite flux aperture correction (dAo), 332 // the nominal sky bias (dsky), and the error on dAo 333 // the values of dA are contaminated by stars with close neighbors in the aperture 334 // we use an outlier rejection to avoid this bias 335 336 // rflux = ten(0.4*fitMag); 337 psVector *rflux = psVectorAlloc (try 338 ->sources->n, PS_TYPE_F64); 339 for (int i = 0; i < try 340 ->sources->n; i++) { 341 if (try 342 ->mask->data.U8[i] & PSFTRY_MASK_ALL) continue; 343 rflux->data.F64[i] = pow(10.0, 0.4*try 344 ->fitMag->data.F64[i]); 345 } 346 347 // XXX EAM : try 3hi/1lo sigma clipping on the rflux vs metric fit 348 psStats *stats = psStatsAlloc (PS_STAT_SAMPLE_MEDIAN | PS_STAT_SAMPLE_STDEV); 349 350 // XXX EAM 351 stats->min = 1.0; 352 stats->max = 3.0; 353 stats->clipIter = 3; 354 355 // linear clipped fit to rfBin, daBin 356 psPolynomial1D *poly = psPolynomial1DAlloc (1, PS_POLYNOMIAL_ORD); 357 poly = psVectorClipFitPolynomial1D (poly, stats, try 358 ->mask, PSFTRY_MASK_ALL, try 359 ->metric, NULL, rflux); 360 fprintf (stderr, "fit stats: %f +/- %f\n", stats->sampleMedian, stats->sampleStdev); 361 362 try 363 ->psf->ApResid = poly->coeff[0]; 364 try 365 ->psf->dApResid = stats->sampleStdev; 366 try 367 ->psf->skyBias = poly->coeff[1] / (M_PI * PS_SQR(RADIUS)); 368 369 fprintf (stderr, "*******************************************************************************\n"); 370 371 FILE *f; 372 f = fopen ("apresid.dat", "w"); 373 if (f == NULL) 374 psAbort ("pmPSFtry", "can't open output file"); 375 376 for (int i = 0; i < try 377 ->sources->n; i++) { 378 fprintf (f, "%3d %8.4f %12.5e %8.4f %3d\n", i, try 379 ->fitMag->data.F64[i], rflux->data.F64[i], try 380 ->metric->data.F64[i], try 381 ->mask->data.U8[i]); 382 } 383 fclose (f); 384 385 psFree (rflux); 386 psFree (poly); 387 psFree (stats); 388 389 // psFree (daFit); 390 // psFree (daResid); 391 392 return true; 393 }
Note:
See TracChangeset
for help on using the changeset viewer.
