Changeset 5717 for trunk/pois/src/poisParseConfig.c
- Timestamp:
- Dec 6, 2005, 6:43:52 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/pois/src/poisParseConfig.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pois/src/poisParseConfig.c
r3805 r5717 4 4 #include "pois.h" 5 5 6 staticvoid help(void)6 void help(void) 7 7 { 8 8 fprintf (stderr, "POIS: Pan-STARRS (or Pricey's) Optimal Image Subtraction\n" 9 "Usage: pois [-h] [-v] [-k X Y] [-t T] [-s S1 S2] [-b B AD] [-B BG] [-o N] [-n NSTAMPS] [-i ITER] [-r REJ] REF IN OUT\n"9 "Usage: pois [-h] [-v] [-k X Y] [-t T] [-s S1 S2] [-b B1 B2] [-B BG] [-o N] [-n NSTAMPS] [-S STAMPS] [-i ITER] [-r REJ] [-m] REF IN OUT\n" 10 10 "where\n" 11 11 "\t-h Help (this info)\n" … … 14 14 "\t-t T Threshold for stamps on reference image (0)\n" 15 15 "\t-s S1 S2 Saturation level for reference (S1) and input (S2) (50000)\n" 16 "\t-b B ADBad level for both images (0)\n"16 "\t-b B1 B2 Bad level for both images (0)\n" 17 17 "\t-B BG Level to add to background to get above zero (0)\n" 18 18 "\t-o ORDER Order of spatial variations in the kernel (0)\n" 19 19 "\t-n NSTAMPS Number of stamps in each dimension (5)\n" 20 "\t-S STAMPS File from which to read stamps\n" 21 "\t-R Reverse the sense of the subtraction (REF - IN)\n" 20 22 "\t-i ITER Number of rejection iterations (10)\n" 21 23 "\t-r REJ Rejection level in standard deviations (2.5)\n" 24 "\t-m Output mask frame (OUT.mask)\n" 22 25 "\tREF Reference image\n" 23 26 "\tIN Input image (to be matched to REF)\n" … … 26 29 } 27 30 28 poisConfig *restrict poisConfigAlloc(void) 31 poisConfig *poisParseConfig(int argc, // Number of command-line arguments 32 char **argv // Command-line arguments 33 ) 29 34 { 30 poisConfig *config = (poisConfig *) psAlloc(sizeof(poisConfig)); 35 poisConfig *config; // Configuration values 36 37 /* Variables for getopt */ 38 int opt; /* Option, from getopt */ 39 extern char *optarg; /* Argument accompanying switch */ 40 extern int optind; /* getopt variables */ 41 42 /* Initialise configuration */ 43 config = (poisConfig *) psAlloc(sizeof(poisConfig)); 31 44 config->verbose = 0; 32 45 config->refFile = NULL; … … 39 52 config->refSat = 60000.0; 40 53 config->inSat = 60000.0; 41 config->bad = 0.0; 54 config->refBad = 0.0; 55 config->inBad = 0.0; 42 56 config->background = 0.0; 43 57 config->spatialOrder = 0; … … 47 61 config->sigmaRej = 2.5; 48 62 config->penalty = 0.0; 49 50 return config; 51 } 52 53 54 poisConfig *poisParseConfig(int argc, // Number of command-line arguments 55 char **argv // Command-line arguments 56 ) 57 { 58 poisConfig *config = poisConfigAlloc(); // Configuration values 59 60 /* Variables for getopt */ 61 int opt; /* Option, from getopt */ 62 extern char *optarg; /* Argument accompanying switch */ 63 extern int optind; /* getopt variables */ 64 65 /* Initialise configuration */ 63 config->stampFile = NULL; 64 config->reverse = false; 65 config->mask = false; 66 66 67 67 /* Parse command-line arguments using getopt */ 68 while ((opt = getopt(argc, argv, "hv k:f:q:t:s:o:b:B:n:i:r:p:")) != -1) {68 while ((opt = getopt(argc, argv, "hvRmk:f:q:t:s:o:b:B:n:i:r:p:S:")) != -1) { 69 69 switch (opt) { 70 70 case 'h': … … 115 115 break; 116 116 case 'b': 117 if (sscanf(optarg, "%f", &config->bad) != 1) { 118 help(); 117 if ((sscanf(argv[optind-1], "%f", &config->refBad) != 1) || 118 (sscanf(argv[optind++], "%f", &config->inBad) != 1)) { 119 /* 120 Note: incrementing optind, so I can read more than 121 one parameter. 122 */ 123 help(); 119 124 exit(EXIT_FAILURE); 120 }125 } 121 126 break; 122 127 case 'B': … … 151 156 } 152 157 break; 158 case 'S': 159 config->stampFile = argv[optind-1]; 160 config->threshold = -INFINITY; 161 break; 162 case 'R': 163 config->reverse = true; 164 break; 165 case 'm': 166 config->mask = true; 167 break; 153 168 default: 154 169 help();
Note:
See TracChangeset
for help on using the changeset viewer.
