IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 26, 2009, 2:01:33 PM (17 years ago)
Author:
eugene
Message:

keep input mask values, pass along to pmTrend functions; detect a few failure modes

File:
1 edited

Legend:

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

    r20937 r21173  
    55 *  @author EAM, IfA
    66 *
    7  *  @version $Revision: 1.67 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2008-12-08 02:51:14 $
     7 *  @version $Revision: 1.68 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2009-01-27 00:01:33 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    175175
    176176        pmSource *source = psfTry->sources->data[i];
     177        if (!source->moments) {
     178            psfTry->mask->data.U8[i] = PSFTRY_MASK_EXT_FAIL;
     179            continue;
     180        }
     181        if (!source->moments->nPixels) {
     182            psfTry->mask->data.U8[i] = PSFTRY_MASK_EXT_FAIL;
     183            continue;
     184        }
     185
    177186        source->modelEXT = pmSourceModelGuess (source, psfTry->psf->type);
    178187        if (source->modelEXT == NULL) {
    179             psError(PS_ERR_UNKNOWN, false, "failed to build model");
    180             psFree(psfTry);
    181             return NULL;
     188            psfTry->mask->data.U8[i] = PSFTRY_MASK_EXT_FAIL;
     189            psTrace ("psModules.objects", 4, "masking %d (%d,%d) : failed to generate model guess\n", i, source->peak->x, source->peak->y);
     190            continue;
    182191        }
    183192
     
    591600    psVector *e2   = psVectorAlloc (sources->n, PS_TYPE_F32);
    592601    psVector *mag  = psVectorAlloc (sources->n, PS_TYPE_F32);
     602
    593603    for (int i = 0; i < sources->n; i++) {
     604        // skip any masked sources (failed to fit one of the model steps or get a magnitude)
     605        if (srcMask->data.U8[i]) continue;
     606       
    594607        pmSource *source = sources->data[i];
    595         if (source->modelEXT == NULL) continue;
    596         // XXX I am relying on the fact that none of the masked sources
    597         // have modelEXT set here.  perhaps use the value of psfTry->mask instead?
     608        assert (source->modelEXT); // all unmasked sources should have modelEXT
    598609
    599610        psEllipsePol pol = pmPSF_ModelToFit (source->modelEXT->params->data.F32);
     
    619630        for (int i = 1; i <= PS_MAX (psf->trendNx, psf->trendNy); i++) {
    620631
    621             psVectorInit (mask, 0);
     632            // copy srcMask to mask (we do not want the mask values set in pmPSFFitShapeParamsMap to be sticky)
     633            for (int i = 0; i < mask->n; i++) {
     634                mask->data.U8[i] = srcMask->data.U8[i];
     635            }
    622636            if (!pmPSFFitShapeParamsMap (psf, i, &scatterTotal, mask, x, y, mag, e0, e1, e2, dz)) {
    623637                break;
     
    635649        }
    636650
    637         // XXX supply the resulting mask values back to srcMask
    638         psVectorInit (mask, 0);
     651        // copy srcMask to mask (we do not want the mask values set in pmPSFFitShapeParamsMap to be sticky)
     652        for (int i = 0; i < mask->n; i++) {
     653            mask->data.U8[i] = srcMask->data.U8[i];
     654        }
    639655        if (!pmPSFFitShapeParamsMap (psf, entryMin, &scatterTotal, mask, x, y, mag, e0, e1, e2, dz)) {
    640656            psAbort ("failed pmPSFFitShapeParamsMap on second pass?");
     
    836852    // the mask marks the values not used to calculate the ApTrend
    837853    psVector *fitMask = psVectorAlloc (x_fit->n, PS_TYPE_U8);
    838     psVectorInit (fitMask, 0);
     854    // copy mask values to fitMask as a starting point
     855    for (int i = 0; i < fitMask->n; i++) {
     856        fitMask->data.U8[i] = mask->data.U8[i];
     857    }
    839858
    840859    // we run 'clipIter' cycles clipping in each of x and y, with only one iteration each.
     
    884903
    885904    // construct the fitted values and the residuals
    886     psVector *e0fit = pmTrend2DEvalVector (psf->params->data[PM_PAR_E0], x_tst, y_tst);
    887     psVector *e1fit = pmTrend2DEvalVector (psf->params->data[PM_PAR_E1], x_tst, y_tst);
    888     psVector *e2fit = pmTrend2DEvalVector (psf->params->data[PM_PAR_E2], x_tst, y_tst);
     905    psVector *e0fit = pmTrend2DEvalVector (psf->params->data[PM_PAR_E0], fitMask, 0xff, x_tst, y_tst);
     906    psVector *e1fit = pmTrend2DEvalVector (psf->params->data[PM_PAR_E1], fitMask, 0xff, x_tst, y_tst);
     907    psVector *e2fit = pmTrend2DEvalVector (psf->params->data[PM_PAR_E2], fitMask, 0xff, x_tst, y_tst);
    889908
    890909    psVector *e0res = (psVector *) psBinaryOp (NULL, (void *) e0obs_tst, "-", (void *) e0fit);
     
    895914    // psTraceSetLevel ("psLib.math.vectorSampleStdev", 10);
    896915    // psTraceSetLevel ("psLib.math.vectorClippedStats", 10);
    897     pmPSFShapeParamsScatter (scatterTotal, e0res, e1res, e2res, psStatsStdevOption(psf->psfTrendStats->options));
     916    pmPSFShapeParamsScatter (scatterTotal, e0res, e1res, e2res, fitMask, 0xff, psStatsStdevOption(psf->psfTrendStats->options));
    898917    // psTraceSetLevel ("psLib.math.vectorSampleStdev", 0);
    899918    // psTraceSetLevel ("psLib.math.vectorClippedStats", 0);
     
    932951
    933952// calculate the scatter of the parameters
    934 bool pmPSFShapeParamsScatter(float *scatterTotal, psVector *e0res, psVector *e1res, psVector *e2res, psStatsOptions stdevOpt)
     953bool pmPSFShapeParamsScatter(float *scatterTotal, psVector *e0res, psVector *e1res, psVector *e2res, psVector *mask, psMaskType maskValue, psStatsOptions stdevOpt)
    935954{
    936955
     
    941960    float dEsquare = 0.0;
    942961    psStatsInit (stats);
    943     psVectorStats (stats, e0res, NULL, NULL, 0xff);
     962    psVectorStats (stats, e0res, NULL, mask, maskValue);
    944963    dEsquare += PS_SQR(psStatsGetValue(stats, stdevOpt));
    945964
    946965    psStatsInit (stats);
    947     psVectorStats (stats, e1res, NULL, NULL, 0xff);
     966    psVectorStats (stats, e1res, NULL, mask, maskValue);
    948967    dEsquare += PS_SQR(psStatsGetValue(stats, stdevOpt));
    949968
    950969    psStatsInit (stats);
    951     psVectorStats (stats, e2res, NULL, NULL, 0xff);
     970    psVectorStats (stats, e2res, NULL, mask, maskValue);
    952971    dEsquare += PS_SQR(psStatsGetValue(stats, stdevOpt));
    953972
Note: See TracChangeset for help on using the changeset viewer.