Changeset 19226 for trunk/ppStack/src/ppStackSources.c
- Timestamp:
- Aug 26, 2008, 2:20:43 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/ppStack/src/ppStackSources.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppStack/src/ppStackSources.c
r19215 r19226 5 5 #include "ppStack.h" 6 6 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 9 10 #define SOURCE_FAINTEST 50.0 // Faintest magnitude to consider 10 11 #define SOURCES_MAX_LEAF 2 // Maximum number of points on a tree leaf … … 220 221 long numIn = 0; // Number of sources in list 221 222 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 222 232 223 233 psVector *magDiff = psVectorAlloc(numSources, PS_TYPE_F32); // Magnitude differences … … 239 249 float listMag = listSource->psfMag; // Magnitude of source in list 240 250 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 242 257 magDiff->data.F32[numIn] = listSource->psfMag - source->psfMag; 243 258 psArrayAdd(inside, 1, source); … … 246 261 } 247 262 magDiff->n = numIn; 263 264 #ifdef TESTING 265 fclose(file); 266 #endif 248 267 249 268 psFree(coords); … … 256 275 if (numIn > minOverlap) { 257 276 // 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)); 259 279 stats->clipSigma = rej; 260 280 stats->clipIter = iter; … … 265 285 return -1; 266 286 } 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); 269 292 psFree(stats); 270 293 … … 437 460 } 438 461 439 #ifdef TESTING440 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 #endif452 453 462 return psMemIncrRefCounter(firstList->sources); 454 463 }
Note:
See TracChangeset
for help on using the changeset viewer.
