Changeset 7073 for trunk/ppMerge/src
- Timestamp:
- May 4, 2006, 5:37:16 PM (20 years ago)
- Location:
- trunk/ppMerge/src
- Files:
-
- 6 edited
-
ppMergeCheckInputs.c (modified) (4 diffs)
-
ppMergeConfig.c (modified) (4 diffs)
-
ppMergeData.c (modified) (2 diffs)
-
ppMergeData.h (modified) (1 diff)
-
ppMergeOptions.c (modified) (3 diffs)
-
ppMergeOptions.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppMerge/src/ppMergeCheckInputs.c
r7067 r7073 49 49 // FPAview from the specified camera format configuration, and use pmFPAAddSourceFromView), but for 50 50 // now it's less hassle just to limit the output format to be the input format. 51 if (! data->format) {52 data->format = pmConfigCameraFormatFromHeader(config, header);51 if (!options->format) { 52 options->format = pmConfigCameraFormatFromHeader(config, header); 53 53 psFree(header); 54 if (! data->format) {54 if (!options->format) { 55 55 psLogMsg(__func__, PS_LOG_WARN, "Unable to identify camera format for input file %s --- " 56 56 "ignored.\n", name); … … 60 60 continue; 61 61 } 62 } else if (!pmConfigValidateCameraFormat( data->format, header)) {62 } else if (!pmConfigValidateCameraFormat(options->format, header)) { 63 63 psLogMsg(__func__, PS_LOG_WARN, "Input file %s doesn't match camera format --- ignored.\n", name); 64 64 // Kick it out … … 69 69 70 70 data->in->data[i] = pmFPAConstruct(config->camera); 71 pmFPAview *view = pmFPAAddSourceFromHeader(data->in->data[i], header, data->format);71 pmFPAview *view = pmFPAAddSourceFromHeader(data->in->data[i], header, options->format); 72 72 psFree(view); 73 73 … … 75 75 if (!data->out) { 76 76 data->out = pmFPAConstruct(config->camera); 77 pmFPAview *view = pmFPAAddSourceFromHeader(data->out, header, data->format);77 pmFPAview *view = pmFPAAddSourceFromHeader(data->out, header, options->format); 78 78 psFree(view); 79 79 } -
trunk/ppMerge/src/ppMergeConfig.c
r7067 r7073 7 7 8 8 // Output usage information 9 static void usage(const char *programName // Name of the program 9 static void usage(const char *programName, // Name of the program 10 pmConfig *config // Configuration (contains the arguments list) 10 11 ) 11 12 { 12 13 printf("Merge multiple calibration frames into a master frame by stacking.\n\n" 13 14 "Usage:\n" 14 "\t%s OUTPUT.fits [-files FILES] [-list FILE_LIST]\n\n" 15 "where:\n" 16 "FILES is a glob to be interpreted by the program.\n" 17 "FILE_LIST is a list of files (including a glob interpreted by the shell).\n" 15 "\t%s OUTPUT.fits INPUT1.fits INPUT2.fits ...\n" 18 16 "\n", programName); 17 psArgumentHelp(config->arguments); 19 18 exit(EXIT_FAILURE); 20 19 } … … 22 21 pmConfig *ppMergeConfig(int *argc, char **argv) 23 22 { 24 if (*argc == 1) { 25 usage(argv[0]); 23 pmConfig *config = pmConfigRead(argc, argv); 24 // Load the site-wide configuration information 25 if (! config) { 26 psErrorStackPrint(stderr, "Can't find site configuration!\n"); 27 exit(EXIT_FAILURE); 26 28 } 27 29 28 // Load the site-wide configuration information 29 pmConfig *config = pmConfigRead(argc, argv); 30 if (! config) { 31 psErrorStackPrint(stderr, "Can't find site configuration!\n"); 32 usage(argv[0]); 33 } 34 35 // Parse other command-line arguments, save for future use 30 // Command-line arguments 36 31 config->arguments = psMetadataAlloc(); // The arguments, with default values 37 32 psMetadataAddStr(config->arguments, PS_LIST_TAIL, "-type", 0, "Type of calibration frame", ""); … … 41 36 psMetadataAddS32(config->arguments, PS_LIST_TAIL, "-onoff", 0, "Number of on/off pairs", 0); 42 37 38 if (*argc == 1) { 39 usage(argv[0], config); 40 } 41 43 42 // Parse the arguments 44 if (! psArgumentParse(config->arguments, argc, argv) || *argc != 2) {45 usage(argv[0] );43 if (! psArgumentParse(config->arguments, argc, argv) || *argc < 3) { 44 usage(argv[0], config); 46 45 } 47 46 … … 56 55 psArray *files = psArrayAlloc(*argc - 2); 57 56 for (int i = 2; i < *argc; i++) { 58 files->data[i ] = psStringCopy(argv[i]);57 files->data[i - 2] = psStringCopy(argv[i]); 59 58 } 59 files->n = *argc - 2; 60 60 psMetadataAddPtr(config->arguments, PS_LIST_TAIL, "INPUT", PS_DATA_ARRAY, 61 61 "Array of inputs images", files); -
trunk/ppMerge/src/ppMergeData.c
r7067 r7073 9 9 ) 10 10 { 11 psFree(data->format);12 11 psFree(data->in); 13 12 psFree(data->out); … … 23 22 psMemSetDeallocator(data, (psFreeFunc)mergeDataFree); 24 23 25 data->format = NULL;26 24 data->numCells = 0; 27 25 data->in = NULL; -
trunk/ppMerge/src/ppMergeData.h
r7064 r7073 7 7 // Container for the data 8 8 typedef struct { 9 psMetadata *format; // The camera format for the input and output10 9 int numCells; // Number of (valid) cells in the FPA 11 10 psArray *in; // Input FPA structures -
trunk/ppMerge/src/ppMergeOptions.c
r7067 r7073 14 14 ) 15 15 { 16 psFree(options->format); 16 17 psFree(options->combine); 17 18 } … … 23 24 psMemSetDeallocator(options, (psFreeFunc)mergeOptionsFree); 24 25 26 options->format = NULL; 25 27 options->rows = 0; 26 28 options->minElectrons = NAN; … … 91 93 ppMergeOptions *options = ppMergeOptionsAlloc(); // The merge options 92 94 95 // We need to work out the camera before we can get the recipe. Take the first input and inspect it. 96 if (!config->camera) { 97 psArray *filenames = psMetadataLookupPtr(NULL, config->arguments, "INPUT"); // The input file names 98 psFits *inFile = psFitsOpen(filenames->data[0], "r"); // The FITS file to read 99 if (!inFile) { 100 psError(PS_ERR_IO, false, "Unable to open input file %s to determine camera.\n", 101 filenames->data[0]); 102 exit(EXIT_FAILURE); 103 } 104 psMetadata *header = psFitsReadHeader(NULL, inFile); // The FITS (primary) header 105 psFitsClose(inFile); 106 107 options->format = pmConfigCameraFormatFromHeader(config, header); 108 psFree(header); 109 if (!options->format) { 110 psLogMsg(__func__, PS_LOG_WARN, "Unable to identify camera format for input file %s\n", 111 filenames->data[0]); 112 exit(EXIT_FAILURE); 113 } 114 } 115 116 // Get the recipes 117 if (!config->recipes && !pmConfigReadRecipes(config)) { 118 psError(PS_ERR_IO, false, "Unable to read recipes.\n"); 119 exit(EXIT_FAILURE); 120 } 121 122 // Now we can read the recipe 93 123 bool mdok = true; // Status of MD lookup 94 124 psMetadata *recipe = psMetadataLookupMD(&mdok, config->recipes, RECIPENAME); // Recipe information -
trunk/ppMerge/src/ppMergeOptions.h
r7067 r7073 16 16 // Options for ppMerge 17 17 typedef struct { 18 psMetadata *format; // Camera format configuration 18 19 unsigned int rows; // Number of rows to read at once 19 20 float minElectrons; // Minimum number of electrons for useful signal
Note:
See TracChangeset
for help on using the changeset viewer.
