IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 7, 2009, 4:08:25 PM (17 years ago)
Author:
Paul Price
Message:

Merging trunk (r25026) to get up-to-date on old branch.

Location:
branches/pap
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/pap

  • branches/pap/psModules

    • Property svn:mergeinfo deleted
  • branches/pap/psModules/src/objects/pmSource.c

    r23187 r25027  
    242242    extend |= (mySource->maskView == NULL);
    243243
    244     // extend = true;
    245244    if (extend) {
    246245        // re-create the subimage
     
    250249
    251250        mySource->pixels   = psImageSubset(readout->image,  newRegion);
    252         mySource->variance   = psImageSubset(readout->variance, newRegion);
     251        mySource->variance = psImageSubset(readout->variance, newRegion);
    253252        mySource->maskView = psImageSubset(readout->mask,   newRegion);
    254253        mySource->region   = newRegion;
     
    291290
    292291    bool status = true;                 // Status of MD lookup
    293     float PSF_CLUMP_SN_LIM = psMetadataLookupF32(&status, recipe, "PSF_CLUMP_SN_LIM");
     292    float PSF_SN_LIM = psMetadataLookupF32(&status, recipe, "PSF_SN_LIM");
    294293    if (!status) {
    295         PSF_CLUMP_SN_LIM = 0;
     294        PSF_SN_LIM = 0;
    296295    }
    297296    float PSF_CLUMP_GRID_SCALE = psMetadataLookupF32(&status, recipe, "PSF_CLUMP_GRID_SCALE");
     
    342341            }
    343342
    344             if (src->moments->SN < PSF_CLUMP_SN_LIM) {
     343            if (src->moments->SN < PSF_SN_LIM) {
    345344                psTrace("psModules.objects", 10, "Rejecting source from clump because of low S/N (%f)\n",
    346345                        src->moments->SN);
     
    450449            if (tmpSrc->moments == NULL)
    451450                continue;
    452             if (tmpSrc->moments->SN < PSF_CLUMP_SN_LIM)
     451            if (tmpSrc->moments->SN < PSF_SN_LIM)
    453452                continue;
    454453
     
    479478        stats = psStatsAlloc (PS_STAT_CLIPPED_MEAN | PS_STAT_CLIPPED_STDEV);
    480479
    481         psVectorStats (stats, tmpSx, NULL, NULL, 0);
     480        if (!psVectorStats (stats, tmpSx, NULL, NULL, 0)) {
     481            psError(PS_ERR_UNKNOWN, false, "failed to measure Sx stats");
     482            return (emptyClump);
     483        }
    482484        psfClump.X  = stats->clippedMean;
    483485        psfClump.dX = stats->clippedStdev;
    484486
    485         psVectorStats (stats, tmpSy, NULL, NULL, 0);
     487        if (!psVectorStats (stats, tmpSy, NULL, NULL, 0)) {
     488            psError(PS_ERR_UNKNOWN, false, "failed to measure Sy stats");
     489            return (emptyClump);
     490        }
    486491        psfClump.Y  = stats->clippedMean;
    487492        psfClump.dY = stats->clippedStdev;
     
    528533    bool status;
    529534    float PSF_SN_LIM = psMetadataLookupF32 (&status, recipe, "PSF_SN_LIM");
    530     if (!status)
    531         PSF_SN_LIM = 20.0;
     535    if (!status) PSF_SN_LIM = 20.0;
    532536    float PSF_CLUMP_NSIGMA = psMetadataLookupF32 (&status, recipe, "PSF_CLUMP_NSIGMA");
    533     if (!status)
    534         PSF_CLUMP_NSIGMA = 1.5;
    535     float INNER_RADIUS = psMetadataLookupF32 (&status, recipe, "SKY_INNER_RADIUS");
     537    if (!status) PSF_CLUMP_NSIGMA = 1.5;
     538
     539    // float INNER_RADIUS = psMetadataLookupF32 (&status, recipe, "SKY_INNER_RADIUS");
    536540
    537541    pmSourceMode noMoments = PM_SOURCE_MODE_MOMENTS_FAILURE | PM_SOURCE_MODE_SKYVAR_FAILURE | PM_SOURCE_MODE_SKY_FAILURE | PM_SOURCE_MODE_BELOW_MOMENTS_SN;
     
    543547        pmSource *source = (pmSource *) sources->data[i];
    544548
    545         // psf clumps are found for image subregions:
    546         // skip sources not in this region
     549        // psf clumps are found for image subregions:
     550        // skip sources not in this region
    547551        if (source->peak->x <  region->x0) continue;
    548552        if (source->peak->x >= region->x1) continue;
    549553        if (source->peak->y <  region->y0) continue;
    550         if (source->peak->y >= region->y1) continue;
    551 
    552         // should be set by pmSourceAlloc
     554        if (source->peak->y >= region->y1) continue;
     555
     556        // should be set by pmSourceAlloc
    553557        psAssert (source->type == PM_SOURCE_TYPE_UNKNOWN, "source type was not init-ed?");
    554558
     
    556560        if (!source->moments) {
    557561            source->type = PM_SOURCE_TYPE_STAR;
    558             psAssert (source->mode & noMoments, "why is this source missing moments?");
     562            psAssert (source->mode & noMoments, "why is this source missing moments?");
    559563            Nstar++;
    560564            continue;
     
    576580            source->type = PM_SOURCE_TYPE_STAR;
    577581            source->mode |= PM_SOURCE_MODE_SATSTAR;
    578             // recalculate moments here with larger box?
    579             pmSourceMoments (source, INNER_RADIUS);
     582            // why do we recalculate moments here?
     583            // we already attempt to do this in psphotSourceStats
     584            // pmSourceMoments (source, INNER_RADIUS);
    580585            Nsatstar ++;
    581586            continue;
     
    590595        }
    591596
    592         // likely defect (too small to be stellar) (push out to 3 sigma)
    593         // low S/N objects which are small are probably stellar
    594         // only set candidate defects if
    595         // XXX these limits are quite arbitrary
    596         if ((sigX < 0.05) || (sigY < 0.05)) {
    597             source->type = PM_SOURCE_TYPE_DEFECT;
    598             source->mode |= PM_SOURCE_MODE_DEFECT;
    599             Ncr ++;
    600             continue;
    601         }
    602 
    603         // likely unsaturated extended source (too large to be stellar)
    604         if ((sigX > (clump.X + 3*clump.dX)) || (sigY > (clump.Y + 3*clump.dY))) {
    605             source->type = PM_SOURCE_TYPE_EXTENDED;
    606             Next ++;
    607             continue;
    608         }
    609 
    610         // the rest are probable stellar objects
    611         starsn_moments->data.F32[starsn_moments->n] = source->moments->SN;
    612         starsn_moments->n ++;
    613         starsn_peaks->data.F32[starsn_peaks->n] = source->peak->SN;
    614         starsn_peaks->n ++;
    615         Nstar ++;
    616 
    617         // PSF star (within 1.5 sigma of clump center, S/N > limit)
    618         psF32 radius = hypot ((sigX-clump.X)/clump.dX, (sigY-clump.Y)/clump.dY);
    619         if ((source->moments->SN > PSF_SN_LIM) && (radius < PSF_CLUMP_NSIGMA)) {
    620             source->type = PM_SOURCE_TYPE_STAR;
    621             source->mode |= PM_SOURCE_MODE_PSFSTAR;
    622             Npsf ++;
    623             continue;
     597        // The following determinations require the use of moments
     598        if (!(source->mode & noMoments)) {
     599            // likely defect (too small to be stellar) (push out to 3 sigma)
     600            // low S/N objects which are small are probably stellar
     601            // XXX these limits are quite arbitrary
     602            if (sigX < 0.05 || sigY < 0.05) {
     603                source->type = PM_SOURCE_TYPE_DEFECT;
     604                source->mode |= PM_SOURCE_MODE_DEFECT;
     605                Ncr ++;
     606                continue;
     607            }
     608
     609            // likely unsaturated extended source (too large to be stellar)
     610            if (sigX > clump.X + 3*clump.dX || sigY > clump.Y + 3*clump.dY) {
     611                source->type = PM_SOURCE_TYPE_EXTENDED;
     612                Next ++;
     613                continue;
     614            }
     615
     616            // the rest are probable stellar objects
     617            starsn_moments->data.F32[starsn_moments->n] = source->moments->SN;
     618            starsn_moments->n ++;
     619            starsn_peaks->data.F32[starsn_peaks->n] = source->peak->SN;
     620            starsn_peaks->n ++;
     621            Nstar ++;
     622
     623            // PSF star (within 1.5 sigma of clump center, S/N > limit)
     624            psF32 radius = hypot ((sigX-clump.X)/clump.dX, (sigY-clump.Y)/clump.dY);
     625            if ((source->moments->SN > PSF_SN_LIM) && (radius < PSF_CLUMP_NSIGMA)) {
     626                source->type = PM_SOURCE_TYPE_STAR;
     627                source->mode |= PM_SOURCE_MODE_PSFSTAR;
     628                Npsf ++;
     629                continue;
     630            }
    624631        }
    625632
     
    636643
    637644        if (!psVectorStats (stats, starsn_moments, NULL, NULL, 0)) {
    638             // Don't care about this error
    639             psErrorClear();
     645            psError(PS_ERR_UNKNOWN, false, "failed to measure SN / moments stats");
     646            psFree (stats);
     647            psFree (starsn_peaks);
     648            return false;
    640649        }
    641650        psLogMsg ("pmObjects", 3, "SN range (moments): %f - %f\n", stats->min, stats->max);
     
    648657        stats = psStatsAlloc (PS_STAT_MIN | PS_STAT_MAX);
    649658        if (!psVectorStats (stats, starsn_peaks, NULL, NULL, 0)) {
    650             // Don't care about this error
    651             psErrorClear();
     659            psError(PS_ERR_UNKNOWN, false, "failed to measure SN / moments stats");
     660            psFree (stats);
     661            psFree (starsn_peaks);
     662            return false;
    652663        }
    653664        psLogMsg ("psModules.objects", 3, "SN range (peaks)  : %f - %f (%ld)\n",
Note: See TracChangeset for help on using the changeset viewer.