IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 4, 2011, 1:04:41 PM (15 years ago)
Author:
eugene
Message:

updates to pmPeak to better distinguish peak flux versions; updates to visualization; add bits for substantial suspect masking; consolidate assignment of source position and flux based on peak, moments, etc; improve footprint culling process; fix PSF_QF and PSF_QF_PERFECT calculations; fix source model chisq values

Location:
trunk/psModules
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules

    • Property svn:ignore
      •  

        old new  
        2828ChangeLog
        2929psmodules-*.tar.*
         30a.out.dSYM
  • trunk/psModules/src/objects/pmSource.c

    r30621 r31153  
    171171    // peak has the same values as the original
    172172    if (in->peak != NULL) {
    173         source->peak = pmPeakAlloc (in->peak->x, in->peak->y, in->peak->value, in->peak->type);
     173        source->peak = pmPeakAlloc (in->peak->x, in->peak->y, in->peak->detValue, in->peak->type);
    174174        source->peak->xf = in->peak->xf;
    175175        source->peak->yf = in->peak->yf;
    176         source->peak->flux = in->peak->flux;
    177         source->peak->SN = in->peak->SN;
     176        source->peak->rawFlux         = in->peak->rawFlux;
     177        source->peak->rawFluxStdev    = in->peak->rawFluxStdev;
     178        source->peak->smoothFlux      = in->peak->smoothFlux;
     179        source->peak->smoothFluxStdev = in->peak->smoothFluxStdev;
     180        // source->peak->SN = in->peak->SN;
    178181    }
    179182
     
    328331*****************************************************************************/
    329332
    330 // XXX EAM include a S/N cutoff in selecting the sources?
    331 // XXX this function should probably accept the values, not a recipe. wrap with a
    332 // psphot-specific function which applies the recipe values
    333 // only apply selection to sources within specified region
    334333pmPSFClump pmSourcePSFClump(psImage **savedImage, psRegion *region, psArray *sources, float PSF_SN_LIM, float PSF_CLUMP_GRID_SCALE, psF32 SX_MAX, psF32 SY_MAX, psF32 AR_MAX)
    335334{
     
    429428
    430429        psfClump.nSigma = stats->sampleStdev;
     430        psfClump.nTotal = nValid;
    431431
    432432        if (savedImage) {
     
    465465        psStats *stats  = NULL;
    466466
    467         // select the single highest peak
    468         psArraySort (peaks, pmPeaksCompareDescend);
     467        // select the single highest peak (note that we only have detValue, not rawFlux, etc
     468        psArraySort (peaks, pmPeaksSortByDetValueDescend);
    469469        clump = peaks->data[0];
    470         psTrace ("psModules.objects", 2, "clump is at %d, %d (%f)\n", clump->x, clump->y, clump->value);
     470        psTrace ("psModules.objects", 2, "clump is at %d, %d (%f)\n", clump->x, clump->y, clump->detValue);
    471471
    472472        // XXX store the mean sigma?
    473473        float meanSigma = psfClump.nSigma;
    474         psfClump.nStars = clump->value;
    475         psfClump.nSigma = clump->value / meanSigma;
     474        psfClump.nStars = clump->detValue;
     475        psfClump.nSigma = clump->detValue / meanSigma;
    476476
    477477        // define section window for clump
     
    643643            }
    644644
     645            // check for insignificant sources or excessively low-surface brightness
     646            float coreSN = source->moments->KronCore / source->moments->KronCoreErr;
     647            float coreKR = source->moments->KronCore / source->moments->KronFlux;
     648
     649            // XXX these values need to be in the recipe...
     650            if (false && isfinite(coreSN) && (coreSN < 5.0)) {
     651                source->type = PM_SOURCE_TYPE_DEFECT;
     652                source->mode |= PM_SOURCE_MODE_DEFECT;
     653                Ncr ++;
     654                continue;
     655            }
     656            if (false && isfinite(coreKR) && (coreKR < 0.1)) {
     657                source->type = PM_SOURCE_TYPE_DEFECT;
     658                source->mode |= PM_SOURCE_MODE_DEFECT;
     659                Ncr ++;
     660                continue;
     661            }
     662
    645663            // likely unsaturated extended source (too large to be stellar)
    646664            if (sigX > clump.X + 3*clump.dX || sigY > clump.Y + 3*clump.dY) {
     
    651669
    652670            // the rest are probable stellar objects
     671            // the vectors below are accumulated to give user feedback on the S/N ranges
    653672            starsn_moments->data.F32[starsn_moments->n] = source->moments->SN;
    654673            starsn_moments->n ++;
    655             starsn_peaks->data.F32[starsn_peaks->n] = source->peak->SN;
     674            starsn_peaks->data.F32[starsn_peaks->n] = sqrt(source->peak->detValue);
    656675            starsn_peaks->n ++;
    657676            Nstar ++;
     
    11491168}
    11501169
     1170// this function decides if the source position should be based on the peak or the moments.
     1171// this is only used if we know we should not use a model fit position (eg, no model, or no
     1172// model yet)
     1173bool pmSourcePositionUseMoments(pmSource *source) {
     1174
     1175    if (!source->moments) return false;          // can't if there are no moments
     1176    if (!source->moments->nPixels) return false; // can't if the moments were not measured
     1177    if (source->mode && PM_SOURCE_MODE_MOMENTS_FAILURE) return false; // can't if the moments failed...
     1178
     1179    if (source->mode & PM_SOURCE_MODE_SATSTAR) return true; // moments are best for SATSTARs
     1180
     1181    float dX = source->moments->Mx - source->peak->xf;
     1182    float dY = source->moments->My - source->peak->yf;
     1183    float dR = hypot(dX, dY);
     1184   
     1185    // only use the moments position if the moment-peak offset is small or the star is saturated
     1186    if (dR > 1.5) return false;
     1187
     1188    return true;
     1189}
     1190
    11511191// sort by SN (descending)
    1152 int pmSourceSortBySN (const void **a, const void **b)
     1192int pmSourceSortByFlux (const void **a, const void **b)
    11531193{
    11541194    pmSource *A = *(pmSource **)a;
    11551195    pmSource *B = *(pmSource **)b;
    11561196
    1157     psF32 fA = (A->peak == NULL) ? 0 : A->peak->SN;
    1158     psF32 fB = (B->peak == NULL) ? 0 : B->peak->SN;
     1197    psF32 fA = (A->peak == NULL) ? 0 : A->peak->rawFlux;
     1198    psF32 fB = (B->peak == NULL) ? 0 : B->peak->rawFlux;
    11591199    if (isnan (fA)) fA = 0;
    11601200    if (isnan (fB)) fB = 0;
     
    11661206}
    11671207
     1208// sort by SN (descending)
     1209int pmSourceSortByParentFlux (const void **a, const void **b)
     1210{
     1211    pmSource *Ao = *(pmSource **)a;
     1212    pmSource *Bo = *(pmSource **)b;
     1213    pmSource *A  = Ao->parent;
     1214    pmSource *B  = Bo->parent;
     1215
     1216    psF32 fA = (A->peak == NULL) ? 0 : A->peak->rawFlux;
     1217    psF32 fB = (B->peak == NULL) ? 0 : B->peak->rawFlux;
     1218    if (isnan (fA)) fA = 0;
     1219    if (isnan (fB)) fB = 0;
     1220
     1221    psF32 diff = fA - fB;
     1222    if (diff > FLT_EPSILON) return (-1);
     1223    if (diff < FLT_EPSILON) return (+1);
     1224    return (0);
     1225}
     1226
    11681227// sort by Y (ascending)
    11691228int pmSourceSortByY (const void **a, const void **b)
     
    12011260    pmSource *A = *(pmSource **)a;
    12021261    pmSource *B = *(pmSource **)b;
     1262
     1263    int iA = A->seq;
     1264    int iB = B->seq;
     1265
     1266    int diff = iA - iB;
     1267    if (diff > 0) return (+1);
     1268    if (diff < 0) return (-1);
     1269    return (0);
     1270}
     1271
     1272// sort by Seq (ascending)
     1273int pmSourceSortByParentSeq (const void **a, const void **b)
     1274{
     1275    pmSource *Ao = *(pmSource **)a;
     1276    pmSource *Bo = *(pmSource **)b;
     1277    pmSource *A  = Ao->parent;
     1278    pmSource *B  = Bo->parent;
    12031279
    12041280    int iA = A->seq;
Note: See TracChangeset for help on using the changeset viewer.