IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 34415


Ignore:
Timestamp:
Sep 7, 2012, 10:06:48 AM (14 years ago)
Author:
eugene
Message:

when growing the CR mask, copy the values into the existing readout->mask array, otherwise we lose the association to source->maskView; mask a small region for sources that have already been detected (the exclusion radius is curretnly set to 4 pixels, and is not user-specified; deactivate some test code; saturate linear fit fluxes to min valid flux (probably superfluous); calls to psphotFitSourcesLinear in psphotReadout should skip negative fluxes

Location:
branches/eam_branches/ipp-20120905/psphot/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20120905/psphot/src/psphotAddNoise.c

    r34404 r34415  
    11# include "psphotInternal.h"
     2
     3bool psphotMaskSource(pmSource *source, bool add, psImageMaskType maskVal);
    24
    35bool psphotAddNoise (pmConfig *config, const pmFPAview *view, const char *filerule) {
     
    3032}
    3133
     34static int Nmasked = 0;
     35
    3236bool psphotAddOrSubNoiseReadout (pmConfig *config, const pmFPAview *view, const char *filerule, int index, psMetadata *recipe, bool add) {
    3337
     
    5660    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
    5761    psAssert (maskVal, "missing mask value?");
     62
     63    psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT"); // Mask value for bad pixels
     64    psAssert (markVal, "missing mask value?");
    5865
    5966    // increase variance by factor*(object noise):
     
    94101
    95102        pmSourceNoiseOp (source, PM_MODEL_OP_FULL | PM_MODEL_OP_NOISE, FACTOR, SIZE, add, maskVal, 0, 0);
     103
     104        psphotMaskSource (source, add, markVal);
    96105    }
    97106    if (add) {
     
    100109        psLogMsg ("psphot.noise", PS_LOG_WARN, "sub noise for %ld objects: %f sec\n", sources->n, psTimerMark ("psphot.noise"));
    101110    }
     111    fprintf (stderr, "masked %d objects\n", Nmasked);
    102112
    103113    psphotVisualShowImage (readout);
     
    105115    return true;
    106116}
     117
     118bool psphotMaskSource(pmSource *source, bool add, psImageMaskType maskVal) {
     119
     120    if (!source) return false;
     121    if (!source->peak) return false; // XXX how can we have a peak-less source?
     122    if (source->type == PM_SOURCE_TYPE_DEFECT) return false;
     123    if (source->type == PM_SOURCE_TYPE_SATURATED) return false;
     124
     125    float Xc = source->peak->xf - source->pixels->col0 - 0.5;
     126    float Yc = source->peak->yf - source->pixels->row0 - 0.5;
     127
     128    psImageMaskType notMaskVal = ~maskVal;
     129
     130    for (int iy = 0; iy < source->pixels->numRows; iy++) {
     131        for (int ix = 0; ix < source->pixels->numCols; ix++) {
     132
     133            float radius = hypot (ix - Xc, iy - Yc) ;
     134
     135            if (radius > 4) continue;
     136
     137            if (add) {
     138              source->maskView->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] |= maskVal;
     139            } else {
     140              source->maskView->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] &= notMaskVal;
     141            }
     142        }
     143    }
     144    Nmasked ++;
     145
     146    return true;
     147}
     148
  • branches/eam_branches/ipp-20120905/psphot/src/psphotBlendFit.c

    r34409 r34415  
    9696    assert (status && isfinite(skySig) && skySig > 0);
    9797
    98 # if (1)
     98# if (0)
    9999    // **** test block : generate an ID image where pixels are set based the source models (flux > 0.1 peak && flux > 2.0 skySig)
    100100    psImage *IDimage = psImageAlloc (readout->image->numCols, readout->image->numRows, PS_TYPE_S32);
     
    258258
    259259        int TEST_ON = false;
    260 # if (1)
     260# if (0)
    261261# define TEST_X 653
    262262# define TEST_Y 466
    263263        if ((fabs(source->peak->xf - TEST_X) < 5) && (fabs(source->peak->yf - TEST_Y) < 5)) {
    264264            fprintf (stderr, "test object\n");
    265             //  psTraceSetLevel("psLib.math.psMinimizeLMChi2", 5);
     265            psTraceSetLevel("psLib.math.psMinimizeLMChi2", 5);
    266266            TEST_ON = true;
    267267        }
     
    379379    if (!source) return false;
    380380    if (!source->peak) return false; // XXX how can we have a peak-less source?
     381
     382# if (0)
     383# define TEST_X 653
     384# define TEST_Y 466
     385        if ((fabs(source->peak->xf - TEST_X) < 5) && (fabs(source->peak->yf - TEST_Y) < 5)) {
     386            fprintf (stderr, "test object\n");
     387        }
     388# undef TEST_X
     389# undef TEST_Y
     390# endif
     391
    381392    if (!source->moments) return false;
    382393    if (source->type == PM_SOURCE_TYPE_DEFECT) return false;
     
    473484
    474485    // what is the radius for a specific peak fraction?
    475     for (int i = 0; i < logFmodel->n; i++) {
     486    for (int i = 1; i < logFmodel->n; i++) {
    476487        float logF = logFmodel->data.F32[i];
     488        if (!isfinite(logF)) continue;
     489
    477490        float flux = pow(10.0, logF);
    478491        if (flux > threshold) continue;
    479         if (i == 0) continue;
    480492       
    481493        float logF0 = logFmodel->data.F32[i - 1];
     
    512524    int ID = source->id;
    513525
     526    fprintf (stderr, "Xo,Yo: %f,%f; radius: %f\n", Xo, Yo, radius);
     527
    514528    for (int iy = minY; iy < maxY; iy++) {
    515529        for (int ix = minX; ix < maxX; ix++) {
  • branches/eam_branches/ipp-20120905/psphot/src/psphotDeblendSatstars.c

    r34408 r34415  
    121121    int BIG_SIGMA = BIG_RADIUS / 4.0;
    122122
    123     int display = psphotKapaChannel (1);
    124     psphotVisualScaleImage (display, (psImage *) source->pixels->parent, NULL, "image", 1.0, 0);
     123    // int display = psphotKapaChannel (1);
     124    // psphotVisualScaleImage (display, (psImage *) source->pixels->parent, NULL, "image", 1.0, 0);
    125125
    126126    // examine sources in decreasing SN order
     
    182182    }
    183183    // show the image after object have been subtracted
    184     psphotVisualScaleImage (display, (psImage *) source->pixels->parent, NULL, "image", 1.0, 1);
     184    // psphotVisualScaleImage (display, (psImage *) source->pixels->parent, NULL, "image", 1.0, 1);
    185185
    186186    psFree (SN);
  • branches/eam_branches/ipp-20120905/psphot/src/psphotFindDetections.c

    r34404 r34415  
    4545    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
    4646    psAssert (maskVal, "missing mask value?");
     47
     48    // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
     49    psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT"); // Mask value for bad pixels
     50    psAssert (markVal, "missing mark value?");
     51
     52    maskVal |= markVal;
    4753
    4854    // Use the new pmFootprints approach?
  • branches/eam_branches/ipp-20120905/psphot/src/psphotFitSourcesLinear.c

    r34404 r34415  
    439439        model->params->data.F32[PM_PAR_I0] = norm->data.F32[i];
    440440        model->dparams->data.F32[PM_PAR_I0] = errors->data.F32[i];
     441
     442        if (norm->data.F32[i] < MIN_VALID_FLUX) {
     443          fprintf (stderr, "fit out of bounds for %f,%f : %f\n", source->peak->xf, source->peak->yf, norm->data.F32[i]);
     444          model->params->data.F32[PM_PAR_I0] = MIN_VALID_FLUX;
     445        }
    441446
    442447        // clear the 'mark' pixels so the subtraction covers the full window
  • branches/eam_branches/ipp-20120905/psphot/src/psphotKronIterate.c

    r34404 r34415  
    321321            if (!source->peak) continue; // XXX how can we have a peak-less source?
    322322
     323# if (0)
     324# define TEST_X 653
     325# define TEST_Y 466
     326        if ((fabs(source->peak->xf - TEST_X) < 5) && (fabs(source->peak->yf - TEST_Y) < 5)) {
     327            fprintf (stderr, "test object\n");
     328        }
     329# undef TEST_X
     330# undef TEST_Y
     331# endif
     332
    323333            // check status of this source's moments
    324334            if (!source->moments) continue;
     
    541551    if (RF <= 0. || RS <= 0 || !isfinite(MrfTry)) {
    542552        // We did not get a good measurement
    543         source->moments->Mrf = NAN;
     553        source->moments->Mrf = NAN;
    544554        source->moments->KronFlux  = NAN;
    545555        source->moments->KronFluxErr  = NAN;
  • branches/eam_branches/ipp-20120905/psphot/src/psphotReadout.c

    r34404 r34415  
    185185
    186186    // linear PSF fit to source peaks, subtract the models from the image (in PSF mask)
    187     psphotFitSourcesLinear (config, view, filerule, false, false); // pass 1 (detections->allSources)
     187    psphotFitSourcesLinear (config, view, filerule, false, true); // pass 1 (detections->allSources)
    188188
    189189    // measure the radial profiles to the sky
     
    212212    // linear fit to include all sources (subtract again)
    213213    // NOTE : apply to ALL sources (extended + psf)
    214     psphotFitSourcesLinear (config, view, filerule, true, false); // pass 2 (detections->allSources)
     214    psphotFitSourcesLinear (config, view, filerule, true, true); // pass 2 (detections->allSources)
    215215
    216216    // if we only do one pass, skip to extended source analysis
     
    260260
    261261        // NOTE: apply to ALL sources
    262         psphotFitSourcesLinear (config, view, filerule, true, false); // pass 3 (detections->allSources)
     262        psphotFitSourcesLinear (config, view, filerule, true, true); // pass 3 (detections->allSources)
    263263    }
    264264
     
    300300
    301301        // NOTE: apply to ALL sources
    302         psphotFitSourcesLinear (config, view, filerule, true, false); // pass 3 (detections->allSources)
     302        psphotFitSourcesLinear (config, view, filerule, true, true); // pass 3 (detections->allSources)
    303303    }
    304304
  • branches/eam_branches/ipp-20120905/psphot/src/psphotSourceSize.c

    r34404 r34415  
    675675            return false;
    676676        }
    677         psFree(readout->mask);
    678         readout->mask = newMask;
     677        // Copy the new mask pixel values to the old mask array.  NOTE: we cannot replace
     678        // the mask pointer because the source->maskView objects point to the old data
     679        // area
     680        psImage *oldMask = readout->mask;
     681        readout->mask = psImageCopy (readout->mask, newMask, PS_TYPE_IMAGE_MASK);
     682        psAssert (oldMask == readout->mask, "should have copied the values in-situ");
     683        psFree(newMask);
    679684    }
    680685
  • branches/eam_branches/ipp-20120905/psphot/src/psphotStackReadout.c

    r34354 r34415  
    332332    psphotStackObjectsSelectForAnalysis (config, view, STACK_SRC, objects);
    333333
    334     if (splitLinearFit) {
    335         // NOTE: apply to Matched sources. Since the sources that we fit above are subtracted, they will
    336         // not be included in this fit.
    337         psphotFitSourcesLinear (config, view, STACK_SRC, true, false); // pass 4 (detections->allSources)
    338     } else {
    339         // Fit all sources together
    340         psphotFitSourcesLinear (config, view, STACK_SRC, true, false); // pass 3 (detections->allSources)
    341     }
     334    // final linear fit. NOTE: if splitLinearFit is true above, this pass will only fit
     335    // the unsubtracted (matched) sources (the sources that we fit above are subtracted)
     336    psphotFitSourcesLinear (config, view, STACK_SRC, true, false); // pass 4 (detections->allSources)
    342337
    343338    // measure the radial profiles to the sky (only measures new objects)
Note: See TracChangeset for help on using the changeset viewer.