Changeset 21106 for branches/pap_branch_20090108/ppStack/src/ppStackMatch.c
- Timestamp:
- Jan 12, 2009, 1:03:29 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/pap_branch_20090108/ppStack/src/ppStackMatch.c
r21096 r21106 47 47 #endif 48 48 49 // Get coordinates from a source 50 static void coordsFromSource(float *x, float *y, const pmSource *source) 51 { 52 assert(x && y); 53 assert(source); 54 55 if (source->modelPSF) { 56 *x = source->modelPSF->params->data.F32[PM_PAR_XPOS]; 57 *y = source->modelPSF->params->data.F32[PM_PAR_YPOS]; 58 } else { 59 *x = source->peak->xf; 60 *y = source->peak->yf; 61 } 62 return; 63 } 64 49 65 static psArray *stackSourcesFilter(psArray *sources, // Source list to filter 50 66 int exclusion // Exclusion zone, pixels … … 64 80 continue; 65 81 } 66 x->data.F32[numGood] = source->peak->xf; 67 y->data.F32[numGood] = source->peak->yf; 82 coordsFromSource(&x->data.F32[numGood], &y->data.F32[numGood], source); 68 83 numGood++; 69 84 } … … 80 95 continue; 81 96 } 82 coords->data.F64[0] = source->peak->xf; 83 coords->data.F64[1] = source->peak->yf; 97 float xSource, ySource; // Coordinates of source 98 coordsFromSource(&xSource, &ySource, source); 99 100 coords->data.F64[0] = xSource; 101 coords->data.F64[1] = ySource; 84 102 85 103 long numWithin = psTreeWithin(tree, coords, exclusion); // Number within exclusion zone … … 120 138 } 121 139 122 int x = source->peak->xf + 0.5, y = source->peak->yf + 0.5; // Coordinates of source 140 float xSource, ySource; // Coordinates of source 141 coordsFromSource(&xSource, &ySource, source); 142 143 int x = xSource + 0.5, y = ySource + 0.5; // Coordinates of source 123 144 124 145 int xMin = PS_MAX(x - BG_SIZE, 0), xMax = PS_MIN(x + BG_SIZE, numCols); … … 319 340 pmSource *source = pmSourceAlloc(); // Source 320 341 sources->data[0] = source; 321 source->peak = pmPeakAlloc(50 , 50, 10000, PM_PEAK_LONE);342 source->peak = pmPeakAlloc(500, 500, 10000, PM_PEAK_LONE); 322 343 source->psfMag = -13.0; 323 pmReadoutFakeFromSources(test, 100 , 100, sources, NULL, NULL, psf, 0.1, 0, false, true);344 pmReadoutFakeFromSources(test, 1000, 1000, sources, NULL, NULL, psf, 0.1, 0, false, true); 324 345 float sum = 0.0; 325 346 for (int y = 0; y < test->image->numRows; y++) { … … 351 372 } 352 373 374 375 #if 0 353 376 // Add the background into the target image 354 377 psImage *bgImage = stackBackgroundModel(readout, maskVal, stampSources, footprint); // Image of background 355 378 psBinaryOp(fake->image, fake->image, "+", bgImage); 356 379 psFree(bgImage); 380 #endif 381 357 382 358 383 #ifdef TESTING 359 384 { 385 pmHDU *hdu = pmHDUFromCell(readout->parent); 360 386 psString name = NULL; 361 387 psStringAppend(&name, "fake_%03d.fits", numInput); 362 388 psFits *fits = psFitsOpen(name, "w"); 363 389 psFree(name); 364 psFitsWriteImage(fits, NULL, fake->image, 0, NULL);390 psFitsWriteImage(fits, hdu->header, fake->image, 0, NULL); 365 391 psFitsClose(fits); 366 392 } 367 393 { 394 pmHDU *hdu = pmHDUFromCell(readout->parent); 368 395 psString name = NULL; 369 396 psStringAppend(&name, "real_%03d.fits", numInput); 370 397 psFits *fits = psFitsOpen(name, "w"); 371 398 psFree(name); 372 psFitsWriteImage(fits, NULL, readout->image, 0, NULL);399 psFitsWriteImage(fits, hdu->header, readout->image, 0, NULL); 373 400 psFitsClose(fits); 374 401 } … … 410 437 #ifdef TESTING 411 438 { 439 pmHDU *hdu = pmHDUFromCell(readout->parent); 412 440 psString name = NULL; 413 441 psStringAppend(&name, "conv_%03d.fits", numInput); 414 442 psFits *fits = psFitsOpen(name, "w"); 415 443 psFree(name); 416 psFitsWriteImage(fits, NULL, output->image, 0, NULL);444 psFitsWriteImage(fits, hdu->header, output->image, 0, NULL); 417 445 psFitsClose(fits); 418 446 } 419 447 { 448 pmHDU *hdu = pmHDUFromCell(readout->parent); 420 449 psString name = NULL; 421 450 psStringAppend(&name, "diff_%03d.fits", numInput); … … 423 452 psFree(name); 424 453 psBinaryOp(fake->image, output->image, "-", fake->image); 425 psFitsWriteImage(fits, NULL, fake->image, 0, NULL);454 psFitsWriteImage(fits, hdu->header, fake->image, 0, NULL); 426 455 psFitsClose(fits); 427 456 } … … 582 611 #define RADIUS 10 // Radius of photometry 583 612 #define MIN_ERR 0.05 // Minimum photometric error, mag 613 #define MAX_MAG -13 // Maximum magnitude for source 584 614 585 615 // Ensure the normalisation is correct … … 595 625 pmSource *source = sources->data[i]; // Source of interest 596 626 if (!source || source->mode & SOURCE_MASK || !isfinite(source->psfMag) || !isfinite(source->errMag) || 597 source->errMag > MIN_ERR ) {627 source->errMag > MIN_ERR || source->psfMag > MAX_MAG) { 598 628 continue; 599 629 } 600 630 601 float xSrc = source->peak->xf, ySrc = source->peak->yf; // Source coordinates 631 float xSrc, ySrc; // Source coordinates 632 coordsFromSource(&xSrc, &ySrc, source); 602 633 int xMin = PS_MAX(0, xSrc - RADIUS), xMax = PS_MIN(numCols - 1, xSrc + RADIUS); // Bounds in x 603 634 int yMin = PS_MAX(0, ySrc - RADIUS), yMax = PS_MIN(numRows - 1, ySrc + RADIUS); // Bounds in y … … 635 666 #ifdef TESTING 636 667 { 668 pmHDU *hdu = pmHDUFromCell(readout->parent); 637 669 psString name = NULL; 638 670 psStringAppend(&name, "convolved_%03d.fits", numInput); 639 671 psFits *fits = psFitsOpen(name, "w"); 640 672 psFree(name); 641 psFitsWriteImage(fits, NULL, output->image, 0, NULL);673 psFitsWriteImage(fits, hdu->header, output->image, 0, NULL); 642 674 psFitsClose(fits); 643 675 }
Note:
See TracChangeset
for help on using the changeset viewer.
