IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 23, 2005, 3:24:38 PM (20 years ago)
Author:
desonia
Message:

changes from eam_rel9_b1

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/objects/pmPSFtry.c

    r5765 r5844  
    55 *  @author EAM, IfA
    66 *
    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 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    176176
    177177    // XXX this function wants aperture radius for pmSourcePhotometry
    178     pmPSFtryMetric (psfTry, RADIUS);
     178    pmPSFtryMetric_Alt (psfTry, RADIUS);
    179179    psLogMsg ("psphot.pspsf", 3, "try model %s, ap-fit: %f +/- %f, sky bias: %f\n",
    180180              modelName,
     
    288288
    289289    // 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);
    291293
    292294    // 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);
    294296
    295297    // XXX EAM : replace this when the above version is implemented
     
    314316    psFree (poly);
    315317    psFree (stats);
     318    psFree (fitstat);
    316319
    317320    return true;
    318321}
     322
     323bool 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.