Changeset 7355 for trunk/ppMerge/src/ppMergeScaleZero.c
- Timestamp:
- Jun 5, 2006, 3:47:48 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/ppMerge/src/ppMergeScaleZero.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppMerge/src/ppMergeScaleZero.c
r7263 r7355 42 42 ) 43 43 { 44 assert(data); 45 assert(options); 46 assert(config); 47 48 if (!options->scale && !options->zero) { 49 return true; // We did everything we were asked for 50 } 51 44 52 assert(config->camera); // Need the camera configuration 53 assert(config->arguments); // Need the list of files 45 54 46 55 psArray *filenames = psMetadataLookupPtr(NULL, config->arguments, "INPUT"); // The input file names … … 57 66 (*zeros)->numRows == filenames->n)); 58 67 68 // Allocate the outputs 69 if (options->scale) { 70 if (*scales) { 71 psFree(*scales); 72 } 73 *scales = psImageAlloc(data->numCells, filenames->n, PS_TYPE_F32); 74 } 75 if (options->zero) { 76 if (*zeros) { 77 psFree(*zeros); 78 } 79 *zeros = psImageAlloc(data->numCells, filenames->n, PS_TYPE_F32); 80 } 81 82 bool fromConcepts = false; // Do we get the scale and zero points from the concepts 83 bool first = true; // Are we on the first cell (that sets the standard for the rest)? 84 bool done = false; // Are we done going through the list? 85 bool mdok = true; // Status of MD lookup 86 for (long i = 0; i < data->in->n && !done; i++) { 87 pmFPA *fpa = data->in->data[i]; // The FPA 88 if (!fpa) { 89 continue; 90 } 91 long cellNum = -1; // Number of the cell 92 psArray *chips = fpa->chips; // The array of chips 93 for (long j = 0; j < chips->n && !done; j++) { 94 pmChip *chip = chips->data[j]; // The chip 95 if (!chip) { 96 continue; 97 } 98 psArray *cells = chip->cells; // The array of cells 99 for (long k = 0; k < cells->n && !done; k++) { 100 pmCell *cell = cells->data[k]; // The cell 101 if (!cell) { 102 continue; 103 } 104 cellNum++; 105 106 if (options->scale) { 107 float scale = psMetadataLookupF32(&mdok, cell->concepts, "PPMERGE.SCALE"); // The scale 108 if (mdok && !isnan(scale)) { 109 if (!first && !fromConcepts) { 110 psLogMsg(__func__, PS_LOG_WARN, "PPMERGE.SCALE and PPMERGE.ZERO have been set " 111 "for some, but not all cells --- we will re-measure it for all cells."); 112 done = true; 113 continue; 114 } 115 fromConcepts = true; 116 (*scales)->data.F32[i][cellNum] = scale; 117 psTrace(__func__, 9, "Scale for input %ld, chip %ld, cell %ld: %f\n", i, j, k, scale); 118 } else if (!first && fromConcepts) { 119 psLogMsg(__func__, PS_LOG_WARN, "PPMERGE.SCALE and PPMERGE.ZERO have been set " 120 "for some, but not all cells --- we will re-measure it for all cells."); 121 fromConcepts = false; 122 done = true; 123 continue; 124 } 125 } 126 127 if (options->zero) { 128 float zero = psMetadataLookupF32(&mdok, cell->concepts, "PPMERGE.ZERO"); // The zero 129 if (mdok && !isnan(zero)) { 130 if (!first && !fromConcepts) { 131 psLogMsg(__func__, PS_LOG_WARN, "PPMERGE.SCALE and PPMERGE.ZERO have been set " 132 "for some, but not all cells --- we will re-measure it for all cells."); 133 done = true; 134 continue; 135 } 136 fromConcepts = true; 137 (*zeros)->data.F32[i][cellNum] = zero; 138 psTrace(__func__, 9, "Zero for input %ld, chip %ld, cell %ld: %f\n", i, j, k, zero); 139 } else if (!first && fromConcepts) { 140 psLogMsg(__func__, PS_LOG_WARN, "PPMERGE.SCALE and PPMERGE.ZERO have been set " 141 "for some, but not all cells --- we will re-measure it for all cells."); 142 fromConcepts = false; 143 done = true; 144 continue; 145 } 146 } 147 148 first = false; 149 } 150 } 151 } 152 153 if (fromConcepts) { 154 // We've already done everything we need to 155 return true; 156 } 157 59 158 psImage *background = psImageAlloc(data->numCells, filenames->n, PS_TYPE_F32); // Background measurements 60 159 psImageInit(background, NAN); … … 108 207 // Normalising by the exposure time 109 208 if (options->exptime) { 110 bool mdok = true; // Status of MD lookup111 209 exptime->data.F32[i][cellNum] = psMetadataLookupF32(&mdok, cell->concepts, 112 210 "CELL.EXPOSURE"); … … 203 301 psFree(gains); 204 302 205 *scales = psImageCopy(*scales, background, PS_TYPE_F32);206 303 psImage *scalesDeref = *scales; // Dereference the pointer 207 304 … … 217 314 if (!options->scale) { 218 315 // Copy over the exposure times 219 psImageCopy(*scales, exptime, PS_TYPE_F32);316 *scales = psImageCopy(*scales, exptime, PS_TYPE_F32); 220 317 } else { 221 psBinaryOp(*scales, *scales, "*", exptime);318 *scales = (psImage*)psBinaryOp(*scales, *scales, "*", exptime); 222 319 } 223 320 }
Note:
See TracChangeset
for help on using the changeset viewer.
