IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 32236


Ignore:
Timestamp:
Aug 31, 2011, 3:23:36 AM (15 years ago)
Author:
eugene
Message:

cleanup test code, allow for usage with new or allSources, only subtract source if we added it in, do not symmetrize the mag, just the radius

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20110710/psphot/src/psphotKronIterate.c

    r32216 r32236  
    3737        psAssert (detections, "missing detections?");
    3838
    39         psArray *sources = detections->allSources;
     39        psArray *sources = detections->newSources ? detections->newSources : detections->allSources;
    4040        psAssert (sources, "missing sources?");
    4141
     
    127127    // psphotVisualRangeImage (kapa, kronWindow, "kronwin", 0, 0.0, 1.0);
    128128
    129     psphotSaveImage (NULL, kronWindow, "kron.window.v0.fits");
     129    // psphotSaveImage (NULL, kronWindow, "kron.window.v0.fits");
    130130
    131131    for (int j = 0; j < 5; j++) {
     
    139139
    140140            // replace object in image
     141            bool reSubtract = false;
    141142            if (source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED) {
    142143                pmSourceAdd (source, PM_MODEL_OP_FULL, maskVal);
     144                reSubtract = true;
    143145            }
    144146
     
    151153            // clear the window function for this source based on the moments
    152154            psphotKronWindowSetSource (source, kronWindow, (j > 0), false);
    153             // psphotKronWindowSetSource (source, kronWindow, false, false);
    154155            // psphotVisualRangeImage (kapa, kronWindow, "kronwin", 1, 0.0, 1.0);
    155 
    156             // 165, 539;
    157             if ((fabs(source->peak->xf - 165) < 3) && (fabs(source->peak->yf - 539) < 3)) {
    158                 fprintf (stderr, "test obj\n");
    159             }
    160156
    161157            // this function populates moments->Mrf,KronFlux,KronFluxErr
     
    165161            // set a window function for each source based on the moments
    166162            psphotKronWindowSetSource (source, kronWindow, true, true);
    167             // psphotKronWindowSetSource (source, kronWindow, false, true);
    168 
    169             // test source fluxes
    170             pmSourceMagnitudes (source, psf, photMode, maskVal, markVal, source->apRadius);
    171             float kmag = -2.5*log10(source->moments->KronFlux);
    172 # define TEST_X1 167
    173 # define TEST_Y1 299
    174 # define TEST_X2 180
    175 # define TEST_Y2 300
    176             if ((fabs(source->peak->xf - TEST_X1) < 3) && (fabs(source->peak->yf - TEST_Y1) < 3)) {
    177                 fprintf (stderr, "R1: %f vs %f  (%f) (%f)\n", source->moments->KronRadiusPSF, source->moments->Mrf, kmag, windowRadius);
     163
     164            // if we subtracted it above, re-subtract the object, leave local sky
     165            if (reSubtract) {
     166                pmSourceSub (source, PM_MODEL_OP_FULL, maskVal);
    178167            }
    179             if ((fabs(source->peak->xf - TEST_X2) < 3) && (fabs(source->peak->yf - TEST_Y2) < 3)) {
    180                 fprintf (stderr, "R2: %f vs %f  (%f) (%f)\n", source->moments->KronRadiusPSF, source->moments->Mrf, kmag, windowRadius);
    181             }
    182 
    183             // re-subtract the object, leave local sky
    184             pmSourceSub (source, PM_MODEL_OP_FULL, maskVal);
    185168        }
    186         char name[64];
    187         sprintf (name, "kron.window.v%d.fits", j+1);
    188         psphotSaveImage (NULL, kronWindow, name);
     169        // char name[64];
     170        // sprintf (name, "kron.window.v%d.fits", j+1);
     171        // psphotSaveImage (NULL, kronWindow, name);
    189172    }
    190173    psFree (kronWindow);
     
    275258            assert (z >= 0.0);
    276259
    277             // float weight  = 1.0;
     260            // weight by window image and wide Gaussian
    278261            float weight1  = vWin[row+Ywo][col+Xwo]*exp(-z);
    279262            float weight2  = vWin[yFlip+Ywo][xFlip+Xwo]*exp(-z);
    280             // float weight1  = vWin[row+Ywo][col+Xwo];
    281             // float weight2  = vWin[yFlip+Ywo][xFlip+Xwo];
    282263
    283264            float fDiff1 = vPix[row][col]*weight1;
     
    315296        if (fabs(yDiff) > radKron) continue;
    316297
    317         // coordinate of mirror pixel
    318         int yFlip = yCM - yDiff;
    319         if (yFlip < 0) continue;
    320         if (yFlip >= source->pixels->numRows) continue;
    321 
    322298        for (psS32 col = 0; col < source->pixels->numCols ; col++) {
    323299            // check mask and value for this pixel
     
    328304            if (fabs(xDiff) > radKron) continue;
    329305
    330             // coordinate of mirror pixel
    331             int xFlip = xCM - xDiff;
    332             if (xFlip < 0) continue;
    333             if (xFlip >= source->pixels->numCols) continue;
    334 
    335             // check mask and value for mirror pixel
    336             if (vMsk && (vMsk[yFlip][xFlip] & maskVal)) continue;
    337             if (isnan(vPix[yFlip][xFlip])) continue;
    338 
    339306            // radKron is just a function of (xDiff, yDiff)
    340307            psF32 r2  = PS_SQR(xDiff) + PS_SQR(yDiff);
    341308            if (r2 > radKron2) continue;
    342309
    343             // float z = r2 * rsigma2;
    344             // assert (z >= 0.0);
    345 
    346             // float weight  = 1.0;
    347             // float weight1  = vWin[row+Ywo][col+Xwo]*exp(-z);
    348             // float weight2  = vWin[yFlip+Ywo][xFlip+Xwo]*exp(-z);
    349310            float weight1  = vWin[row+Ywo][col+Xwo];
    350             float weight2  = vWin[yFlip+Ywo][xFlip+Xwo];
    351 
    352311            float fDiff1 = vPix[row][col]*weight1;
    353             float fDiff2 = vPix[yFlip][xFlip]*weight2;
    354 
    355             float pDiff = (fDiff1 > 0.0) ? sqrt(fabs(fDiff1*fDiff2)) : -sqrt(fabs(fDiff1*fDiff2));
     312
     313            float pDiff = fDiff1;
    356314            psF32 wDiff = vWgt[row][col] * weight1;
    357315
     
    365323    source->moments->Mrf = Mrf;
    366324    source->moments->KronFlux    = Sum;
    367     source->moments->KronFluxErr = Sum * (nKronPix / Win);
    368     // source->moments->KronFluxErr = sqrt(Var / Win);
     325    source->moments->KronFluxErr = sqrt(Var);
    369326
    370327    return true;
     
    393350    float Mminor = 0.5*(Mxx + Myy) - 0.5*sqrt(PS_SQR(Mxx - Myy) + 4.0*PS_SQR(Mxy));
    394351
    395     // float kratio = source->moments->KronFinner / source->moments->KronFlux;
    396 
     352    // Mxx, Mxy, Myy define the elliptical shape, but Mrf defines the width
    397353    float scale = PS_SQR(0.5 * source->moments->Mrf) / Mmajor;
    398     // float scale = useKronRadius ? 2.0 * source->moments->Mrf / Mmajor : 2.0;
    399     // float scale = (kratio > 0.4) ? 9.0 * source->moments->Mrf / Mmajor : 3.0 * source->moments->Mrf / Mmajor;
    400354
    401355    float Sxx = scale * Mmajor * Mminor / Myy; // sigma_x^2
Note: See TracChangeset for help on using the changeset viewer.