Changeset 29449
- Timestamp:
- Oct 17, 2010, 9:10:35 AM (16 years ago)
- Location:
- branches/eam_branches/ipp-20100823/psModules/src/imcombine
- Files:
-
- 8 edited
-
pmPSFEnvelope.c (modified) (1 diff)
-
pmSubtractionEquation.c (modified) (6 diffs)
-
pmSubtractionKernels.c (modified) (1 diff)
-
pmSubtractionMatch.c (modified) (3 diffs)
-
pmSubtractionMatch.h (modified) (1 diff)
-
pmSubtractionStamps.c (modified) (14 diffs)
-
pmSubtractionStamps.h (modified) (1 diff)
-
pmSubtractionVisual.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20100823/psModules/src/imcombine/pmPSFEnvelope.c
r29004 r29449 380 380 381 381 // measure the source moments: tophat windowing, no pixel S/N cutoff 382 // XXX probably should be passing the maskVal to this function so we can pass it along here... 383 if (!pmSourceMoments(source, maxRadius, 0.0, 1.0, maskVal)) { 382 if (!pmSourceMoments(source, maxRadius, 0.0, 0.0, maskVal)) { 384 383 // Can't do anything about it; limp along as best we can 385 384 psErrorClear(); -
branches/eam_branches/ipp-20100823/psModules/src/imcombine/pmSubtractionEquation.c
r29170 r29449 19 19 20 20 //#define USE_WEIGHT // Include weight (1/variance) in equation? 21 //#define USE_WINDOW // Include weight (1/variance) in equation? 21 22 // XXX TEST: 23 # define USE_WINDOW // window to avoid neighbor contamination 22 24 23 25 # define PENALTY false … … 752 754 stamps->normValue2 = stats->robustMedian; 753 755 754 fprintf (stderr, "norm (1): %f (%f)\n", stamps->normValue, stamps->normValue2);756 psLogMsg ("psModules.imcombine", PS_LOG_INFO, "norm (1): %f (%f)\n", stamps->normValue, stamps->normValue2); 755 757 756 758 psFree(stats); … … 797 799 stamp->normSquare2 = normSquare2; 798 800 799 fprintf (stderr, "normValue: %f %f %f (%f %f)\n", normI1, normI2, stamp->norm, normSquare1, normSquare2);801 psLogMsg ("psModules.imcombine", PS_LOG_DETAIL, "normValue: %f %f %f (%f %f)\n", normI1, normI2, stamp->norm, normSquare1, normSquare2); 800 802 801 803 return true; … … 1089 1091 } 1090 1092 1093 #if 1 1094 psImage *save = psImageCopy(NULL, sumMatrix, PS_TYPE_F32); 1095 psFitsWriteImageSimple ("sumMatrix.fits", save, NULL); 1096 psVectorWriteFile("sumVector.dat", sumVector); 1097 psFree (save); 1098 #endif 1099 1091 1100 psVector *solution = NULL; // Solution to equation! 1092 1101 solution = psVectorAlloc(numParams, PS_TYPE_F64); 1093 1102 psVectorInit(solution, 0); 1094 1103 1104 // XXX TEST: try some constraint on the svd solution 1105 // solution = psMatrixSolveSVD(solution, sumMatrix, sumVector, NAN); 1095 1106 solution = psMatrixSolveSVD(solution, sumMatrix, sumVector, NAN); 1096 1107 … … 1149 1160 } 1150 1161 1151 #if 01162 #if 1 1152 1163 psImage *save = psImageCopy(NULL, sumMatrix, PS_TYPE_F32); 1153 1164 psFitsWriteImageSimple ("sumMatrix.fits", save, NULL); … … 1264 1275 if (!isfinite(dTotal)) return false; 1265 1276 1266 fprintf (stderr, "sum: %f, peak: %f, sigma: %f, fsigma: %f, fmax: %f, fmin: %f\n", sum, peak, sigma, sigma/sum, dOuter/sum, dTotal/sum);1277 // fprintf (stderr, "sum: %f, peak: %f, sigma: %f, fsigma: %f, fmax: %f, fmin: %f\n", sum, peak, sigma, sigma/sum, dOuter/sum, dTotal/sum); 1267 1278 psVectorAppend(fResSigma, sigma/sum); 1268 1279 psVectorAppend(fResOuter, dOuter/sum); -
branches/eam_branches/ipp-20100823/psModules/src/imcombine/pmSubtractionKernels.c
r29148 r29449 258 258 } 259 259 260 #if 1260 #if 0 261 261 { 262 262 double Sum = 0.0; // Sum of kernel component -
branches/eam_branches/ipp-20100823/psModules/src/imcombine/pmSubtractionMatch.c
r29215 r29449 1202 1202 1203 1203 bool pmSubtractionParamsScale(int *kernelSize, int *stampSize, psVector *widths, 1204 float fwhm1, float fwhm2, floatscaleRef, float scaleMin, float scaleMax)1204 float scaleRef, float scaleMin, float scaleMax) 1205 1205 { 1206 1206 PS_ASSERT_PTR_NON_NULL(kernelSize, false); … … 1208 1208 PS_ASSERT_VECTOR_NON_NULL(widths, false); 1209 1209 PS_ASSERT_VECTOR_TYPE(widths, PS_TYPE_F32, false); 1210 PS_ASSERT_FLOAT_LARGER_THAN(fwhm1, 0.0, false);1211 PS_ASSERT_FLOAT_LARGER_THAN(fwhm2, 0.0, false);1212 1210 PS_ASSERT_FLOAT_LARGER_THAN(scaleRef, 0.0, false); 1213 1211 PS_ASSERT_FLOAT_LARGER_THAN(scaleMin, 0.0, false); … … 1215 1213 PS_ASSERT_FLOAT_LARGER_THAN(scaleMax, scaleMin, false); 1216 1214 1215 float fwhm1; 1216 float fwhm2; 1217 1218 pmSubtractionGetFWHMs(&fwhm1, &fwhm2); 1219 psAssert(isfinite(fwhm1), "fwhm 1 not set"); 1220 psAssert(isfinite(fwhm2), "fwhm 2 not set"); 1221 1217 1222 // float diff = sqrtf(PS_SQR(PS_MAX(fwhm1, fwhm2)) - PS_SQR(PS_MIN(fwhm1, fwhm2))); // Difference 1218 1223 float scale = PS_MAX(fwhm1, fwhm2) / scaleRef; // Scaling factor 1219 1224 1220 // XXX save these values in a static for later use1221 pmSubtractionSetFWHMs(fwhm1, fwhm2);1222 1223 1225 if (isfinite(scaleMin) && scale < scaleMin) { 1224 1226 scale = scaleMin; -
branches/eam_branches/ipp-20100823/psModules/src/imcombine/pmSubtractionMatch.h
r29004 r29449 104 104 int *stampSize, ///< Half-size of the stamp (footprint) 105 105 psVector *widths, ///< ISIS widths 106 float fwhm1, float fwhm2, ///< FWHMs for inputs107 106 float scaleRef, ///< Reference width for scaling 108 107 float scaleMin, ///< Minimum scaling ratio, or NAN -
branches/eam_branches/ipp-20100823/psModules/src/imcombine/pmSubtractionStamps.c
r29274 r29449 51 51 psFree(list->y); 52 52 psFree(list->flux); 53 psFree(list->window); 53 54 psFree(list->window1); 54 55 psFree(list->window2); … … 96 97 97 98 // fprintf (stderr, "xMin, xMax: %d, %d -> ", xMin, xMax); 98 float xRaw = xMin;99 float yRaw = yMin;99 // float xRaw = xMin; 100 // float yRaw = yMin; 100 101 101 102 // Ensure we're not going to go outside the bounds of the image … … 126 127 if (subMask && subMask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & 127 128 (PM_SUBTRACTION_MASK_BORDER | PM_SUBTRACTION_MASK_REJ)) { 128 fprintf (stderr, "%f,%f : masked\n", xRaw, yRaw);129 // fprintf (stderr, "%f,%f : masked\n", xRaw, yRaw); 129 130 return false; 130 131 } … … 142 143 } 143 144 144 if (!found) { 145 fprintf (stderr, "%f,%f : fails flux test\n", xRaw, yRaw); 146 } 145 // if (!found) { 146 // fprintf (stderr, "%f,%f : fails flux test\n", xRaw, yRaw); 147 // } 148 147 149 return found; 148 150 } … … 245 247 list->normFrac = normFrac; 246 248 list->normValue = NAN; 249 list->window = NULL; 247 250 list->window1 = NULL; 248 251 list->window2 = NULL; … … 269 272 out->y = NULL; 270 273 out->flux = NULL; 274 out->window = psMemIncrRefCounter(in->window); 271 275 out->window1 = psMemIncrRefCounter(in->window1); 272 276 out->window2 = psMemIncrRefCounter(in->window2); … … 487 491 yList->data.F32[j], yList->data.F32[j], numCols, numRows, border); 488 492 #endif 489 if (0 && goodStamp) {490 fprintf (stderr, "find: %6.1f < %6.1f < %6.1f, %6.1f < %6.1f %6.1f\n",491 region->x0 + size, xStamp, region->x1 - size,492 region->y0 + size, yStamp, region->y1 - size);493 }494 493 } 495 494 } else { … … 684 683 psImageInit(stamps->window2->image, 0.0); 685 684 685 // Generate a weighting window based on the fwhms (20% larger than the largest) 686 { 687 float fwhm1, fwhm2; 688 689 // XXX this is annoyingly hack-ish 690 pmSubtractionGetFWHMs(&fwhm1, &fwhm2); 691 692 float sigma = 1.5 * PS_MAX(fwhm1, fwhm2) / 2.35; 693 694 psFree (stamps->window); 695 stamps->window = psKernelAlloc(-size, size, -size, size); 696 psImageInit(stamps->window->image, 0.0); 697 698 for (int y = -size; y <= size; y++) { 699 for (int x = -size; x <= size; x++) { 700 stamps->window->kernel[y][x] = exp(-0.5*(x*x + y*y)/(sigma*sigma)); 701 } 702 } 703 } 704 686 705 // generate normalizations for each stamp 687 706 psVector *norm1 = psVectorAlloc(stamps->num, PS_TYPE_F32); … … 759 778 { 760 779 psFits *fits = NULL; 761 fits = psFitsOpen ("window1. fits", "w");780 fits = psFitsOpen ("window1.raw.fits", "w"); 762 781 psFitsWriteImage (fits, NULL, stamps->window1->image, 0, NULL); 763 782 psFitsClose (fits); 764 fits = psFitsOpen ("window2. fits", "w");783 fits = psFitsOpen ("window2.raw.fits", "w"); 765 784 psFitsWriteImage (fits, NULL, stamps->window2->image, 0, NULL); 766 785 psFitsClose (fits); … … 818 837 // interpolate to the radius at which delta2 is normFrac: 819 838 stamps->normWindow1 = radius - (stamps->normFrac - delta1) / (delta1o - delta1); 820 fprintf (stderr, "choosing %f (%d) for 1 (%f : %f)\n", stamps->normWindow1, radius, within1, delta1);839 psLogMsg ("psModules.imcombine", PS_LOG_DETAIL, "choosing %f (%d) for 1 (%f : %f)\n", stamps->normWindow1, radius, within1, delta1); 821 840 done1 = true; 822 841 } … … 825 844 // interpolate to the radius at which delta2 is normFrac: 826 845 stamps->normWindow2 = radius - (stamps->normFrac - delta2) / (delta2o - delta2); 827 fprintf (stderr, "choosing %f (%d) for 2 (%f : %f)\n", stamps->normWindow2, radius, within2, delta2);846 psLogMsg ("psModules.imcombine", PS_LOG_DETAIL, "choosing %f (%d) for 2 (%f : %f)\n", stamps->normWindow2, radius, within2, delta2); 828 847 done2 = true; 829 848 } … … 873 892 { 874 893 psFits *fits = NULL; 875 fits = psFitsOpen ("window1. fits", "w");894 fits = psFitsOpen ("window1.norm.fits", "w"); 876 895 psFitsWriteImage (fits, NULL, stamps->window1->image, 0, NULL); 877 896 psFitsClose (fits); 878 fits = psFitsOpen ("window2. fits", "w");897 fits = psFitsOpen ("window2.norm.fits", "w"); 879 898 psFitsWriteImage (fits, NULL, stamps->window2->image, 0, NULL); 880 899 psFitsClose (fits); … … 962 981 psAssert (isfinite(kernels->penalties2->data.F32[index]), "invalid penalty"); 963 982 964 fprintf(stderr, "penalty1: %f, penalty2: %f\n", penalty1, penalty2);983 // fprintf(stderr, "penalty1: %f, penalty2: %f\n", penalty1, penalty2); 965 984 966 985 return true; … … 989 1008 penalty *= 1.0 / sum2; 990 1009 991 if ( 1) {992 fprintf(stderr, "min: %lf, max: %lf, moment: %lf, flux^2: %lf\n", min, max, penalty, sum2);1010 if (0) { 1011 // fprintf(stderr, "min: %lf, max: %lf, moment: %lf, flux^2: %lf\n", min, max, penalty, sum2); 993 1012 // psTrace("psModules.imcombine", 7, "Kernel %d: %f %d %d %f\n", index, fwhm, uOrder, vOrder, penalty); 994 1013 } -
branches/eam_branches/ipp-20100823/psModules/src/imcombine/pmSubtractionStamps.h
r29170 r29449 29 29 psKernel *window1; ///< window function generated from ensemble of stamps (input 1) 30 30 psKernel *window2; ///< window function generated from ensemble of stamps (input 2) 31 psKernel *window; ///< weighting window function (sigma = 1.1 * MAX(fwhm)) 31 32 float normWindow1; ///< Size of window for measuring normalisation 32 33 float normWindow2; ///< Size of window for measuring normalisation -
branches/eam_branches/ipp-20100823/psModules/src/imcombine/pmSubtractionVisual.c
r29148 r29449 146 146 } 147 147 pmVisualScaleImage(kapa1, canvas, "Subtraction_Stamps", 0, true); 148 psFree(canvas); 148 149 149 150 pmVisualAskUser(&plotStamps); … … 281 282 } 282 283 } 283 fprintf (stderr, "kernel %d, sum %f\n", i, sum);284 // fprintf (stderr, "kernel %d, sum %f\n", i, sum); 284 285 } 285 286 286 287 pmVisualScaleImage(kapa1, output, "Image", 0, true); 288 psFree(output); 287 289 pmVisualAskUser(&plotImage); 288 290 return true; … … 309 311 if (!isfinite(stamp->flux)) continue; 310 312 if (!stamp->convolutions1 && !stamp->convolutions2) continue; 311 fprintf (stderr, "flux: %f, maxFlux: %f ", stamp->flux, maxFlux);313 // fprintf (stderr, "flux: %f, maxFlux: %f ", stamp->flux, maxFlux); 312 314 if (!maxStamp) { 313 315 maxFlux = stamp->flux; 314 316 maxStamp = stamp; 315 fprintf (stderr, "maxStamp %d\n", i);317 // fprintf (stderr, "maxStamp %d\n", i); 316 318 continue; 317 319 } else { 318 fprintf (stderr, "\n");320 // fprintf (stderr, "\n"); 319 321 } 320 322 if (stamp->flux > maxFlux) { … … 361 363 } 362 364 } 363 fprintf (stderr, "kernel %d, sum %f, sum2: %e\n", i, sum, sum2);365 // fprintf (stderr, "kernel %d, sum %f, sum2: %e\n", i, sum, sum2); 364 366 } 365 367 pmVisualScaleImage(kapa2, output, "Image", 0, true); … … 403 405 } 404 406 } 405 fprintf (stderr, "kernel %d, sum %f, sum2: %e\n", i, sum, sum2);407 // fprintf (stderr, "kernel %d, sum %f, sum2: %e\n", i, sum, sum2); 406 408 } 407 409 pmVisualScaleImage(kapa2, output, "Image", 1, true); … … 412 414 psFitsClose(fits); 413 415 } 416 psFree(output); 414 417 } 415 418 … … 708 711 psFree (x); 709 712 psFree (y); 713 psFree (polyValues); 710 714 711 715 pmVisualAskUser(NULL);
Note:
See TracChangeset
for help on using the changeset viewer.
