Changeset 25754 for trunk/psModules/src/objects/pmSource.c
- Timestamp:
- Oct 2, 2009, 3:11:32 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/objects/pmSource.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/objects/pmSource.c
r24874 r25754 282 282 283 283 psArray *peaks = NULL; 284 pmPSFClump errorClump = {-1.0, -1.0, 0.0, 0.0 };285 pmPSFClump emptyClump = {+0.0, +0.0, 0.0, 0.0 };284 pmPSFClump errorClump = {-1.0, -1.0, 0.0, 0.0, 0, 0.0}; 285 pmPSFClump emptyClump = {+0.0, +0.0, 0.0, 0.0, 0, 0.0}; 286 286 pmPSFClump psfClump; 287 287 … … 319 319 320 320 // construct a sigma-plane image 321 int numCols = SX_MAX / PSF_CLUMP_GRID_SCALE, numRows = SY_MAX / PSF_CLUMP_GRID_SCALE; // Size of sigma-plane image 321 int numCols = 1 + SX_MAX / PSF_CLUMP_GRID_SCALE; // Size of sigma-plane image 322 int numRows = 1 + SY_MAX / PSF_CLUMP_GRID_SCALE; // Size of sigma-plane image 322 323 psTrace("psModules.objects", 10, "sigma-plane dimensions: %dx%d\n", numCols, numRows); 323 324 psImage *splane = psImageAlloc(numCols, numRows, PS_TYPE_F32); // sigma-plane image … … 332 333 } 333 334 334 int x = src->peak->x, y = src->peak->y; // Coordinates of peak 335 if (x < region->x0 || x > region->x1 || y < region->y0 || y > region->y1) { 336 continue; 337 } 335 if (region) { 336 int x = src->peak->x, y = src->peak->y; // Coordinates of peak 337 if (x < region->x0 || x > region->x1 || y < region->y0 || y > region->y1) { 338 continue; 339 } 340 } 338 341 339 342 if (src->mode & PM_SOURCE_MODE_BLEND) { 340 343 continue; 341 344 } 345 346 if (!src->moments->nPixels) continue; 342 347 343 348 if (src->moments->SN < PSF_SN_LIM) { … … 384 389 385 390 // find the peak in this image 386 psStats *stats = psStatsAlloc (PS_STAT_MAX );391 psStats *stats = psStatsAlloc (PS_STAT_MAX | PS_STAT_SAMPLE_STDEV); 387 392 if (!psImageStats (stats, splane, NULL, 0)) { 388 393 psError(PS_ERR_UNKNOWN, false, "Unable to get image statistics.\n"); … … 393 398 peaks = pmPeaksInImage (splane, stats[0].max / 2); 394 399 psTrace ("psModules.objects", 2, "clump threshold is %f\n", stats[0].max/2); 400 401 psfClump.nSigma = stats->sampleStdev; 395 402 396 403 const bool keep_psf_clump = psMetadataLookupBool(NULL, recipe, "KEEP_PSF_CLUMP"); … … 430 437 psTrace ("psModules.objects", 2, "clump is at %d, %d (%f)\n", clump->x, clump->y, clump->value); 431 438 439 // XXX store the mean sigma? 440 float meanSigma = psfClump.nSigma; 441 psfClump.nStars = clump->value; 442 psfClump.nSigma = clump->value / meanSigma; 443 432 444 // define section window for clump 433 445 minSx = clump->x * PSF_CLUMP_GRID_SCALE - 2.0*PSF_CLUMP_GRID_SCALE; … … 452 464 continue; 453 465 454 if (tmpSrc->peak->x < region->x0) continue; 455 if (tmpSrc->peak->x > region->x1) continue; 456 if (tmpSrc->peak->y < region->y0) continue; 457 if (tmpSrc->peak->y > region->y1) continue; 466 if (region) { 467 if (tmpSrc->peak->x < region->x0) continue; 468 if (tmpSrc->peak->x > region->x1) continue; 469 if (tmpSrc->peak->y < region->y0) continue; 470 if (tmpSrc->peak->y > region->y1) continue; 471 } 458 472 459 473 if (tmpSrc->moments->Mxx < minSx) … … 919 933 if (model == NULL) return false; // model must be defined 920 934 935 bool addNoise = mode & PM_MODEL_OP_NOISE; 936 921 937 if (source->modelFlux) { 922 938 // add in the pixels from the modelFlux image … … 940 956 941 957 psF32 **target = source->pixels->data.F32; 942 if ( mode & PM_MODEL_OP_NOISE) {943 // XXX need to scale by the gain... 958 if (addNoise) { 959 // when adding noise, we assume the shape and Io have been modified 944 960 target = source->variance->data.F32; 945 961 } 946 962 947 // XXX need to respect the source and model masks?948 963 for (int iy = 0; iy < source->modelFlux->numRows; iy++) { 949 964 int oy = iy + dY; … … 959 974 } 960 975 } 976 if (!addNoise) { 977 if (add) { 978 source->tmpFlags &= ~PM_SOURCE_TMPF_SUBTRACTED; 979 } else { 980 source->tmpFlags |= PM_SOURCE_TMPF_SUBTRACTED; 981 } 982 } 961 983 return true; 962 984 } 963 985 964 986 psImage *target = source->pixels; 965 if ( mode & PM_MODEL_OP_NOISE) {987 if (addNoise) { 966 988 target = source->variance; 967 989 } 968 990 969 if (add) { 970 status = pmModelAddWithOffset (target, source->maskObj, model, PM_MODEL_OP_FULL, maskVal, dx, dy); 971 } else { 972 status = pmModelSubWithOffset (target, source->maskObj, model, PM_MODEL_OP_FULL, maskVal, dx, dy); 991 if (!addNoise) { 992 if (add) { 993 status = pmModelAddWithOffset (target, source->maskObj, model, PM_MODEL_OP_FULL, maskVal, dx, dy); 994 source->tmpFlags &= ~PM_SOURCE_TMPF_SUBTRACTED; 995 } else { 996 status = pmModelSubWithOffset (target, source->maskObj, model, PM_MODEL_OP_FULL, maskVal, dx, dy); 997 source->tmpFlags |= PM_SOURCE_TMPF_SUBTRACTED; 998 } 973 999 } 974 1000
Note:
See TracChangeset
for help on using the changeset viewer.
