IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 32245


Ignore:
Timestamp:
Aug 31, 2011, 12:49:01 PM (15 years ago)
Author:
eugene
Message:

clean up test code in pmSourceMoments

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20110710/psModules/src/objects/pmSourceMoments.c

    r32216 r32245  
    115115    // Now calculate higher-order moments, using the above-calculated first moments to adjust coordinates
    116116    // Xn  = SUM (x - xc)^n * (z - sky)
    117 
    118     float RFa = 0.0;
    119     float RSa = 0.0;
    120 
    121     float RF = 0.0;
    122     float RH = 0.0;
    123     float RS = 0.0;
    124117    float XX = 0.0;
    125118    float XY = 0.0;
     
    269262    source->moments->Myyyy = YYYY/Sum;
    270263
    271 # define TEST_X1 167
    272 # define TEST_Y1 299
    273 # define TEST_X2 180
    274 # define TEST_Y2 300
    275     if ((fabs(Xo - TEST_X1) < 3) && (fabs(Yo - TEST_Y1) < 3)) {
    276         fprintf (stderr, "test obj 1\n");
    277     }
    278     if ((fabs(Xo - TEST_X2) < 3) && (fabs(Yo - TEST_Y2) < 3)) {
    279         fprintf (stderr, "test obj 2\n");
    280     }
     264    // *** now calculate the 1st radial moment (for kron flux) -- symmetrical averaging
    281265
    282266    float **vPix = source->pixels->data.F32;
     
    284268    psImageMaskType  **vMsk = (source->maskObj == NULL) ? NULL : source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA;
    285269
    286     // calculate the 1st radial moment (for kron flux) -- symmetrical averaging
     270    float RF = 0.0;
     271    float RH = 0.0;
     272    float RS = 0.0;
     273
    287274    for (psS32 row = 0; row < source->pixels->numRows ; row++) {
    288275
     
    326313            float rs = 0.5 * (fDiff1 + fDiff2);
    327314
    328             float rfa = r * fDiff1;
    329             float rsa = fDiff1;
    330 
    331315            RF  += rf;
    332316            RH  += rh;
    333317            RS  += rs;
    334 
    335             RFa  += rfa;
    336             RSa  += rsa;
    337318        }
    338319    }
     
    340321    source->moments->Mrf = RF/RS;
    341322    source->moments->Mrh = RH/RS;
    342 
    343     float R1 = RFa / RSa;
    344     if ((fabs(Xo - TEST_X1) < 3) && (fabs(Yo - TEST_Y1) < 3)) {
    345         fprintf (stderr, "R1: %f vs %f\n", R1, source->moments->Mrf);
    346     }
    347     if ((fabs(Xo - TEST_X2) < 3) && (fabs(Yo - TEST_Y2) < 3)) {
    348         fprintf (stderr, "R2: %f vs %f\n", R1, source->moments->Mrf);
    349     }
    350 
    351     // fprintf (stderr, "Rad: %f vs %f\n", R1, source->moments->Mrf);
    352323
    353324    // if Mrf (first radial moment) is very small, we are getting into low-significance
     
    358329        kronRefRadius = MIN(radius, kronRefRadius);
    359330    }
     331
     332    // *** now calculate the kron flux values using the 1st radial moment
    360333
    361334    float radKinner = 1.0*kronRefRadius;
     
    371344    float SumOuter = 0.0;
    372345
    373     // calculate the Kron flux, and related fluxes (symmetrical averaging)
     346    // calculate the Kron flux, and related fluxes (NO symmetrical averaging)
    374347    for (psS32 row = 0; row < source->pixels->numRows ; row++) {
    375348       
    376349        float yDiff = row - yCM;
    377350        if (fabs(yDiff) > radKouter) continue;
    378        
    379         // coordinate of mirror pixel
    380         int yFlip = yCM - yDiff;
    381         if (yFlip < 0) continue;
    382         if (yFlip >= source->pixels->numRows) continue;
    383351       
    384352        for (psS32 col = 0; col < source->pixels->numCols ; col++) {
     
    390358            if (fabs(xDiff) > radKouter) continue;
    391359           
    392             // coordinate of mirror pixel
    393             int xFlip = xCM - xDiff;
    394             if (xFlip < 0) continue;
    395             if (xFlip >= source->pixels->numCols) continue;
    396            
    397             // check mask and value for mirror pixel
    398             if (vMsk && (vMsk[yFlip][xFlip] & maskVal)) continue;
    399             if (isnan(vPix[yFlip][xFlip])) continue;
    400            
    401360            // radKron is just a function of (xDiff, yDiff)
    402361            float r2  = PS_SQR(xDiff) + PS_SQR(yDiff);
    403362
    404363            float fDiff1 = vPix[row][col] - sky;
    405             float fDiff2 = vPix[yFlip][xFlip] - sky;
    406             float pDiff = (fDiff1 > 0.0) ? sqrt(fabs(fDiff1*fDiff2)) : -sqrt(fabs(fDiff1*fDiff2));
    407             // float pDiff = vPix[row][col] - sky;
     364            float pDiff = fDiff1;
    408365            float wDiff = vWgt[row][col];
    409366                                   
     
    413370            if (PS_SQR(pDiff) < minSN2*wDiff) continue;
    414371           
    415 # define WEIGHTED 0
    416 # if (WEIGHTED)
    417             float z = r2 * rsigma2 / 4.0;
    418             assert (z >= 0.0);
    419             float weight  = exp(-z);
    420 # else
    421             float weight  = 1.0;
    422 # endif
    423 
    424372            float r  = sqrt(r2);
    425373            if (r < radKron) {
    426                 Sum += pDiff*weight;
    427                 Var += wDiff*weight;
     374                Sum += pDiff;
     375                Var += wDiff;
    428376                nKronPix ++;
    429377                // if (beVerbose) fprintf (stderr, "mome: %d %d  %f  %f  %f\n", col, row, sky, *vPix, Sum);
Note: See TracChangeset for help on using the changeset viewer.