IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 5, 2009, 5:03:33 PM (17 years ago)
Author:
Paul Price
Message:

Merging pap_branch_20090128. Resolved a small number of conflicts. Compiles, but not tested in detail.

File:
1 edited

Legend:

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

    r21183 r21366  
    5858    // for each input source:
    5959    // - construct a residual image, renormalized
    60     // - construct a renormalized weight image
     60    // - construct a renormalized variance image
    6161    // - construct a new mask image
    6262
    6363    // construct the output residual table (Nx*DX,Ny*DY)
    6464    // for each output pixel:
    65     // - construct a histogram of the values & weights (interpolate to the common pixel coordinate)
     65    // - construct a histogram of the values & variances (interpolate to the common pixel coordinate)
    6666    // - measure the robust median & sigma
    6767    // - reject (mask) input pixels which are outliers
    6868    // - re-measure the robust median & sigma
    69     // - set output pixel, weight, and mask
     69    // - set output pixel, variance, and mask
    7070
    7171    // these mask values do not correspond to the recipe values: they
     
    7676    // psVectorStats
    7777
    78     const psImageMaskType badMask     = 0x01;   // mask bits
    79     const psImageMaskType poorMask    = 0x02;   // from psImageInterpolate
    80     const psImageMaskType clippedMask = 0x04;   // mask bit set for clipped values
     78    const psImageMaskType badMask     = 0x01;   // mask bits
     79    const psImageMaskType poorMask    = 0x02;   // from psImageInterpolate
     80    const psImageMaskType clippedMask = 0x04;   // mask bit set for clipped values
    8181    const psVectorMaskType fmaskVal = badMask | poorMask | clippedMask;
    8282
     
    101101
    102102        psImage *image  = psImageCopy (NULL, source->pixels,   PS_TYPE_F32);
    103         psImage *weight = psImageCopy (NULL, source->weight,   PS_TYPE_F32);
     103        psImage *variance = psImageCopy (NULL, source->variance,   PS_TYPE_F32);
    104104        psImage *mask   = psImageCopy (NULL, source->maskView, PS_TYPE_IMAGE_MASK);
    105105        pmModelSub (image, mask, model, PM_MODEL_OP_FUNC, maskVal);
    106106
    107         // re-normalize image and weight
     107        // re-normalize image and variance
    108108        float Io = model->params->data.F32[PM_PAR_I0];
    109109        psBinaryOp (image, image, "/", psScalarAlloc(Io, PS_TYPE_F32));
    110         psBinaryOp (weight, weight, "/", psScalarAlloc(Io*Io, PS_TYPE_F32));
    111 
    112         // we interpolate the image and weight - include the mask or not?
    113         // XXX why not the mask?
    114         // psImageInterpolation *interp = psImageInterpolationAlloc(mode, image, weight, mask, maskVal, 0.0, 0.0, badMask, poorMask, 0.0, 0);
    115         psImageInterpolation *interp = psImageInterpolationAlloc(mode, image, weight, NULL, 0xff, 0.0, 0.0, badMask, poorMask, 0.0, 0);
     110        psBinaryOp (variance, variance, "/", psScalarAlloc(Io*Io, PS_TYPE_F32));
     111
     112        // we interpolate the image and variance - include the mask or not?
     113        // XXX why not the mask?
     114        // psImageInterpolation *interp = psImageInterpolationAlloc(mode, image, variance, mask, maskVal, 0.0, 0.0, badMask, poorMask, 0.0, 0);
     115        psImageInterpolation *interp = psImageInterpolationAlloc(mode, image, variance, NULL, 0xff, 0.0, 0.0, badMask, poorMask, 0.0, 0);
    116116        psArrayAdd (input, 100, interp);
    117117
     
    128128        psFree (mask);
    129129        psFree (image);
    130         psFree (weight);
     130        psFree (variance);
    131131        psFree (interp);
    132132    }
     
    176176                    fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i] = badMask;
    177177                } else {
    178                   fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i] = mflux; // XXX is mflux IMAGE or VECTOR type?
    179                 }
    180                 fluxes->data.F32[i] = flux;
    181                 dfluxes->data.F32[i] = dflux;
     178                  fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i] = mflux; // XXX is mflux IMAGE or VECTOR type?
     179                }
     180                fluxes->data.F32[i] = flux;
     181                dfluxes->data.F32[i] = dflux;
    182182                if (isnan(flux)) {
    183183                    fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i] = badMask;
     
    204204
    205205            // mark input pixels which are more than N sigma from the median
    206             int nKeep = 0;
     206            int nKeep = 0;
    207207            for (int i = 0; i < fluxes->n; i++) {
    208208                float delta = fluxes->data.F32[i] - fluxClip->robustMedian;
     
    210210                float swing = fabs(delta) / sigma;
    211211
    212                 // mask pixels which are out of range
     212                // mask pixels which are out of range
    213213                if (swing > nSigma) {
    214214                    fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i] = clippedMask;
    215215                }
    216                 if (!fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i]) nKeep++;
     216                if (!fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i]) nKeep++;
    217217            }
    218218
     
    225225                resid->Ro->data.F32[oy][ox] = psStatsGetValue(fluxStats, statOption);
    226226                resid->Rx->data.F32[oy][ox] = resid->Ry->data.F32[oy][ox] = 0.0;
    227                 //resid->weight->data.F32[oy][ox] = fluxStats->sampleStdev;
     227                //resid->variance->data.F32[oy][ox] = fluxStats->sampleStdev;
    228228
    229229                if (fabs(resid->Ro->data.F32[oy][ox]) < pixelSN*fluxStats->sampleStdev/sqrt(nKeep)) {
     
    231231                }
    232232
    233                 // fprintf (stderr, "res: %2d %2d : %6.4f  %6.4f  %6.4f   %3d  %1d\n", ox, oy, resid->Ro->data.F32[oy][ox], fluxStats->sampleStdev, fluxStats->sampleStdev/sqrt(nKeep), nKeep, resid->mask->data.PM_TYPE_RESID_MASK_DATA[oy][ox]);
     233                // fprintf (stderr, "res: %2d %2d : %6.4f  %6.4f  %6.4f   %3d  %1d\n", ox, oy, resid->Ro->data.F32[oy][ox], fluxStats->sampleStdev, fluxStats->sampleStdev/sqrt(nKeep), nKeep, resid->mask->data.PM_TYPE_RESID_MASK_DATA[oy][ox]);
    234234
    235235            } else {
     
    268268
    269269                float dRo = sqrt(A->data.F32[0][0]);
    270                 // fprintf (stderr, "res: %2d %2d : %6.4f  %6.4f  %6.4f   %3d  %1d\n",
    271                 // ox, oy, resid->Ro->data.F32[oy][ox], dRo, dRo/sqrt(nKeep), nKeep, resid->mask->data.PM_TYPE_RESID_MASK_DATA[oy][ox]);
     270                // fprintf (stderr, "res: %2d %2d : %6.4f  %6.4f  %6.4f   %3d  %1d\n",
     271                // ox, oy, resid->Ro->data.F32[oy][ox], dRo, dRo/sqrt(nKeep), nKeep, resid->mask->data.PM_TYPE_RESID_MASK_DATA[oy][ox]);
    272272
    273273                if (fabs(resid->Ro->data.F32[oy][ox]) < pixelSN*dRo/sqrt(nKeep)) {
    274274                  resid->mask->data.PM_TYPE_RESID_MASK_DATA[oy][ox] = 1;
    275275                }
    276                 //resid->weight->data.F32[oy][ox] = XXX;
     276                //resid->variance->data.F32[oy][ox] = XXX;
    277277            }
    278278        }
     
    301301      psphotSaveImage (NULL, resid->Rx,     "resid.rx.fits");
    302302      psphotSaveImage (NULL, resid->Ry,     "resid.ry.fits");
    303       psphotSaveImage (NULL, resid->weight, "resid.wt.fits");
     303      psphotSaveImage (NULL, resid->variance, "resid.wt.fits");
    304304      psphotSaveImage (NULL, resid->mask,   "resid.mk.fits");
    305305    }
Note: See TracChangeset for help on using the changeset viewer.