Changeset 19928 for trunk/ppImage/src/ppImageLoop.c
- Timestamp:
- Oct 6, 2008, 12:24:10 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/ppImage/src/ppImageLoop.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppImage/src/ppImageLoop.c
r19399 r19928 5 5 #include "ppImage.h" 6 6 7 # define ESCAPE(MESSAGE) { \7 #define ESCAPE(MESSAGE) { \ 8 8 psError(PS_ERR_UNKNOWN, false, MESSAGE); \ 9 psFree (view); \9 psFree(view); \ 10 10 return false; \ 11 11 } 12 12 13 bool ppImageLoop (pmConfig *config, ppImageOptions *options)13 bool ppImageLoop(pmConfig *config, ppImageOptions *options) 14 14 { 15 bool status; 16 pmChip *chip; 17 pmCell *cell; 18 pmReadout *readout; 19 20 // measure the total elapsed time in ppImageLoop. 21 psTimerStart ("ppImageLoop"); 22 15 psMetadata *stats = options->doStats ? psMetadataAlloc() : NULL; // Statistics to output 16 float timeDetrend = 0; // Amount of time spent in detrend 17 float timePhot = 0; // Amount of time spent in photometry 18 19 bool status; // Status of MD lookup 23 20 pmFPAfile *input = psMetadataLookupPtr(&status, config->files, "PPIMAGE.INPUT"); 24 21 if (!status) { … … 40 37 41 38 // files associated with the science image 42 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) ESCAPE ("load failure for FPA"); 43 39 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) { 40 ESCAPE("load failure for FPA"); 41 } 42 43 pmChip *chip; // Chip from FPA 44 44 while ((chip = pmFPAviewNextChip(view, input->fpa, 1)) != NULL) { 45 45 psLogMsg ("ppImageLoop", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process); … … 47 47 continue; 48 48 } 49 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) ESCAPE ("load failure for Chip"); 50 49 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) { 50 ESCAPE("load failure for Chip"); 51 } 52 53 psTimerStart(TIMER_DETREND); 54 pmCell *cell; // Cell from chip 51 55 while ((cell = pmFPAviewNextCell(view, input->fpa, 1)) != NULL) { 52 56 psLogMsg ("ppImageLoop", 5, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process); … … 54 58 continue; 55 59 } 56 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) ESCAPE ("load failure for Cell"); 60 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) { 61 ESCAPE("load failure for Cell"); 62 } 57 63 58 64 // Put version information into the header … … 70 76 71 77 // process each of the readouts 78 pmReadout *readout; // Readout from cell 72 79 while ((readout = pmFPAviewNextReadout (view, input->fpa, 1)) != NULL) { 73 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) ESCAPE ("load failure for Readout"); 80 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) { 81 ESCAPE("load failure for Readout"); 82 } 74 83 if (!readout->data_exists) { 75 84 continue; … … 78 87 // XXX set the options->*Mask values here (after the mask images have been loaded 79 88 // and before any of the value are used) 80 if (!ppImageSetMaskBits (config, options)) 81 ESCAPE ("Unable to set bit masks"); 89 if (!ppImageSetMaskBits(config, options)) { 90 ESCAPE("Unable to set bit masks"); 91 } 82 92 83 93 // perform the detrend analysis 84 if (!ppImageDetrendReadout(config, options, view)) 85 ESCAPE ("Unable to detrend readout"); 94 if (!ppImageDetrendReadout(config, options, view)) { 95 ESCAPE("Unable to detrend readout"); 96 } 86 97 } 87 98 } … … 89 100 // Apply the fringe correction 90 101 if (options->doFringe) { 91 if (!ppImageDetrendFringeApply (config, chip, view, options)) 92 ESCAPE ("Unable to defringe"); 102 if (!ppImageDetrendFringeApply(config, chip, view, options)) { 103 ESCAPE("Unable to defringe"); 104 } 93 105 } 94 106 95 107 // measure various statistics for this image 96 if (!ppImagePixelStats (config, options, view)) 97 ESCAPE ("Unable to measures stats for image"); 98 99 if (!ppImageMosaicChip(config, options, view, "PPIMAGE.CHIP", "PPIMAGE.OUTPUT")) 100 ESCAPE ("Unable to mosaic chip"); 108 if (!ppImagePixelStats(config, stats, options, view)) { 109 ESCAPE("Unable to measures stats for image"); 110 } 111 if (!ppImageMosaicChip(config, options, view, "PPIMAGE.CHIP", "PPIMAGE.OUTPUT")) { 112 ESCAPE("Unable to mosaic chip"); 113 } 114 timeDetrend += psTimerClear(TIMER_DETREND); 115 101 116 102 117 // we perform photometry on the readouts of this chip in the output 118 psTimerStart(TIMER_PHOT); 103 119 if (options->doPhotom) { 104 if (!ppImagePhotom(config, view)) ESCAPE ("error running photometry."); 105 } 120 if (!ppImagePhotom(config, view)) { 121 ESCAPE("error running photometry."); 122 } 123 } 124 timePhot += psTimerClear(TIMER_PHOT); 106 125 107 126 // replace the masked pixels with the background level 108 127 if (options->replaceMasked) { 109 if (!ppImageReplaceBackground (config, view, options)) 110 ESCAPE ("Unable to replace masked pixels with background level"); 128 if (!ppImageReplaceBackground(config, view, options)) { 129 ESCAPE("Unable to replace masked pixels with background level"); 130 } 111 131 } 112 132 113 133 // binning (used for display) must take place after the background is replaced, if desired 114 if (!ppImageRebinChip(config, view, options, "PPIMAGE.BIN1")) 115 ESCAPE ("Unable to bin chip (level 1)."); 116 117 if (!ppImageRebinChip(config, view, options, "PPIMAGE.BIN2")) 118 ESCAPE ("Unable to bin chip (level 2)."); 134 if (!ppImageRebinChip(config, view, options, "PPIMAGE.BIN1")) { 135 ESCAPE("Unable to bin chip (level 1)."); 136 } 137 if (!ppImageRebinChip(config, view, options, "PPIMAGE.BIN2")) { 138 ESCAPE("Unable to bin chip (level 2)."); 139 } 119 140 120 141 // Close cells (XXX shouldn't pmFPAfileClose iterate down as needed?) … … 124 145 continue; 125 146 } 126 if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) ESCAPE ("save failure for Cell"); 147 if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) { 148 ESCAPE("save failure for Cell"); 149 } 127 150 } 128 151 129 152 // Close chip 130 if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) ESCAPE ("save failure for Chip"); 153 if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) { 154 ESCAPE("save failure for Chip"); 155 } 131 156 } 132 157 133 158 // generate the full-scale FPA mosaic 134 if (!ppImageMosaicFPA(config, options, "PPIMAGE.OUTPUT.FPA1", "PPIMAGE.BIN1")) ESCAPE ("failure in FPA Mosaic (level 1)"); 135 if (!ppImageMosaicFPA(config, options, "PPIMAGE.OUTPUT.FPA2", "PPIMAGE.BIN2")) ESCAPE ("failure in FPA Mosaic (level 2)"); 159 if (!ppImageMosaicFPA(config, options, "PPIMAGE.OUTPUT.FPA1", "PPIMAGE.BIN1")) { 160 ESCAPE("failure in FPA Mosaic (level 1)"); 161 } 162 if (!ppImageMosaicFPA(config, options, "PPIMAGE.OUTPUT.FPA2", "PPIMAGE.BIN2")) { 163 ESCAPE("failure in FPA Mosaic (level 2)"); 164 } 136 165 137 166 // we perform astrometry on all chips after sources have been detected 138 167 // this also performs the psastro file IO 139 168 if (options->doAstromChip || options->doAstromMosaic) { 140 if (!ppImageAstrom(config)) ESCAPE ("error running astrometry."); 169 if (!ppImageAstrom(config)) { 170 ESCAPE("error running astrometry."); 171 } 141 172 } 142 173 143 174 if (psTraceGetLevel("ppImage") >= 3) { 144 ppImageFileCheck (config);175 ppImageFileCheck(config); 145 176 } 146 177 147 178 // Write out summary statistics 148 if (!ppImageMetadataStats (config, options)) ESCAPE ("Unable to write statistics file."); 179 if (!ppImageMetadataStats(config, stats, options)) { 180 ESCAPE("Unable to write statistics file."); 181 } 182 183 // Output and Close FPA 184 if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) { 185 ESCAPE("save failure for FPA"); 186 } 187 188 psFree(view); 149 189 150 190 // Write out summary statistics 151 if (!ppImageStatsOutput (config, options)) ESCAPE ("Unable to write statistics file."); 152 153 // Output and Close FPA 154 if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) ESCAPE ("save failure for FPA"); 155 156 psFree(view); 191 if (options->doStats) { 192 psMetadataAddF32(stats, PS_LIST_TAIL, "DT_DET", 0, "Time spent detrending (sec)", timeDetrend); 193 psMetadataAddF32(stats, PS_LIST_TAIL, "DT_PHOT", 0, "Time spent photometering (sec)", timePhot); 194 psMetadataAddF32(stats, PS_LIST_TAIL, "DT_TOTAL", 0, "Total time (sec)", psTimerMark(TIMER_TOTAL)); 195 if (!ppImageStatsOutput(config, stats, options)) { 196 ESCAPE("Unable to write statistics file."); 197 } 198 } 199 157 200 return true; 158 201 }
Note:
See TracChangeset
for help on using the changeset viewer.
