Changeset 6887 for trunk/stac/src/combineConfig.c
- Timestamp:
- Apr 18, 2006, 12:20:45 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/stac/src/combineConfig.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/stac/src/combineConfig.c
r3680 r6887 11 11 { 12 12 fprintf (stderr, "shift: shift an image, given the transformation\n" 13 "Usage: %s [-h] [-v] [-g GAIN] [-r READNOISE] [-s SAT] [-b BAD] [-p FILE MAP] [-a APER] [-k SIGMAREJ] [-n NREJECT] OUT IN1 IN2...\n"14 "where\n"15 "\t-h Help (this info)\n"16 "\t-v Increase verbosity level\n"17 "\t-g GAIN Gain in e/ADU (1.0)\n"18 "\t-r READNOISE Read noise in e (0.0)\n"19 "\t-s SAT Saturation point (65535)\n"20 "\t-b BAD Bad level (0)\n"21 "\t-p FILE MAP Specify file containing star coordinates, with map\n"22 "\t-a APER Aperture radius for photometry (3.0)\n"23 "\t-k SIGMAREJ k-sigma rejection threshold (3.0)\n"24 "\t-n NREJECT Number of rejection iterations (1)\n"25 "\tOUT Output image\n"26 "\tIN1 IN2... Input images (identical size)\n",27 programName28 );13 "Usage: %s [-h] [-v] [-g GAIN] [-r READNOISE] [-s SAT] [-b BAD] [-p FILE MAP] [-a APER] [-k SIGMAREJ] [-n NREJECT] OUT IN1 IN2...\n" 14 "where\n" 15 "\t-h Help (this info)\n" 16 "\t-v Increase verbosity level\n" 17 "\t-g GAIN Gain in e/ADU (1.0)\n" 18 "\t-r READNOISE Read noise in e (0.0)\n" 19 "\t-s SAT Saturation point (65535)\n" 20 "\t-b BAD Bad level (0)\n" 21 "\t-p FILE MAP Specify file containing star coordinates, with map\n" 22 "\t-a APER Aperture radius for photometry (3.0)\n" 23 "\t-k SIGMAREJ k-sigma rejection threshold (3.0)\n" 24 "\t-n NREJECT Number of rejection iterations (1)\n" 25 "\tOUT Output image\n" 26 "\tIN1 IN2... Input images (identical size)\n", 27 programName 28 ); 29 29 } 30 30 … … 35 35 36 36 // Parameters with default values 37 config->verbose = 0; // Verbosity level38 config->gain = 1.0; // Gain (e/ADU)39 config->readnoise = 0.0; // Read noise (e)40 config->reject = 4.0; // Rejection threshold (sigma)41 config->nReject = 1; // Number of rejection iterations42 config->saturated = 65535.0; // Saturation level43 config->bad = 0.0; // Bad level44 config->outName = NULL; // Output name45 config->inNames = NULL; // Input names;46 config->starFile = NULL; // Filename of file containing stars47 config->starMap = NULL; // Map for stars48 config->aper = 3.0; // Aperture for photometry37 config->verbose = 0; // Verbosity level 38 config->gain = 1.0; // Gain (e/ADU) 39 config->readnoise = 0.0; // Read noise (e) 40 config->reject = 4.0; // Rejection threshold (sigma) 41 config->nReject = 1; // Number of rejection iterations 42 config->saturated = 65535.0; // Saturation level 43 config->bad = 0.0; // Bad level 44 config->outName = NULL; // Output name 45 config->inNames = NULL; // Input names; 46 config->starFile = NULL; // Filename of file containing stars 47 config->starMap = NULL; // Map for stars 48 config->aper = 3.0; // Aperture for photometry 49 49 50 50 return config; … … 62 62 combineConfig *config = combineConfigAlloc(); // Configuration 63 63 64 const char *programName = argv[0]; // Program name64 const char *programName = argv[0]; // Program name 65 65 66 66 /* Variables for getopt */ … … 72 72 while ((opt = getopt(argc, argv, "hvg:r:s:b:p:a:k:n:")) != -1) { 73 73 switch (opt) { 74 case 'h':75 help(programName);76 exit(EXIT_SUCCESS);77 case 'v':74 case 'h': 75 help(programName); 76 exit(EXIT_SUCCESS); 77 case 'v': 78 78 config->verbose++; 79 79 break; 80 case 'r':80 case 'r': 81 81 if (sscanf(optarg, "%f", &config->readnoise) != 1) { 82 printf("Unable to read readnoise.\n"); 83 help(programName); 84 exit(EXIT_FAILURE); 85 } 86 break; 87 case 'g': 88 if (sscanf(optarg, "%f", &config->gain) != 1) { 89 printf("Unable to read gain.\n"); 90 help(programName); 91 exit(EXIT_FAILURE); 92 } 93 break; 94 case 's': 95 if (sscanf(optarg, "%f", &config->saturated) != 1) { 96 printf("Unable to read saturation limit.\n"); 97 help(programName); 98 exit(EXIT_FAILURE); 99 } 100 break; 101 case 'b': 102 if (sscanf(optarg, "%f", &config->bad) != 1) { 103 printf("Unable to read bad limit.\n"); 104 help(programName); 105 exit(EXIT_FAILURE); 106 } 107 break; 108 case 'p': 109 if (argc < optind+1) { 110 printf("Unable to read photometric files.\n"); 111 help(programName); 112 exit(EXIT_FAILURE); 113 } 114 config->starFile = argv[optind-1]; 115 config->starMap = argv[optind++]; 116 // Note: incrementing optind, so I can read more than one parameter. 117 break; 118 case 'a': 119 if (sscanf(optarg, "%f", &config->aper) != 1) { 120 printf("Unable to read aperture.\n"); 82 printf("Unable to read readnoise.\n"); 121 83 help(programName); 122 84 exit(EXIT_FAILURE); 123 85 } 124 break;125 case 'k':126 if (sscanf(optarg, "%f", &config-> reject) != 1) {127 printf("Unable to read rejection limit.\n");86 break; 87 case 'g': 88 if (sscanf(optarg, "%f", &config->gain) != 1) { 89 printf("Unable to read gain.\n"); 128 90 help(programName); 129 91 exit(EXIT_FAILURE); 130 92 } 131 break;132 case 'n':133 if (sscanf(optarg, "% d", &config->nReject) != 1) {134 printf("Unable to read number of rejection iterations.\n");135 help(programName);93 break; 94 case 's': 95 if (sscanf(optarg, "%f", &config->saturated) != 1) { 96 printf("Unable to read saturation limit.\n"); 97 help(programName); 136 98 exit(EXIT_FAILURE); 137 99 } 138 break; 139 default: 140 printf("Bad option: %c\n", opt); 141 help(programName); 142 exit(EXIT_FAILURE); 143 } 100 break; 101 case 'b': 102 if (sscanf(optarg, "%f", &config->bad) != 1) { 103 printf("Unable to read bad limit.\n"); 104 help(programName); 105 exit(EXIT_FAILURE); 106 } 107 break; 108 case 'p': 109 if (argc < optind+1) { 110 printf("Unable to read photometric files.\n"); 111 help(programName); 112 exit(EXIT_FAILURE); 113 } 114 config->starFile = argv[optind-1]; 115 config->starMap = argv[optind++]; 116 // Note: incrementing optind, so I can read more than one parameter. 117 break; 118 case 'a': 119 if (sscanf(optarg, "%f", &config->aper) != 1) { 120 printf("Unable to read aperture.\n"); 121 help(programName); 122 exit(EXIT_FAILURE); 123 } 124 break; 125 case 'k': 126 if (sscanf(optarg, "%f", &config->reject) != 1) { 127 printf("Unable to read rejection limit.\n"); 128 help(programName); 129 exit(EXIT_FAILURE); 130 } 131 break; 132 case 'n': 133 if (sscanf(optarg, "%d", &config->nReject) != 1) { 134 printf("Unable to read number of rejection iterations.\n"); 135 help(programName); 136 exit(EXIT_FAILURE); 137 } 138 break; 139 default: 140 printf("Bad option: %c\n", opt); 141 help(programName); 142 exit(EXIT_FAILURE); 143 } 144 144 } 145 145 … … 151 151 exit(EXIT_FAILURE); 152 152 } 153 config->outName = argv[0]; // Output filename153 config->outName = argv[0]; // Output filename 154 154 config->inNames = psArrayAlloc(argc-1); // Input filenames 155 config->inNames->n = argc-1; 155 156 for (int i = 1; i < argc; i++) { 156 config->inNames->data[i-1] = psAlloc(strlen(argv[i]));157 strncpy(config->inNames->data[i-1], argv[i], strlen(argv[i]));157 config->inNames->data[i-1] = psAlloc(strlen(argv[i])); 158 strncpy(config->inNames->data[i-1], argv[i], strlen(argv[i])); 158 159 } 159 160
Note:
See TracChangeset
for help on using the changeset viewer.
