IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 28, 2007, 3:40:54 PM (19 years ago)
Author:
eugene
Message:

merging diffs from cvs head

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branch_20071023/psModules/src/imcombine/pmSubtraction.c

    r15325 r15399  
    44 *  @author GLG, MHPCC
    55 *
    6  *  @version $Revision: 1.65 $ $Name: not supported by cvs2svn $
    7  *  @date $Date: 2007-10-17 02:45:40 $
     6 *  @version $Revision: 1.65.2.1 $ $Name: not supported by cvs2svn $
     7 *  @date $Date: 2007-10-29 01:40:54 $
    88 *
    99 *  Copyright 2004-2007 Institute for Astronomy, University of Hawaii
     
    907907                    for (int j = 0; j < numKernels; j++) {
    908908                        psKernel *convolution = convolutions->data[j]; // Convolution of reference
     909
     910                        // XXX Precalculate these values, so that we're not calculating the same thing for
     911                        // every pixel.
    909912                        double polynomial = 0.0; // Value of the polynomial
    910913                        for (int yOrder = 0, index = j; yOrder <= spatialOrder; yOrder++) {
     
    928931            deviations->data.F32[i] = devNorm * deviation;
    929932            psTrace("psModules.imcombine", 5, "Deviation for stamp %d (%d,%d): %f\n",
    930                     i, (int)stamp->x, (int)stamp->y, deviations->data.F32[i]);
     933                    i, (int)(stamp->x + 0.5), (int)(stamp->y + 0.5), deviations->data.F32[i]);
    931934            totalSquareDev += PS_SQR(deviations->data.F32[i]);
    932935            numStamps++;
     
    947950    }
    948951
     952    if (!isfinite(sigmaRej) || sigmaRej <= 0.0) {
     953        psLogMsg("psModules.imcombine", PS_LOG_INFO, "RMS deviation: %f", sqrt(totalSquareDev / numStamps));
     954        psFree(deviations);
     955        return 0;
     956    }
     957
     958    int numRejected = 0;                // Number of stamps rejected
     959    int numGood = 0;                    // Number of good stamps
     960    double newSquareDev = 0.0;          // New square deviation
     961
    949962    float limit = sigmaRej * sqrt(totalSquareDev / numStamps); // Limit on maximum deviation
    950963    psTrace("psModules.imcombine", 1, "Deviation limit: %f\n", limit);
    951964
    952     int numRejected = 0;
    953965    for (int i = 0; i < stamps->num; i++) {
    954966        pmSubtractionStamp *stamp = stamps->stamps->data[i]; // Stamp of interest
    955         if (stamp->status == PM_SUBTRACTION_STAMP_USED && deviations->data.F32[i] > limit) {
    956             // Mask out the stamp in the image so you it's not found again
    957             psTrace("psModules.imcombine", 3, "Rejecting stamp %d (%d,%d)\n", i,
    958                     (int)(stamp->x + 0.5), (int)(stamp->y + 0.5));
    959             numRejected++;
    960             for (int y = stamp->y - footprint; y <= stamp->y + footprint; y++) {
    961                 for (int x = stamp->x - footprint; x <= stamp->x + footprint; x++) {
    962                     subMask->data.PS_TYPE_MASK_DATA[y][x] |= PM_SUBTRACTION_MASK_REJ;
     967        if (stamp->status == PM_SUBTRACTION_STAMP_USED) {
     968            if (deviations->data.F32[i] > limit) {
     969                // Mask out the stamp in the image so you it's not found again
     970                psTrace("psModules.imcombine", 3, "Rejecting stamp %d (%d,%d)\n", i,
     971                        (int)(stamp->x + 0.5), (int)(stamp->y + 0.5));
     972                numRejected++;
     973                for (int y = stamp->y - footprint; y <= stamp->y + footprint; y++) {
     974                    for (int x = stamp->x - footprint; x <= stamp->x + footprint; x++) {
     975                        subMask->data.PS_TYPE_MASK_DATA[y][x] |= PM_SUBTRACTION_MASK_REJ;
     976                    }
    963977                }
    964             }
    965 
    966             // Set stamp for replacement
    967             stamp->x = 0;
    968             stamp->y = 0;
    969             stamp->status = PM_SUBTRACTION_STAMP_REJECTED;
    970             // Recalculate convolutions
    971             psFree(stamp->convolutions);
    972             stamp->convolutions = NULL;
    973         }
    974     }
     978
     979                // Set stamp for replacement
     980                stamp->x = 0;
     981                stamp->y = 0;
     982                stamp->status = PM_SUBTRACTION_STAMP_REJECTED;
     983                // Recalculate convolutions
     984                psFree(stamp->convolutions);
     985                stamp->convolutions = NULL;
     986            } else {
     987                numGood++;
     988                newSquareDev += PS_SQR(deviations->data.F32[i]);
     989            }
     990        }
     991    }
     992
     993    psLogMsg("psModules.imcombine", PS_LOG_INFO, "%d good stamps; %d rejected.\nRMS deviation: %f --> %f\n",
     994             numGood, numRejected, sqrt(totalSquareDev / numStamps), sqrt(newSquareDev / numGood));
    975995
    976996    psFree(deviations);
Note: See TracChangeset for help on using the changeset viewer.