Changeset 7067 for trunk/ppMerge
- Timestamp:
- May 4, 2006, 3:53:10 PM (20 years ago)
- Location:
- trunk/ppMerge/src
- Files:
-
- 10 edited
-
ppMerge.c (modified) (1 diff)
-
ppMerge.h (modified) (1 diff)
-
ppMergeBackground.c (modified) (2 diffs)
-
ppMergeCheckInputs.c (modified) (6 diffs)
-
ppMergeCheckInputs.h (modified) (1 diff)
-
ppMergeCombine.c (modified) (9 diffs)
-
ppMergeConfig.c (modified) (1 diff)
-
ppMergeData.c (modified) (2 diffs)
-
ppMergeOptions.c (modified) (6 diffs)
-
ppMergeOptions.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppMerge/src/ppMerge.c
r7064 r7067 12 12 13 13 //#include "ppMem.h" 14 15 // Yet to do: 16 // 17 // 1. Mask pixels with less than the minimum number of electrons 18 // 2. Sampling factor for background measurement 19 // 3. On/off pairs 14 20 15 21 int main(int argc, char **argv) -
trunk/ppMerge/src/ppMerge.h
r7064 r7067 3 3 4 4 #define TIMERNAME "ppMerge" 5 #define RECIPENAME "PPMERGE" 5 6 6 7 #endif -
trunk/ppMerge/src/ppMergeBackground.c
r7064 r7067 4 4 #include <psmodules.h> 5 5 6 #include "ppMerge.h" 6 7 #include "ppMergeBackground.h" 7 8 … … 150 151 151 152 // Get the background 152 psImageStats(bgStats, image, readout->mask, options-> maskVal);153 psImageStats(bgStats, image, readout->mask, options->combine->maskVal); 153 154 background->data.F64[i][cellNum] = getStat(bgStats, options->background); 154 155 } -
trunk/ppMerge/src/ppMergeCheckInputs.c
r7061 r7067 4 4 #include <psmodules.h> 5 5 6 #include "ppMerge.h" 6 7 #include "ppMergeCheckInputs.h" 7 8 #include "ppMergeData.h" … … 9 10 // Check input files to make sure everything's consistent 10 11 ppMergeData *ppMergeCheckInputs(ppMergeOptions *options, // Options 11 constpmConfig *config // Configuration12 pmConfig *config // Configuration 12 13 ) 13 14 { … … 34 35 psFits *inFile = psFitsOpen(filenames->data[i], "r"); // The FITS file to read 35 36 if (!inFile) { 36 ps ErrorPrint(PS_ERR_IO, false, "Unable to open input file %s --- ignored.\n", name);37 psLogMsg(__func__, PS_LOG_WARN, "Unable to open input file %s --- ignored.\n", name); 37 38 // Kick it out 38 39 psFree(filenames->data[i]); … … 51 52 data->format = pmConfigCameraFormatFromHeader(config, header); 52 53 psFree(header); 53 if (! options->format) {54 if (!data->format) { 54 55 psLogMsg(__func__, PS_LOG_WARN, "Unable to identify camera format for input file %s --- " 55 56 "ignored.\n", name); … … 59 60 continue; 60 61 } 61 } else if (!pmConfigValidateCameraFormat( options->format, header)) {62 } else if (!pmConfigValidateCameraFormat(data->format, header)) { 62 63 psLogMsg(__func__, PS_LOG_WARN, "Input file %s doesn't match camera format --- ignored.\n", name); 63 64 // Kick it out … … 99 100 data->numCells = numCells; 100 101 101 return (numGood > 1); 102 if (numGood > 1) { 103 return data; 104 } 105 106 psFree(data); 107 return NULL; 102 108 } 103 109 -
trunk/ppMerge/src/ppMergeCheckInputs.h
r7064 r7067 8 8 // Check input files to make sure everything's consistent 9 9 ppMergeData *ppMergeCheckInputs(ppMergeOptions *options, // Options 10 constpmConfig *config // Configuration10 pmConfig *config // Configuration 11 11 ); 12 12 -
trunk/ppMerge/src/ppMergeCombine.c
r7061 r7067 4 4 #include <psmodules.h> 5 5 6 #include "ppMerge.h" 6 7 #include "ppMergeData.h" 7 8 #include "ppMergeCombine.h" … … 21 22 // Sanity checks 22 23 assert(!options->scale || scales); 23 assert(!scales || !*scales || ((*scales)->type.type == PS_TYPE_F64 &&24 (*scales)->numCols == data->numCells &&25 (*scales)->numRows == filenames->n));24 assert(!scales || (scales->type.type == PS_TYPE_F64 && 25 scales->numCols == data->numCells && 26 scales->numRows == filenames->n)); 26 27 assert(!options->zero || zeros); 27 assert(!zeros || !*zeros || ((*zeros)->type.type == PS_TYPE_F64 &&28 (*zeros)->numCols == data->numCells &&29 (*zeros)->numRows == filenames->n));28 assert(!zeros || (zeros->type.type == PS_TYPE_F64 && 29 zeros->numCols == data->numCells && 30 zeros->numRows == filenames->n)); 30 31 31 32 // Iterate over the FPA … … 38 39 continue; 39 40 } 40 pmChipWrite(chip, outFile, config->database, false);41 pmChipWrite(chip, data->outFile, config->database, false); 41 42 psArray *cells = chip->cells; // Array of output cells 42 43 for (int j = 0; j < cells->n; j++) { … … 46 47 } 47 48 cellNum++; 48 pmCellWrite(cell, outFile, config->database, false);49 pmCellWrite(cell, data->outFile, config->database, false); 49 50 pmReadout *readout = pmReadoutAlloc(cell); // Output readout of interest 50 51 psArray *stack = psArrayAlloc(filenames->n); // Stack of readouts to combine … … 53 54 cellScales = psImageCol(NULL, scales, cellNum); 54 55 } 55 psVector cellZeros = NULL; // Zeros for this cell56 psVector *cellZeros = NULL; // Zeros for this cell 56 57 if (zeros) { 57 58 cellZeros = psImageCol(NULL, zeros, cellNum); … … 81 82 82 83 // Only reading and writing the first readout in each cell (plane 0) 83 stillReading |= pmReadoutReadNext(stack->data[k], fits, 0, options->rows);84 stillReadingRows |= pmReadoutReadNext(stack->data[k], fits, 0, options->rows); 84 85 psFitsClose(fits); 85 86 } 86 87 87 pmReadoutCombine(readout, stack, cellZeros, cellScales, combineParams);88 pmReadoutWriteNext(readout, outFile, 0);88 pmReadoutCombine(readout, stack, cellZeros, cellScales, options->combine); 89 pmReadoutWriteNext(readout, data->outFile, 0); 89 90 90 91 } while (stillReadingRows); 91 92 92 93 // Write the pixels 93 pmCellWrite(cell, outFile, config->database, true);94 pmCellWrite(cell, data->outFile, config->database, true); 94 95 95 96 // Blow away the cell data … … 104 105 105 106 // Write the pixels 106 pmChipWrite(chip, outFile, config->database, true);107 pmChipWrite(chip, data->outFile, config->database, true); 107 108 108 109 // Blow away the chip data … … 117 118 118 119 // Write the pixels 119 pmFPAWrite( fpa,outFile, config->database, true);120 pmFPAWrite(data->out, data->outFile, config->database, true); 120 121 121 122 // Blow away the FPA data … … 124 125 pmFPAFreeData(fpaIn); 125 126 } 126 pmFPAFreeData( fpa);127 pmFPAFreeData(data->out); 127 128 128 129 return true; -
trunk/ppMerge/src/ppMergeConfig.c
r7002 r7067 3 3 #include <psmodules.h> 4 4 5 #include "ppMerge.h" 5 6 #include "ppMergeConfig.h" 6 7 -
trunk/ppMerge/src/ppMergeData.c
r7061 r7067 2 2 #include <pslib.h> 3 3 4 #include "ppMerge.h" 4 5 #include "ppMergeData.h" 5 6 … … 20 21 { 21 22 ppMergeData *data = psAlloc(sizeof(ppMergeData)); // The data, to return 22 psMemSet FreeFunction(data, (psFreeFunc)mergeDataFree);23 psMemSetDeallocator(data, (psFreeFunc)mergeDataFree); 23 24 24 25 data->format = NULL; -
trunk/ppMerge/src/ppMergeOptions.c
r7061 r7067 2 2 #include <pslib.h> 3 3 #include <psmodules.h> 4 5 #include "ppMerge.h" 6 #include "ppMergeOptions.h" 4 7 5 8 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// … … 7 10 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 8 11 9 #if 010 12 // Free function 11 13 static void mergeOptionsFree(ppMergeOptions *options // Options to free 12 14 ) 13 15 { 16 psFree(options->combine); 14 17 } 15 #endif16 18 17 19 // Allocator … … 19 21 { 20 22 ppMergeOptions *options = psAlloc(sizeof(ppMergeOptions)); // The options, to return 21 //psMemSetDeallocator(options, (psFreeFunc)mergeOptionsFree);23 psMemSetDeallocator(options, (psFreeFunc)mergeOptionsFree); 22 24 23 25 options->rows = 0; … … 29 31 options->background = PS_STAT_SAMPLE_MEDIAN; 30 32 options->onOff = 0; 31 options->combine = PS_STAT_SAMPLE_MEAN;32 options-> ref= 3.0;33 options-> iter = 1;34 options-> fracHigh = 0.0;35 options-> fracLow = 0.0;36 options-> nKeep = 1;37 options-> maskVal = 0xffff;33 options->combine = pmCombineParamsAlloc(PS_STAT_SAMPLE_MEAN); 34 options->combine->rej = 3.0; 35 options->combine->iter = 1; 36 options->combine->fracHigh = 0.0; 37 options->combine->fracLow = 0.0; 38 options->combine->nKeep = 1; 39 options->combine->maskVal = 0xff; 38 40 39 41 return options; … … 84 86 85 87 // Parse the options 86 ppMergeOptions *ppMergeOptionsParse(p pConfig *config // Configuration88 ppMergeOptions *ppMergeOptionsParse(pmConfig *config // Configuration 87 89 ) 88 90 { 89 91 ppMergeOptions *options = ppMergeOptionsAlloc(); // The merge options 90 92 93 bool mdok = true; // Status of MD lookup 94 psMetadata *recipe = psMetadataLookupMD(&mdok, config->recipes, RECIPENAME); // Recipe information 95 if (!mdok || !recipe) { 96 psError(PS_ERR_IO, true, "Unable to find recipe %s", RECIPENAME); 97 exit(EXIT_FAILURE); 98 } 99 91 100 // First, deal with the recipe. These are parameters that will typically be constant for a camera. 92 OPTION_PARSE(options->rows, config->recipe, "ROWS", U16 );93 OPTION_PARSE(options->minElectrons, config->recipe, "ELECTRONS", F32 );94 OPTION_PARSE(options->sample, config->recipe, "SAMPLE", S32 );95 OPTION_PARSE(options-> rej, config->recipe, "REJ", F32 );96 OPTION_PARSE(options-> iter, config->recipe, "ITER", S32 );97 OPTION_PARSE(options-> fracHigh, config->recipe, "FRACHIGH", F32 );98 OPTION_PARSE(options-> fracLow, config->recipe, "FRACLOW", F32 );99 OPTION_PARSE(options-> nKeep, config->recipe, "NKEEP", S32 );100 OPTION_PARSE(options-> maskVal, config->recipe, "MASKVAL", U8 );101 options->combine = parseStat(config->recipe, "COMBINE");102 options->background = parseStat(config->recipe, "BACKGROUND");101 OPTION_PARSE(options->rows, recipe, "ROWS", U16 ); 102 OPTION_PARSE(options->minElectrons, recipe, "ELECTRONS", F32 ); 103 OPTION_PARSE(options->sample, recipe, "SAMPLE", S32 ); 104 OPTION_PARSE(options->combine->rej, recipe, "REJ", F32 ); 105 OPTION_PARSE(options->combine->iter, recipe, "ITER", S32 ); 106 OPTION_PARSE(options->combine->fracHigh, recipe, "FRACHIGH", F32 ); 107 OPTION_PARSE(options->combine->fracLow, recipe, "FRACLOW", F32 ); 108 OPTION_PARSE(options->combine->nKeep, recipe, "NKEEP", S32 ); 109 OPTION_PARSE(options->combine->maskVal, recipe, "MASKVAL", U8 ); 110 options->combine->combine = parseStat(recipe, "COMBINE"); 111 options->background = parseStat(recipe, "BACKGROUND"); 103 112 104 113 // Now the command-line options. These are parameters that depend on what type of frame is being combined … … 127 136 128 137 // Or you can set them individually 129 OPTION_PARSE(options->zero, config-> recipe, "-zero", Bool);130 OPTION_PARSE(options->scale, config-> recipe, "-scale", Bool);131 OPTION_PARSE(options->exptime, config-> recipe, "-exptime", Bool);138 OPTION_PARSE(options->zero, config->arguments, "-zero", Bool); 139 OPTION_PARSE(options->scale, config->arguments, "-scale", Bool); 140 OPTION_PARSE(options->exptime, config->arguments, "-exptime", Bool); 132 141 133 142 // Number of on/off images 134 OPTION_PARSE(options->on off, config->recipe, "-onoff", S32);143 OPTION_PARSE(options->onOff, config->arguments, "-onoff", S32); 135 144 136 145 return options; -
trunk/ppMerge/src/ppMergeOptions.h
r7064 r7067 24 24 psStatsOptions background; // Statistic to use to measure the background 25 25 ppOnOff onOff; // On/off pairs? 26 psStatsOptions combine; // Statistic to use in combination 27 float rej; // Rejection level in combination (for sigma clipping) 28 unsigned int iter; // Number of iterations for combination (for sigma clipping) 29 float fracHigh; // Fraction of high pixels to throw 30 float fracLow; // Fraction of low pixels to throw 31 int nKeep; // Minimum number of pixels to keep 32 psMaskType maskVal; // Mask value 26 pmCombineParams *combine; // Combination parameters 33 27 } ppMergeOptions; 34 28 35 29 // Allocator 36 ppMergeOptions *ppMergeOptionsAlloc(psStatsOptions stat // Statistic to use in the merge 37 ); 30 ppMergeOptions *ppMergeOptionsAlloc(void); 38 31 39 32
Note:
See TracChangeset
for help on using the changeset viewer.
