IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 26, 2009, 8:40:07 PM (17 years ago)
Author:
eugene
Message:

incorporating changes from 16bit mask upgrades (eam_branch_20081230)

File:
1 edited

Legend:

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

    r21173 r21183  
    55 *  @author EAM, IfA
    66 *
    7  *  @version $Revision: 1.68 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2009-01-27 00:01:33 $
    9  *
     7 *  @version $Revision: 1.69 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2009-01-27 06:39:38 $
    109 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    1110 *
     
    115114    test->metricErr = psVectorAlloc (sources->n, PS_TYPE_F32);
    116115    test->fitMag    = psVectorAlloc (sources->n, PS_TYPE_F32);
    117     test->mask      = psVectorAlloc (sources->n, PS_TYPE_U8);
     116    test->mask      = psVectorAlloc (sources->n, PS_TYPE_VECTOR_MASK);
    118117
    119118    psVectorInit (test->mask,        0);
     
    148147
    149148// generate a pmPSFtry with a copy of the test PSF sources
    150 pmPSFtry *pmPSFtryModel (const psArray *sources, const char *modelName, pmPSFOptions *options, psMaskType maskVal, psMaskType markVal)
     149pmPSFtry *pmPSFtryModel (const psArray *sources, const char *modelName, pmPSFOptions *options, psImageMaskType maskVal, psImageMaskType markVal)
    151150{
    152151    bool status;
     
    176175        pmSource *source = psfTry->sources->data[i];
    177176        if (!source->moments) {
    178             psfTry->mask->data.U8[i] = PSFTRY_MASK_EXT_FAIL;
     177            psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_EXT_FAIL;
    179178            continue;
    180179        }
    181180        if (!source->moments->nPixels) {
    182             psfTry->mask->data.U8[i] = PSFTRY_MASK_EXT_FAIL;
     181            psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_EXT_FAIL;
    183182            continue;
    184183        }
     
    186185        source->modelEXT = pmSourceModelGuess (source, psfTry->psf->type);
    187186        if (source->modelEXT == NULL) {
    188             psfTry->mask->data.U8[i] = PSFTRY_MASK_EXT_FAIL;
     187            psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_EXT_FAIL;
    189188            psTrace ("psModules.objects", 4, "masking %d (%d,%d) : failed to generate model guess\n", i, source->peak->x, source->peak->y);
    190189            continue;
     
    198197
    199198        // clear object mask to define valid pixels
    200         psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->radius, "AND", PS_NOT_U8(markVal));
     199        psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->radius, "AND", PS_NOT_IMAGE_MASK(markVal));
    201200
    202201        // exclude the poor fits
    203202        if (!status) {
    204             psfTry->mask->data.U8[i] = PSFTRY_MASK_EXT_FAIL;
     203            psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_EXT_FAIL;
    205204            psTrace ("psModules.objects", 4, "masking %d (%d,%d) : status is poor\n", i, source->peak->x, source->peak->y);
    206205            continue;
     
    231230
    232231        // masked for: bad model fit, outlier in parameters
    233         if (psfTry->mask->data.U8[i] & PSFTRY_MASK_ALL) {
     232        if (psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PSFTRY_MASK_ALL) {
    234233            psTrace ("psModules.objects", 4, "dropping %d (%d,%d) : source is masked\n", i, source->peak->x, source->peak->y);
    235234            continue;
     
    239238        source->modelPSF = pmModelFromPSF (source->modelEXT, psfTry->psf);
    240239        if (source->modelPSF == NULL) {
    241             psfTry->mask->data.U8[i] = PSFTRY_MASK_BAD_MODEL;
     240            psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_BAD_MODEL;
    242241            abort();
    243242            continue;
     
    253252        // skip poor fits
    254253        if (!status) {
    255             psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->radius, "AND", PS_NOT_U8(markVal));
    256             psfTry->mask->data.U8[i] = PSFTRY_MASK_PSF_FAIL;
     254            psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->radius, "AND", PS_NOT_IMAGE_MASK(markVal));
     255            psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_PSF_FAIL;
    257256            psTrace ("psModules.objects", 4, "dropping %d (%d,%d) : failed PSF fit\n", i, source->peak->x, source->peak->y);
    258257            continue;
     
    261260        status = pmSourceMagnitudes (source, psfTry->psf, PM_SOURCE_PHOT_INTERP, maskVal);
    262261        if (!status || isnan(source->apMag)) {
    263             psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->radius, "AND", PS_NOT_U8(markVal));
    264             psfTry->mask->data.U8[i] = PSFTRY_MASK_BAD_PHOT;
     262            psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->radius, "AND", PS_NOT_IMAGE_MASK(markVal));
     263            psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_BAD_PHOT;
    265264            psTrace ("psModules.objects", 4, "dropping %d (%d,%d) : poor photometry\n", i, source->peak->x, source->peak->y);
    266265            continue;
     
    268267
    269268        // clear object mask to define valid pixels
    270         psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->radius, "AND", PS_NOT_U8(markVal));
     269        psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->radius, "AND", PS_NOT_IMAGE_MASK(markVal));
    271270
    272271        psfTry->fitMag->data.F32[i] = source->psfMag;
     
    292291    psVector *flux  = psVectorAlloc (psfTry->sources->n, PS_TYPE_F32);
    293292    psVector *chisq = psVectorAlloc (psfTry->sources->n, PS_TYPE_F32);
    294     psVector *mask  = psVectorAlloc (psfTry->sources->n, PS_TYPE_MASK);
     293    psVector *mask  = psVectorAlloc (psfTry->sources->n, PS_TYPE_VECTOR_MASK);
    295294
    296295    // generate the x and y vectors, and mask missing models
     
    300299            flux->data.F32[i] = 0.0;
    301300            chisq->data.F32[i] = 0.0;
    302             mask->data.U8[i] = 0xff;
     301            mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 0xff;
    303302        } else {
    304303            flux->data.F32[i] = source->modelPSF->params->data.F32[PM_PAR_I0];
    305304            chisq->data.F32[i] = source->modelPSF->chisq / source->modelPSF->nDOF;
    306             mask->data.U8[i] = 0;
     305            mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 0;
    307306        }
    308307    }
     
    312311
    313312    // linear clipped fit of chisq trend vs flux
    314     bool result = psVectorClipFitPolynomial1D(psfTry->psf->ChiTrend, options->stats, mask,
    315                                               0xff, chisq, NULL, flux);
     313    bool result = psVectorClipFitPolynomial1D(psfTry->psf->ChiTrend, options->stats, mask, 0xff, chisq, NULL, flux);
    316314    psStatsOptions meanStat = psStatsMeanOption(options->stats->options); // Statistic for mean
    317315    psStatsOptions stdevStat = psStatsStdevOption(options->stats->options); // Statistic for stdev
     
    370368
    371369    for (int i = 0; i < psfTry->sources->n; i++) {
    372         if (psfTry->mask->data.U8[i] & PSFTRY_MASK_ALL)
     370        if (psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PSFTRY_MASK_ALL)
    373371            continue;
    374372        r2rflux->data.F32[i] = PS_SQR(RADIUS) * pow(10.0, 0.4*psfTry->fitMag->data.F32[i]);
     
    379377        FILE *f = fopen ("apresid.dat", "w");
    380378        for (int i = 0; i < psfTry->sources->n; i++) {
    381             int keep = (psfTry->mask->data.U8[i] & PSFTRY_MASK_ALL);
     379            int keep = (psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PSFTRY_MASK_ALL);
    382380
    383381            pmSource *source = psfTry->sources->data[i];
     
    427425        psVector *apfit = psPolynomial1DEvalVector (poly, r2rflux);
    428426        for (int i = 0; i < psfTry->sources->n; i++) {
    429             int keep = (psfTry->mask->data.U8[i] & PSFTRY_MASK_ALL);
     427            int keep = (psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PSFTRY_MASK_ALL);
    430428
    431429            pmSource *source = psfTry->sources->data[i];
     
    603601    for (int i = 0; i < sources->n; i++) {
    604602        // skip any masked sources (failed to fit one of the model steps or get a magnitude)
    605         if (srcMask->data.U8[i]) continue;
     603        if (srcMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) continue;
    606604       
    607605        pmSource *source = sources->data[i];
     
    624622
    625623        psVector *dz = NULL;
    626         psVector *mask = psVectorAlloc (sources->n, PS_TYPE_U8);
     624        psVector *mask = psVectorAlloc (sources->n, PS_TYPE_VECTOR_MASK);
    627625
    628626        // check the fit residuals and increase Nx,Ny until the error is minimized
     
    632630            // copy srcMask to mask (we do not want the mask values set in pmPSFFitShapeParamsMap to be sticky)
    633631            for (int i = 0; i < mask->n; i++) {
    634                 mask->data.U8[i] = srcMask->data.U8[i];
     632                mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = srcMask->data.PS_TYPE_VECTOR_MASK_DATA[i];
    635633            }
    636634            if (!pmPSFFitShapeParamsMap (psf, i, &scatterTotal, mask, x, y, mag, e0, e1, e2, dz)) {
     
    651649        // copy srcMask to mask (we do not want the mask values set in pmPSFFitShapeParamsMap to be sticky)
    652650        for (int i = 0; i < mask->n; i++) {
    653             mask->data.U8[i] = srcMask->data.U8[i];
     651            mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = srcMask->data.PS_TYPE_VECTOR_MASK_DATA[i];
    654652        }
    655653        if (!pmPSFFitShapeParamsMap (psf, entryMin, &scatterTotal, mask, x, y, mag, e0, e1, e2, dz)) {
     
    663661        // copy mask back to srcMask
    664662        for (int i = 0; i < mask->n; i++) {
    665             srcMask->data.U8[i] = mask->data.U8[i];
     663            srcMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = mask->data.PS_TYPE_VECTOR_MASK_DATA[i];
    666664        }
    667665
     
    736734                     pmTrend2DEval (psf->params->data[PM_PAR_E1], x->data.F32[i], y->data.F32[i]),
    737735                     pmTrend2DEval (psf->params->data[PM_PAR_E2], x->data.F32[i], y->data.F32[i]),
    738                      srcMask->data.U8[i]);
     736                     srcMask->data.PS_TYPE_VECTOR_MASK_DATA[i]);
    739737        }
    740738        fclose (f);
     
    851849
    852850    // the mask marks the values not used to calculate the ApTrend
    853     psVector *fitMask = psVectorAlloc (x_fit->n, PS_TYPE_U8);
     851    psVector *fitMask = psVectorAlloc (x_fit->n, PS_TYPE_VECTOR_MASK);
    854852    // copy mask values to fitMask as a starting point
    855853    for (int i = 0; i < fitMask->n; i++) {
    856         fitMask->data.U8[i] = mask->data.U8[i];
     854        fitMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = mask->data.PS_TYPE_VECTOR_MASK_DATA[i];
    857855    }
    858856
     
    943941    // XXX copy fitMask values back to mask
    944942    for (int i = 0; i < fitMask->n; i++) {
    945         mask->data.U8[i] = fitMask->data.U8[i];
     943        mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = fitMask->data.PS_TYPE_VECTOR_MASK_DATA[i];
    946944    }
    947945    psFree (fitMask);
     
    951949
    952950// calculate the scatter of the parameters
    953 bool pmPSFShapeParamsScatter(float *scatterTotal, psVector *e0res, psVector *e1res, psVector *e2res, psVector *mask, psMaskType maskValue, psStatsOptions stdevOpt)
     951bool pmPSFShapeParamsScatter(float *scatterTotal, psVector *e0res, psVector *e1res, psVector *e2res, psVector *mask, psVectorMaskType maskValue, psStatsOptions stdevOpt)
    954952{
    955953
     
    994992    psVector *dE1subset = psVectorAllocEmpty (nGroup, PS_TYPE_F32);
    995993    psVector *dE2subset = psVectorAllocEmpty (nGroup, PS_TYPE_F32);
    996     psVector *mkSubset  = psVectorAllocEmpty (nGroup, PS_TYPE_U8);
     994    psVector *mkSubset  = psVectorAllocEmpty (nGroup, PS_TYPE_VECTOR_MASK);
    997995
    998996    int n = 0;
     
    10071005            dE2subset->data.F32[j] = e2res->data.F32[N];
    10081006
    1009             mkSubset->data.U8[j]   = mask->data.U8[N];
    1010             if (!mask->data.U8[N]) nValid ++;
     1007            mkSubset->data.PS_TYPE_VECTOR_MASK_DATA[j]   = mask->data.PS_TYPE_VECTOR_MASK_DATA[N];
     1008            if (!mask->data.PS_TYPE_VECTOR_MASK_DATA[N]) nValid ++;
    10111009        }
    10121010        if (nValid < 3) continue;
Note: See TracChangeset for help on using the changeset viewer.