Changeset 25964 for branches/pap/ppStack
- Timestamp:
- Oct 28, 2009, 5:35:05 PM (17 years ago)
- Location:
- branches/pap/ppStack/src
- Files:
-
- 8 edited
-
ppStack.h (modified) (2 diffs)
-
ppStackCombineFinal.c (modified) (2 diffs)
-
ppStackCombineInitial.c (modified) (3 diffs)
-
ppStackLoop.c (modified) (6 diffs)
-
ppStackLoop.h (modified) (1 diff)
-
ppStackReadout.c (modified) (11 diffs)
-
ppStackReject.c (modified) (7 diffs)
-
ppStackThread.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/pap/ppStack/src/ppStack.h
r25924 r25964 59 59 // Perform stacking on a readout 60 60 // 61 // Returns an array of pixels to inspect for each input image61 // Returns two arrays: pixels to inspect for each input image, and pixels to reject for each input image. 62 62 psArray *ppStackReadoutInitial(const pmConfig *config, // Configuration 63 63 pmReadout *outRO, // Output readout … … 84 84 const psVector *weightings, // Weighting factors for each image 85 85 const psVector *addVariance, // Additional variance for rejection 86 bool full, // Combine full image?87 86 bool safety, // Enable safety switch? 88 87 const psVector *norm // Normalisations to apply -
branches/pap/ppStack/src/ppStackCombineFinal.c
r25950 r25964 13 13 14 14 bool ppStackCombineFinal(pmReadout *target, ppStackThreadData *stack, psArray *covariances, 15 ppStackOptions *options, pmConfig *config, bool full, boolsafe, bool normalise)15 ppStackOptions *options, pmConfig *config, bool safe, bool normalise) 16 16 { 17 17 psAssert(stack, "Require stack"); … … 43 43 psArrayAdd(job->args, 1, options); 44 44 psArrayAdd(job->args, 1, config); 45 PS_ARRAY_ADD_SCALAR(job->args, full, PS_TYPE_U8);46 45 PS_ARRAY_ADD_SCALAR(job->args, safe, PS_TYPE_U8); 47 46 PS_ARRAY_ADD_SCALAR(job->args, normalise, PS_TYPE_U8); -
branches/pap/ppStack/src/ppStackCombineInitial.c
r25950 r25964 62 62 // Harvest the jobs, gathering the inspection lists 63 63 options->inspect = psArrayAlloc(options->num); 64 options->rejected = psArrayAlloc(options->num); 64 65 for (int i = 0; i < options->num; i++) { 65 66 if (options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) { … … 67 68 } 68 69 options->inspect->data[i] = psArrayAllocEmpty(numChunk); 70 options->rejected->data[i] = psArrayAllocEmpty(numChunk); 69 71 } 70 72 psThreadJob *job; // Completed job … … 73 75 "Job has incorrect type: %s", job->type); 74 76 psArray *results = job->results; // Results of job 77 psAssert(results->n == 2, "Results array has wrong size!"); 78 psArray *inspect = results->data[0]; // Pixels to inspect 79 psArray *reject = results->data[1]; // Pixels to reject 75 80 for (int i = 0; i < options->num; i++) { 76 81 if (options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) { 77 82 continue; 78 83 } 79 options->inspect->data[i] = psArrayAdd(options->inspect->data[i], 1, results->data[i]); 84 options->inspect->data[i] = psArrayAdd(options->inspect->data[i], 1, inspect->data[i]); 85 options->rejected->data[i] = psArrayAdd(options->rejected->data[i], 1, reject->data[i]); 80 86 } 81 87 psFree(job); -
branches/pap/ppStack/src/ppStackLoop.c
r25950 r25964 97 97 // Final combination 98 98 psTrace("ppStack", 2, "Final stack of convolved images....\n"); 99 if (!ppStackCombineFinal(options->outRO, stack, options->convCovars, options, config, 100 true, false, false)) { 99 if (!ppStackCombineFinal(options->outRO, stack, options->convCovars, options, config, false, false)) { 101 100 psError(PS_ERR_UNKNOWN, false, "Unable to perform final combination."); 102 101 psFree(stack); … … 106 105 psLogMsg("ppStack", PS_LOG_INFO, "Stage 5: Final Stack: %f sec", psTimerClear("PPSTACK_STEPS")); 107 106 ppStackMemDump("final"); 108 109 107 110 108 // Clean up … … 121 119 psFree(stack); 122 120 123 124 121 #if 1 125 122 // Unconvolved stack --- it's cheap to calculate, compared to everything else! … … 133 130 } 134 131 psTrace("ppStack", 2, "Stack of unconvolved images....\n"); 135 if (!ppStackCombineFinal(options->unconvRO, stack, options->origCovars, options, config, 136 true, true, true)) { 132 if (!ppStackCombineFinal(options->unconvRO, stack, options->origCovars, options, config, true, true)) { 137 133 psError(PS_ERR_UNKNOWN, false, "Unable to perform unconvolved combination."); 138 134 psFree(stack); … … 158 154 ppStackMemDump("photometry"); 159 155 160 161 156 // Finish up 162 157 psTrace("ppStack", 1, "Finishing up....\n"); … … 170 165 171 166 psFree(options); 167 172 168 return true; 173 169 } -
branches/pap/ppStack/src/ppStackLoop.h
r25924 r25964 61 61 ppStackOptions *options, // Options 62 62 pmConfig *config, // Configuration 63 bool full, // Combine full image?64 63 bool safe, // Allow safe combination? 65 64 bool norm // Normalise images? -
branches/pap/ppStack/src/ppStackReadout.c
r25924 r25964 25 25 psVector *addVariance = options->matchChi2; // Additional variance when rejecting 26 26 27 psArray *inspect = ppStackReadoutInitial(config, outRO, thread->readouts, mask, 28 weightings, addVariance); 29 30 job->results = inspect; 27 job->results = ppStackReadoutInitial(config, outRO, thread->readouts, mask, 28 weightings, addVariance); 31 29 thread->busy = false; 32 30 33 return inspect? true : false;31 return job->results ? true : false; 34 32 } 35 33 … … 43 41 ppStackOptions *options = args->data[2]; // Options 44 42 pmConfig *config = args->data[3]; // Configuration 45 bool full = PS_SCALAR_VALUE(args->data[4], U8); // Combine full image? 46 bool safety = PS_SCALAR_VALUE(args->data[5], U8); // Safety switch on? 47 bool normalise = PS_SCALAR_VALUE(args->data[6], U8); // Normalise images? 43 bool safety = PS_SCALAR_VALUE(args->data[4], U8); // Safety switch on? 44 bool normalise = PS_SCALAR_VALUE(args->data[5], U8); // Normalise images? 48 45 49 46 psVector *mask = options->inputMask; // Mask for inputs … … 54 51 55 52 bool status = ppStackReadoutFinal(config, target, thread->readouts, mask, rejected, 56 weightings, addVariance, full,safety, norm); // Status of operation53 weightings, addVariance, safety, norm); // Status of operation 57 54 58 55 thread->busy = false; … … 67 64 68 65 psArray *args = job->args; // Input arguments 69 psArray *inspect = args->data[0]; // Array of pixel arrays 70 int index = PS_SCALAR_VALUE(args->data[1], S32); // Index of interest 71 72 psArray *inputs = inspect->data[index]; // Array of interest 73 psPixels *output = NULL; // Output pixel list 74 for (int i = 0; i < inputs->n; i++) { 75 psPixels *input = inputs->data[i]; // Input pixel list 76 if (!input || input->n == 0) { 77 continue; 78 } 79 output = psPixelsConcatenate(output, input); 80 } 81 82 if (!output) { 83 // If there are no pixels to inspect, then just fake it 84 output = psPixelsAllocEmpty(0); 85 } 86 87 psFree(inputs); 88 inspect->data[index] = output; 66 psArray *inspects = args->data[0]; // Array of pixel arrays 67 psArray *rejects = args->data[1]; // Array of pixel arrays 68 int index = PS_SCALAR_VALUE(args->data[2], S32); // Index of interest 69 70 psArray *inInspects = inspects->data[index]; // Array of interest 71 psArray *inRejects = rejects->data[index]; // Array of interest 72 psAssert(inInspects->n == inRejects->n, "Size should be the same"); 73 psPixels *outInspect = NULL, *outReject = NULL; // Output pixel lists 74 for (int i = 0; i < inInspects->n; i++) { 75 psPixels *inInspect = inInspects->data[i]; // Input pixel list 76 if (inInspect && inInspect->n > 0) { 77 outInspect = psPixelsConcatenate(outInspect, inInspect); 78 } 79 psPixels *inReject = inRejects->data[i]; // Input pixel list 80 if (inReject && inReject->n > 0) { 81 outReject = psPixelsConcatenate(outReject, inReject); 82 } 83 } 84 85 // If there are no pixels to inspect, then just fake it 86 if (!outInspect) { 87 outInspect = psPixelsAllocEmpty(0); 88 } 89 if (!outReject) { 90 outReject = psPixelsAllocEmpty(0); 91 } 92 93 psFree(inspects->data[index]); 94 inspects->data[index] = outInspect; 95 psFree(rejects->data[index]); 96 rejects->data[index] = outReject; 89 97 90 98 return true; … … 154 162 155 163 if (!pmStackCombine(outRO, stack, maskVal | maskBad, maskBad, kernelSize, iter, 156 combineRej, combineSys, combineDiscard, true,useVariance, safe, false)) {164 combineRej, combineSys, combineDiscard, useVariance, safe, false)) { 157 165 psError(PS_ERR_UNKNOWN, false, "Unable to combine input readouts with rejection."); 158 166 psFree(stack); … … 160 168 } 161 169 162 // Save list of pixels to inspect170 // Save lists of pixels 163 171 psArray *inspect = psArrayAlloc(num); // List of pixels to inspect 172 psArray *reject = psArrayAlloc(num); // List of pixels rejected 164 173 for (int i = 0; i < num; i++) { 165 174 pmStackData *data = stack->data[i]; // Data for this image … … 172 181 } 173 182 inspect->data[i] = psMemIncrRefCounter(data->inspect); 183 reject->data[i] = psMemIncrRefCounter(data->reject); 174 184 } 175 185 psFree(stack); … … 177 187 sectionNum++; 178 188 179 return inspect; 189 psArray *results = psArrayAlloc(2); // Array of results 190 results->data[0] = inspect; 191 results->data[1] = reject; 192 193 return results; 180 194 } 181 195 … … 184 198 bool ppStackReadoutFinal(const pmConfig *config, pmReadout *outRO, const psArray *readouts, 185 199 const psVector *mask, const psArray *rejected, const psVector *weightings, 186 const psVector *addVariance, bool full, boolsafety, const psVector *norm)200 const psVector *addVariance, bool safety, const psVector *norm) 187 201 { 188 202 assert(config); … … 225 239 for (int i = 0; i < num; i++) { 226 240 pmReadout *ro = readouts->data[i]; 227 if (mask->data.U8[i] & (PPSTACK_MASK_REJECT | PPSTACK_MASK_BAD)) { 228 // Image completely rejected since previous combination 229 full = true; 230 continue; 231 } else if (mask->data.U8[i]) { 232 // Image completely rejected before original combination 241 if (mask->data.U8[i]) { 242 // Image completely rejected 233 243 continue; 234 244 } … … 262 272 } 263 273 264 if (!pmStackCombine(outRO, stack, maskVal | maskBad, maskBad, 0, 265 iter, combineRej, combineSys, combineDiscard, 266 full, useVariance, safe, !rejected)) { 274 if (!pmStackCombine(outRO, stack, maskVal | maskBad, maskBad, 0, iter, combineRej, 275 combineSys, combineDiscard, useVariance, safe, !rejected)) { 267 276 psError(PS_ERR_UNKNOWN, false, "Unable to combine input readouts."); 268 277 psFree(stack); -
branches/pap/ppStack/src/ppStackReject.c
r25950 r25964 23 23 24 24 int num = options->num; // Number of inputs 25 options->rejected = psArrayAlloc(num);26 25 27 26 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSTACK_RECIPE); // ppStack recipe … … 53 52 psThreadJob *job = psThreadJobAlloc("PPSTACK_INSPECT"); // Job to start 54 53 psArrayAdd(job->args, 1, options->inspect); 54 psArrayAdd(job->args, 1, options->rejected); 55 55 PS_ARRAY_ADD_SCALAR(job->args, i, PS_TYPE_S32); 56 56 if (!psThreadJobAddPending(job)) { … … 92 92 #endif 93 93 94 psPixels *reject = pmStackReject(options->inspect->data[i], options->numCols, options->numRows,95 threshold, poorFrac, stride, options->regions->data[i],96 options->kernels->data[i]); // Rejected pixels97 98 94 #ifdef TESTING 99 95 { 100 psImage *mask = psPixelsToMask(NULL, reject,96 psImage *mask = psPixelsToMask(NULL, options->rejected->data[i], 101 97 psRegionSet(0, options->numCols - 1, 0, options->numRows - 1), 102 98 0xff); // Mask image 103 99 psString name = NULL; // Name of image 104 psStringAppend(&name, " reject_%03d.fits", i);100 psStringAppend(&name, "pre_reject_%03d.fits", i); 105 101 pmStackVisualPlotTestImage(mask, name); 106 102 psFits *fits = psFitsOpen(name, "w"); … … 111 107 } 112 108 #endif 109 110 psPixels *reject = pmStackReject(options->inspect->data[i], options->numCols, options->numRows, 111 threshold, poorFrac, stride, options->regions->data[i], 112 options->kernels->data[i]); // Rejected pixels 113 113 114 114 psFree(options->inspect->data[i]); … … 127 127 "exceeds limit (%.3f)", i, frac, imageRej); 128 128 psFree(reject); 129 // reject == NULL means reject image completely130 129 reject = NULL; 131 130 options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= PPSTACK_MASK_BAD; … … 134 133 } 135 134 136 // Images without a list of rejected pixels (the list may be empty) are rejected completely 137 options->rejected->data[i] = reject; 135 if (reject) { 136 // Add to list of pixels already rejected 137 reject = psPixelsConcatenate(reject, options->rejected->data[i]); 138 options->rejected->data[i] = psPixelsDuplicates(options->rejected->data[i], reject); 139 } 140 141 #ifdef TESTING 142 { 143 psImage *mask = psPixelsToMask(NULL, options->rejected->data[i], 144 psRegionSet(0, options->numCols - 1, 0, options->numRows - 1), 145 0xff); // Mask image 146 psString name = NULL; // Name of image 147 psStringAppend(&name, "reject_%03d.fits", i); 148 pmStackVisualPlotTestImage(mask, name); 149 psFits *fits = psFitsOpen(name, "w"); 150 psFree(name); 151 psFitsWriteImage(fits, NULL, mask, 0, NULL); 152 psFree(mask); 153 psFitsClose(fits); 154 } 155 #endif 138 156 139 157 if (options->stats) { … … 143 161 "Number of pixels rejected", reject ? reject->n : 0); 144 162 } 163 164 psFree(reject); 145 165 psLogMsg("ppStack", PS_LOG_INFO, "Time to perform rejection on image %d: %f sec", i, 146 166 psTimerClear("PPSTACK_REJECT")); -
branches/pap/ppStack/src/ppStackThread.c
r25924 r25964 275 275 276 276 { 277 psThreadTask *task = psThreadTaskAlloc("PPSTACK_INSPECT", 2);277 psThreadTask *task = psThreadTaskAlloc("PPSTACK_INSPECT", 3); 278 278 task->function = &ppStackInspect; 279 279 psThreadTaskAdd(task); … … 282 282 283 283 { 284 psThreadTask *task = psThreadTaskAlloc("PPSTACK_FINAL_COMBINE", 7);284 psThreadTask *task = psThreadTaskAlloc("PPSTACK_FINAL_COMBINE", 6); 285 285 task->function = &ppStackReadoutFinalThread; 286 286 psThreadTaskAdd(task);
Note:
See TracChangeset
for help on using the changeset viewer.
