Changeset 21244 for trunk/ppMerge/src/ppMergeLoop.c
- Timestamp:
- Feb 1, 2009, 11:43:05 AM (17 years ago)
- File:
-
- 1 edited
-
trunk/ppMerge/src/ppMergeLoop.c (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppMerge/src/ppMergeLoop.c
r21183 r21244 1 /** @file ppMergeLoop.c 2 * 3 * @brief 4 * 5 * @ingroup ppMerge 6 * 7 * @author IfA 8 * @version $Revision: 1.14 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-02-01 21:43:05 $ 10 * Copyright 2009 Institute for Astronomy, University of Hawaii 11 */ 12 1 13 #include "ppMerge.h" 2 14 … … 5 17 assert(config); 6 18 7 psMetadata *arguments = config->arguments; // Arguments8 ppMergeType type = psMetadataLookupS32(NULL, config->arguments, "TYPE"); // Type of frame9 int numFiles = psMetadataLookupS32(NULL, arguments, "INPUTS.NUM"); // Number of input files10 bool mdok; // Status of MD lookup11 bool haveMasks = psMetadataLookupBool(&mdok, arguments, "INPUTS.MASKS"); // Do we have masks?12 bool haveWeights = psMetadataLookupBool(&mdok, arguments, "INPUTS.WEIGHTS"); // Do we have weights?13 14 psArray *inputs = ppMergeFileDataLevel(config, "PPMERGE.INPUT", PM_FPA_LEVEL_READOUT); // Input images15 psArray *masks = NULL, *weights = NULL; // Input masks and weights19 psMetadata *arguments = config->arguments; ///< Arguments 20 ppMergeType type = psMetadataLookupS32(NULL, config->arguments, "TYPE"); ///< Type of frame 21 int numFiles = psMetadataLookupS32(NULL, arguments, "INPUTS.NUM"); ///< Number of input files 22 bool mdok; ///< Status of MD lookup 23 bool haveMasks = psMetadataLookupBool(&mdok, arguments, "INPUTS.MASKS"); ///< Do we have masks? 24 bool haveWeights = psMetadataLookupBool(&mdok, arguments, "INPUTS.WEIGHTS"); ///< Do we have weights? 25 26 psArray *inputs = ppMergeFileDataLevel(config, "PPMERGE.INPUT", PM_FPA_LEVEL_READOUT); ///< Input images 27 psArray *masks = NULL, *weights = NULL; ///< Input masks and weights 16 28 if (haveMasks) { 17 29 masks = ppMergeFileDataLevel(config, "PPMERGE.INPUT.MASK", PM_FPA_LEVEL_READOUT); … … 21 33 } 22 34 23 / / General combination parameters24 int rows = psMetadataLookupS32(NULL, arguments, "ROWS"); // Number of rows to read per chunk25 int iter = psMetadataLookupS32(NULL, arguments, "ITER"); // Number of rejection iterations26 float rej = psMetadataLookupF32(NULL, arguments, "REJ"); // Rejection level27 float fraclow = psMetadataLookupF32(NULL, arguments, "FRACLOW"); // Reject fraction of low pixels28 float frachigh = psMetadataLookupF32(NULL, arguments, "FRACHIGH"); // Reject fraction of hi pixels29 int nKeep = psMetadataLookupS32(NULL, arguments, "NKEEP"); // Minimum number of values to keep30 psStatsOptions combineStat = psMetadataLookupS32(NULL, arguments, "COMBINE"); // Combination statistic31 bool useWeights = psMetadataLookupBool(NULL, arguments, "WEIGHTS"); // Use weights?32 33 / / Fringe parameters34 int fringeNum = psMetadataLookupS32(NULL, arguments, "FRINGE.NUM"); // Number of fringe points35 int fringeSize = psMetadataLookupS32(NULL, arguments, "FRINGE.SIZE"); // Size of fringe regions36 int fringeSmoothX = psMetadataLookupS32(NULL, arguments, "FRINGE.XSMOOTH"); // Smoothing regions in x37 int fringeSmoothY = psMetadataLookupS32(NULL, arguments, "FRINGE.YSMOOTH"); // Smoothing regions in y35 /** General combination parameters */ 36 int rows = psMetadataLookupS32(NULL, arguments, "ROWS"); ///< Number of rows to read per chunk 37 int iter = psMetadataLookupS32(NULL, arguments, "ITER"); ///< Number of rejection iterations 38 float rej = psMetadataLookupF32(NULL, arguments, "REJ"); ///< Rejection level 39 float fraclow = psMetadataLookupF32(NULL, arguments, "FRACLOW"); ///< Reject fraction of low pixels 40 float frachigh = psMetadataLookupF32(NULL, arguments, "FRACHIGH"); ///< Reject fraction of hi pixels 41 int nKeep = psMetadataLookupS32(NULL, arguments, "NKEEP"); ///< Minimum number of values to keep 42 psStatsOptions combineStat = psMetadataLookupS32(NULL, arguments, "COMBINE"); ///< Combination statistic 43 bool useWeights = psMetadataLookupBool(NULL, arguments, "WEIGHTS"); ///< Use weights? 44 45 /** Fringe parameters */ 46 int fringeNum = psMetadataLookupS32(NULL, arguments, "FRINGE.NUM"); ///* Number of fringe points 47 int fringeSize = psMetadataLookupS32(NULL, arguments, "FRINGE.SIZE"); ///* Size of fringe regions 48 int fringeSmoothX = psMetadataLookupS32(NULL, arguments, "FRINGE.XSMOOTH"); ///< Smoothing regions in x 49 int fringeSmoothY = psMetadataLookupS32(NULL, arguments, "FRINGE.YSMOOTH"); ///< Smoothing regions in y 38 50 39 51 // set the mask and mark bit values based on the named masks … … 45 57 } 46 58 47 pmCombineParams *combination = pmCombineParamsAlloc(combineStat); // Combination parameters59 pmCombineParams *combination = pmCombineParamsAlloc(combineStat); ///< Combination parameters 48 60 combination->maskVal = maskVal; 49 61 combination->blank = pmConfigMaskGet("BLANK", config); … … 55 67 combination->weights = useWeights; 56 68 57 psMetadata *stats = NULL; // Statistics for output69 psMetadata *stats = NULL; ///< Statistics for output 58 70 if (psMetadataLookup(config->arguments, "STATS.NAME")) { 59 71 stats = psMetadataAlloc(); … … 61 73 } 62 74 63 pmFPAview *view = pmFPAviewAlloc(0); // View to component of interest75 pmFPAview *view = pmFPAviewAlloc(0); ///< View to component of interest 64 76 65 77 // Retrieve data placed on analysis 66 psVector *scales = NULL, *zeros = NULL; // Scale and zeroes for combination67 psArray *shutters = NULL; // Shutter correction data78 psVector *scales = NULL, *zeros = NULL; ///< Scale and zeroes for combination 79 psArray *shutters = NULL; ///< Shutter correction data 68 80 switch (type) { 69 81 case PPMERGE_TYPE_FRINGE: … … 97 109 98 110 // Dark parameters 99 psArray *darkOrdinates = psMetadataLookupPtr(NULL, arguments, "DARK.ORDINATES"); // Dark info100 psString darkNorm = psMetadataLookupStr(&mdok, arguments, "DARK.NORM"); // Dark normalisation111 psArray *darkOrdinates = psMetadataLookupPtr(NULL, arguments, "DARK.ORDINATES"); ///< Dark info 112 psString darkNorm = psMetadataLookupStr(&mdok, arguments, "DARK.NORM"); ///< Dark normalisation 101 113 102 114 … … 105 117 goto ERROR; 106 118 } 107 psString outName = ppMergeOutputFile(config); // Name of output file108 pmFPAfile *output = psMetadataLookupPtr(NULL, config->files, outName); // Output file119 psString outName = ppMergeOutputFile(config); ///< Name of output file 120 pmFPAfile *output = psMetadataLookupPtr(NULL, config->files, outName); ///< Output file 109 121 psFree(outName); 110 122 assert(output && output->fpa); 111 pmFPA *outFPA = output->fpa; // Output FPA112 int cellNum = 0; // Index of cell123 pmFPA *outFPA = output->fpa; ///< Output FPA 124 int cellNum = 0; ///< Index of cell 113 125 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) { 114 126 goto ERROR; 115 127 } 116 pmChip *outChip; // Chip of interest128 pmChip *outChip; ///< Chip of interest 117 129 while ((outChip = pmFPAviewNextChip(view, outFPA, 1))) { 118 130 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) { 119 131 goto ERROR; 120 132 } 121 pmCell *outCell; // Cell of interest133 pmCell *outCell; ///< Cell of interest 122 134 while ((outCell = pmFPAviewNextCell(view, outFPA, 1))) { 123 135 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) { … … 125 137 } 126 138 127 pmHDU *hdu = pmHDUGetLowest(outFPA, outChip, outCell); // HDU for cell139 pmHDU *hdu = pmHDUGetLowest(outFPA, outChip, outCell); ///< HDU for cell 128 140 if (!hdu || hdu->blankPHU) { 129 141 // No data here … … 133 145 pmReadout *outRO = pmReadoutAlloc(outCell); 134 146 135 psArray *readouts = psArrayAlloc(numFiles); // Input readouts147 psArray *readouts = psArrayAlloc(numFiles); ///< Input readouts 136 148 for (int i = 0; i < numFiles; i++) { 137 149 // We need to do some of the opening ourselves … … 142 154 143 155 pmFPAfile *input = pmFPAfileSelectSingle(config->files, "PPMERGE.INPUT", i); 144 pmCell *inCell = pmFPAviewThisCell(view, input->fpa); // Input cell156 pmCell *inCell = pmFPAviewThisCell(view, input->fpa); ///< Input cell 145 157 readouts->data[i] = pmReadoutAlloc(inCell); 146 158 } 147 159 148 float shutterRef = NAN; // Reference shutter correction160 float shutterRef = NAN; ///< Reference shutter correction 149 161 if (type == PPMERGE_TYPE_SHUTTER) { 150 162 shutterRef = pmShutterCorrectionReference(shutters->data[cellNum]); … … 156 168 psTrace("ppStack", 2, "Initial stack of chunk %d....\n", numChunk); 157 169 for (int i = 0; i < numFiles; i++) { 158 pmReadout *inRO = readouts->data[i]; // Input readout170 pmReadout *inRO = readouts->data[i]; ///< Input readout 159 171 160 172 // Read a chunk from a file … … 229 241 230 242 // Get list of cells for concepts averaging 231 psList *inCells = psListAlloc(NULL); // List of cells243 psList *inCells = psListAlloc(NULL); ///< List of cells 232 244 for (int i = 0; i < numFiles; i++) { 233 pmReadout *readout = readouts->data[i]; // Readout of interest245 pmReadout *readout = readouts->data[i]; ///< Readout of interest 234 246 psListAdd(inCells, PS_LIST_TAIL, readout->parent); 235 247 } … … 247 259 { 248 260 pmCell *countsCell = pmFPAfileThisCell(config->files, view, "PPMERGE.OUTPUT.COUNT"); 249 pmReadout *countsRO = pmReadoutAlloc(countsCell); // Readout with count of inputs per pixel261 pmReadout *countsRO = pmReadoutAlloc(countsCell); ///< Readout with count of inputs per pixel 250 262 psImage *counts = psMetadataLookupPtr(NULL, outRO->analysis, PM_READOUT_STACK_ANALYSIS_COUNT); 251 263 countsRO->image = psImageCopy(countsRO->image, counts, PS_TYPE_F32); … … 263 275 264 276 pmCell *sigmaCell = pmFPAfileThisCell(config->files, view, "PPMERGE.OUTPUT.SIGMA"); 265 pmReadout *sigmaRO = pmReadoutAlloc(sigmaCell); // Readout with stdev per pixel277 pmReadout *sigmaRO = pmReadoutAlloc(sigmaCell); ///< Readout with stdev per pixel 266 278 psImage *sigma = psMetadataLookupPtr(NULL, outRO->analysis, PM_READOUT_STACK_ANALYSIS_SIGMA); 267 279 sigmaRO->image = psImageCopy(sigmaRO->image, sigma, PS_TYPE_F32); … … 297 309 } 298 310 299 psArray *fringes = psArrayAlloc(1); // Array of fringes311 psArray *fringes = psArrayAlloc(1); ///< Array of fringes 300 312 fringes->data[0] = fringe; 301 313 … … 336 348 337 349 // Get list of FPAs for concepts averaging 338 psList *inFPAs = psListAlloc(NULL); // List of FPAs350 psList *inFPAs = psListAlloc(NULL); ///< List of FPAs 339 351 for (int i = 0; i < numFiles; i++) { 340 pmFPAfile *input = inputs->data[i]; // Input file352 pmFPAfile *input = inputs->data[i]; ///< Input file 341 353 psListAdd(inFPAs, PS_LIST_TAIL, input->fpa); 342 354 }
Note:
See TracChangeset
for help on using the changeset viewer.
