Changeset 14738 for trunk/psModules/src/imcombine/pmSubtractionMatch.c
- Timestamp:
- Sep 4, 2007, 1:56:07 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/imcombine/pmSubtractionMatch.c
r14713 r14738 214 214 // Putting important variable declarations here, since they are freed after a "goto" if there is an error. 215 215 psImage *subMask = NULL; // Mask for subtraction 216 psArray *stamps = NULL; // Stamps for matching PSF217 216 psRegion *region = NULL; // Iso-kernel region 218 217 psString regionString = NULL; // String for region 218 psArray *stamps = NULL; // Stamps for matching PSF 219 219 psVector *solution = NULL; // Solution to match PSF 220 220 pmSubtractionKernels *kernels = NULL; // Kernel basis functions … … 224 224 if (stampsName && strlen(stampsName) > 0) { 225 225 psTrace("psModules.imcombine", 3, "Reading stamps from %s...\n", stampsName); 226 psVector *xStamp = NULL, *yStamp = NULL; // Stamp positions and fluxes227 226 if (input) { 228 227 // We have x, y because the target is provided by the input image … … 234 233 if (!stampsData) { 235 234 psError(PS_ERR_IO, false, "Unable to read stamps file %s", stampsName); 236 goto ERROR;235 return false; 237 236 } 238 237 239 238 // Correct for IRAF/FITS (unit-offset) positions to C (zero-offset) positions 240 xStamp = stampsData->data[0];241 yStamp = stampsData->data[1];239 psVector *xStamp = stampsData->data[0]; // x positions 240 psVector *yStamp = stampsData->data[1]; // y positions 242 241 psBinaryOp(xStamp, xStamp, "-", psScalarAlloc(1.0, PS_TYPE_F32)); 243 242 psBinaryOp(yStamp, yStamp, "-", psScalarAlloc(1.0, PS_TYPE_F32)); … … 251 250 252 251 memCheck("mask"); 253 254 if (optimum && (type == PM_SUBTRACTION_KERNEL_ISIS || type == PM_SUBTRACTION_KERNEL_GUNK)) {255 if (!getStamps(&stamps, stampsData, reference, input, subMask, weight, NULL,256 threshold, stampSpacing, targetWidth, size, footprint)) {257 goto ERROR;258 }259 kernels = pmSubtractionKernelsOptimumISIS(type, size, inner, spatialOrder, optFWHMs, optOrder,260 stamps, footprint, optThreshold);261 // XXX This is not quite the best thing to do here--- we'll find the same set of stamps again later,262 // but since we may not be interested in the entire image on the first pass through, we have to blow263 // the whole lot away. The alternative is to mark stamps that are outside the region of interest, and264 // ignore them when generating sums and rejecting.265 psFree(stamps);266 stamps = NULL;267 268 if (!kernels) {269 psErrorClear();270 psWarning("Unable to derive optimum ISIS kernel --- switching to default.");271 }272 }273 274 if (kernels == NULL) {275 // Not an ISIS/GUNK kernel, or the optimum kernel search failed276 kernels = pmSubtractionKernelsGenerate(type, size, spatialOrder, isisWidths, isisOrders,277 inner, binning, ringsOrder);278 }279 280 psMetadataAddPtr(convolved->analysis, PS_LIST_TAIL, "SUBTRACTION.KERNEL", PS_DATA_UNKNOWN,281 "Subtraction kernels", kernels);282 283 memCheck("kernels");284 252 285 253 // Get region of interest … … 307 275 regionString, numCols, numRows); 308 276 } 277 278 // Define kernel basis functions 279 if (optimum && (type == PM_SUBTRACTION_KERNEL_ISIS || type == PM_SUBTRACTION_KERNEL_GUNK)) { 280 if (!getStamps(&stamps, stampsData, reference, input, subMask, weight, NULL, 281 threshold, stampSpacing, targetWidth, size, footprint)) { 282 goto ERROR; 283 } 284 kernels = pmSubtractionKernelsOptimumISIS(type, size, inner, spatialOrder, optFWHMs, optOrder, 285 stamps, footprint, optThreshold); 286 if (!kernels) { 287 psErrorClear(); 288 psWarning("Unable to derive optimum ISIS kernel --- switching to default."); 289 } 290 } 291 if (kernels == NULL) { 292 // Not an ISIS/GUNK kernel, or the optimum kernel search failed 293 kernels = pmSubtractionKernelsGenerate(type, size, spatialOrder, isisWidths, isisOrders, 294 inner, binning, ringsOrder); 295 } 296 psMetadataAddPtr(convolved->analysis, PS_LIST_TAIL, "SUBTRACTION.KERNEL", 297 PS_DATA_UNKNOWN | PS_META_DUPLICATE_OK, "Subtraction kernels", kernels); 298 299 memCheck("kernels"); 309 300 310 301 int numRejected = -1; // Number of rejected stamps in each iteration … … 422 413 goto ERROR; 423 414 } 415 psFree(kernels); 416 kernels = NULL; 424 417 425 418 // Put the solution on the metadata … … 466 459 goto ERROR; 467 460 } 468 psFree(kernels);469 461 470 462 memCheck("convolution");
Note:
See TracChangeset
for help on using the changeset viewer.
