Changeset 16842
- Timestamp:
- Mar 6, 2008, 10:49:03 AM (18 years ago)
- Location:
- trunk/ppMerge/src
- Files:
-
- 4 edited
-
ppMergeCombine.c (modified) (13 diffs)
-
ppMergeOptions.c (modified) (13 diffs)
-
ppMergeOptions.h (modified) (3 diffs)
-
ppMergeScaleZero.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppMerge/src/ppMergeCombine.c
r16229 r16842 16 16 #include "ppMergeVersion.h" 17 17 18 #define TESTING 19 20 18 21 #if 0 19 static psMemId memId = 0;20 21 22 static FILE *dumpFile = NULL; 22 23 … … 36 37 exit(EXIT_FAILURE); 37 38 } 38 39 39 #endif 40 41 #if 0 42 static psMemId memId = 0; 40 43 static void memDump(void) 41 44 { … … 52 55 psFree(leaks); 53 56 } 54 57 #endif 58 59 #if 0 55 60 static void memCheck(void) 56 61 { … … 73 78 psTrace("ppMerge", 0, "Memory in use: %zd\n", totalSize); 74 79 psTrace("ppMerge", 0, "Largest block: %ld\n", largest); 75 psTrace("ppMerge", 0, "sbrk(): % zd\n", sbrk(0));80 psTrace("ppMerge", 0, "sbrk(): %p\n", sbrk(0)); 76 81 } 77 82 return; … … 119 124 } 120 125 while ((chip = pmFPAviewNextChip(view, fpa, 1))) { 121 if (chip->hdu) { 122 // Data will exist soon 123 pmFPAUpdateNames(data->out, chip, NULL); 124 chip->data_exists = true; 125 } 126 if (!chip->hdu) { 127 continue; 128 } 129 // Data will exist soon 130 pmFPAUpdateNames(data->out, chip, NULL); 131 chip->data_exists = true; 126 132 pmChipWrite(chip, data->outFile, config->database, true, false); // Write header only 127 133 pmCell *cell; // Cell of interest 128 134 while ((cell = pmFPAviewNextCell(view, fpa, 1))) { 129 135 cellNum++; 130 if (cell->hdu) { 131 // Data will exist soon 132 pmFPAUpdateNames(data->out, chip, cell); 133 chip->data_exists = cell->data_exists = true; 134 } 136 if (!cell->hdu) { 137 continue; 138 } 139 // Data will exist soon 140 pmFPAUpdateNames(data->out, chip, cell); 141 chip->data_exists = cell->data_exists = true; 135 142 pmCellWrite(cell, data->outFile, config->database, true); // Write header only 136 143 pmReadout *readout = pmReadoutAlloc(cell); // Output readout of interest … … 197 204 198 205 // If we're combining with weights, we want to generate weights. 199 if (options->combine->weights ) {206 if (options->combine->weights && !options->dark) { 200 207 201 208 // If it's a bias or dark, set the gain to zero: noise only contributed by read 202 if ( (!options->zero && !options->scale) || options->darktime) {209 if (!options->zero && !options->scale) { 203 210 pmReadoutSetWeight(stack->data[i], false); 204 211 } else { … … 209 216 numRead++; 210 217 } else { 211 psTrace("ppMerge", 3, "Finished reading file %d, chip %d, cell %d, scan %d\n", i, view->chip, view->cell, numScan); 218 psTrace("ppMerge", 3, "Finished reading file %d, chip %d, cell %d, scan %d\n", 219 i, view->chip, view->cell, numScan); 212 220 } 213 221 … … 220 228 options->shutterIter, options->shutterRej, 221 229 options->combine->maskVal); 230 } else if (options->dark) { 231 pmDarkCombine(cell, stack, options->darkOrdinates, options->combine->iter, 232 options->combine->rej, options->combine->maskVal); 222 233 } else { 223 234 pmReadoutCombine(readout, stack, cellZeros, cellScales, options->combine); … … 246 257 psFree(stack); 247 258 259 #if 0 248 260 // Set the dark time for the output image, since we normalised 249 261 if (options->darktime) { … … 253 265 expItem->data.F32 = 1.0; 254 266 } 267 #endif 255 268 256 269 // Measure the fringes for this cell … … 334 347 if (cell->hdu && !cell->hdu->blankPHU) { 335 348 psTrace("ppMerge", 5, "Writing out cell HDU.\n"); 336 pmCellWrite(cell, data->outFile, config->database, false); 337 if (options->fringe) { 338 pmCellWriteTable(data->outFile, cell, "FRINGE"); 339 } 340 349 if (options->dark) { 350 pmCellWriteDark(cell, data->outFile, config->database, false); 351 } else { 352 pmCellWrite(cell, data->outFile, config->database, false); 353 if (options->fringe) { 354 pmCellWriteTable(data->outFile, cell, "FRINGE"); 355 } 356 } 341 357 pmCellFreeData(cell); 342 358 } … … 354 370 if (chip->hdu && !chip->hdu->blankPHU) { 355 371 psTrace("ppMerge", 5, "Writing out chip HDU.\n"); 356 pmChipWrite(chip, data->outFile, config->database, false, false); 357 if (options->fringe) { 358 pmChipWriteTable(data->outFile, chip, "FRINGE"); 372 if (options->dark) { 373 pmChipWriteDark(chip, data->outFile, config->database, false, false); 374 } else { 375 pmChipWrite(chip, data->outFile, config->database, false, false); 376 if (options->fringe) { 377 pmChipWriteTable(data->outFile, chip, "FRINGE"); 378 } 359 379 } 360 380 … … 373 393 // Write the pixels 374 394 psTrace("ppMerge", 5, "Writing out FPA HDU.\n"); 375 pmFPAWrite(data->out, data->outFile, config->database, false, false); 376 if (options->fringe) { 377 pmFPAWriteTable(data->outFile, fpa, "FRINGE"); 395 if (options->dark) { 396 pmFPAWriteDark(data->out, data->outFile, config->database, false, false); 397 } else { 398 pmFPAWrite(data->out, data->outFile, config->database, false, false); 399 if (options->fringe) { 400 pmFPAWriteTable(data->outFile, fpa, "FRINGE"); 401 } 378 402 } 379 403 } -
trunk/ppMerge/src/ppMergeOptions.c
r15953 r16842 10 10 #include "ppMerge.h" 11 11 #include "ppMergeOptions.h" 12 13 #define ARRAY_BUFFER 4 // Number of values to add at once 12 14 13 15 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// … … 34 36 options->zero = false; 35 37 options->scale = false; 36 options->dark time= false;38 options->dark = false; 37 39 options->fringe = false; 38 40 options->shutter = false; … … 65 67 options->badMask = 0x00; 66 68 options->growPixels = 0; 69 options->darkOrdinates = NULL; 67 70 return options; 68 71 } … … 174 177 options->zero = false; 175 178 options->scale = false; 176 options->dark time= false;179 options->dark = false; 177 180 options->fringe = false; 178 181 options->shutter = false; … … 181 184 options->zero = false; 182 185 options->scale = false; 183 options->dark time= true;186 options->dark = true; 184 187 options->fringe = false; 185 188 options->shutter = false; … … 188 191 options->zero = false; 189 192 options->scale = true; 190 options->dark time= false;193 options->dark = false; 191 194 options->fringe = false; 192 195 options->shutter = false; … … 195 198 options->zero = false; 196 199 options->scale = true; 197 options->dark time= false;200 options->dark = false; 198 201 options->fringe = false; 199 202 options->shutter = false; … … 202 205 options->zero = false; 203 206 options->scale = true; 204 options->dark time= false;207 options->dark = false; 205 208 options->fringe = false; 206 209 options->shutter = false; … … 209 212 options->zero = true; 210 213 options->scale = true; 211 options->dark time= false;214 options->dark = false; 212 215 options->fringe = true; 213 216 options->shutter = false; … … 216 219 options->zero = false; 217 220 options->scale = false; 218 options->dark time= false;221 options->dark = false; 219 222 options->fringe = false; 220 223 options->shutter = true; … … 225 228 options->zero = false; 226 229 options->scale = false; 227 options->dark time= false;230 options->dark = false; 228 231 options->fringe = false; 229 232 options->shutter = false; … … 255 258 256 259 #if 0 257 // Or you can set them individually258 OPTION_PARSE(options->zero, config->arguments, "-zero", Bool);259 OPTION_PARSE(options->scale, config->arguments, "-scale", Bool);260 OPTION_PARSE(options->darktime, config->arguments, "-exptime", Bool);261 #endif262 263 260 // Number of on/off images 264 261 OPTION_PARSE(options->onOff, config->arguments, "-onoff", S32); 262 #endif 265 263 266 264 // Masking options … … 268 266 options->badMask = pmConfigMask("BAD", config); 269 267 268 if (options->dark) { 269 psMetadata *ordinates = psMetadataLookupMetadata(NULL, recipe, "DARK.ORDINATES"); // Ordinates info 270 options->darkOrdinates = psArrayAllocEmpty(psListLength(ordinates->list)); 271 272 psMetadataIterator *iter = psMetadataIteratorAlloc(ordinates, PS_LIST_HEAD, NULL); // Iterator 273 psMetadataItem *item; // Item from iteration 274 while ((item = psMetadataGetAndIncrement(iter))) { 275 int order = 0; // Polynomial order 276 bool scale = false; // Scale values? 277 float min = NAN, max = NAN; // Minimum and maximum values for scaling 278 switch (item->type) { 279 case PS_TYPE_S32: 280 order = item->data.S32; 281 break; 282 case PS_DATA_METADATA: 283 order = psMetadataLookupS32(NULL, item->data.md, "ORDER"); 284 bool mdok; // Status of MD lookup 285 scale = psMetadataLookupBool(&mdok, item->data.md, "SCALE"); 286 min = psMetadataLookupF32(&mdok, item->data.md, "MIN"); 287 max = psMetadataLookupF32(&mdok, item->data.md, "MAX"); 288 break; 289 default: 290 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 291 "Type of DARK.ORDINATES entry %s (%x) is not METADATA or S32", 292 item->name, item->type); 293 psFree(options); 294 return false; 295 } 296 if (order <= 0) { 297 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "ORDER not positive (%d) for DARK.ORDINATES %s", 298 order, item->name); 299 psFree(options); 300 return false; 301 } 302 303 pmDarkOrdinate *ord = pmDarkOrdinateAlloc(item->name, order); 304 ord->scale = scale; 305 ord->min = min; 306 ord->max = max; 307 psArrayAdd(options->darkOrdinates, options->darkOrdinates->n, ord); 308 psFree(ord); 309 } 310 psFree(iter); 311 } 312 270 313 return options; 271 314 } -
trunk/ppMerge/src/ppMergeOptions.h
r15953 r16842 21 21 bool zero; // Subtract background before combining? 22 22 bool scale; // Scale by the background before combining? 23 bool dark time; // Normalise by the dark time (time since flush)?23 bool dark; // Generate dark? 24 24 bool fringe; // Make fringe measurements? 25 25 bool shutter; // Generate shutter correction? … … 37 37 float maskSuspect; // Threshold for identifying suspect pixels 38 38 float maskBad; // Threshold for identifying bad pixels 39 bool statsByChip; // measure statistics for masking by chip or readout?40 pmMaskIdentifyMode maskMode; // how to set the limit based on the threshold value above?39 bool statsByChip; // measure statistics for masking by chip or readout? 40 pmMaskIdentifyMode maskMode; // how to set the limit based on the threshold value above? 41 41 ppOnOff onOff; // On/off pairs? 42 42 pmCombineParams *combine; // Combination parameters … … 44 44 psMaskType badMask; // Mask value for bad (low) pixels 45 45 int growPixels; 46 psArray *darkOrdinates; // Ordinates for dark combination 46 47 } ppMergeOptions; 47 48 -
trunk/ppMerge/src/ppMergeScaleZero.c
r13957 r16842 25 25 assert(config); 26 26 27 if (!options->scale && !options->zero && !options-> darktime && !options->shutter) {27 if (!options->scale && !options->zero && !options->shutter) { 28 28 return true; // We did everything we were asked for 29 29 } … … 151 151 psStats *bgStats = psStatsAlloc(options->mean); // Statistic to measure the background 152 152 psVector *gains = NULL; // The gains for each cell 153 psImage *darktime = NULL; // The dark time for each integration of each cell154 153 if (options->scale) { 155 154 gains = psVectorAlloc(data->numCells, PS_TYPE_F32); 156 }157 if (options->darktime) {158 darktime = psImageAlloc(data->numCells, filenames->n, PS_TYPE_F32);159 155 } 160 156 … … 187 183 if (!pmCellReadHeader(cell, inFile)) { 188 184 continue; 189 }190 191 // Normalising by the exposure time192 if (options->darktime) {193 darktime->data.F32[i][cellNum] = psMetadataLookupF32(NULL, cell->concepts,194 "CELL.DARKTIME");195 if (isnan(darktime->data.F32[i][cellNum])) {196 psWarning("CELL.DARKTIME for file %s chip %d cell %d is not set.\n", name, j, k);197 status = false;198 } else {199 view->chip = j;200 view->cell = k;201 202 // This step applies the dark exptime / background relationship: F =203 // polymomial(exptime). Below, the input images are scaled by the204 // output of this relationship.205 206 // For devices with linear dark and no residual bias, this relationship207 // is not defined in the configuration system, and the transformation208 // is defined (when loaded by the concepts) to be F = exptime. Thus,209 // in this case, the resulting dark image consists of counts/sec.210 211 // For devices with a different relationship, the transformation yields212 // the expected number of counts in the given exposure, based on the213 // recorded exptime. Thus, in this case, the resulting dark image214 // should have a median value of 1.0.215 216 // note that these corrections must be applied differently when used to217 // correct a science image.218 219 darktime->data.F32[i][cellNum] = pmFPADarkNorm(fpa, view,220 darktime->data.F32[i][cellNum]);221 if (isnan(darktime->data.F32[i][cellNum])) {222 psWarning("Cannot get dark normalisation for file %s chip %d cell %d.\n",223 name, j, k);224 status = false;225 }226 }227 185 } 228 186 … … 355 313 } 356 314 357 if (options->darktime) {358 if (!options->scale) {359 // Copy over the exposure times360 *scales = psImageCopy(*scales, darktime, PS_TYPE_F32);361 } else {362 *scales = (psImage*)psBinaryOp(*scales, *scales, "*", darktime);363 }364 }365 366 315 if (options->zero) { 367 316 if (!*zeros) {
Note:
See TracChangeset
for help on using the changeset viewer.
