Changeset 13873 for trunk/ppMerge/src/ppMergeScaleZero.c
- Timestamp:
- Jun 18, 2007, 5:59:32 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/ppMerge/src/ppMergeScaleZero.c (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note:
See TracChangeset
for help on using the changeset viewer.
