Changeset 9857 for trunk/ppImage/src/ppImageLoop.c
- Timestamp:
- Nov 3, 2006, 4:40:46 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/ppImage/src/ppImageLoop.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppImage/src/ppImageLoop.c
r9657 r9857 5 5 #include <ppStats.h> 6 6 #include "ppImage.h" 7 #include "ppImageDetrendFringe.h" 7 8 8 9 bool ppImageLoop (pmConfig *config, ppImageOptions *options) { … … 44 45 if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) return false; 45 46 47 const char *chipName = psMetadataLookupStr(NULL, chip->concepts, "CHIP.NAME"); // Name of chip 48 psArray *fringeRef = NULL; // Array of array of fringe statistics for reference --- for each cell 49 psArray *fringeSci = NULL; // Array of fringe statistics for science --- for each cell 50 if (options->doFringe) { 51 fringeRef = psArrayAlloc(chip->cells->n); 52 fringeSci = psArrayAlloc(chip->cells->n); 53 } 54 46 55 while ((cell = pmFPAviewNextCell (view, input->fpa, 1)) != NULL) { 47 56 psLogMsg ("ppImageLoop", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process); 48 57 if (!cell->process || !cell->file_exists) { continue; } 49 58 if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) return false; 59 const char *cellName = psMetadataLookupStr(NULL, cell->concepts, "CELL.NAME"); // Name of cell 60 61 if (options->doFringe) { 62 pmFPAfile *fringeFile = psMetadataLookupPtr(&status, config->files, "PPIMAGE.FRINGE"); 63 if (!status || !fringeFile) { 64 psErrorStackPrint(stderr, "Can't find fringe data!\n"); 65 exit(EXIT_FAILURE); 66 } 67 68 psString fringeExt = NULL; // Fringe extension name 69 psStringAppend(&fringeExt, "FRINGE_%s_%s", chipName, cellName); 70 fringeRef->data[view->cell] = pmFringesReadFits(NULL, fringeFile->fits, fringeExt); 71 psFree(fringeExt); 72 } 50 73 51 74 // process each of the readouts … … 57 80 if (!ppImageDetrendReadout (config, options, view)) return false; 58 81 82 if (options->doFringe) { 83 ppImageDetrendFringeMeasure((pmFringeStats**)(&fringeSci->data[view->cell]), 84 fringeRef->data[view->cell], readout, options); 85 } 86 } 87 } 88 89 // Solve the fringe system 90 pmFringeScale *fringeSoln = NULL; // Solution for the fringes 91 if (options->doFringe) { 92 fringeSoln = ppImageDetrendFringeSolve(fringeSci, fringeRef, options); 93 psFree(fringeSci); 94 psFree(fringeRef); 95 } 96 97 // Go back over the cells to apply the fringe and do statistics 98 view->cell = view->readout = -1; 99 while ((cell = pmFPAviewNextCell (view, input->fpa, 1)) != NULL) { 100 if (!cell->process || !cell->file_exists) { continue; } 101 102 // Apply the fringe correction 103 psTrace("ppImage", 3, "Applying fringe correction...\n"); 104 bool mdok; // Status of MD lookup 105 pmFPAfile *fringeFile = psMetadataLookupPtr(&mdok, config->files, "PPIMAGE.FRINGE"); 106 pmCell *fringeCell = pmFPAviewThisCell(view, fringeFile->fpa); 107 psImage *fringe = ppImageDetrendFringeGenerate(cell, fringeCell, fringeSoln); 108 while ((readout = pmFPAviewNextReadout (view, input->fpa, 1)) != NULL) { 109 if (!readout->data_exists) { continue; } 110 111 // XXX: Make generic, so subregions may be subtracted as well 112 psBinaryOp(readout->image, readout->image, "-", fringe); 113 59 114 if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) return false; 60 115 } 116 psFree(fringe); 117 61 118 62 119 // Perform statistics on the detrended cell … … 67 124 if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) return false; 68 125 } 126 psFree(fringeSoln); 69 127 70 128 ppImageMosaicChip (config, view, "PPIMAGE.OUTPUT.CHIP", "PPIMAGE.OUTPUT");
Note:
See TracChangeset
for help on using the changeset viewer.
