Changeset 7061 for trunk/ppMerge/src/ppMergeCheckInputs.c
- Timestamp:
- May 3, 2006, 5:57:35 PM (20 years ago)
- Location:
- trunk/ppMerge/src
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
ppMergeCheckInputs.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppMerge/src
-
Property svn:ignore
set to
.deps
Makefile
Makefile.in
-
Property svn:ignore
set to
-
trunk/ppMerge/src/ppMergeCheckInputs.c
r7002 r7061 5 5 6 6 #include "ppMergeCheckInputs.h" 7 #include "ppMergeData.h" 7 8 8 9 // Check input files to make sure everything's consistent 9 bool ppCheckInputs(const pmConfig *config // Configuration 10 ppMergeData *ppMergeCheckInputs(ppMergeOptions *options, // Options 11 const pmConfig *config // Configuration 10 12 ) 11 13 { 14 ppMergeData *data = ppMergeDataAlloc(); // The data, to return 15 16 // Output file 17 psString outName = psMetadataLookupStr(NULL, config->arguments, "OUTPUT"); // The output file name 18 assert(outName); // It should be there! 19 data->outFile = psFitsOpen(outName, "w"); // Output FITS file 20 if (!data->outFile) { 21 // There's no point in continuing if we can't open the output 22 psErrorStackPrint(stderr, "Can't open output image: %s\n", outName); 23 exit(EXIT_FAILURE); 24 } 25 12 26 psArray *filenames = psMetadataLookupPtr(NULL, config->arguments, "INPUT"); // The input file names 13 27 assert(filenames); … … 27 41 } 28 42 psMetadata *header = psFitsReadHeader(NULL, inFile); // The FITS (primary) header 29 psMetadata *format = pmConfigCameraFormatFromHeader(config, header); // The camera format 30 psFree(header); 31 if (!format) { 32 psErrorPrint(PS_ERR_IO, false, "Unable to identify camera format for input file %s --- " 33 "ignored.\n", name); 43 psFitsClose(inFile); 44 45 // The formats must be identical. The chief reason for this is so that we know what output format to 46 // use. I guess one could specify a different output format on the command line, but how do we 47 // generate a PHU for that? Perhaps we could revisit this restriction in the future (construct an 48 // FPAview from the specified camera format configuration, and use pmFPAAddSourceFromView), but for 49 // now it's less hassle just to limit the output format to be the input format. 50 if (!data->format) { 51 data->format = pmConfigCameraFormatFromHeader(config, header); 52 psFree(header); 53 if (!options->format) { 54 psLogMsg(__func__, PS_LOG_WARN, "Unable to identify camera format for input file %s --- " 55 "ignored.\n", name); 56 // Kick it out 57 psFree(header); 58 data->in->data[i] = NULL; 59 continue; 60 } 61 } else if (!pmConfigValidateCameraFormat(options->format, header)) { 62 psLogMsg(__func__, PS_LOG_WARN, "Input file %s doesn't match camera format --- ignored.\n", name); 34 63 // Kick it out 35 psFree( filenames->data[i]);36 filenames->data[i] = NULL;64 psFree(header); 65 data->in->data[i] = NULL; 37 66 continue; 38 67 } 39 psFitsClose(inFile); 68 69 data->in->data[i] = pmFPAConstruct(config->camera); 70 pmFPAview *view = pmFPAAddSourceFromHeader(data->in->data[i], header, data->format); 71 psFree(view); 72 73 // Use the first valid input as the basis for the output --- including the header 74 if (!data->out) { 75 data->out = pmFPAConstruct(config->camera); 76 pmFPAview *view = pmFPAAddSourceFromHeader(data->out, header, data->format); 77 psFree(view); 78 } 79 40 80 numGood++; 41 81 } 42 82 83 // Count the cells 84 int numCells = 0; // Number of cells in the output FPA 85 psArray *chips = data->out->chips; // Array of chips in output 86 for (int i = 0; i < chips->n; i++) { 87 pmChip *chip = chips->data[i]; // Chip of interest 88 if (!chip) { 89 continue; 90 } 91 psArray *cells = chip->cells; // Array of cells 92 for (int j = 0; j < cells->n; j++) { 93 pmCell *cell = cells->data[j]; 94 if (cell) { 95 numCells++; 96 } 97 } 98 } 99 data->numCells = numCells; 100 43 101 return (numGood > 1); 44 102 } 103 104
Note:
See TracChangeset
for help on using the changeset viewer.
