IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 19, 2007, 4:22:26 PM (19 years ago)
Author:
Paul Price
Message:

Extensive changes to APIs to allow use of a nominated value to mask
against (the maskVal). Previously, the mask values were either
hard-coded (e.g., PM_MASK_SAT) or taken as anything non-zero. The
code is tested under psphot (which has similar changes) and does not
crash, but neither is it successful in marking all bad pixels (EAM
will investigate). For this reason, I have left the "gutter" pixels
(cell gaps) set to 0 instead of NAN in pmFPAMosaic.

File:
1 edited

Legend:

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

    r13472 r13898  
    33 *  @author EAM, IfA; GLG, MHPCC
    44 *
    5  *  @version $Revision: 1.27 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2007-05-22 21:45:00 $
     5 *  @version $Revision: 1.28 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2007-06-20 02:22:26 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    5858        - the source is a STAR (PSF)
    5959        - the option is selected (mode & PM_SOURCE_PHOT_APCORR)
    60  
     60
    6161    - extMag : all sources with non-NULL modelEXT
    6262**/
    6363
    6464// XXX masked region should be (optionally) elliptical
    65 bool pmSourceMagnitudes (pmSource *source, pmPSF *psf, pmSourcePhotometryMode mode)
     65bool pmSourceMagnitudes (pmSource *source, pmPSF *psf, pmSourcePhotometryMode mode, psMaskType maskVal, psMaskType mark)
    6666{
    6767
     
    110110    // XXX use pmSourceAdd instead?
    111111    if (source->mode & PM_SOURCE_MODE_SUBTRACTED) {
    112         pmModelAdd (source->pixels, source->maskObj, model, PM_MODEL_OP_FULL);
     112        pmModelAdd (source->pixels, source->maskObj, model, PM_MODEL_OP_FULL, maskVal);
    113113    }
    114114
     
    185185    // XXX can I remove this?  the source should have the mask defined when it is constructed or
    186186    // when the fit / aperture radius is changed...
    187     psImageKeepCircle (source->maskObj, x, y, model->radiusFit, "OR", PM_MASK_MARK);
     187    psImageKeepCircle (source->maskObj, x, y, model->radiusFit, "OR", mark);
    188188
    189189    // measure the weight of included pixels
    190190    // XXX is this supposed to use the weight or the flux?
    191191    if (mode & PM_SOURCE_PHOT_WEIGHT) {
    192         pmSourcePixelWeight (&source->pixWeight, model, source->pixels, source->maskObj);
     192        pmSourcePixelWeight (&source->pixWeight, model, source->pixels, source->maskObj, maskVal);
    193193    }
    194194
    195195    // measure object aperture photometry
    196     status = pmSourcePhotometryAper  (&source->apMag, model, flux, source->maskObj);
     196    status = pmSourcePhotometryAper  (&source->apMag, model, flux, source->maskObj, maskVal);
    197197    if (!status) {
    198         psErrorCode last = psErrorCodeLast();
    199         if (last == PM_ERR_PHOTOM) {
    200             // the aper mag was undefined (flux < 0).  bad object, but
    201             // don't keep the error on the stack
    202             psErrorClear();
    203         }
     198        psErrorCode last = psErrorCodeLast();
     199        if (last == PM_ERR_PHOTOM) {
     200            // the aper mag was undefined (flux < 0).  bad object, but
     201            // don't keep the error on the stack
     202            psErrorClear();
     203        }
    204204    }
    205205
     
    220220    // unmask aperture
    221221    // XXX can I remove this?  this will probably break things downstream...
    222     psImageKeepCircle (source->maskObj, x, y, model->radiusFit, "AND", PS_NOT_U8(PM_MASK_MARK));
     222    psImageKeepCircle (source->maskObj, x, y, model->radiusFit, "AND", PS_NOT_U8(mark));
    223223
    224224    // if source was originally subtracted, re-subtract object, leave local sky
    225225    // XXX replace with pmSourceSub...
    226226    if (source->mode & PM_SOURCE_MODE_SUBTRACTED) {
    227         pmModelSub (source->pixels, source->maskObj, model, PM_MODEL_OP_FULL);
     227        pmModelSub (source->pixels, source->maskObj, model, PM_MODEL_OP_FULL, maskVal);
    228228    }
    229229
     
    235235(aprMag - flux*skySat - r^2*rflux*skyBias) - fitMAg = ApTrend(x,y)
    236236(aprMag - flux*skySat - r^2*rflux*skyBias) = fitMAg + ApTrend(x,y)
    237  
     237
    238238*/
    239239
     
    262262
    263263// return source aperture magnitude
    264 bool pmSourcePhotometryAper (float *apMag, pmModel *model, psImage *image, psImage *mask)
     264bool pmSourcePhotometryAper (float *apMag, pmModel *model, psImage *image, psImage *mask, psMaskType maskVal)
    265265{
    266266    float apSum = 0;
     
    269269
    270270    if (model == NULL) {
    271         psError(PM_ERR_OBJECTS, true, "Model is NULL");
     271        psError(PM_ERR_OBJECTS, true, "Model is NULL");
    272272        return false;
    273273    }
     
    285285    for (int ix = 0; ix < image->numCols; ix++) {
    286286        for (int iy = 0; iy < image->numRows; iy++) {
    287             if (mkData[iy][ix])
     287            if (mkData[iy][ix] & maskVal)
    288288                continue;
    289289            apSum += imData[iy][ix] - sky;
     
    291291    }
    292292    if (apSum <= 0) {
    293         psError(PM_ERR_PHOTOM, true, "apSum is negative");
     293        psError(PM_ERR_PHOTOM, true, "apSum is negative");
    294294        return false;
    295295    }
     
    300300
    301301// return source aperture magnitude
    302 bool pmSourcePixelWeight (float *pixWeight, pmModel *model, psImage *image, psImage *mask)
     302bool pmSourcePixelWeight (float *pixWeight, pmModel *model, psImage *image, psImage *mask, psMaskType maskVal)
    303303{
    304304    float modelSum = 0;
     
    366366            if (my >= NY)
    367367                continue;
    368             if (mask->data.U8[my][mx])
     368            if (mask->data.U8[my][mx] & maskVal)
    369369                continue;
    370370
     
    400400    const psImage *Wi = Mi->weight;
    401401    if (!unweighted_sum) {
    402         assert (Wi != NULL);
     402        assert (Wi != NULL);
    403403    }
    404404
     
    463463    const psImage *Wi = Mi->weight;
    464464    if (!unweighted_sum) {
    465         assert (Wi != NULL);
     465        assert (Wi != NULL);
    466466    }
    467467
     
    518518    const psImage *Wi = Mi->weight;
    519519    if (!unweighted_sum) {
    520         assert (Wi != NULL);
     520        assert (Wi != NULL);
    521521    }
    522522    const psImage *Ti = Mi->maskObj;
     
    561561# endif
    562562
    563 bool pmSourceChisq (pmModel *model, psImage *image, psImage *mask, psImage *weight)
     563bool pmSourceChisq (pmModel *model, psImage *image, psImage *mask, psImage *weight, psMaskType maskVal)
    564564{
    565565
     
    568568    for (int j = 0; j < image->numRows; j++) {
    569569        for (int i = 0; i < image->numCols; i++) {
    570             if (mask->data.U8[j][i])
     570            if (mask->data.U8[j][i] & maskVal)
    571571                continue;
    572572            if (weight->data.F32[j][i] <= 0)
     
    593593    const psImage *Wi = Mi->weight;
    594594    if (!unweighted_sum) {
    595         assert (Wi != NULL);
     595        assert (Wi != NULL);
    596596    }
    597597    const psImage *Ti = Mi->maskObj;
     
    633633
    634634double pmSourceModelDotModel (const pmSource *Mi,
    635                               const pmSource *Mj,
    636                               const bool unweighted_sum) // should the cross product be weighted?
     635                              const pmSource *Mj,
     636                              const bool unweighted_sum) // should the cross product be weighted?
    637637{
    638638    int Xs, Xe, Ys, Ye;
     
    649649    const psImage *Wi = Mi->weight;
    650650    if (!unweighted_sum) {
    651         assert (Wi != NULL);
     651        assert (Wi != NULL);
    652652    }
    653653
     
    680680                continue;
    681681
    682             // XXX skip the nonsense weight pixels?
     682            // XXX skip the nonsense weight pixels?
    683683            if (unweighted_sum) {
    684684                flux += (Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj]);
     
    712712    const psImage *Wi = Mi->weight;
    713713    if (!unweighted_sum) {
    714         assert (Wi != NULL);
     714        assert (Wi != NULL);
    715715    }
    716716
     
    743743                continue;
    744744
    745             // XXX skip the nonsense weight pixels?
     745            // XXX skip the nonsense weight pixels?
    746746            if (unweighted_sum) {
    747747                flux += (Pi->data.F32[yi][xi] * Pj->data.F32[yj][xj]);
Note: See TracChangeset for help on using the changeset viewer.