]> Pileus Git - ~andy/rsl/blob - examples/qlook_usage.c
Changes from Bart (2011-02-01)
[~andy/rsl] / examples / qlook_usage.c
1 #define TRUE 1
2 #define FALSE 0
3
4 #include <stdio.h>
5 #include <string.h>
6 #include <stdlib.h>
7 #include <unistd.h>
8
9 void process_args(int argc, char **argv, char *in_file, int *verbose,
10                   char *site_id, char *tape_id,
11                   int *qc_reflectivity, int *total_reflectivity,
12                   int *differential_reflectivity, 
13                   int *velocity, int *spectral_width,
14                   int *make_gif, int *make_pgm, int *make_bscan, int *make_uf,
15                   int *num_sweeps, float *dbz_offset,
16                   int *xdim, int *ydim, float *range,
17                   float *gate_size_adjustment, int *print_azim,
18                   char *gifdir, char *pgmdir, char *ufdir)
19 {
20     extern char   *optarg;
21     extern int    optind, optopt;
22     char c;
23
24     while ((c = getopt(argc, argv, "vgpus:t:n:x:y:r:o:a:ADCQTWVG:P:U:")) != -1) {
25
26       switch(c) {
27 /*
28   RSL Verbose flag
29 */
30       case 'v': *verbose = TRUE; break;
31
32 /* 
33   s: First file or call sign 
34 */
35       case 's': strcpy(site_id, optarg); break;
36       case 't': strcpy(tape_id, optarg); break;
37
38 /*
39    x: x dimension
40    y: y dimension
41    r: max range
42    z: zoom factor (km/pixel)
43 */
44       case 'x': *xdim  = atoi(optarg); break;
45       case 'y': *ydim  = atoi(optarg); break;
46       case 'r': *range = atof(optarg); break;
47       case 'a': *gate_size_adjustment = atof(optarg); break;
48       
49 /*  dBZ Offset
50 */
51       case 'o': *dbz_offset = atof(optarg); break;
52 /* 
53    T: Total reflectivity
54    Q: Do qc'd reflectivity
55    V: Do radial velocity
56    W: Do spectral width
57 */
58       case 'Q': *qc_reflectivity = TRUE; break;
59       case 'T': *total_reflectivity = TRUE; break;
60       case 'V': *velocity        = TRUE; break;
61       case 'W': *spectral_width  = TRUE; break;
62       case 'A': *print_azim = TRUE; break;
63       case 'D': *differential_reflectivity  = TRUE; break;
64
65 /*
66    g: Make gif images
67    p: Make pgm images
68    u: Make uf files
69 */
70       case 'g': *make_gif = TRUE; break;
71       case 'p': *make_pgm = TRUE; break;
72       case 'u': *make_uf  = TRUE; break;
73
74 /*
75    G: gif directory
76    P: pgm directory
77    U: uf directory
78 */
79       case 'G': strcpy(gifdir, optarg); break;
80       case 'P': strcpy(pgmdir, optarg); break;
81       case 'U': strcpy(ufdir,  optarg); break;
82
83 /* 
84    num_sweeps: Number of sweeps to make images of 
85 */
86       case 'n': *num_sweeps = atoi(optarg); break;
87
88 /*
89   Deal with bad input
90 */
91       case '?': fprintf(stderr, "ERROR: option -%c is undefined\n", optopt);
92         goto Usage;
93       case ':': fprintf(stderr, "ERROR: option -%c requires an argument\n",optopt);
94         goto Usage;
95       default: break;
96       }
97     }
98
99 /*
100    Must have at the least a file listed on the command lines, everything
101    can be defaulted.
102  */
103
104     if (argc - optind != 1) {
105 Usage:
106         fprintf(stderr,"ERROR:::\n");
107         fprintf(stderr,"%s [options] input_file:",argv[0]);
108         fprintf(stderr,"\n[options]: ");
109         fprintf(stderr,"\n\t[-v verbose_flag?] ");
110         fprintf(stderr,"\n\t[-s First file or call sign?] ");
111         fprintf(stderr,"\n\t[-t Tape ID] ");
112         fprintf(stderr,"\n\t[-u Make UF file]");
113         fprintf(stderr,"\n\t[-g Make GIF images?]");
114         fprintf(stderr,"\n\t[-p Make PGM images?]");
115         fprintf(stderr,"\n\t[-U Directory for UF output files]");
116         fprintf(stderr,"\n\t[-G Directory for GIF output files]");
117         fprintf(stderr,"\n\t[-P Directory for PGM output files]");
118         fprintf(stderr,"\n\t[-x X dimension]");
119         fprintf(stderr,"\n\t[-y Y dimension]");
120         fprintf(stderr,"\n\t[-r max range]");
121         fprintf(stderr,"\n\t[-n Number of sweeps to make images]");
122         fprintf(stderr,"\n\t[-Q Do qc reflectivity]");
123         fprintf(stderr,"\n\t[-T Do total reflectivity]");
124         fprintf(stderr,"\n\t[-V Do velocity]");
125         fprintf(stderr,"\n\t[-W Do spectral_width]");
126         fprintf(stderr,"\n\t[-D Do differential reflectivity");
127         fprintf(stderr,"\n\t[-o Apply dBZ offset");
128         fprintf(stderr,":::\n");
129         exit(-1);
130     }
131     
132     strcpy(in_file, argv[optind]);
133
134 }
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154