IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 18, 2010, 5:06:01 PM (16 years ago)
Author:
watersc1
Message:

Almost working version of the mask-stats/software revision code.

Almost.

Location:
branches/czw_branch/20100427
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/czw_branch/20100427

  • branches/czw_branch/20100427/psphot

    • Property svn:mergeinfo deleted
  • branches/czw_branch/20100427/psphot/src/psphotPetrosianStats.c

    r25755 r28017  
    1010bool psphotPetrosianStats (pmSource *source) {
    1111
    12     pmSourceRadialProfile *profile = source->extpars->profile;
    13 
    14     float petRadius = NAN;
    15     float petFlux = NAN;
     12    psAssert (source, "missing source");
     13    psAssert (source->extpars, "missing extpars");
     14    psAssert (source->extpars->petProfile, "missing petProfile");
     15
     16    pmSourceRadialProfile *profile = source->extpars->petProfile;
    1617
    1718    psVector *binSB      = profile->binSB;
     
    2829    psVector *areaSum     = psVectorAllocEmpty(binSB->n, PS_TYPE_F32);
    2930
     31    float petRadius = NAN;
     32    float petFlux = NAN;
     33
    3034    bool anyPetro = false;
    3135    bool manyPetro = false;
     
    3842    int lowestSignificantRadius = 0;
    3943    float lowestSignificantRatio = 1.0;
     44
     45    // find the Petrosian Radius and Petrosian Flux
    4046
    4147    int nOut = 0;
     
    142148    }
    143149
    144     if (!source->extpars->petrosian_80) {
    145         source->extpars->petrosian_80 = pmSourceExtendedFluxAlloc ();
    146     }
    147     pmSourceExtendedFlux *petrosian = source->extpars->petrosian_80;
     150    // now measure the radii R90 and R50 where flux = 0.9 (or 0.5) * petFlux;
     151    float flux90 = 0.9 * petFlux;
     152    float flux50 = 0.5 * petFlux;
     153    float R50 = NAN;
     154    float R90 = NAN;
     155    bool found50 = false;
     156    bool found90 = false;
     157    // XXX use bisection to do this faster:
     158    for (int i = 0; !(found50 && found90) && i < refRadius->n; i++) {
     159        if (!found50 && (fluxSum->data.F32[i] > flux50)) {
     160            if (i == 0) {
     161                psWarning ("does this case make any sense? (fluxSum[0] > flux50)");
     162                continue;
     163            } else {
     164                R50 = InterpolateValues (fluxSum->data.F32[i-1], refRadius->data.F32[i-1], fluxSum->data.F32[i], refRadius->data.F32[i], flux50);
     165                found50 = true;
     166            }
     167        }
     168        if (!found90 && (fluxSum->data.F32[i] > flux90)) {
     169            if (i == 0) {
     170                psWarning ("does this case make any sense? (fluxSum[0] > flux90)");
     171                continue;
     172            } else {
     173                R90 = InterpolateValues (fluxSum->data.F32[i-1], refRadius->data.F32[i-1], fluxSum->data.F32[i], refRadius->data.F32[i], flux90);
     174                found90 = true;
     175            }
     176        }
     177    }
     178
    148179
    149180    // XXX save flags (anyPetro, manyPetro)
    150     petrosian->radius = petRadius;
    151     petrosian->flux   = petFlux;
    152 
    153     // psphotPetrosianVisualStats (binRad, binSB, refRadius, meanSB, petRatio, petRatioErr, fluxSum, petRadius, PETROSIAN_RATIO, petFlux, apRadius);
     181    source->extpars->petrosianRadius = petRadius;
     182    source->extpars->petrosianFlux   = petFlux;
     183    source->extpars->petrosianR50    = R50;
     184    source->extpars->petrosianR90    = R90;
     185   
     186    // XXX add the errors
     187    source->extpars->petrosianRadiusErr = NAN;
     188    source->extpars->petrosianFluxErr   = NAN;
     189    source->extpars->petrosianR50Err    = NAN;
     190    source->extpars->petrosianR90Err    = NAN;
     191
     192    fprintf (stderr, "source @ %f,%f\n", source->peak->xf, source->peak->yf);
     193    psphotPetrosianVisualStats (binRad, binSB, refRadius, meanSB, petRatio, petRatioErr, fluxSum, petRadius, PETROSIAN_RATIO, petFlux, apRadius);
    154194
    155195    psFree(fluxSum);
Note: See TracChangeset for help on using the changeset viewer.