Changeset 6887 for trunk/stac/src/shiftSize.c
- Timestamp:
- Apr 18, 2006, 12:20:45 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/stac/src/shiftSize.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/stac/src/shiftSize.c
r5743 r6887 17 17 { 18 18 fprintf (stderr, "shiftSize: Calculate size for output combined image\n" 19 "Usage: %s [-h] [-v] IN1 IN2...\n"20 "where\n"21 "\t-h Help (this info)\n"22 "\t-v Increase verbosity level\n"23 "\tIN1, IN2... Input images, which have associated .map files.\n",24 name25 );19 "Usage: %s [-h] [-v] IN1 IN2...\n" 20 "where\n" 21 "\t-h Help (this info)\n" 22 "\t-v Increase verbosity level\n" 23 "\tIN1, IN2... Input images, which have associated .map files.\n", 24 name 25 ); 26 26 } 27 27 … … 41 41 42 42 43 int verbose = 0; // Verbosity level43 int verbose = 0; // Verbosity level 44 44 45 45 // Parse command line 46 const char *programName = argv[0]; // Program name46 const char *programName = argv[0]; // Program name 47 47 /* Variables for getopt */ 48 48 int opt; /* Option, from getopt */ … … 53 53 while ((opt = getopt(argc, argv, "hv")) != -1) { 54 54 switch (opt) { 55 case 'h':56 help(programName);57 exit(EXIT_SUCCESS);58 case 'v':55 case 'h': 56 help(programName); 57 exit(EXIT_SUCCESS); 58 case 'v': 59 59 verbose++; 60 60 break; 61 default:62 help(programName);63 }61 default: 62 help(programName); 63 } 64 64 } 65 65 … … 73 73 74 74 psArray *inputs = psArrayAlloc(argc); // Input filenames 75 inputs->n = argc; 75 76 for (int i = 0; i < argc; i++) { 76 inputs->data[i] = psAlloc(strlen(argv[i])); 77 strncpy(inputs->data[i], argv[i], strlen(argv[i])); 77 inputs->data[i] = psAlloc(strlen(argv[i])); 78 strncpy(inputs->data[i], argv[i], strlen(argv[i])); 79 psTrace("stac.size", 8, "Input file: %s\n", inputs->data[i]); 78 80 } 79 81 80 82 // Read input files 81 psArray *images = stacReadImages(NULL, inputs); 83 psVector *xSize = psVectorAlloc(inputs->n, PS_TYPE_S32); 84 psVector *ySize = psVectorAlloc(inputs->n, PS_TYPE_S32); 85 xSize->n = inputs->n; 86 ySize->n = inputs->n; 87 for (int i = 0; i < inputs->n; i++) { 88 const char *filename = inputs->data[i]; // Name of FITS file 89 psFits *file = psFitsOpen(filename, "r"); // FITS file handle 90 psMetadata *header = psFitsReadHeader(NULL, file); // FITS header 91 psFitsClose(file); 92 bool mdok = true; // Status of MD lookup 93 xSize->data.S32[i] = psMetadataLookupS32(&mdok, header, "NAXIS1"); 94 if (!mdok) { 95 psError(PS_ERR_IO, true, "Unable to find NAXIS1 in %s\n", filename); 96 exit(EXIT_FAILURE); 97 } 98 ySize->data.S32[i] = psMetadataLookupS32(&mdok, header, "NAXIS2"); 99 if (!mdok) { 100 psError(PS_ERR_IO, true, "Unable to find NAXIS2 in %s\n", filename); 101 exit(EXIT_FAILURE); 102 } 103 psFree(header); 104 } 82 105 83 106 // Read maps … … 85 108 86 109 // Get size 87 int outnx, outny; // Size of combined image 88 float xMapDiff, yMapDiff; // Difference to apply to maps 89 stacSize(&outnx, &outny, &xMapDiff, &yMapDiff, images, maps); 110 int outnx, outny; // Size of combined image 111 float xMapDiff, yMapDiff; // Difference to apply to maps 112 stacSize(&outnx, &outny, &xMapDiff, &yMapDiff, xSize, ySize, maps); 113 psFree(xSize); 114 psFree(ySize); 90 115 91 116 printf("%d %d\n", outnx, outny); … … 95 120 96 121 psFree(inputs); 97 psFree(images);98 122 psFree(maps); 99 123
Note:
See TracChangeset
for help on using the changeset viewer.
