Changeset 14738 for trunk/psModules/src/imcombine/pmSubtraction.c
- Timestamp:
- Sep 4, 2007, 1:56:07 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/imcombine/pmSubtraction.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/imcombine/pmSubtraction.c
r14716 r14738 4 4 * @author GLG, MHPCC 5 5 * 6 * @version $Revision: 1.5 4$ $Name: not supported by cvs2svn $7 * @date $Date: 2007-0 8-30 23:09:52$6 * @version $Revision: 1.55 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2007-09-04 23:56:07 $ 8 8 * 9 9 * Copyright 2004-2007 Institute for Astronomy, University of Hawaii … … 548 548 } 549 549 550 bool pmSubtractionConvolveStamp(pmSubtractionStamp *stamp, const pmSubtractionKernels *kernels, int footprint) 551 { 552 PS_ASSERT_PTR_NON_NULL(stamp, false); 553 PS_ASSERT_KERNEL_NON_NULL(stamp->reference, false); 554 PS_ASSERT_PTR_NON_NULL(kernels, false); 555 PS_ASSERT_VECTORS_SIZE_EQUAL(kernels->u, kernels->v, false); 556 PS_ASSERT_INT_NONNEGATIVE(footprint, false); 557 558 if (stamp->status != PM_SUBTRACTION_STAMP_CALCULATE) { 559 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Stamp not marked for calculation."); 560 return false; 561 } 562 563 if (stamp->convolutions) { 564 // Already done 565 return true; 566 } 567 568 stamp->convolutions = psArrayAlloc(kernels->num); 569 psKernel *reference = stamp->reference; // Reference postage stamp 570 571 for (int i = 0; i < kernels->num; i++) { 572 stamp->convolutions->data[i] = convolveRef(kernels, i, reference, footprint); 573 } 574 575 return true; 576 } 577 550 578 551 579 bool pmSubtractionCalculateEquation(psArray *stamps, const pmSubtractionKernels *kernels, int footprint) … … 591 619 psVectorInit(stampVector, 0.0); 592 620 593 psKernel *reference = stamp->reference; // Reference postage stamp594 621 psKernel *input = stamp->input; // Input postage stamp 595 622 psKernel *weight = stamp->weight; // Weight map postage stamp 596 623 597 624 // Generate convolutions of the reference 625 if (!pmSubtractionConvolveStamp(stamp, kernels, footprint)) { 626 psError(PS_ERR_UNKNOWN, false, "Unable to convolve stamp %d.", i); 627 return NULL; 628 } 629 598 630 psArray *convolutions = stamp->convolutions; // Convolutions of the reference for each kernel 599 if (!convolutions) {600 stamp->convolutions = convolutions = psArrayAlloc(numKernels);601 }602 for (int j = 0; j < numKernels; j++) {603 if (convolutions->data[j]) {604 psFree(convolutions->data[j]);605 }606 convolutions->data[j] = convolveRef(kernels, j, reference, footprint);607 #ifdef TESTING608 {609 psKernel *conv = convolutions->data[j]; // Convolution of interest610 psString filename = NULL;611 psStringAppend(&filename, "conv_%03d_%03d.fits", i, j);612 psFits *fits = psFitsOpen(filename, "w");613 psFree(filename);614 psFitsWriteImage(fits, NULL, conv->image, 0, NULL);615 psFitsClose(fits);616 }617 #endif618 }619 620 631 psImage *polyValues = spatialPolyValues(spatialOrder, stamp->xNorm, stamp->yNorm); // Polynomial terms 621 632 … … 900 911 stamp->y = 0; 901 912 stamp->status = PM_SUBTRACTION_STAMP_REJECTED; 913 // Recalculate convolutions 914 psFree(stamp->convolutions); 915 stamp->convolutions = NULL; 902 916 } 903 917 }
Note:
See TracChangeset
for help on using the changeset viewer.
