Changeset 13873
- Timestamp:
- Jun 18, 2007, 5:59:32 PM (19 years ago)
- Location:
- trunk/ppMerge/src
- Files:
-
- 6 edited
-
ppMerge.c (modified) (2 diffs)
-
ppMergeCombine.c (modified) (6 diffs)
-
ppMergeCombine.h (modified) (1 diff)
-
ppMergeOptions.c (modified) (3 diffs)
-
ppMergeScaleZero.c (modified) (14 diffs)
-
ppMergeScaleZero.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppMerge/src/ppMerge.c
r9996 r13873 46 46 } 47 47 48 psImage *scale = NULL; // The scalings49 psImage *zero = NULL; // The zeros50 51 48 if (options->mask) { 52 49 // Generate a mask 53 50 ppMergeMask(data, options, config); 54 51 } else { 52 53 psImage *scale = NULL; // The scalings 54 psImage *zero = NULL; // The zeros 55 psArray *shutters = NULL; // The shutter correction data 56 55 57 // Measure the background in each image 56 ppMergeScaleZero(&scale, &zero, data, options, config);58 ppMergeScaleZero(&scale, &zero, &shutters, data, options, config); 57 59 58 60 // Do the combination and write 59 ppMergeCombine(scale, zero, data, options, config); 61 ppMergeCombine(scale, zero, shutters, data, options, config); 62 63 psFree(scale); 64 psFree(zero); 65 psFree(shutters); 60 66 } 61 67 … … 73 79 // Cleaning up 74 80 psFree(data); 75 psFree(scale);76 psFree(zero);77 81 psFree(options); 78 82 psFree(config); -
trunk/ppMerge/src/ppMergeCombine.c
r13769 r13873 83 83 bool ppMergeCombine(psImage *scales, // Scales for each cell of each integration, or NULL 84 84 psImage *zeros, // Zeros for each cell of each integration, or NULL 85 psArray *shutters, // Shutter correction data for each cell, or NULL 85 86 ppMergeData *data, // Data 86 87 ppMergeOptions *options, // Options … … 100 101 zeros->numCols == data->numCells && 101 102 zeros->numRows == filenames->n)); 103 assert(!options->shutter || shutters); 104 assert(!shutters || (shutters->n == data->numCells)); 102 105 103 106 // Iterate over the FPA … … 143 146 } 144 147 148 float shutterRef; // Reference shutter correction 149 if (options->shutter) { 150 shutterRef = pmShutterCorrectionReference(shutters->data[cellNum]); 151 } 152 145 153 do { 146 154 numRead = 0; … … 162 170 163 171 // Only reading and writing the first readout in each cell (plane 0) 164 bool readOK;172 bool readOK; 165 173 if (pmReadoutReadNext(&readOK, stack->data[i], fits, 0, options->rows)) { 166 if (!readOK) {167 psError(PS_ERR_IO, false, "Failed to read concepts for cell.\n");168 psErrorStackPrint(stderr, "trouble reading data!\n");169 exit (1);170 }174 if (!readOK) { 175 psError(PS_ERR_IO, false, "Failed to read concepts for cell.\n"); 176 psErrorStackPrint(stderr, "trouble reading data!\n"); 177 exit (1); 178 } 171 179 // If we're creating a bias or a dark, we don't want to generate a mask 172 180 if ((options->zero || options->scale || options->shutter || options->mask) && … … 198 206 199 207 if (options->shutter) { 200 pmShutterCorrectionMeasure(readout, stack, options->shutterSize, 201 options->mean, options->stdev, 202 options->shutterIter, 203 options->shutterRej, 204 options->combine->maskVal); 208 pmShutterCorrectionGenerate(readout, NULL, stack, shutterRef, shutters->data[cellNum], 209 options->shutterIter, options->shutterRej, 210 options->combine->maskVal); 205 211 } else { 206 212 pmReadoutCombine(readout, stack, cellZeros, cellScales, options->combine); … … 271 277 // Statistics on the merged cell 272 278 if (data->statsFile) { 273 if (!data->stats) { 274 data->stats = psMetadataAlloc(); 275 } 276 if (!ppStats(data->stats, 277 data->out, 278 view, 279 options->combine->maskVal, 280 config)) { 279 if (!data->stats) { 280 data->stats = psMetadataAlloc(); 281 } 282 if (!ppStats(data->stats, data->out, view, options->combine->maskVal, config)) { 281 283 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to generate stats for image.\n"); 282 return false;283 }284 }284 return false; 285 } 286 } 285 287 286 288 // We threw away the bias sections --- record this -
trunk/ppMerge/src/ppMergeCombine.h
r7064 r13873 11 11 bool ppMergeCombine(psImage *scales, // Scales for each cell of each integration, or NULL 12 12 psImage *zeros, // Zeros for each cell of each integration, or NULL 13 psArray *shutters, // Shutter correction data for each cell, or NULL 13 14 ppMergeData *data, // Data 14 15 ppMergeOptions *options, // Options -
trunk/ppMerge/src/ppMergeOptions.c
r13593 r13873 61 61 options->satMask = 0x00; 62 62 options->badMask = 0x00; 63 64 63 return options; 65 64 } … … 135 134 136 135 // First, deal with the recipe. These are parameters that will typically be constant for a camera. 137 OPTION_PARSE(options->rows, recipe, "ROWS", U16);136 OPTION_PARSE(options->rows, recipe, "ROWS", S32); 138 137 OPTION_PARSE(options->minElectrons, recipe, "ELECTRONS", F32); 139 138 OPTION_PARSE(options->sample, recipe, "SAMPLE", S32); … … 215 214 options->shutter = true; 216 215 options->mask = false; 217 options->rows = 0; // Read the whole image at once218 216 } else if (strcasecmp(type, "MASK") == 0) { 219 217 options->zero = false; -
trunk/ppMerge/src/ppMergeScaleZero.c
r13814 r13873 15 15 bool ppMergeScaleZero(psImage **scales, // The scales for each integration/cell 16 16 psImage **zeros, // The zeroes for each integration/cell 17 psArray **shutters, // The shutter correction data for each cell 17 18 ppMergeData *data,// The data 18 19 const ppMergeOptions *options, // The options … … 24 25 assert(config); 25 26 26 if (!options->scale && !options->zero && !options->darktime ) {27 if (!options->scale && !options->zero && !options->darktime && !options->shutter) { 27 28 return true; // We did everything we were asked for 28 29 } … … 43 44 (*zeros)->numCols == data->numCells && 44 45 (*zeros)->numRows == filenames->n)); 46 assert(!options->shutter || shutters); 47 assert(!shutters || !*shutters || (*shutters)->n == data->numCells); 45 48 46 49 // Allocate the outputs … … 57 60 *zeros = psImageAlloc(data->numCells, filenames->n, PS_TYPE_F32); 58 61 } 59 60 bool fromConcepts = false; // Do we get the scale and zero points from the concepts 62 psRandom *rng = NULL; // Random number generator 63 if (options->shutter) { 64 if (*shutters) { 65 psFree(*shutters); 66 } 67 *shutters = psArrayAlloc(data->numCells); 68 rng = psRandomAlloc(PS_RANDOM_TAUS, 0); 69 } 70 71 bool fromConcepts = false; // Do we get the scale and zero points from the concepts? 61 72 bool first = true; // Are we on the first cell (that sets the standard for the rest)? 62 73 bool done = false; // Are we done going through the list? … … 86 97 if (mdok && !isnan(scale)) { 87 98 if (!first && !fromConcepts) { 88 ps LogMsg(__func__, PS_LOG_WARN,"PPMERGE.SCALE and PPMERGE.ZERO have been set "99 psWarning("PPMERGE.SCALE and PPMERGE.ZERO have been set " 89 100 "for some, but not all cells --- we will re-measure it for all cells."); 90 101 done = true; … … 93 104 fromConcepts = true; 94 105 (*scales)->data.F32[i][cellNum] = scale; 95 psTrace("ppMerge", 9, "Scale for input %ld, chip %ld, cell %ld: %f\n", i, j, k, scale); 106 psTrace("ppMerge", 9, "Scale for input %ld, chip %ld, cell %ld: %f\n", 107 i, j, k, scale); 96 108 } else if (!first && fromConcepts) { 97 ps LogMsg(__func__, PS_LOG_WARN,"PPMERGE.SCALE and PPMERGE.ZERO have been set "109 psWarning("PPMERGE.SCALE and PPMERGE.ZERO have been set " 98 110 "for some, but not all cells --- we will re-measure it for all cells."); 99 111 fromConcepts = false; … … 107 119 if (mdok && !isnan(zero)) { 108 120 if (!first && !fromConcepts) { 109 ps LogMsg(__func__, PS_LOG_WARN,"PPMERGE.SCALE and PPMERGE.ZERO have been set "121 psWarning("PPMERGE.SCALE and PPMERGE.ZERO have been set " 110 122 "for some, but not all cells --- we will re-measure it for all cells."); 111 123 done = true; … … 116 128 psTrace("ppMerge", 9, "Zero for input %ld, chip %ld, cell %ld: %f\n", i, j, k, zero); 117 129 } else if (!first && fromConcepts) { 118 ps LogMsg(__func__, PS_LOG_WARN,"PPMERGE.SCALE and PPMERGE.ZERO have been set "130 psWarning("PPMERGE.SCALE and PPMERGE.ZERO have been set " 119 131 "for some, but not all cells --- we will re-measure it for all cells."); 120 132 fromConcepts = false; … … 131 143 if (fromConcepts) { 132 144 // We've already done everything we need to 145 psFree(rng); 133 146 return true; 134 147 } … … 205 218 206 219 if (cell->readouts->n > 1) { 207 ps LogMsg(__func__, PS_LOG_WARN,"File %s chip %d cell %d contains more than one "220 psWarning("File %s chip %d cell %d contains more than one " 208 221 "readout --- ignoring all but the first.\n", name, j, k); 209 222 status = false; … … 222 235 gains->data.F32[cellNum] = psMetadataLookupF32(&mdok, cell->concepts, "CELL.GAIN"); 223 236 if (!mdok || isnan(gains->data.F32[cellNum])) { 224 ps LogMsg(__func__, PS_LOG_WARN,"CELL.GAIN for file %s chip %d cell %d is not "237 psWarning("CELL.GAIN for file %s chip %d cell %d is not " 225 238 "set.\n", name, j, k); 226 239 gains->data.F32[cellNum] = NAN; … … 259 272 } 260 273 274 // Shutter correction 275 if (options->shutter) { 276 if (!pmCellRead(cell, inFile, config->database)) { 277 // Nothing here 278 pmCellFreeData(cell); 279 continue; 280 } 281 282 if (cell->readouts->n > 1) { 283 psWarning("File %s chip %d cell %d contains more than one " 284 "readout --- ignoring all but the first.\n", name, j, k); 285 status = false; 286 } 287 pmReadout *readout = cell->readouts->data[0]; // The readout of interest 288 289 pmShutterCorrectionData *shutter = (*shutters)->data[cellNum]; // Shutter correction data 290 if (!shutter) { 291 shutter = pmShutterCorrectionDataAlloc(readout->image->numCols, 292 readout->image->numRows, 293 options->shutterSize); 294 (*shutters)->data[cellNum] = shutter; 295 } 296 if (!pmShutterCorrectionAddReadout(shutter, readout, options->mean, options->stdev, 297 options->combine->maskVal, rng)) { 298 psWarning("Can't add file %s chip %d cell %d to shutter correction --- ignored.", 299 name, j, k); 300 status = false; 301 } 302 } 303 304 261 305 pmCellFreeData(cell); 262 306 } … … 265 309 pmFPAFreeData(fpa); 266 310 } 311 psFree(rng); 267 312 psFree(bgStats); 268 313 psFree(view); … … 277 322 psVector *fluxes = NULL; // Solution to fluxes 278 323 if (!pmFlatNormalize(&fluxes, &gains, background)) { 279 ps LogMsg(__func__, PS_LOG_WARN,"Normalisation failed to converge --- continuing anyway.\n");324 psWarning("Normalisation failed to converge --- continuing anyway.\n"); 280 325 status = false; 281 326 } -
trunk/ppMerge/src/ppMergeScaleZero.h
r7263 r13873 11 11 bool ppMergeScaleZero(psImage **scales, // The scales for each integration/cell 12 12 psImage **zeros, // The zeroes for each integration/cell 13 psArray **shutter,// The shutter correction data for each cell 13 14 ppMergeData *data,// The data 14 15 const ppMergeOptions *options, // The options
Note:
See TracChangeset
for help on using the changeset viewer.
