IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 18, 2012, 5:56:48 AM (14 years ago)
Author:
eugene
Message:

merge changes from trunk

Location:
branches/eam_branches/ipp-20121130/psphot
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20121130/psphot

  • branches/eam_branches/ipp-20121130/psphot/src

  • branches/eam_branches/ipp-20121130/psphot/src/psphotOutput.c

    r34528 r34838  
    201201    int nCR  = 0;
    202202    int nEXT = 0;
     203    int nForced = 0;
     204    int nDetections = sources != NULL ? sources->n : 0;
    203205
    204206    // count the number of sources which will be written and other sub-types
    205207    for (int i = 0; (sources != NULL) && (i < sources->n); i++) {
    206208        pmSource *source = (pmSource *) sources->data[i];
     209        if (source->mode2 & PM_SOURCE_MODE2_MATCHED) {
     210            nForced ++;
     211        }
    207212        pmModel *model = pmSourceGetModel (NULL, source);
    208213        if (model == NULL)
     
    217222    }
    218223
     224    // XXX: This loop cauess nSrc to be twice as large as it should be. This is kept
     225    // for compatability
    219226    for (int i = 0; (sources != NULL) && (i < sources->n); i++) {
    220227        pmSource *source = (pmSource *) sources->data[i];
     
    226233
    227234    psMetadataAddS32 (header, PS_LIST_TAIL, "NSTARS",   PS_META_REPLACE, "Number of sources", nSrc);
     235    psMetadataAddS32 (header, PS_LIST_TAIL, "NDET",     PS_META_REPLACE, "Number of detections", nDetections);
    228236    psMetadataAddS32 (header, PS_LIST_TAIL, "NDET_EXT", PS_META_REPLACE, "Number of extended sources", nEXT);
    229237    psMetadataAddS32 (header, PS_LIST_TAIL, "NDET_CR",  PS_META_REPLACE, "Number of cosmic rays", nCR);
     238    psMetadataAddS32 (header, PS_LIST_TAIL, "NDET_FRC", PS_META_REPLACE, "Number of Forced detections", nForced);
    230239    return true;
    231240}
     
    306315    psMetadataItemSupplement (&status, header, analysis, "NSTARS");
    307316
     317    psMetadataItemSupplement (&status, header, analysis, "NDET");
    308318    psMetadataItemSupplement (&status, header, analysis, "NDET_EXT");
    309319    psMetadataItemSupplement (&status, header, analysis, "NDET_CR");
     320    psMetadataItemSupplement (&status, header, analysis, "NDET_FRC");
    310321
    311322    psMetadataItemSupplement (&status, header, analysis, "PSPHOT.PSF.APRESID");
  • branches/eam_branches/ipp-20121130/psphot/src/psphotSourceMatch.c

    r34542 r34838  
    77    int     order;
    88    bool    matchAll;
     9    long    nSources;
     10    float   yRatioMax;
    911    char    filterID[MATCH_INFO_FILTER_STR_LEN];
    1012} psphotStackMatchInfo;
     
    218220        pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");
    219221        psAssert (detections, "missing detections?");
     222        psAssert (detections->allSources, "all sources not defined?");
    220223
    221224        detArrays->data[i] = psMemIncrRefCounter(detections);
    222225        readouts->data[i] = psMemIncrRefCounter(readout);
     226    }
     227
     228    // We are having a problem with large number of false y band detections causing large numbers of
     229    // matched detections to be created.
     230    // The matchInfo recipe each entry contains a value for Y.RATIO.MAX. For each filter with a non-zero value
     231    // we compare the ratio of the number of y detections to the number of detections in that filter to Y.RATIO.MAX.
     232    // If the ratio in all filters with a non-zero is above its limit we consider the y band stack to
     233    // be suspect and so disable the y band matchAll recipe (if set)
     234
     235    int iy = -1;
     236    // note now we are looping over matchInfo
     237    for (int i = 0; i < nImages; i++) {
     238        // Remember which input is y
     239        if (!strcmp(matchInfo[i].filterID, "y")) {
     240            iy = i;
     241        }
     242        pmDetections *detections = detArrays->data[matchInfo[i].inputNum];
     243        matchInfo[i].nSources = detections->allSources->n;
     244    }
     245
     246    if (iy >= 0) {
     247        int nCut = 0;
     248        int nTry = 0;
     249        for (int i = 0; i < nImages; i++) {
     250            if (i == iy) continue;
     251            if (matchInfo[i].yRatioMax != 0.0 && matchInfo[i].nSources > 0) {
     252                ++nTry;
     253                float ratio = (float) matchInfo[iy].nSources / (float) matchInfo[i].nSources;
     254                psLogMsg ("psphot", PS_LOG_DETAIL, "nSrc_y / nSrc_%s: %6.3f max: %6.3f", matchInfo[i].filterID, ratio,
     255                    matchInfo[i].yRatioMax);
     256                if (ratio > matchInfo[i].yRatioMax) {
     257                    // This one is above it's threshold
     258                    ++nCut;
     259                }
     260            }
     261        }
     262        if (nTry > 0 && nCut == nTry) {
     263            // All filters with a cut were above the threshold. Disable matchAll for y band
     264            psLogMsg ("psphot", PS_LOG_INFO, "Clearing y band matchAll because y ratio was too high in %d filters", nTry);
     265            matchInfo[iy].matchAll = false;
     266        }
    223267    }
    224268
     
    516560            bool matchAll = (strcasecmp("true", matchAllStr) == 0);
    517561
     562            psString yRatioStr = psMetadataLookupStr (&status, item->data.md, "Y.RATIO.MAX");
     563            psF32 yRatioMax = atof(yRatioStr);
     564
    518565            // look for this filter in the inputs
    519566            for (int i = 0; i < num; i++) {
     
    524571                    matchInfo[i].order = order;
    525572                    matchInfo[i].matchAll = matchAll;
     573                    matchInfo[i].yRatioMax = yRatioMax;
     574                    matchInfo[i].nSources = 0;
    526575                    psLogMsg ("psphot", PS_LOG_DETAIL, "input: %d %s match order: %d match all: %d\n",
    527576                                                               i, thisFilter, order, matchAll);
  • branches/eam_branches/ipp-20121130/psphot/src/psphotSourceSize.c

    r34418 r34838  
    1111    float nSigmaMoments;
    1212    float nSigmaCR;
     13    bool altDiffExt;
     14    float altDiffExtThresh;
    1315    float soft;
    1416    int grow;
     
    120122    assert (status);
    121123
     124    // Optional extended source measurement algorithm to improve diff image trails
     125    options.altDiffExt = psMetadataLookupBool(&status, recipe, "PSPHOT.EXT.DIFF.ALTERNATE");
     126    assert (status);
     127    // Threshold for this alternate method
     128    options.altDiffExtThresh = psMetadataLookupF32(&status, recipe, "PSPHOT.EXT.DIFF.ALTERNATE.THRESH");
     129    assert (status);
     130   
    122131    // location of a single test source
    123132    options.xtest = psMetadataLookupS32 (&status, recipe, "PSPHOT.CRMASK.XTEST");
     
    601610            continue;
    602611        }
    603 
     612        // Alternate extended source limit calculation
     613        if (options->altDiffExt) {
     614          // ratio of major to minor axes
     615          // MRV = Major / Minor
     616          // MRV = (0.5 * (Mxx + Myy) + 0.5 * sqrt( (Mxx + Myy)^2 + 4 Mxy^2)) /
     617          //       (0.5 * (Mxx + Myy) - 0.5 * sqrt( (Mxx + Myy)^2 + 4 Mxy^2))
     618          // MRV = (2 * 0.5 * (Mxx + Myy) - Minor) / Minor
     619          float momentRatioVeres = (Mxx + Myy - Mminor) / Mminor;
     620          bool  isAltEXT = (momentRatioVeres > options->altDiffExtThresh);
     621          if (isAltEXT) {
     622            psTrace("psphotSourceClassRegion.EXT",4,"CLASS: %g %g\t%g %g\t%g %g\t%g %g\t%g ALTEXT\t%g %g\n",
     623                    source->peak->xf, source->peak->yf, Mminor, kMag, dMag, nSigmaMAG, options->sizeLimitCR, options->magLimitCR, options->nSigmaApResid,
     624                    momentRatioVeres,options->altDiffExtThresh);
     625            source->mode |= PM_SOURCE_MODE_EXT_LIMIT;
     626            source->tmpFlags |= PM_SOURCE_TMPF_SIZE_MEASURED;
     627            Next ++;
     628            continue;
     629          }
     630        }
     631       
    604632        // Everything else should just be treated as a PSF
    605633        psTrace("psphotSourceClassRegion.PSF",4,"CLASS: %g %g\t%g %g\t%g %g\t%g %g\t%g PSF\n",
  • branches/eam_branches/ipp-20121130/psphot/src/psphotStackImageLoop.c

Note: See TracChangeset for help on using the changeset viewer.