Changeset 23576 for trunk/ppStack
- Timestamp:
- Mar 27, 2009, 1:26:55 PM (17 years ago)
- Location:
- trunk/ppStack/src
- Files:
-
- 1 added
- 7 edited
-
Makefile.am (modified) (1 diff)
-
ppStackCamera.c (modified) (5 diffs)
-
ppStackCombineInitial.c (modified) (1 diff)
-
ppStackCombinePrepare.c (added)
-
ppStackLoop.c (modified) (1 diff)
-
ppStackLoop.h (modified) (1 diff)
-
ppStackReadout.c (modified) (3 diffs)
-
ppStackSetup.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppStack/src/Makefile.am
r23341 r23576 29 29 ppStackPrepare.c \ 30 30 ppStackConvolve.c \ 31 ppStackCombinePrepare.c \ 31 32 ppStackCombineInitial.c \ 32 33 ppStackReject.c \ -
trunk/ppStack/src/ppStackCamera.c
r23371 r23576 51 51 bool status = false; // Status of file definition 52 52 53 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSTACK_RECIPE); // Recipe for ppSim 54 if (!recipe) { 55 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find recipe %s", PPSTACK_RECIPE); 56 return false; 57 } 58 bool convolve = psMetadataLookupBool(NULL, recipe, "CONVOLVE"); // Convolve images before stack? 59 53 60 psArray *runImages = pmFPAfileDefineMultipleFromRun(&status, NULL, config, 54 61 "PPSTACK.INPUT"); // Input images from previous run … … 98 105 } 99 106 if (!runSrc) { 100 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to define input sources from RUN metad ta.");107 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to define input sources from RUN metadata."); 101 108 psFree(runImages); 102 109 return false; … … 104 111 psFree(runSrc); 105 112 106 psArray *runKernel = pmFPAfileDefineMultipleFromRun(&status, runImages, config, 107 "PPSTACK.CONV.KERNEL"); // Convolution kernels 108 if (!status) { 109 psError(PS_ERR_UNKNOWN, false, "Unable to define convolution kernels from RUN metadata."); 110 psFree(runImages); 111 return false; 112 } 113 if (!runSrc) { 114 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to define convolution kernels from RUN metadta."); 115 psFree(runImages); 116 return false; 117 } 118 psFree(runKernel); 113 if (convolve) { 114 psArray *runKernel = pmFPAfileDefineMultipleFromRun(&status, runImages, config, 115 "PPSTACK.CONV.KERNEL"); // Convolution kernels 116 if (!status) { 117 psError(PS_ERR_UNKNOWN, false, "Unable to define convolution kernels from RUN metadata."); 118 psFree(runImages); 119 return false; 120 } 121 if (!runKernel) { 122 psError(PS_ERR_UNEXPECTED_NULL, true, 123 "Unable to define convolution kernels from RUN metadata."); 124 psFree(runImages); 125 return false; 126 } 127 psFree(runKernel); 128 } 119 129 120 130 psFree(runImages); … … 200 210 } 201 211 202 pmFPAfile *kernel = pmFPAfileDefineOutput(config, imageFile->fpa, "PPSTACK.CONV.KERNEL"); 203 if (!kernel) { 204 psError(PS_ERR_IO, false, _("Unable to generate output file from PPSTACK.CONV.KERNEL")); 205 return false; 206 } 207 kernel->save = true; 212 if (convolve) { 213 pmFPAfile *kernel = pmFPAfileDefineOutput(config, imageFile->fpa, "PPSTACK.CONV.KERNEL"); 214 if (!kernel) { 215 psError(PS_ERR_IO, false, _("Unable to generate output file from PPSTACK.CONV.KERNEL")); 216 return false; 217 } 218 kernel->save = true; 219 } 208 220 209 221 i++; … … 300 312 } 301 313 jpeg2->save = true; 302 303 304 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSTACK_RECIPE); // Recipe for ppSim305 if (!recipe) {306 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find recipe %s", PPSTACK_RECIPE);307 return false;308 }309 314 310 315 // For photometry, we operate on the chip-mosaicked image -
trunk/ppStack/src/ppStackCombineInitial.c
r23573 r23576 23 23 psTimerStart("PPSTACK_INITIAL"); 24 24 25 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSTACK_RECIPE); // ppStack recipe26 psAssert(recipe, "We've thrown an error on this before.");27 28 25 psMetadata *ppsub = psMetadataLookupMetadata(NULL, config->recipes, "PPSUB"); // PPSUB recipe 29 26 int overlap = 2 * psMetadataLookupS32(NULL, ppsub, 30 27 "KERNEL.SIZE"); // Overlap by kernel size between consecutive scans 31 28 32 pmFPAview *view = NULL; // View to readout33 34 int row0, col0; // Offset for readout35 int numCols, numRows; // Size of readout36 ppStackThread *thread = stack->threads->data[0]; // Representative thread37 if (!pmReadoutStackSetOutputSize(&col0, &row0, &numCols, &numRows, thread->readouts)) {38 psError(PS_ERR_UNKNOWN, false, "problem setting output readout size.");39 return false;40 }41 42 pmFPAfileActivate(config->files, false, NULL);43 ppStackFileActivation(config, PPSTACK_FILES_COMBINE, true);44 view = ppStackFilesIterateDown(config);45 if (!view) {46 return false;47 }48 49 pmCell *outCell = pmFPAfileThisCell(config->files, view, "PPSTACK.OUTPUT"); // Output cell50 options->outRO = pmReadoutAlloc(outCell); // Output readout51 psFree(view);52 53 psString maskBadStr = psMetadataLookupStr(NULL, recipe, "MASK.BAD"); // Name of bits to mask for bad54 psImageMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels55 if (!pmReadoutStackDefineOutput(options->outRO, col0, row0, numCols, numRows, true, true, maskBad)) {56 psError(PS_ERR_UNKNOWN, false, "Unable to prepare output.");57 return false;58 }59 60 psFree(options->cells); options->cells = NULL;61 29 62 30 bool status; // Status of read -
trunk/ppStack/src/ppStackLoop.c
r23367 r23576 59 59 if (!stack) { 60 60 psError(PS_ERR_IO, false, "Unable to initialise stack threads."); 61 psFree(options); 62 return false; 63 } 64 psFree(options->cells); options->cells = NULL; 65 66 // Prepare for combination 67 if (!ppStackCombinePrepare(stack, options, config)) { 68 psError(PS_ERR_UNKNOWN, false, "Unable to prepare for combination."); 69 psFree(stack); 61 70 psFree(options); 62 71 return false; -
trunk/ppStack/src/ppStackLoop.h
r23368 r23576 30 30 // Convolve inputs to match target PSF 31 31 bool ppStackConvolve( 32 ppStackOptions *options, // Options 33 pmConfig *config // Configuration 34 ); 35 36 // Prepare for combination 37 bool ppStackCombinePrepare( 38 ppStackThreadData *stack, // Stack 32 39 ppStackOptions *options, // Options 33 40 pmConfig *config // Configuration -
trunk/ppStack/src/ppStackReadout.c
r23346 r23576 185 185 assert(outRO); 186 186 assert(readouts); 187 assert(rejected); 188 assert(readouts->n == rejected->n); 187 assert(!rejected || readouts->n == rejected->n); 189 188 assert(mask && mask->n == readouts->n && mask->type.type == PS_TYPE_VECTOR_MASK); 190 189 assert(weightings && weightings->n == readouts->n && weightings->type.type == PS_TYPE_F32); … … 207 206 psArray *stack = psArrayAlloc(num); // Array for stacking 208 207 209 int numGood = num; // Number of good inputs: images that haven't been completely rejected208 bool entire = (rejected ? false : true); // Combine entire image? 210 209 for (int i = 0; i < num; i++) { 211 210 pmReadout *ro = readouts->data[i]; 212 if (!ro || !rejected->data[i] || mask->data.PS_TYPE_VECTOR_MASK_DATA[i]) { 213 // Image completely rejected 214 numGood--; 211 if (mask->data.U8[i] & (PPSTACK_MASK_REJECT | PPSTACK_MASK_BAD)) { 212 // Image completely rejected since previous combination 213 entire = true; 214 continue; 215 } else if (mask->data.U8[i]) { 216 // Image completely rejected before original combination 215 217 continue; 216 218 } … … 234 236 pmStackData *data = pmStackDataAlloc(ro, weightings->data.F32[i], 235 237 addVariance ? addVariance->data.F32[i] : NAN); 236 data->reject = psMemIncrRefCounter(rejected->data[i]);238 data->reject = rejected ? psMemIncrRefCounter(rejected->data[i]) : NULL; 237 239 stack->data[i] = data; 238 240 } 239 241 240 242 if (!pmStackCombine(outRO, stack, maskVal | maskBad, maskBad, 0, 0, NAN, NAN, NAN, 241 numGood != num, useVariance, false)) {243 entire, useVariance, false)) { 242 244 psError(PS_ERR_UNKNOWN, false, "Unable to combine input readouts."); 243 245 psFree(stack); -
trunk/ppStack/src/ppStackSetup.c
r23573 r23576 14 14 15 15 // Generate an array of input filenames 16 static psArray *stackNameArray(pmConfig *config, // Configuration 16 static psArray *stackNameArray(const ppStackOptions *options, // Stack options 17 pmConfig *config, // Configuration 17 18 const char *name // Name of file 18 19 ) … … 21 22 psAssert(config, "Require file name"); 22 23 23 psString regex = NULL; // Regular expression for selecting file 24 psStringAppend(®ex, "^%s$", name); 25 psMetadataIterator *iter = psMetadataIteratorAlloc(config->files, PS_LIST_HEAD, regex); // Iterator 26 psFree(regex); 27 psMetadataItem *item; // Item from iteration 28 psArray *array = psArrayAlloc(BUFFER); // Array of file names 29 while ((item = psMetadataGetAndIncrement(iter))) { 30 psAssert(item->type == PS_DATA_UNKNOWN, "Should be this type"); 31 pmFPAfile *file = item->data.V; // An input file 24 psArray *array = psArrayAllocEmpty(options->num); // Array with filenames 25 pmFPAview *view = pmFPAviewAlloc(0);// View to readout 26 view->chip = view->cell = view->readout = -1; 32 27 33 psString filename = psStringCopy(file->filename); // Filename of interest 28 for (int i = 0; i < options->num; i++) { 29 pmFPAfile *file = pmFPAfileSelectSingle(config->files, name, i); // File of interest 30 31 psString filename = pmFPAfileName(file, view, config); // Filename of interest 32 psAssert(filename, "Can't determine filename"); 34 33 psArrayAdd(array, array->n, filename); 35 34 psFree(filename); // Drop reference 36 35 } 37 psFree(iter);38 36 39 37 return array; … … 114 112 psFree(outputName); 115 113 } else { 116 options->imageNames = stackNameArray( config, "PPSTACK.INPUT");117 options->maskNames = stackNameArray( config, "PPSTACK.INPUT.MASK");118 options->varianceNames = stackNameArray( config, "PPSTACK.INPUT.VARIANCE");114 options->imageNames = stackNameArray(options, config, "PPSTACK.INPUT"); 115 options->maskNames = stackNameArray(options, config, "PPSTACK.INPUT.MASK"); 116 options->varianceNames = stackNameArray(options, config, "PPSTACK.INPUT.VARIANCE"); 119 117 } 120 118
Note:
See TracChangeset
for help on using the changeset viewer.
