IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 17, 2006, 1:02:21 PM (20 years ago)
Author:
magnier
Message:

pulled code into pmSourceGetModel; added pmSourceWeights

Location:
trunk/psModules/src/objects
Files:
2 edited

Legend:

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

    r10031 r10050  
    33 *  @author EAM, IfA; GLG, MHPCC
    44 *
    5  *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2006-11-17 02:39:34 $
     5 *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2006-11-17 23:02:18 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    7676    source->apMag  = NAN;
    7777
    78     // XXX these tests prevent aperture photometry without valid model.  is
    79     // this reasonable?  probably not...
    80     switch (source->type) {
    81     case PM_SOURCE_TYPE_STAR:
    82         model = source->modelPSF;
    83         if (model == NULL)
    84             return false;
    85         isPSF = true;
    86         break;
    87 
    88     case PM_SOURCE_TYPE_EXTENDED:
    89         model = source->modelEXT;
    90         if (model == NULL)
    91             return false;
    92         isPSF = false;
    93         break;
    94 
    95     default:
    96         return false;
    97     }
     78    // we must have a valid model
     79    model = pmSourceGetModel (&isPSF, source);
     80    if (model == NULL)
     81        return false;
    9882
    9983    if (model->dparams->data.F32[PM_PAR_I0] > 0) {
     
    278262    }
    279263
     264    psF32 **imData = image->data.F32;
     265    psU8 **mkData = mask->data.U8;
     266
    280267    // measure apMag
    281268    for (int ix = 0; ix < image->numCols; ix++) {
    282269        for (int iy = 0; iy < image->numRows; iy++) {
    283             if (mask->data.U8[iy][ix])
    284                 continue;
    285             apSum += image->data.F32[iy][ix] - sky;
     270            if (mkData[iy][ix])
     271                continue;
     272            apSum += imData[iy][ix] - sky;
    286273        }
    287274    }
     
    487474}
    488475
     476double pmSourceWeight(const pmSource *Mi,
     477                      int term,
     478                      const bool unweighted_sum) // should the cross product be weighted?
     479{
     480
     481    int xi, yi;
     482    double flux, wt, factor;
     483
     484    const psImage *Pi = Mi->pixels;
     485    const psImage *Wi = Mi->weight;
     486    const psImage *Ti = Mi->mask;
     487
     488    // note that this is addressing the same image pixels,
     489    // though only if both are source not model images
     490    flux = 0;
     491    for (yi = 0; yi < Pi->numRows; yi++) {
     492        for (xi = 0; xi < Pi->numCols; xi++) {
     493            if (Ti->data.U8[yi][xi])
     494                continue;
     495            if (!unweighted_sum) {
     496                wt = Wi->data.F32[yi][xi];
     497                if (wt == 0)
     498                    continue;
     499            }
     500
     501            switch (term) {
     502            case 0:
     503                factor = 1;
     504                break;
     505            case 1:
     506                factor = xi + Pi->col0;
     507                break;
     508            case 2:
     509                factor = yi + Pi->row0;
     510                break;
     511            default:
     512                psAbort ("models/objects", "invalid term for pmSourceWeight");
     513            }
     514
     515            if (unweighted_sum) {
     516                flux += (factor * Pi->data.F32[yi][xi]);
     517            } else {
     518                flux += (factor * Pi->data.F32[yi][xi]) / wt;
     519            }
     520        }
     521    }
     522    return flux;
     523}
     524
    489525bool pmSourceChisq (pmModel *model, psImage *image, psImage *mask, psImage *weight)
    490526{
     
    507543    return (true);
    508544}
     545
     546// given a source, which model is currently appropriate?
     547// choose PSF or EXT based on source->type, but fall back on PSF
     548// if the EXT model is NULL
     549pmModel *pmSourceGetModel (bool *isPSF, const pmSource *source)
     550{
     551
     552    pmModel *model;
     553
     554    switch (source->type) {
     555    case PM_SOURCE_TYPE_STAR:
     556        model = source->modelPSF;
     557        if (model == NULL)
     558            return NULL;
     559        if (isPSF)
     560            *isPSF = true;
     561        return model;
     562
     563    case PM_SOURCE_TYPE_EXTENDED:
     564        model = source->modelEXT;
     565        if (isPSF)
     566            *isPSF = false;
     567        if (model == NULL) {
     568            model = source->modelPSF;
     569            if (isPSF)
     570                *isPSF = true;
     571        }
     572        if (model == NULL) {
     573            if (isPSF)
     574                *isPSF = FALSE;
     575            return NULL;
     576        }
     577        return (model);
     578        break;
     579
     580    default:
     581        if (isPSF)
     582            *isPSF = false;
     583        return NULL;
     584    }
     585    return NULL;
     586}
  • trunk/psModules/src/objects/pmSourcePhotometry.h

    r10031 r10050  
    33 *  @author EAM, IfA; GLG, MHPCC
    44 *
    5  *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2006-11-17 02:39:34 $
     5 *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2006-11-17 23:02:21 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    5252bool pmSourcePixelWeight (float *pixWeight, pmModel *model, psImage *image, psImage *mask);
    5353bool pmSourceChisq (pmModel *model, psImage *image, psImage *mask, psImage *weight);
     54pmModel *pmSourceGetModel (bool *isPSF, const pmSource *source);
    5455
     56double pmSourceWeight(const pmSource *Mi, int term, const bool unweighted_sum);
    5557# endif /* PM_SOURCE_PHOTOMETRY_H */
Note: See TracChangeset for help on using the changeset viewer.