Changeset 3610 for trunk/stac/src/stacConfig.c
- Timestamp:
- Mar 31, 2005, 5:07:12 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/stac/src/stacConfig.c (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/stac/src/stacConfig.c
r3387 r3610 9 9 { 10 10 fprintf (stderr, "STAC: Simultaneous Telescope Array Combination\n" 11 "Usage: %s [-h] [-v] [-g GAIN] [-r RN] [-o NX NY] [- s SAT] [-b BAD] [-k REJ] [-n NREJECT] [-k FRAC] [-G GRAD] OUT IN1 IN2...\n"11 "Usage: %s [-h] [-v] [-g GAIN] [-r RN] [-o NX NY] [-S] [-s SAT] [-b BAD] [-p FILE MAP] [-a APER] [-k REJ] [-n NREJECT] [-k FRAC] [-G GRAD] OUT IN1 IN2...\n" 12 12 "where\n" 13 13 "\t-h Help (this info)\n" … … 16 16 "\t-r Read noise (e) for detectors\n" 17 17 "\t-o NX NY Size of output image (512, 512)\n" 18 "\t-s SAT Saturation level (65536)\n" 18 "\t-S Save shifted images (false)\n" 19 "\t-s SAT Saturation level (65535)\n" 19 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 size to use for photometry (3 pix)\n" 20 23 "\t-k REJ Rejection level (k-sigma; 3.5)\n" 21 24 "\t-n NREJECT Number of rejection iterations (2)\n" … … 39 42 config->inputs = NULL; 40 43 config->output = NULL; 44 config->saveShifts = false; 45 config->starFile = NULL; 46 config->starMapFile = NULL; 47 config->aper = 3.0; 41 48 config->outnx = 512; 42 49 config->outny = 512; 43 config->saturated = 65535.0;44 config->bad = 0.0;50 config->saturated = NULL; // Saturations; will fill this in later, when we know how many images 51 config->bad = NULL; // Bad levels; will fill this in later, when we know how many images 45 52 config->reject = 3.0; 46 53 config->frac = 0.5; … … 54 61 void stacConfigFree(stacConfig *config) 55 62 { 56 // Free the vector , if necessary63 // Free the vectors, if necessary 57 64 if (config->inputs) { 58 65 psFree(config->inputs); 66 } 67 if (config->saturated) { 68 psFree(config->saturated); 69 } 70 if (config->bad) { 71 psFree(config->bad); 59 72 } 60 73 // Free everything … … 69 82 stacConfig *config = stacConfigAlloc(); // Configuration values 70 83 const char *programName = argv[0]; // Program name 84 85 float saturated = 65535.0; // Saturation level 86 float bad = 0.0; // Bad level 71 87 72 88 /* Variables for getopt */ … … 76 92 77 93 /* Parse command-line arguments using getopt */ 78 while ((opt = getopt(argc, argv, "hv g:r:o:s:b:k:n:f:G:")) != -1) {94 while ((opt = getopt(argc, argv, "hvSg:r:o:s:b:k:n:f:G:p:a:")) != -1) { 79 95 switch (opt) { 80 96 case 'h': … … 87 103 if (sscanf(optarg, "%f", &config->gain) != 1) { 88 104 help(programName); 105 exit(EXIT_FAILURE); 89 106 } 90 107 break; … … 92 109 if (sscanf(optarg, "%f", &config->readnoise) != 1) { 93 110 help(programName); 111 exit(EXIT_FAILURE); 94 112 } 95 113 break; … … 97 115 if ((sscanf(argv[optind-1], "%d", &config->outnx) != 1) || 98 116 (sscanf(argv[optind++], "%d", &config->outny) != 1)) { 99 /* 100 Note: incrementing optind, so I can read more than 101 one parameter. 102 */ 117 // Note: incrementing optind, so I can read more than one parameter. 103 118 help(programName); 104 119 exit(EXIT_FAILURE); … … 106 121 break; 107 122 case 's': 108 if (sscanf(optarg, "%f", &config->saturated) != 1) { 109 help(programName); 123 if (sscanf(optarg, "%f", &saturated) != 1) { 124 help(programName); 125 exit(EXIT_FAILURE); 110 126 } 111 127 break; 112 128 case 'b': 113 if (sscanf(optarg, "%f", &config->bad) != 1) { 114 help(programName); 129 if (sscanf(optarg, "%f", &bad) != 1) { 130 help(programName); 131 exit(EXIT_FAILURE); 132 } 133 break; 134 case 'p': 135 if (argc < optind+1) { 136 help(programName); 137 exit(EXIT_FAILURE); 138 } 139 config->starFile = argv[optind-1]; 140 config->starMapFile = argv[optind++]; 141 // Note: incrementing optind, so I can read more than one parameter. 142 break; 143 case 'a': 144 if (sscanf(optarg, "%f", &config->aper) != 1) { 145 help(programName); 146 exit(EXIT_FAILURE); 115 147 } 116 148 break; … … 118 150 if (sscanf(optarg, "%f", &config->reject) != 1) { 119 151 help(programName); 152 exit(EXIT_FAILURE); 120 153 } 121 154 break; … … 123 156 if (sscanf(optarg, "%d", &config->nReject) != 1) { 124 157 help(programName); 158 exit(EXIT_FAILURE); 125 159 } 126 160 break; … … 128 162 if (sscanf(optarg, "%f", &config->frac) != 1) { 129 163 help(programName); 164 exit(EXIT_FAILURE); 130 165 } 131 166 break; … … 133 168 if (sscanf(optarg, "%f", &config->grad) != 1) { 134 169 help(programName); 135 } 170 exit(EXIT_FAILURE); 171 } 172 break; 173 case 'S': 174 config->saveShifts = true; 136 175 break; 137 176 default: … … 156 195 } 157 196 197 // Create the saturation and bad vectors 198 config->saturated = psVectorAlloc(argc-1, PS_TYPE_F32); 199 config->bad = psVectorAlloc(argc-1, PS_TYPE_F32); 200 for (int i = 0; i < argc - 1; i++) { 201 ((psVector*)config->saturated)->data.F32[i] = saturated; 202 ((psVector*)config->bad)->data.F32[i] = bad; 203 } 204 158 205 // Debugging output 159 206 psTrace("stac.config", 8, "Parsed command line for configuration\n");
Note:
See TracChangeset
for help on using the changeset viewer.
