Changeset 26505
- Timestamp:
- Jan 4, 2010, 10:06:09 AM (16 years ago)
- Location:
- branches/eam_branches/20091201/psModules/src/imcombine
- Files:
-
- 8 edited
-
pmSubtractionEquation.c (modified) (1 diff)
-
pmSubtractionKernels.c (modified) (3 diffs)
-
pmSubtractionMatch.c (modified) (9 diffs)
-
pmSubtractionMatch.h (modified) (1 diff)
-
pmSubtractionStamps.c (modified) (15 diffs)
-
pmSubtractionStamps.h (modified) (6 diffs)
-
pmSubtractionVisual.c (modified) (1 diff)
-
pmSubtractionVisual.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20091201/psModules/src/imcombine/pmSubtractionEquation.c
r26502 r26505 1695 1695 double background = p_pmSubtractionSolutionBackground(kernels, polyValues);// Difference in background 1696 1696 psLogMsg("psModules.imcombine", PS_LOG_INFO, "normalization: %f, background: %f", norm, background); 1697 } 1698 1699 pmSubtractionVisualShowFit();1700 pmSubtractionVisualPlotFit(kernels);1697 1698 pmSubtractionVisualShowFit(norm); 1699 pmSubtractionVisualPlotFit(kernels); 1700 } 1701 1701 1702 1702 psFree(residual); -
branches/eam_branches/20091201/psModules/src/imcombine/pmSubtractionKernels.c
r26502 r26505 177 177 } 178 178 } 179 #if 1179 #if 0 180 180 fprintf(stderr, "%d raw: %lf, null: %f, min: %lf, max: %lf, moment: %lf\n", index, sum, preCalc->kernel->kernel[0][0], min, max, moment); 181 181 #endif … … 211 211 } 212 212 213 #if 1213 #if 0 214 214 sum = 0.0; // Sum of kernel component 215 215 min = FLT_MAX; … … 409 409 preCalc->kernel = pmSubtractionDeconvolveKernel(kernelTarget, kernelGauss); // Kernel 410 410 411 pmSubtractionKernelPreCalcNormalize (kernels, preCalc, index, size, uOrder, vOrder, fwhms->data.F32[i], false); 411 // XXX do we use Alard-Lupton normalization (last param true) or not? 412 pmSubtractionKernelPreCalcNormalize (kernels, preCalc, index, size, uOrder, vOrder, fwhms->data.F32[i], true); 412 413 413 414 // XXXX test demo that deconvolved kernel is valid -
branches/eam_branches/20091201/psModules/src/imcombine/pmSubtractionMatch.c
r26469 r26505 75 75 float stampSpacing, // Spacing between stamps 76 76 float sysError, // Relative systematic error in images 77 float skyError, // Relative systematic error in images 77 78 int size, // Kernel half-size 78 79 int footprint, // Convolution footprint for stamps … … 85 86 86 87 *stamps = pmSubtractionStampsFind(*stamps, image1, image2, subMask, region, thresh1, thresh2, 87 size, footprint, stampSpacing, sysError, mode);88 size, footprint, stampSpacing, sysError, skyError, mode); 88 89 if (!*stamps) { 89 90 psError(psErrorCodeLast(), false, "Unable to find stamps."); … … 109 110 int stride, // Size for convolution patches 110 111 float sysError, // Systematic error in images 112 float skyError, // Systematic error in images 111 113 float kernelError, // Systematic error in kernel 112 114 psImageMaskType maskVal, // Value to mask for input … … 159 161 PS_ASSERT_FLOAT_LESS_THAN(sysError, 1.0, false); 160 162 } 163 if (isfinite(sysError)) { 164 PS_ASSERT_FLOAT_LARGER_THAN_OR_EQUAL(skyError, 0.0, false); 165 } 161 166 if (isfinite(kernelError)) { 162 167 PS_ASSERT_FLOAT_LARGER_THAN_OR_EQUAL(kernelError, 0.0, false); … … 276 281 } 277 282 278 if (!subtractionMatchCheck(conv1, conv2, ro1, ro2, stride, NAN, kernelError,283 if (!subtractionMatchCheck(conv1, conv2, ro1, ro2, stride, NAN, NAN, kernelError, 279 284 maskVal, maskBad, maskPoor, poorFrac, badFrac, mode)) { 280 285 psFree(kernels); … … 342 347 int inner, int ringsOrder, int binning, float penalty, 343 348 bool optimum, const psVector *optFWHMs, int optOrder, float optThreshold, 344 int iter, float rej, float sysError, float kernelError, psImageMaskType maskVal,349 int iter, float rej, float sysError, float skyError, float kernelError, psImageMaskType maskVal, 345 350 psImageMaskType maskBad, psImageMaskType maskPoor, float poorFrac, 346 351 float badFrac, pmSubtractionMode subMode) 347 352 { 348 if (!subtractionMatchCheck(conv1, conv2, ro1, ro2, stride, sysError, kernelError,353 if (!subtractionMatchCheck(conv1, conv2, ro1, ro2, stride, sysError, skyError, kernelError, 349 354 maskVal, maskBad, maskPoor, poorFrac, badFrac, subMode)) { 350 355 return false; … … 476 481 if (stampsName && strlen(stampsName) > 0) { 477 482 stamps = pmSubtractionStampsSetFromFile(stampsName, ro1->image, subMask, region, size, 478 footprint, stampSpacing, sysError, s ubMode);483 footprint, stampSpacing, sysError, skyError, subMode); 479 484 } else if (sources) { 480 485 stamps = pmSubtractionStampsSetFromSources(sources, ro1->image, subMask, region, size, 481 footprint, stampSpacing, sysError, s ubMode);486 footprint, stampSpacing, sysError, skyError, subMode); 482 487 } 483 488 … … 485 490 // doesn't matter. 486 491 if (!subtractionGetStamps(&stamps, ro1, ro2, subMask, variance, NULL, stampThresh1, stampThresh2, 487 stampSpacing, sysError, s ize, footprint, subMode)) {492 stampSpacing, sysError, skyError, size, footprint, subMode)) { 488 493 goto MATCH_ERROR; 489 494 } … … 557 562 558 563 if (!subtractionGetStamps(&stamps, ro1, ro2, subMask, variance, region, 559 stampThresh1, stampThresh2, stampSpacing, sysError, 564 stampThresh1, stampThresh2, stampSpacing, sysError, skyError, 560 565 size, footprint, subMode)) { 561 566 goto MATCH_ERROR; -
branches/eam_branches/20091201/psModules/src/imcombine/pmSubtractionMatch.h
r26035 r26505 40 40 float rej, ///< Rejection threshold 41 41 float sysError, ///< Relative systematic error in images 42 float skyError, ///< Relative systematic error in images 42 43 float kernelError, ///< Relative systematic error in kernel 43 44 psImageMaskType maskVal, ///< Value to mask for input -
branches/eam_branches/20091201/psModules/src/imcombine/pmSubtractionStamps.c
r26502 r26505 181 181 182 182 pmSubtractionStampList *pmSubtractionStampListAlloc(int numCols, int numRows, const psRegion *region, 183 int footprint, float spacing, float sysErr )183 int footprint, float spacing, float sysErr, float skyErr) 184 184 { 185 185 pmSubtractionStampList *list = psAlloc(sizeof(pmSubtractionStampList)); // Stamp list to return … … 224 224 list->footprint = footprint; 225 225 list->sysErr = sysErr; 226 list->skyErr = skyErr; 226 227 227 228 return list; … … 326 327 const psImage *image2, const psImage *subMask, 327 328 const psRegion *region, float thresh1, float thresh2, 328 int size, int footprint, float spacing, float sysErr, 329 int size, int footprint, float spacing, float sysErr, float skyErr, 329 330 pmSubtractionMode mode) 330 331 { … … 383 384 384 385 if (!stamps) { 385 stamps = pmSubtractionStampListAlloc(numCols, numRows, region, footprint, spacing, sysErr);386 stamps = pmSubtractionStampListAlloc(numCols, numRows, region, footprint, spacing, sysErr, skyErr); 386 387 } 387 388 … … 441 442 xStamp = xList->data.F32[j]; 442 443 yStamp = yList->data.F32[j]; 443 fprintf (stderr, "find: %d %d ==> %5.1f %5.1f\n", xCentre, yCentre, xStamp, yStamp);444 // fprintf (stderr, "find: %d %d ==> %5.1f %5.1f\n", xCentre, yCentre, xStamp, yStamp); 444 445 } 445 446 } else { … … 496 497 const psImage *image, const psImage *subMask, 497 498 const psRegion *region, int size, int footprint, 498 float spacing, float sysErr, pmSubtractionMode mode)499 float spacing, float sysErr, float skyErr, pmSubtractionMode mode) 499 500 500 501 { … … 517 518 pmSubtractionStampList *stamps = pmSubtractionStampListAlloc(subMask->numCols, subMask->numRows, 518 519 region, footprint, spacing, 519 sysErr ); // Stamp list520 sysErr, skyErr); // Stamp list 520 521 int numStamps = stamps->num; // Number of stamps 521 522 … … 548 549 } 549 550 550 fprintf (stderr, "stamp: %5.1f %5.1f == %d %d\n", xStamp, yStamp, xPix, yPix);551 // fprintf (stderr, "stamp: %5.1f %5.1f == %d %d\n", xStamp, yStamp, xPix, yPix); 551 552 552 553 bool found = false; … … 742 743 return false; 743 744 } 744 fprintf (stderr, "stamp: %5.1f %5.1f == %d %d\n", stamp->x, stamp->y, x, y);745 // fprintf (stderr, "stamp: %5.1f %5.1f == %d %d\n", stamp->x, stamp->y, x, y); 745 746 746 747 // Catch memory leaks --- these should have been freed and NULLed before … … 765 766 psImage *varSub = psImageSubset(variance, region); // Subimage with stamp 766 767 psKernel *var = psKernelAllocFromImage(varSub, size, size); // Variance postage stamp 767 if (isfinite(stamps->sysErr) && stamps->sysErr > 0) { 768 769 if ((isfinite(stamps->skyErr) && (stamps->skyErr > 0)) || 770 (isfinite(stamps->sysErr) && (stamps->sysErr > 0))) { 768 771 float sysErr = 0.25 * PS_SQR(stamps->sysErr); // Systematic error 772 float skyErr = stamps->skyErr; 769 773 psKernel *image1 = stamp->image1, *image2 = stamp->image2; // Input images 770 774 for (int y = -size; y <= size; y++) { 771 775 for (int x = -size; x <= size; x++) { 772 776 float additional = image1->kernel[y][x] + image2->kernel[y][x]; 773 weight->kernel[y][x] = 1.0 / ( var->kernel[y][x] + sysErr * PS_SQR(additional));777 weight->kernel[y][x] = 1.0 / (skyErr + var->kernel[y][x] + sysErr * PS_SQR(additional)); 774 778 } 775 779 } … … 795 799 pmSubtractionStampList *pmSubtractionStampsSetFromSources(const psArray *sources, const psImage *image, 796 800 const psImage *subMask, const psRegion *region, 797 int size, int footprint, float spacing, float sysErr, 801 int size, int footprint, float spacing, float sysErr, float skyErr, 798 802 pmSubtractionMode mode) 799 803 { … … 819 823 y->data.F32[numOut] = source->peak->yf; 820 824 } 821 fprintf (stderr, "stamp: %5.1f %5.1f\n", x->data.F32[numOut], y->data.F32[numOut]);825 // fprintf (stderr, "stamp: %5.1f %5.1f\n", x->data.F32[numOut], y->data.F32[numOut]); 822 826 numOut++; 823 827 } … … 826 830 827 831 pmSubtractionStampList *stamps = pmSubtractionStampsSet(x, y, image, subMask, region, size, 828 footprint, spacing, sysErr, mode); // Stamps832 footprint, spacing, sysErr, skyErr, mode); // Stamps 829 833 psFree(x); 830 834 psFree(y); … … 840 844 pmSubtractionStampList *pmSubtractionStampsSetFromFile(const char *filename, const psImage *image, 841 845 const psImage *subMask, const psRegion *region, 842 int size, int footprint, float spacing, float sysErr, 846 int size, int footprint, float spacing, float sysErr, float skyErr, 843 847 pmSubtractionMode mode) 844 848 { … … 858 862 859 863 pmSubtractionStampList *stamps = pmSubtractionStampsSet(x, y, image, subMask, region, size, footprint, 860 spacing, sysErr, mode);864 spacing, sysErr, skyErr, mode); 861 865 psFree(data); 862 866 -
branches/eam_branches/20091201/psModules/src/imcombine/pmSubtractionStamps.h
r26342 r26505 26 26 psKernel *window; ///< window function generated from ensemble of stamps 27 27 float sysErr; ///< Systematic error 28 float skyErr; ///< Systematic error 28 29 } pmSubtractionStampList; 29 30 … … 34 35 int footprint, // Half-size of stamps 35 36 float spacing, // Rough average spacing between stamps 36 float sysErr // Relative systematic error or NAN 37 float sysErr, // Relative systematic error or NAN 38 float skyErr // Relative systematic error or NAN 37 39 ); 38 40 … … 95 97 float spacing, ///< Rough spacing for stamps 96 98 float sysErr, ///< Relative systematic error in images 99 float skyErr, ///< Relative systematic error in images 97 100 pmSubtractionMode mode ///< Mode for subtraction 98 101 ); … … 108 111 float spacing, ///< Rough spacing for stamps 109 112 float sysErr, ///< Systematic error in images 113 float skyErr, ///< Systematic error in images 110 114 pmSubtractionMode mode ///< Mode for subtraction 111 115 ); … … 121 125 float spacing, ///< Rough spacing for stamps 122 126 float sysErr, ///< Systematic error in images 127 float skyErr, ///< Systematic error in images 123 128 pmSubtractionMode mode ///< Mode for subtraction 124 129 ); … … 134 139 float spacing, ///< Rough spacing for stamps 135 140 float sysErr, ///< Systematic error in images 141 float skyErr, ///< Systematic error in images 136 142 pmSubtractionMode mode ///< Mode for subtraction 137 143 ); -
branches/eam_branches/20091201/psModules/src/imcombine/pmSubtractionVisual.c
r26502 r26505 535 535 } 536 536 537 bool pmSubtractionVisualShowFit() { 537 bool pmSubtractionVisualShowFit(double norm) { 538 539 // XXX a dumb test : dump the residual image and exit 540 { 541 psMetadata *header = psMetadataAlloc(); 542 psMetadataAddF32 (header, PS_LIST_TAIL, "NORM", 0, "Normalization", norm); 543 psFits *fits = psFitsOpen("resid.fits", "w"); 544 psFitsWriteImage(fits, header, residualImage, 0, NULL); 545 psFitsClose(fits); 546 exit (0); 547 } 538 548 539 549 // if (!pmVisualIsVisual()) return true; -
branches/eam_branches/20091201/psModules/src/imcombine/pmSubtractionVisual.h
r26472 r26505 9 9 bool pmSubtractionVisualShowFitInit(pmSubtractionStampList *stamps); 10 10 bool pmSubtractionVisualShowFitAddStamp(psKernel *target, psKernel *source, psKernel *convolution, double background, double norm, int index); 11 bool pmSubtractionVisualShowFit( );11 bool pmSubtractionVisualShowFit(double norm); 12 12 bool pmSubtractionVisualPlotFit(const pmSubtractionKernels *kernels); 13 13 bool pmSubtractionVisualShowKernels(pmSubtractionKernels *kernels);
Note:
See TracChangeset
for help on using the changeset viewer.
