Changeset 26076 for trunk/ppStack/src/ppStackCombineFinal.c
- Timestamp:
- Nov 9, 2009, 2:53:12 PM (17 years ago)
- Location:
- trunk/ppStack
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
src/ppStackCombineFinal.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppStack
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/czw_branch/cleanup/ppStack merged eligible /branches/eam_branches/20090522/ppStack merged eligible /branches/eam_branches/20090715/ppStack merged eligible /branches/eam_branches/20090820/ppStack merged eligible /branches/pap/ppStack merged eligible /branches/pap_mops/ppStack 25137-25255
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/ppStack/src/ppStackCombineFinal.c
r25096 r26076 10 10 #include "ppStackLoop.h" 11 11 12 bool ppStackCombineFinal(ppStackThreadData *stack, ppStackOptions *options, pmConfig *config) 12 //#define TESTING // Enable test output 13 14 bool ppStackCombineFinal(pmReadout *target, ppStackThreadData *stack, psArray *covariances, 15 ppStackOptions *options, pmConfig *config, bool safe, bool normalise) 13 16 { 14 17 psAssert(stack, "Require stack"); 15 18 psAssert(options, "Require options"); 16 19 psAssert(config, "Require configuration"); 20 21 if (!target->mask) { 22 target->mask = psImageAlloc(target->image->numCols, target->image->numRows, PS_TYPE_IMAGE_MASK); 23 } 17 24 18 25 stack->lastScan = 0; // Reset read … … 30 37 } 31 38 32 // call: ppStackReadoutFinal(config, outRO, readouts, rejected)39 // call: ppStackReadoutFinal(config, target, readouts, rejected) 33 40 psThreadJob *job = psThreadJobAlloc("PPSTACK_FINAL_COMBINE"); // Job to start 41 psArrayAdd(job->args, 1, target); 34 42 psArrayAdd(job->args, 1, thread); 35 43 psArrayAdd(job->args, 1, options); 36 44 psArrayAdd(job->args, 1, config); 45 PS_ARRAY_ADD_SCALAR(job->args, safe, PS_TYPE_U8); 46 PS_ARRAY_ADD_SCALAR(job->args, normalise, PS_TYPE_U8); 37 47 if (!psThreadJobAddPending(job)) { 38 48 psFree(job); … … 48 58 49 59 // Sum covariance matrices 50 double sumWeights = 0.0; // Sum of weights 51 for (int i = 0; i < options->num; i++) { 52 if (options->inputMask->data.U8[i]) { 53 psFree(options->covariances->data[i]); 54 options->covariances->data[i] = NULL; 55 continue; 60 if (covariances) { 61 double sumWeights = 0.0; // Sum of weights 62 for (int i = 0; i < options->num; i++) { 63 if (options->inputMask->data.U8[i]) { 64 psFree(covariances->data[i]); 65 covariances->data[i] = NULL; 66 continue; 67 } 68 psKernel *covar = covariances->data[i]; // Covariance matrix 69 if (!covar) { 70 continue; 71 } 72 float weight = options->weightings->data.F32[i]; // Weight to apply 73 psBinaryOp(covar->image, covar->image, "*", psScalarAlloc(weight, PS_TYPE_F32)); 74 sumWeights += weight; 56 75 } 57 psKernel *covar = options->covariances->data[i]; // Covariance matrix 58 if (!covar) { 59 continue; 76 if (sumWeights > 0.0) { 77 target->covariance = psImageCovarianceSum(covariances); 78 psBinaryOp(target->covariance->image, target->covariance->image, "/", 79 psScalarAlloc(sumWeights, PS_TYPE_F32)); 80 psImageCovarianceTransfer(target->variance, target->covariance); 60 81 } 61 float weight = options->weightings->data.F32[i]; // Weight to apply 62 psBinaryOp(covar->image, covar->image, "*", psScalarAlloc(weight, PS_TYPE_F32)); 63 sumWeights += weight; 64 } 65 if (sumWeights > 0.0) { 66 pmReadout *outRO = options->outRO; // Output readout 67 outRO->covariance = psImageCovarianceSum(options->covariances); 68 psBinaryOp(outRO->covariance->image, outRO->covariance->image, "/", 69 psScalarAlloc(sumWeights, PS_TYPE_F32)); 70 psFree(options->covariances); options->covariances = NULL; 71 psImageCovarianceTransfer(outRO->variance, outRO->covariance); 82 } else { 83 target->covariance = psImageCovarianceNone(); 72 84 } 73 85 74 86 #ifdef TESTING 75 pmStackVisualPlotTestImage(outRO->image, "combined_initial.fits"); 76 ppStackWriteImage("combined_final.fits", NULL, outRO->image, config); 87 static int pass = 0; // Pass through 88 psString name = NULL; // Name of file 89 psStringAppend(&name, "combined_image_final_%d.fits", pass); 90 pass++; 91 ppStackWriteImage(name, NULL, target->image, config); 92 psStringSubstitute(&name, "mask", "image"); 93 ppStackWriteImage(name, NULL, target->mask, config); 94 psStringSubstitute(&name, "variance", "mask"); 95 ppStackWriteImage(name, NULL, target->variance, config); 96 psFree(name); 97 98 pmStackVisualPlotTestImage(target->image, "combined_image_final.fits"); 77 99 #endif 78 100
Note:
See TracChangeset
for help on using the changeset viewer.
