IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 19226


Ignore:
Timestamp:
Aug 26, 2008, 2:20:43 PM (18 years ago)
Author:
Paul Price
Message:

Expanded source mask to weed out everything that could upset the
measurement of the magnitude difference: was getting bad magDiff due
to sources that weren't "pure". Added debugging output. Made the
magnitude difference a log message instead of trace: it's important
and can help identify problems.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppStack/src/ppStackSources.c

    r19215 r19226  
    55#include "ppStack.h"
    66
    7 #define SOURCE_MASK (PM_SOURCE_MODE_FAIL | PM_SOURCE_MODE_DEFECT | PM_SOURCE_MODE_SATURATED | \
    8                      PM_SOURCE_MODE_CR_LIMIT) // Mask to apply to input sources
     7#define SOURCE_MASK (PM_SOURCE_MODE_FAIL | PM_SOURCE_MODE_SATSTAR | PM_SOURCE_MODE_BLEND | \
     8                     PM_SOURCE_MODE_BADPSF | PM_SOURCE_MODE_DEFECT | PM_SOURCE_MODE_SATURATED | \
     9                     PM_SOURCE_MODE_CR_LIMIT | PM_SOURCE_MODE_EXT_LIMIT) // Mask to apply to input sources
    910#define SOURCE_FAINTEST 50.0            // Faintest magnitude to consider
    1011#define SOURCES_MAX_LEAF 2              // Maximum number of points on a tree leaf
     
    220221    long numIn = 0;                     // Number of sources in list
    221222    long numOut = 0;                    // Number of sources outside list
     223
     224#ifdef TESTING
     225    static int fileNum = 0;             // Number of file
     226    psString filename = NULL;   // Name of file
     227    psStringAppend(&filename, "source_match_%d.txt", fileNum++);
     228    FILE *file = fopen(filename, "w"); // File to write
     229    psFree(filename);
     230    fprintf(file, "# x y mag1 mag2\n");
     231#endif
    222232
    223233    psVector *magDiff = psVectorAlloc(numSources, PS_TYPE_F32); // Magnitude differences
     
    239249        float listMag = listSource->psfMag; // Magnitude of source in list
    240250        float sourceMag = source->psfMag; // Magnitude of source
    241         if (isfinite(listMag) && isfinite(sourceMag)) {
     251        if (!(listSource->mode & SOURCE_MASK) && !(source->mode & SOURCE_MASK) &&
     252            isfinite(listMag) && isfinite(sourceMag)) {
     253#ifdef TESTING
     254            fprintf(file, "%f %f %f %f %.4x %.4x\n", x->data.F32[i], y->data.F32[i],
     255                    listSource->psfMag, source->psfMag, listSource->mode, source->mode);
     256#endif
    242257            magDiff->data.F32[numIn] = listSource->psfMag - source->psfMag;
    243258            psArrayAdd(inside, 1, source);
     
    246261    }
    247262    magDiff->n = numIn;
     263
     264#ifdef TESTING
     265    fclose(file);
     266#endif
    248267
    249268    psFree(coords);
     
    256275    if (numIn > minOverlap) {
    257276        // There's sufficient overlap --- calculate the magnitude difference
    258         psStats *stats = psStatsAlloc(iter == 0 ? PS_STAT_SAMPLE_MEAN : PS_STAT_CLIPPED_MEAN);
     277        psStats *stats = psStatsAlloc(iter == 0 ? (PS_STAT_SAMPLE_MEAN | PS_STAT_SAMPLE_STDEV) :
     278                                      (PS_STAT_CLIPPED_MEAN | PS_STAT_CLIPPED_STDEV));
    259279        stats->clipSigma = rej;
    260280        stats->clipIter = iter;
     
    265285            return -1;
    266286        }
    267         float meanDiff = stats->clippedMean; // Mean magnitude difference
    268         psTrace("ppStack.sources", 7, "Magnitude difference is %f\n", meanDiff);
     287        float meanDiff = iter == 0 ? stats->sampleMean : stats->clippedMean; // Mean magnitude difference
     288        float stdev = iter == 0 ? stats->sampleStdev : stats->clippedStdev; // Standard deviation
     289        long numStats = iter == 0 ? numIn : stats->clippedNvalues; // Number used for statistics
     290        psLogMsg("ppStack.sources", 7, "Magnitude difference from %ld overlaps is %f +/- %f\n",
     291                 numStats, meanDiff, stdev);
    269292        psFree(stats);
    270293
     
    437460    }
    438461
    439 #ifdef TESTING
    440         FILE *srcFile = fopen("sources.txt", "w");
    441         for (long i = 0; i < firstList->sources->n; i++) {
    442             pmSource *source = firstList->sources->data[i];
    443             if (source->mode & SOURCE_MASK) {
    444                 continue;
    445             }
    446             float x, y;
    447             coordsFromSource(&x, &y, source);
    448             fprintf(srcFile, "%f\t%f\t%f\n", x, y, source->psfMag);
    449         }
    450         fclose(srcFile);
    451 #endif
    452 
    453462    return psMemIncrRefCounter(firstList->sources);
    454463}
Note: See TracChangeset for help on using the changeset viewer.