IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 24, 2007, 11:27:58 AM (19 years ago)
Author:
eugene
Message:

update from eam_branch_20070921

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/src/psphotApResid.c

    r14965 r15000  
    11# include "psphotInternal.h"
    22
     3# define SKIPSTAR(MSG) { psTrace ("psphot", 3, "invalid : %s", MSG); continue; }
    34// measure the aperture residual statistics and 2D variations
    45bool psphotApResid (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf, psMaskType maskVal, psMaskType mark)
     
    6364        model = source->modelPSF;
    6465
    65         if (source->type != PM_SOURCE_TYPE_STAR) continue;
    66         if (source->mode &  PM_SOURCE_MODE_SATSTAR) continue;
    67         if (source->mode &  PM_SOURCE_MODE_BLEND) continue;
    68         if (source->mode &  PM_SOURCE_MODE_FAIL) continue;
    69         if (source->mode &  PM_SOURCE_MODE_POOR) continue;
     66        if (source->type != PM_SOURCE_TYPE_STAR) SKIPSTAR ("NOT STAR");
     67        if (source->mode &  PM_SOURCE_MODE_SATSTAR) SKIPSTAR ("SATSTAR");
     68        if (source->mode &  PM_SOURCE_MODE_BLEND) SKIPSTAR ("BLEND");
     69        if (source->mode &  PM_SOURCE_MODE_FAIL) SKIPSTAR ("FAIL STAR");
     70        if (source->mode &  PM_SOURCE_MODE_POOR) SKIPSTAR ("POOR STAR");
    7071
    7172        // get growth-corrected, apTrend-uncorrected magnitudes in scaled apertures
     
    7374        if (!pmSourceMagnitudes (source, psf, photMode, maskVal, mark)) {
    7475            Nskip ++;
     76            psTrace ("psphot", 3, "skip : bad source mag");
    7577            continue;
    7678        }
    7779
    78         if (!isfinite(source->apMag) || !isfinite(source->apMag)) {
     80        if (!isfinite(source->apMag) || !isfinite(source->psfMag)) {
    7981            Nfail ++;
     82            psTrace ("psphot", 3, "fail : nan mags : %f %f", source->apMag, source->psfMag);
    8083            continue;
    8184        }
     
    8790        if ((MAX_AP_OFFSET > 0) && (fabs(dap) > MAX_AP_OFFSET)) {
    8891            Nfail ++;
     92            psTrace ("psphot", 3, "fail : bad dap %f %f", dap, MAX_AP_OFFSET);
    8993            continue;
    9094        }
     
    99103        dMag->data.F32[Npsf] = model->dparams->data.F32[PM_PAR_I0] / model->params->data.F32[PM_PAR_I0];
    100104
     105        psVectorExtend (mag,     100, 1);
    101106        psVectorExtend (mask,    100, 1);
    102107        psVectorExtend (xPos,    100, 1);
     
    146151    }
    147152
     153    // XXX catch error condition
    148154    psphotApResidTrend (readout, psf, Npsf, entryMin, &errorScale, &errorFloor, mask, xPos, yPos, apResid, dMag);
    149155
     
    152158    psVector *apResidRes = (psVector *) psBinaryOp (NULL, (void *) apResid, "-", (void *) apResidFit);
    153159    psVector *dMagSys = (psVector *) psBinaryOp (NULL, (void *) dMag, "*", (void *) psScalarAlloc(errorScale, PS_TYPE_F32));
    154 
    155     psphotSaveImage (NULL, psf->ApTrend->map->map, "apresid.map.fits");
    156160
    157161    if (psTraceGetLevel("psphot") >= 5) {
     
    170174    float xc = 0.5*readout->image->numCols + readout->image->col0 + 0.5;
    171175    float yc = 0.5*readout->image->numRows + readout->image->row0 + 0.5;
     176
    172177    psf->ApResid  = pmTrend2DEval (psf->ApTrend, xc, yc); // ap-fit at chip center
    173178    psf->dApResid = errorFloor;
     
    206211*/
    207212
    208 bool psphotMagErrorScale (float *errorScale, float *errorFloor, psVector *dMag, psVector *dap, int nGroup) {
     213bool psphotMagErrorScale (float *errorScale, float *errorFloor, psVector *dMag, psVector *dap, psVector *mask, int nGroup) {
    209214
    210215    psStats *statsS = psStatsAlloc (PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV);
     
    225230    psVector *dMSubset = psVectorAllocEmpty (nGroup, PS_TYPE_F32);
    226231    psVector *dASubset = psVectorAllocEmpty (nGroup, PS_TYPE_F32);
     232    psVector *mkSubset = psVectorAllocEmpty (nGroup, PS_TYPE_U8);
    227233
    228234    int n = 0;
     
    233239            dMSubset->data.F32[j] = dMag->data.F32[N];
    234240            dASubset->data.F32[j] = dap->data.F32[N];
     241            mkSubset->data.U8[j]  = mask->data.U8[N];
    235242        }
    236243        dMSubset->n = j;
    237244        dASubset->n = j;
     245        mkSubset->n = j;
    238246
    239247        psStatsInit (statsS);
    240248        psStatsInit (statsM);
    241249
    242         psVectorStats (statsS, dASubset, NULL, NULL, 0xff);
    243         psVectorStats (statsM, dMSubset, NULL, NULL, 0xff);
     250        psVectorStats (statsS, dASubset, NULL, mkSubset, 0xff);
     251        psVectorStats (statsM, dMSubset, NULL, mkSubset, 0xff);
    244252
    245253        dSo->data.F32[i] = statsS->robustStdev;
     
    250258    psFree (dMSubset);
    251259    psFree (dASubset);
     260    psFree (mkSubset);
    252261   
    253262    psStats *stats = psStatsAlloc (PS_STAT_SAMPLE_MEDIAN);
     
    286295    }
    287296
     297    // the mask marks the values not used to calculate the ApTrend
     298    psVectorInit (mask, 0);
     299
    288300    // XXX stats structure for use by ApTrend : make parameters user setable
    289301    psStats *stats = psStatsAlloc (PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV);
     
    305317    // XXX this is a bit arbitrary, but it forces ~3 stars from the bright bin per spatial bin
    306318    int nGroup = PS_MAX (3*Nx*Ny, 10);
    307     psphotMagErrorScale (errorScale, errorFloor, dMag, apResidRes, nGroup);
     319    psphotMagErrorScale (errorScale, errorFloor, dMag, apResidRes, mask, nGroup);
    308320
    309321    psLogMsg ("psphot.apresid", PS_LOG_INFO, "result of %d x %d grid (%d stars per bin)\n", Nx, Ny, nGroup);
Note: See TracChangeset for help on using the changeset viewer.