IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 17, 2006, 7:10:08 AM (20 years ago)
Author:
magnier
Message:

fixed up object output file functions, small speed improvements

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/rel10_ifa/psModules/src/objects/pmSourcePhotometry.c

    r6859 r6864  
    33 *  @author EAM, IfA; GLG, MHPCC
    44 *
    5  *  @version $Revision: 1.1.2.4 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2006-04-14 21:43:59 $
     5 *  @version $Revision: 1.1.2.5 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2006-04-17 17:10:08 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    5656
    5757// XXX EAM : masked region should be (optionally) elliptical
    58 // XXX curve of growth is corrected to
    59 pmModel *pmSourceMagnitudes (pmSource *source, pmPSF *psf, bool growthCorr, bool apTrendCorr)
    60 {
    61 
    62     int status;
     58bool pmSourceMagnitudes (pmSource *source, pmPSF *psf, pmSourcePhotometryMode mode)
     59{
     60
     61    int status = false;
    6362    bool isPSF;
    6463    float x, y;
     
    6766    pmModel *model;
    6867
     68    source->psfMag = 99.0;
     69    source->extMag = 99.0;
     70    source->errMag = 99.0;
     71    source->apMag  = 99.0;
     72
    6973    switch (source->type) {
    7074    case PM_SOURCE_TYPE_STAR:
    7175        model = source->modelPSF;
    7276        if (model == NULL)
    73             return NULL;
     77            return false;
    7478        isPSF = true;
    7579        break;
     
    7882        model = source->modelEXT;
    7983        if (model == NULL)
    80             return NULL;
     84            return false;
    8185        isPSF = false;
    8286        break;
    8387
    8488    default:
    85         return NULL;
     89        return false;
    8690    }
    8791
     
    96100    y = model->params->data.F32[3];
    97101
     102    // measure object model photometry
     103    status = pmSourcePhotometryModel (&source->psfMag, source->modelPSF);
     104    status = pmSourcePhotometryModel (&source->extMag, source->modelEXT);
     105    // for PSFs, correct both apMag and psfMag to same system, consistent with infinite flux star in aperture RADIUS
     106    if ((mode & PM_SOURCE_PHOT_APCORR) && isPSF && psf) {
     107        // convert to the equivalent 2D model?
     108        source->psfMag += psPolynomial4DEval (psf->ApTrend, x, y, 0.0, 0.0);
     109    }
     110
     111    if (SN < AP_MIN_SN)
     112        return false;
     113
    98114    // replace source flux
    99115    // XXX test to see if source has been subtracted?
     
    103119    psImageKeepCircle (source->mask, x, y, model->radiusTMP, "OR", PM_SOURCE_MASK_MARKED);
    104120
    105     // measure object model photometry
    106     status = pmSourcePhotometryModel (&source->psfMag, source->modelPSF);
    107     status = pmSourcePhotometryModel (&source->extMag, source->modelEXT);
    108 
    109121    // measure the weight of included pixels
    110     status = pmSourcePixelWeight (&source->pixWeight, model, source->pixels, source->mask);
     122    if (mode & PM_SOURCE_PHOT_WEIGHT) {
     123        pmSourcePixelWeight (&source->pixWeight, model, source->pixels, source->mask);
     124    }
    111125
    112126    // measure object aperture photometry
    113     if (SN > AP_MIN_SN) {
    114         status = pmSourcePhotometryAper  (&source->apMag, model, source->pixels, source->mask);
    115     } else {
    116         source->apMag = 99.0;
    117     }
     127    status = pmSourcePhotometryAper  (&source->apMag, model, source->pixels, source->mask);
    118128
    119129    // for PSFs, correct both apMag and psfMag to same system, consistent with infinite flux star in aperture RADIUS
    120     if (isPSF && (psf != NULL)) {
    121         if (SN > AP_MIN_SN) {
    122             if ((psf->growth != NULL) && growthCorr) {
    123                 source->apMag += pmGrowthCurveCorrect (psf->growth, model->radiusTMP);
    124             }
    125             if (apTrendCorr) {
    126                 rflux   = pow (10.0, 0.4*source->psfMag);
    127                 source->apMag  -= PS_SQR(model->radiusTMP)*rflux * psf->skyBias + psf->skySat / rflux;
    128             }
    129         }
    130         if (apTrendCorr) {
    131             source->psfMag += psPolynomial4DEval (psf->ApTrend, x, y, 0.0, 0.0);
     130    if (status && isPSF && psf) {
     131        if (psf->growth && (mode & PM_SOURCE_PHOT_GROWTH)) {
     132            source->apMag += pmGrowthCurveCorrect (psf->growth, model->radiusTMP);
     133        }
     134        if (mode & PM_SOURCE_PHOT_APCORR) {
     135            rflux   = pow (10.0, 0.4*source->psfMag);
     136            source->apMag  -= PS_SQR(model->radiusTMP)*rflux * psf->skyBias + psf->skySat / rflux;
    132137        }
    133138    }
     
    139144    pmModelSub (source->pixels, source->mask, model, false, false);
    140145
    141     if (!status)
    142         return NULL;
    143     return model;
     146    return status;
    144147}
    145148
Note: See TracChangeset for help on using the changeset viewer.