Changeset 14802 for trunk/psModules/src/imcombine/pmSubtractionStamps.c
- Timestamp:
- Sep 10, 2007, 11:31:25 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/imcombine/pmSubtractionStamps.c
r14801 r14802 5 5 #include <stdio.h> 6 6 #include <pslib.h> 7 8 // All these includes required to get stamps out of an array of pmSources 9 #include "pmMoments.h" 10 #include "pmPeaks.h" 11 #include "pmResiduals.h" 12 #include "pmHDU.h" 13 #include "pmFPA.h" 14 #include "pmGrowthCurve.h" 15 #include "pmPSF.h" 16 #include "pmModel.h" 17 #include "pmSource.h" 18 7 19 8 20 #include "pmSubtraction.h" … … 133 145 134 146 135 pmSubtractionStampList *pmSubtraction FindStamps(pmSubtractionStampList *stamps, const psImage *image,147 pmSubtractionStampList *pmSubtractionStampsFind(pmSubtractionStampList *stamps, const psImage *image, 136 148 const psImage *subMask, const psRegion *region, 137 149 float threshold, float spacing) … … 170 182 int numStamps = stamps->num; // Number of stamp regions 171 183 int numFound = 0; // Number of stamps found 184 int numValid = 0; // Number of valid regions 172 185 for (int i = 0; i < numStamps; i++) { 173 186 pmSubtractionStamp *stamp = stamps->stamps->data[i]; // Stamp of interest … … 177 190 continue; 178 191 } 192 numValid++; 179 193 180 194 float xStamp = 0, yStamp = 0; // Coordinates of stamp … … 238 252 } 239 253 240 psLogMsg("psModules.imcombine", PS_LOG_INFO, "Found %d stamps", numFound); 254 if (numValid > 0) { 255 psLogMsg("psModules.imcombine", PS_LOG_INFO, "Found %d stamps", numFound); 256 } 241 257 242 258 return stamps; … … 244 260 245 261 246 pmSubtractionStampList *pmSubtractionS etStamps(const psVector *x, const psVector *y, const psVector *flux,262 pmSubtractionStampList *pmSubtractionStampsSet(const psVector *x, const psVector *y, const psVector *flux, 247 263 const psImage *image, const psImage *subMask, 248 264 const psRegion *region, float spacing, int exclusionZone) 249 265 { 250 PS_ASSERT_VECTOR_NON_NULL(x, false);251 PS_ASSERT_VECTOR_TYPE(x, PS_TYPE_F32, false);252 PS_ASSERT_VECTOR_NON_NULL(y, false);253 PS_ASSERT_VECTOR_TYPE(y, PS_TYPE_F32, false);254 PS_ASSERT_VECTORS_SIZE_EQUAL(y, x, false);266 PS_ASSERT_VECTOR_NON_NULL(x, NULL); 267 PS_ASSERT_VECTOR_TYPE(x, PS_TYPE_F32, NULL); 268 PS_ASSERT_VECTOR_NON_NULL(y, NULL); 269 PS_ASSERT_VECTOR_TYPE(y, PS_TYPE_F32, NULL); 270 PS_ASSERT_VECTORS_SIZE_EQUAL(y, x, NULL); 255 271 if (flux) { 256 PS_ASSERT_VECTOR_NON_NULL(flux, false);257 PS_ASSERT_VECTOR_TYPE(flux, PS_TYPE_F32, false);258 PS_ASSERT_VECTORS_SIZE_EQUAL(flux, x, false);272 PS_ASSERT_VECTOR_NON_NULL(flux, NULL); 273 PS_ASSERT_VECTOR_TYPE(flux, PS_TYPE_F32, NULL); 274 PS_ASSERT_VECTORS_SIZE_EQUAL(flux, x, NULL); 259 275 } else { 260 PS_ASSERT_IMAGE_NON_NULL(image, false);276 PS_ASSERT_IMAGE_NON_NULL(image, NULL); 261 277 } 262 278 if (subMask) { 263 PS_ASSERT_IMAGE_NON_NULL(subMask, false);264 PS_ASSERT_IMAGE_TYPE(subMask, PS_TYPE_MASK, false);279 PS_ASSERT_IMAGE_NON_NULL(subMask, NULL); 280 PS_ASSERT_IMAGE_TYPE(subMask, PS_TYPE_MASK, NULL); 265 281 if (image) { 266 PS_ASSERT_IMAGE_NON_NULL(image, false); 267 PS_ASSERT_IMAGES_SIZE_EQUAL(image, subMask, false); 268 } 269 } 282 PS_ASSERT_IMAGE_NON_NULL(image, NULL); 283 PS_ASSERT_IMAGES_SIZE_EQUAL(image, subMask, NULL); 284 } 285 } 286 PS_ASSERT_FLOAT_LARGER_THAN(spacing, 0.0, NULL); 287 PS_ASSERT_INT_NONNEGATIVE(exclusionZone, NULL); 270 288 271 289 int numStars = x->n; // Number of stars … … 399 417 400 418 401 bool pmSubtraction ExtractStamps(pmSubtractionStampList *stamps, psImage *reference, psImage *input,419 bool pmSubtractionStampsExtract(pmSubtractionStampList *stamps, psImage *reference, psImage *input, 402 420 psImage *weight, int footprint, int kernelSize) 403 421 { … … 467 485 468 486 469 bool pmSubtraction GenerateStamps(pmSubtractionStampList *stamps, float fwhm, int footprint, int kernelSize)487 bool pmSubtractionStampsGenerate(pmSubtractionStampList *stamps, float fwhm, int footprint, int kernelSize) 470 488 { 471 489 PM_ASSERT_SUBTRACTION_STAMP_LIST_NON_NULL(stamps, false); … … 510 528 return true; 511 529 } 530 531 532 pmSubtractionStampList *pmSubtractionStampsSetFromSources(const psArray *sources, const psImage *subMask, 533 const psRegion *region, float spacing, 534 int exclusionZone) 535 { 536 PS_ASSERT_ARRAY_NON_NULL(sources, NULL); 537 // Let pmSubtractionStampsSet take care of the rest of the assertions 538 539 int numSources = sources->n; // Number of stars 540 541 psVector *x = psVectorAlloc(numSources, PS_TYPE_F32); // x coordinates 542 psVector *y = psVectorAlloc(numSources, PS_TYPE_F32); // y coordinates 543 psVector *flux = psVectorAlloc(numSources, PS_TYPE_F32); // Fluxes 544 545 for (int i = 0; i < numSources; i++) { 546 pmSource *source = sources->data[i]; // Source of interest 547 if (source->modelPSF) { 548 x->data.F32[i] = source->modelPSF->params->data.F32[PM_PAR_XPOS]; 549 y->data.F32[i] = source->modelPSF->params->data.F32[PM_PAR_YPOS]; 550 } else { 551 x->data.F32[i] = source->peak->xf; 552 y->data.F32[i] = source->peak->yf; 553 } 554 flux->data.F32[i] = powf(10.0, -0.4 * source->psfMag); 555 } 556 557 pmSubtractionStampList *stamps = pmSubtractionStampsSet(x, y, flux, NULL, subMask, region, 558 spacing, exclusionZone); // Stamps to return 559 psFree(x); 560 psFree(y); 561 psFree(flux); 562 563 if (!stamps) { 564 psError(PS_ERR_UNKNOWN, false, "Unable to set stamps from sources."); 565 } 566 567 return stamps; 568 }
Note:
See TracChangeset
for help on using the changeset viewer.
