Changeset 9325 for trunk/ppMerge/src/ppMergeCombine.c
- Timestamp:
- Oct 5, 2006, 3:29:58 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/ppMerge/src/ppMergeCombine.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppMerge/src/ppMergeCombine.c
r8847 r9325 123 123 } 124 124 125 #if 1 126 // Read bit by bit 127 128 int numRead; // Number of inputs read 129 int numScan = 0; 130 do { 131 numRead = 0; 125 // Building a shutter correction 126 if (options->shutter) { 127 // Read in the pixels 128 int numRead = 0; // Number of inputs read 129 psVector *exptimes = psVectorAlloc(filenames->n, PS_TYPE_F32); // Reference measurements 130 exptimes->n = filenames->n; 131 psVectorInit(exptimes, 0); 132 psArray *images = psArrayAlloc(filenames->n); // Array of images 133 psArray *masks = psArrayAlloc(filenames->n); // Array of masks 134 images->n = masks->n = filenames->n; 132 135 for (int i = 0; i < filenames->n; i++) { 133 136 if (! filenames->data[i] || strlen(filenames->data[i]) == 0) { … … 136 139 psFits *fits = data->files->data[i]; // FITS file handle 137 140 if (!fits) { 138 psError(PS_ERR_IO, false, "Unable to open input file %s --- ignored.\n", 139 (char*)filenames->data[i]); 140 continue; 141 } 142 143 if (!stack->data[i]) { 144 pmFPA *fpaIn = data->in->data[i]; // Input FPA 145 pmChip *chipIn = fpaIn->chips->data[view->chip]; // Input chip 146 pmCell *cellIn = chipIn->cells->data[view->cell]; // Input cell 147 stack->data[i] = pmReadoutAlloc(cellIn); // Input readout 148 } 149 150 // Only reading and writing the first readout in each cell (plane 0) 151 if (pmReadoutReadNext(stack->data[i], fits, 0, options->rows)) { 152 // For anything except BIAS and DARK, we want a mask 153 if (options->scale || options->zero) { 154 pmReadoutSetMask(stack->data[i]); 141 continue; 142 } 143 pmFPA *fpaIn = data->in->data[i]; // Input FPA 144 pmChip *chipIn = fpaIn->chips->data[view->chip]; // Input chip 145 pmCell *cellIn = chipIn->cells->data[view->cell]; // Input cell 146 if (!cellIn->file_exists) { 147 // || !cellIn->data_exists) { 148 continue; 149 } 150 if (!pmCellRead(cellIn, fits, config->database) || cellIn->readouts->n == 0) { 151 continue; 152 } 153 if (cellIn->readouts->n > 1) { 154 psWarning("Multiple readouts in file %d, chip %d, cell %d --- " 155 "only the first will be used.\n", i, view->chip, view->cell); 156 } 157 float exptime = psMetadataLookupF32(NULL, cellIn->concepts, "CELL.EXPOSURE"); 158 if (!isfinite(exptime)) { 159 psWarning("File %d, chip %d, cell %d has bad exposure time.\n", 160 i, view->chip, view->cell); 161 } 162 exptimes->data.F32[i] = exptime; 163 pmReadout *readoutIn = cellIn->readouts->data[0]; 164 images->data[i] = psMemIncrRefCounter(readoutIn->image); 165 masks->data[i] = psMemIncrRefCounter(readoutIn->mask); 166 numRead++; 167 } 168 if (numRead > 1) { 169 readout->image = pmShutterCorrectionMeasure(exptimes, images, masks, 170 options->shutterSize, options->mean, 171 options->stdev, options->combine->maskVal); 172 psTrace(__func__, 5, "Chip %d, cell %d\n", view->chip, view->cell); 173 } else { 174 psError(PS_ERR_UNKNOWN, true, "Not enough images to combine: %d\n", numRead); 175 psFree(images); 176 psFree(exptimes); 177 return false; 178 } 179 psFree(images); 180 psFree(exptimes); 181 } else { 182 #if 1 183 // Read bit by bit 184 185 int numRead; // Number of inputs read 186 int numScan = 0; 187 do { 188 numRead = 0; 189 for (int i = 0; i < filenames->n; i++) { 190 if (! filenames->data[i] || strlen(filenames->data[i]) == 0) { 191 continue; 155 192 } 156 numRead++; 157 } 193 psFits *fits = data->files->data[i]; // FITS file handle 194 if (!fits) { 195 continue; 196 } 197 198 if (!stack->data[i]) { 199 pmFPA *fpaIn = data->in->data[i]; // Input FPA 200 pmChip *chipIn = fpaIn->chips->data[view->chip]; // Input chip 201 pmCell *cellIn = chipIn->cells->data[view->cell]; // Input cell 202 stack->data[i] = pmReadoutAlloc(cellIn); // Input readout 203 } 204 205 // Only reading and writing the first readout in each cell (plane 0) 206 if (pmReadoutReadNext(stack->data[i], fits, 0, options->rows)) { 207 // For anything except BIAS and DARK, we want a mask 208 if (options->scale || options->zero) { 209 pmReadoutSetMask(stack->data[i]); 210 } 211 numRead++; 212 } 213 } 214 215 if (numRead > 0) { 216 pmReadoutCombine(readout, stack, cellZeros, cellScales, options->combine); 217 psTrace(__func__, 5, "Chip %d, cell %d, scan %d\n", view->chip, view->cell, numScan); 218 } 219 numScan++; 220 221 } while (numRead > 0); 222 223 #else 224 // Read whole cells at a time 225 226 printf("Chip %d, cell %d\n", view->chip, view->cell); 227 int numRead = 0; // Number of inputs read 228 for (int i = 0; i < filenames->n; i++) { 229 if (! filenames->data[i] || strlen(filenames->data[i]) == 0) { 230 continue; 231 } 232 psFits *fits = data->files->data[i]; // FITS file handle 233 if (!fits) { 234 continue; 235 } 236 pmFPA *fpaIn = data->in->data[i]; // Input FPA 237 pmChip *chipIn = fpaIn->chips->data[view->chip]; // Input chip 238 pmCell *cellIn = chipIn->cells->data[view->cell]; // Input cell 239 if (!cellIn->file_exists || !cellIn->data_exists) { 240 continue; 241 } 242 if (!pmCellRead(cellIn, fits, config->database) || cellIn->readouts->n == 0) { 243 continue; 244 } 245 stack->data[i] = cellIn->readouts->data[0]; 246 numRead++; 158 247 } 159 160 248 if (numRead > 0) { 161 249 pmReadoutCombine(readout, stack, cellZeros, cellScales, options->combine); 162 psTrace(__func__, 5, "Chip %d, cell %d , scan %d\n", view->chip, view->cell, numScan);250 psTrace(__func__, 5, "Chip %d, cell %d\n", view->chip, view->cell); 163 251 } 164 numScan++; 165 166 } while (numRead > 0); 167 168 #else 169 // Read whole cells at a time 170 171 printf("Chip %d, cell %d\n", view->chip, view->cell); 172 int numRead = 0; // Number of inputs read 173 for (int i = 0; i < filenames->n; i++) { 174 if (! filenames->data[i] || strlen(filenames->data[i]) == 0) { 175 continue; 176 } 177 psFits *fits = data->files->data[i]; // FITS file handle 178 if (!fits) { 179 psError(PS_ERR_IO, false, "Unable to open input file %s --- ignored.\n", 180 filenames->data[i]); 181 continue; 182 } 183 pmFPA *fpaIn = data->in->data[i]; // Input FPA 184 pmChip *chipIn = fpaIn->chips->data[view->chip]; // Input chip 185 pmCell *cellIn = chipIn->cells->data[view->cell]; // Input cell 186 if (!cellIn->file_exists || !cellIn->data_exists) { 187 continue; 188 } 189 if (!pmCellRead(cellIn, fits, config->database) || cellIn->readouts->n == 0) { 190 continue; 191 } 192 stack->data[i] = cellIn->readouts->data[0]; 193 numRead++; 194 } 195 if (numRead > 0) { 196 pmReadoutCombine(readout, stack, cellZeros, cellScales, options->combine); 197 psTrace(__func__, 5, "Chip %d, cell %d\n", view->chip, view->cell); 198 } 199 200 memCheck(); 252 253 memCheck(); 201 254 #endif 255 } 202 256 203 257 psFree(readout); // Drop reference
Note:
See TracChangeset
for help on using the changeset viewer.
