]> Pileus Git - ~andy/rsl/blob - examples/qlook.c
Fix more warnings
[~andy/rsl] / examples / qlook.c
1 #define TRUE 1
2 #define FALSE 0
3 #include <stdio.h>
4 #include <math.h>
5 #include <string.h>
6 #include <stdlib.h>
7 #include <unistd.h>
8 #include <libgen.h>
9 #include "rsl.h"
10
11 #define ZDR_WIDTH 10
12 int         verbose;
13
14 void RSL_rebin_ray(Ray *r, int width);
15 void RSL_rebin_sweep(Sweep *s, int width);
16 void RSL_rebin_volume(Volume *v, int width);
17 void adjust_gate_size(Radar *radar, float gate_size_adjustment);
18
19 void process_args(int argc, char **argv, char *in_file, int *verbose,
20                   char *site_id, char *tape_id,
21                   int *qc_reflectivity, int *total_reflectivity,
22                   int *differential_reflectivity, 
23                   int *velocity, int *spectral_width,
24                   int *make_gif, int *make_pgm, int *make_bscan, int *make_uf,
25                   int *num_sweeps, float *dbz_offset,
26                   int *xdim, int *ydim, float *range,
27                   float *gate_size_adjustment, int *print_azim,
28                   char *gifdir, char *pgmdir, char *ufdir);
29
30 void make_pathname(char *filename, char *dir, char *pathname)
31 {
32     /* Make pathname by combining directory name, if given, with filename. */
33
34     if (!dir || !dir[0]) {
35         strcpy(pathname, filename);
36     }
37     else {
38         strcpy(pathname, dir);
39         strcat(pathname, "/");
40         strcat(pathname, filename);
41     }
42 }
43
44 /***********************************************************************/
45 /* This program uses the NASA TRMM Office Radar Software Library (RSL) */
46 /***********************************************************************/
47 /*** DBW ***************************************************************/
48 /***********************************************************************/
49 int main(int argc, char **argv) {
50
51     Radar       *radar     = NULL;
52     Volume      *dz_volume = NULL, *vr_volume = NULL;
53     Volume      *dr_volume = NULL, *zt_volume = NULL;
54     Volume      *sw_volume = NULL, *qc_volume = NULL;
55
56     Sweep       *sweep     = NULL;
57
58     Ray         *ray;
59     int         reflectivity, qc_reflectivity;
60     int         differential_reflectivity, total_reflectivity;
61     int         velocity, spectral_width;
62     int         make_catalog, make_gif, make_pgm; 
63     int         make_uf, make_bscan;
64     int         xdim, ydim, num_sweeps;
65     int         i,j, verbose;
66     int         ncbins, width;
67     int         print_azim;
68     float       scale, dbz_offset;
69     float       latitude, longitude;
70
71     float       maxr;
72     float       max_range, gate_size_adjustment;
73
74     char        tape_id[100];
75     char        in_file[100], site_id[100];
76     char        filename[100];
77     char        file_suffix[10];
78     char        time_string[14];
79     char        pathname[256], gifdir[100], pgmdir[100], ufdir[100];
80     char        *inpath;
81
82 /* Set default values */
83
84     /*strcpy(site_id, "KMLB");*/
85     strcpy(tape_id, "WSR88D");
86
87     verbose         = FALSE;
88     reflectivity    = TRUE;
89     qc_reflectivity = FALSE;
90     total_reflectivity = FALSE;
91     differential_reflectivity = FALSE;
92     velocity        = FALSE;
93     spectral_width  = FALSE;
94     make_gif        = FALSE;
95     make_pgm        = FALSE;
96     make_catalog    = FALSE;
97     make_uf         = FALSE;
98     print_azim      = FALSE;
99     num_sweeps      = 1;
100     xdim = ydim     = 400;
101     maxr            = 200.;
102     dbz_offset      = 0.0;
103     gate_size_adjustment = 1.0;
104     *gifdir = *pgmdir = *ufdir = '\0';
105     *site_id = '\0';
106     
107 /* Process command_line arguments */
108
109     process_args(argc, argv, in_file, &verbose, 
110                  site_id, tape_id, 
111                  &qc_reflectivity, &total_reflectivity,
112                  &differential_reflectivity, 
113                  &velocity, &spectral_width,
114                  &make_gif, &make_pgm, &make_bscan, &make_uf,  
115                  &num_sweeps, &dbz_offset,
116                  &xdim, &ydim, &maxr, &gate_size_adjustment,
117                  &print_azim, gifdir, pgmdir, ufdir);
118     
119 /* If site_id empty, use first 4 characters of file name. */
120
121     if (*site_id == 0) {
122         inpath = strdup(in_file);
123         strncpy(site_id, basename(inpath), 4);
124         site_id[4] = '\0';
125         if (strcmp(site_id, "KWA0") == 0) strcpy(site_id, "KWAJ");
126     }
127
128 /* Be a chatty Kathy? */
129
130     if(verbose)
131        RSL_radar_verbose_on();
132     else
133        RSL_radar_verbose_off(); 
134
135 /* Read data into radar */
136
137     if(verbose) printf("Calling any_format_to_radar\n");
138     radar = RSL_anyformat_to_radar(in_file, site_id);
139     if(verbose) printf("Called any_format_to_radar\n");
140     if(radar==NULL) {
141       if (verbose)
142         printf("No radar loaded, bye\n");
143       exit(-1);
144     }
145
146 /* Print command line parameters */
147
148     if(verbose) {
149         printf("Site ID            = %s\n",site_id);
150         printf("Tape ID            = %s\n",tape_id);
151         printf("Do reflectivity    = %d\n",reflectivity);
152         printf("Do qc_reflectivity = %d\n",qc_reflectivity);
153         printf("Do differential_reflectivity = %d\n",
154                differential_reflectivity);
155         printf("Do total_reflectivity = %d\n",
156                total_reflectivity);
157         printf("Do qc_reflectivity = %d\n",qc_reflectivity);
158         printf("Do velocity        = %d\n",velocity);
159         printf("Do spectral_width  = %d\n",spectral_width);
160         printf("Make gif           = %d\n",make_gif);
161         printf("Make pgm           = %d\n",make_pgm);
162         printf("Make UF file       = %d\n",make_uf);
163         if (ufdir  != NULL) printf("UF output dir      = %s\n",ufdir);
164         if (gifdir != NULL) printf("GIF output dir     = %s\n",gifdir);
165         if (pgmdir != NULL) printf("PGM output dir     = %s\n",pgmdir);
166         printf("dBZ Offset         = %.2f\n",dbz_offset);
167         printf("Gate Size Adjust   = %.2f\n",gate_size_adjustment);
168         printf("Print Azimuths     = %d\n",print_azim);
169     } 
170
171
172 /*
173   If Gate Size Adjustment is not unity, then we must change the
174   following:
175       old_gs = radar->v[i]->sweep[sweepIndex]->ray[rayIndex=]->h.gate_size
176       radar->v[i]->sweep[sweepIndex]->ray[rayIndex=]->h.gate_size = 
177           old_gs*gate_size_adjustment
178
179    Here are some comments from Sandra Yuter on the necessity of this fix.
180    > I dug into the revelant code and it looks like we can do a relatively
181     > simple workaround for the SIGMET raw product file range bin size
182     > errors for the RHB data pulses widths of 0.5 usec and 2.0 usec as follows.
183     > 
184     > Since we are all converting from sigmet to UF I suggest we resize 
185     > the range bin size values in the ray headers in the qlook step
186     > where the sigmet to UF conversion occurs.
187     > 
188     > The resize requires only 1 additional line of code (I have included
189     > a few others for context) in qlook.c
190     > 
191     > rangeToFirstGate = 0.001 *
192     >            radar->v[i]->sweep[sweepIndex]->ray[rayIndex]->h.range_bin1;
193     >         gateSize = 0.001 *
194     >            radar->v[i]->sweep[sweepIndex]->ray[rayIndex]->h.gate_size;
195     >         radar->v[i]->sweep[sweepIndex]->ray[rayIndex]->h.gate_size=
196     >       gateSize*0.6*1000;
197     > 
198     > I have used 0.6 adjustment factor since that is 75/125 which corresponds
199     > to the error in my 0.5 usec data, for the SUR scans, this adjustment
200     > factor is 133.33/125 or 1.067.
201     
202     The following is from Joe Holmes from SIGMET
203     
204     > 
205     > I think you have experienced a problem with the RVP7 range resolution
206     > configuration.  Both in IRIS and in the RVP7 you manually type in
207     > the range resolution.  The RVP7 allows a separate resolution for
208     > each pulsewidth, while IRIS only allows 1 value.  There is no feedback
209     > if these values are not typed in the same.  Based on setup information
210     > we have here from the RH Brown from Oct 23, 1998, you had the following
211     > configuration:
212     > 
213     > RVP7:
214     > 0   0.50 usec   75.0m
215     > 1   0.80 usec  125.0m
216     > 2   1.39 usec  125.0m
217     > 3   2.00 usec  133.3m
218     > 
219     > IRIS: 125.0 meters
220     > 
221     > I think the error at PW#0 was corrected a while back, but
222     > the error  in PW#3 was never corrected.  Next time someone is
223     > at the ship, they should check this, fix the long pulse, and remake
224     > the bandpass filter for the long pulse.
225     > 
226     > In the short term, you can correct the error by taking all your
227     > long pulse data and changing the header to correctly document the
228     > range resolution.  We have a program to do this, it is called "change_raw".
229     > The source is on any IRIS system, which was installed with the
230     > source, headers, and objects turned on.  It is in the
231     > ${IRIS_ROOT}utils/examples directory.  We can supply you with
232     > a compiled version of this program, if you want.  Available platforms
233     > are Linux, HP-UX, and IRIX.
234
235 */
236       
237     if(gate_size_adjustment != 1.0) {
238       printf("Adjusting Gate Size by Factor: %.3f\n",gate_size_adjustment);
239       adjust_gate_size(radar, gate_size_adjustment);
240     }
241     
242  /*
243    Create the filename prefix. Consists of the Site ID,
244    and time string (YYMMDD_hhmm).  The file suffix is 
245    like MIME type (e.g, .gif, .pgm, .uf, etc.)
246 */
247     sprintf(time_string,"%4d/%2.2d%2.2d %2.2d:%2.2d UTC", 
248             radar->h.year, radar->h.month, radar->h.day, 
249             radar->h.hour, radar->h.minute);
250 /*
251   Determine the location (lat/lon) of the radar.
252  */
253     latitude = radar->h.latd + radar->h.latm/60. + radar->h.lats/3600.;
254     longitude = radar->h.lond + radar->h.lonm/60. + radar->h.lons/3600.;
255
256     printf("%s %s %s %.6f %.6f \n",
257            in_file, radar->h.radar_name, time_string, longitude, latitude);
258
259     sprintf(time_string,"%4d_%2.2d%2.2d_%2.2d%2.2d", 
260             radar->h.year, radar->h.month, radar->h.day, 
261             radar->h.hour, radar->h.minute);
262
263 /* 
264    Print the radar/volume info.
265 */
266
267 /*
268  * DZ     Reflectivity (dBZ), may contain some   DZ_INDEX
269  *        signal-processor level QC and/or      
270  *        filters. This field would contain 
271  *        Darwin's CZ, or WSR88D's standard 
272  *        reflectivity. In other words, unless
273  *        the field is described otherwise, it
274  *        should always go here. In essence, this
275  *        is the "cleanest" reflectivity field
276  *        for a radar.
277  *
278  * VR     Radial Velocity (m/s)                  VR_INDEX
279  *
280  * SW     Spectral Width (m2/s2)                 SW_INDEX
281  *
282  * CZ     QC Reflectivity (dBZ), contains
283  *        post-processed QC'd data               CZ_INDEX
284  *
285  * ZT     Total Reflectivity (dBZ)               ZT_INDEX
286  *        May be uncommon, but important
287  *
288  * DR     Differential reflectivity              DR_INDEX
289  *        DR and LR are for dual-polarization
290  *        radars only. Unitless or in dB.
291  *
292  * LR     Another form of differential ref       LR_INDEX
293  *        called LDR, not sure of units
294  *
295  * ZD     ZDR: Reflectivity Depolarization Ratio ZD_INDEX
296  *        ZDR = 10log(ZH/ZV)  (dB)
297  *
298  * DM     Received power measured by the radar.  DM_INDEX
299  *        Units are dBm.
300  *
301  * RH     Rho : Correlation coefficient          RH_INDEX
302  *
303  * PH     Phi (MCTEX parameter)                  PH_INDEX
304  *
305  * XZ     X-band reflectivity                    XZ_INDEX
306  *
307  * CR     Corrected DR reflectivity (differential) CR_INDEX
308  *
309  * MZ     DZ mask volume for HDF 1C-51 product.  MZ_INDEX
310  *
311  * MR     DR mask volume for HDF 1C-51 product.  MR_INDEX
312  *
313  * ZE     Edited Reflectivity.                   ZE_INDEX
314  *
315  * VE     Edited Velocity.                       VE_INDEX
316  *
317  *
318                       * 0 = DZ_INDEX = reflectivity.
319                       * 1 = VR_INDEX = velocity.
320                       * 2 = SW_INDEX = spectrum_width.
321                       * 3 = CZ_INDEX = corrected reflectivity.
322                       * 4 = ZT_INDEX = uncorrected reflectivity.
323                       * 5 = DR_INDEX = differential refl.
324                       * 6 = LR_INDEX = another differential refl.
325                       * 7 = ZD_INDEX = another differential refl.
326                       * 8 = DM_INDEX = received power.
327                       * 9 = RH_INDEX = RhoHV: Horz-Vert power corr coeff
328                       *10 = PH_INDEX = PhiDP: Differential phase angle
329                       *11 = XZ_INDEX = X-band reflectivity.
330                       *12 = CR_INDEX = Corrected DR.
331                       *13 = MZ_INDEX = DZ mask for 1C-51 HDF.
332                       *14 = MR_INDEX = DR mask for 1C-51 HDF.
333                       *15 = ZE_INDEX = Edited reflectivity.
334                       *16 = VE_INDEX = Edited velocity.
335                       *17 = KD_INDEX = KDP deg/km.
336                       *18 = TI_INDEX = TIME (unknown)  for MCTEX data.
337                       *19 = DX_INDEX
338                       *20 = CH_INDEX
339                       *21 = AH_INDEX
340                       *22 = CV_INDEX
341                       *23 = AV_INDEX
342 */
343
344
345     if(verbose) {
346       for(i=0; i< radar->h.nvolumes; i++) {
347         if(radar->v[i] != NULL) {
348           printf("Vol[%2.2d] has %d sweeps\n",i,radar->v[i]->h.nsweeps);
349         } else {
350           printf("Vol[%2.2d] == NULL\n",i);
351         }
352       }
353       printf("--------------------------------------------\n");
354       printf("Number of volumes in radar: %d\n",radar->h.nvolumes);
355     }
356     
357     /* DZ_INDEX */
358     if(radar->v[DZ_INDEX] == NULL) {
359         printf("DZ_INDEX == NULL\n");
360         reflectivity = FALSE;
361     } else {
362         dz_volume = radar->v[DZ_INDEX];
363         if(verbose) printf("Number of sweeps in dz_volume = %d\n",
364                dz_volume->h.nsweeps);
365     }
366     
367     /* CZ_INDEX */
368     if(radar->v[CZ_INDEX] == NULL) {
369         if(verbose) printf("CZ_INDEX == NULL\n");
370         qc_reflectivity = FALSE;
371     } else {
372         qc_volume = radar->v[CZ_INDEX];
373         if(verbose) printf("Number of sweeps in qc_volume = %d\n",
374                qc_volume->h.nsweeps);
375     }
376     
377     /* ZT_INDEX */
378     if(radar->v[ZT_INDEX] == NULL) {
379         if(verbose) printf("ZT_INDEX == NULL\n");
380         total_reflectivity = FALSE;
381     } else {
382         zt_volume = radar->v[ZT_INDEX];
383         if(verbose) printf("Number of sweeps in zt_volume = %d\n", 
384                zt_volume->h.nsweeps);
385     }
386     /* DR_INDEX */
387     if(radar->v[DR_INDEX] == NULL) {
388         if(verbose) printf("DR_INDEX == NULL\n");
389         differential_reflectivity = FALSE;
390     } else {
391         dr_volume = radar->v[DR_INDEX];
392         if(verbose) printf("Number of sweeps in dr_volume = %d\n", 
393                dr_volume->h.nsweeps);
394     }
395     /* VR_INDEX */
396     if(radar->v[VR_INDEX] == NULL) {
397         if(verbose) printf("VR_INDEX == NULL\n");
398         velocity = FALSE;
399     } else {
400         vr_volume = radar->v[VR_INDEX];
401         if(verbose) printf("Number of sweeps in vr_volume = %d\n",
402                vr_volume->h.nsweeps);
403     }
404         
405     /* SW_INDEX */
406     if(radar->v[SW_INDEX] == NULL) {
407         if(verbose) printf("SW_INDEX == NULL\n");
408         spectral_width = FALSE;
409     } else {
410         sw_volume = radar->v[SW_INDEX];
411         if(verbose) printf("Number of sweeps in sw_volume = %d\n",
412                sw_volume->h.nsweeps);
413     }
414     if(verbose) printf("--------------------------------------------\n");
415
416 /*
417    Print out the elevation angles
418 */
419     if(verbose) {
420       if(reflectivity) {
421         printf("Reflectivity Tilts\n");
422         printf("----------------------\n");
423         if(dz_volume != NULL) {
424           for(i=0; i<dz_volume->h.nsweeps; i++) {
425         sweep = dz_volume->sweep[i];
426         if(sweep == NULL) {
427           printf("sweep[%d]==NULL\n",i);
428           continue;
429         }
430         printf("Tilt %2d, Elev=%4.1f\n",i,sweep->h.elev);
431           }
432           printf("----------------------\n");
433         }
434       }
435     }
436       /*
437         Print out the values of the rays in each sweep requsted
438       */
439       
440     if(print_azim) {
441       printf("Ray angles\n");
442       if(reflectivity) {
443         for(i=0; i<dz_volume->h.nsweeps; i++) {
444           if(dz_volume->sweep[i] != NULL) sweep = dz_volume->sweep[i];
445           printf("Elevation angle: %f\n",sweep->h.elev);
446           printf("Number of rays in sweep[%d] = %d\n",i,sweep->h.nrays);
447           
448           for(j=0; j<sweep->h.nrays-1; j++) {
449         if(sweep->ray[j] != NULL) {
450           ray = sweep->ray[j];
451           printf("%d: %7.2f\n  ",j,sweep->ray[j]->h.azimuth);
452         }
453           }
454         }
455       }
456     }
457 /* 
458    Write out some volume statistics
459 */
460     if(verbose) {
461       printf("******************* Volume Statistics *******************\n");
462       if(reflectivity) {
463         sweep = RSL_get_first_sweep_of_volume(dz_volume);
464         if(sweep != NULL) {
465           printf("Number rays        = %d\n", sweep->h.nrays);
466           printf("Beam width         = %.2f deg\n", sweep->h.beam_width);
467           ray = RSL_get_first_ray_of_sweep(sweep);
468           if(ray!= NULL) {
469             max_range = ray->h.range_bin1/1000.0 + 
470               ray->h.nbins*ray->h.gate_size/1000.0;
471             printf("Number of bins     = %d\n",ray->h.nbins);
472             printf("Max range          = %.1f km\n", max_range);
473             printf("Range to first bin = %d m\n",ray->h.range_bin1);
474             printf("Gate size          = %d m\n",ray->h.gate_size);
475             printf("Pulse Rep. Freq.   = %d Hz\n",ray->h.prf);
476             printf("Pulse width        = %.2f us\n",ray->h.pulse_width);
477             printf("Wavelength         = %.2f m\n",ray->h.wavelength);
478             printf("Frequency          = %.2f \n",ray->h.frequency);
479           }
480         }
481       }
482     }
483
484 /*  
485     Add a dBZ offset if requested. The offset can be positive or negative.
486     if(dbz_offset != 0.0) {
487       printf("Adding dbz_offset to dz_volume: %.2f\n", dbz_offset);
488       RSL_add_dbzoffset_to_volume(dz_volume, dbz_offset);
489       printf("Added dbz_offset to dz_volume: %.2f\n", dbz_offset);
490       exit(0);
491     }
492 */
493
494 /* 
495  ****************************************************************
496  *  Make images                                                 *
497  ****************************************************************
498 */
499
500
501     /* CZ_INDEX */
502     if(qc_reflectivity) {
503       if(verbose) printf("Loading refl colortable...\n");
504       RSL_load_refl_color_table();
505       for(i=0; i<num_sweeps; i++) {
506         sweep = qc_volume->sweep[i];
507         if(sweep == NULL) {
508           printf("sweep[%d]==NULL\n",i);
509           continue;
510         }
511         if(make_pgm) {
512           sprintf(file_suffix,"pgm");
513           sprintf(filename,"qc_%s_%2.2d.%s", time_string,i,file_suffix);
514           printf("Creating: %s\n", filename);
515           make_pathname(filename, pgmdir, pathname);
516           RSL_sweep_to_pgm(sweep, pathname, xdim, ydim, maxr);
517         }
518         if(make_gif) {
519           sprintf(file_suffix,"gif");
520           sprintf(filename,"qc_%s_%2.2d.%s", time_string,i,file_suffix);
521           printf("Creating: %s\n", filename);
522           make_pathname(filename, gifdir, pathname);
523           RSL_sweep_to_gif(sweep,pathname,xdim, ydim, maxr);
524         }
525       }
526     }
527
528     /* DZ_INDEX */
529     if(reflectivity) {
530       if(verbose) printf("Loading refl colortable...\n");
531       RSL_load_refl_color_table();
532       for(i=0; i<num_sweeps; i++) {
533         sweep = dz_volume->sweep[i];
534         if(sweep == NULL) {
535           printf("sweep[%d]==NULL\n",i);
536           continue;
537         }
538         if(make_pgm) {
539           sprintf(file_suffix,"pgm");
540           sprintf(filename,"dz_%s_%2.2d.%s", 
541               time_string,i,file_suffix);
542           printf("Creating: %s\n", filename);
543           make_pathname(filename, pgmdir, pathname);
544           RSL_sweep_to_pgm(sweep, pathname, xdim, ydim, maxr);
545         }
546         if(make_gif) {
547           sprintf(file_suffix,"gif");
548           sprintf(filename,"dz_%s_%2.2d.%s", time_string,i,file_suffix); 
549 /*        
550           sprintf(filename,"dz_%s.%s.%s", time_string,in_file,file_suffix); 
551 */
552           printf("Creating: %s\n", filename);
553           make_pathname(filename, gifdir, pathname);
554           RSL_sweep_to_gif(sweep,pathname,xdim, ydim, maxr);
555         }
556       }
557     }
558     
559     /* ZT_INDEX */
560     if(total_reflectivity) {
561       if(verbose) printf("Loading refl colortable...\n");
562       RSL_load_refl_color_table();
563       for(i=0; i<num_sweeps; i++) {
564         sweep = zt_volume->sweep[i];
565         if(sweep == NULL) {
566           printf("sweep[%d]==NULL\n",i);
567           continue;
568         }
569         if(make_pgm) {
570           sprintf(file_suffix,"pgm");
571           sprintf(filename,"zt_%s_%2.2d.%s", 
572                   time_string,i,file_suffix);
573           printf("Creating: %s\n", filename);
574           make_pathname(filename, pgmdir, pathname);
575           RSL_sweep_to_pgm(sweep, pathname, xdim, ydim, maxr);
576         }
577         if(make_gif) {
578           sprintf(file_suffix,"gif");
579           sprintf(filename,"zt_%s_%2.2d.%s", 
580                   time_string,i,file_suffix);
581           printf("Creating: %s\n", filename);
582           make_pathname(filename, gifdir, pathname);
583           RSL_sweep_to_gif(sweep,pathname,xdim, ydim, maxr);
584         }
585       }
586     }
587     
588     /* DR_INDEX */
589     if(differential_reflectivity) {
590         scale = 0.5;
591         ncbins = 21;
592         width = 10;
593         printf("Calling RSL_rebin, %d\n", width);
594         RSL_rebin_volume(dr_volume, width);
595         if(verbose) printf("Loading zdr colortable...\n");
596         RSL_load_zdr_color_table(); 
597         for(i=0; i<num_sweeps; i++) {
598           sweep = dr_volume->sweep[i];
599           if(sweep == NULL) {
600             printf("sweep[%d]==NULL\n",i);
601             continue;
602           }
603           if(make_pgm) {
604             sprintf(file_suffix,"pgm");
605             sprintf(filename,"dr_%s_%2.2d.%s", 
606                     time_string,i,file_suffix);
607             printf("Creating: %s\n", filename);
608             make_pathname(filename, pgmdir, pathname);
609             RSL_sweep_to_pgm(sweep, pathname, xdim, ydim, maxr);
610           }
611           if(make_gif) {
612             sprintf(file_suffix,"gif");
613             sprintf(filename,"dr_%s_%2.2d.%s", 
614                     time_string,i,file_suffix);
615             printf("Creating: %s\n", filename);
616             make_pathname(filename, gifdir, pathname);
617             RSL_sweep_to_gif(sweep,pathname,xdim, ydim, maxr);
618           }
619         }
620     }
621
622     
623     /* VR_INDEX */
624     if(velocity) {
625       if(verbose) printf("Loading vel colortable...\n");
626       RSL_load_vel_color_table();
627       for(i=0; i<num_sweeps; i++) {
628         sweep = vr_volume->sweep[i];
629         if(sweep == NULL) {
630           printf("sweep[%d]==NULL\n",i);
631           continue;
632         }
633         if(make_pgm) {
634           sprintf(file_suffix,"pgm");
635           sprintf(filename,"vr_%s_%2.2d.%s", time_string,i,file_suffix);
636           printf("Creating: %s\n", filename);
637           make_pathname(filename, pgmdir, pathname);
638           RSL_sweep_to_pgm(sweep, pathname, xdim, ydim, maxr);
639         }
640         if(make_gif) {
641           sprintf(file_suffix,"gif");
642           sprintf(filename,"vr_%s_%2.2d.%s", time_string,i,file_suffix);
643           printf("Creating: %s\n", filename);
644           make_pathname(filename, gifdir, pathname);
645           RSL_sweep_to_gif(sweep,pathname,xdim, ydim, maxr);
646         }
647       }
648     }
649     
650     /* SW_INDEX */
651     if(spectral_width) {
652       if(verbose) printf("Loading sw colortable...\n");
653       RSL_load_sw_color_table();
654       for(i=0; i<num_sweeps; i++) {
655         sweep = sw_volume->sweep[i];
656         if(sweep == NULL) {
657           printf("sweep[%d]==NULL\n",i);
658           continue;
659         }
660         if(make_pgm) {
661           sprintf(file_suffix,"pgm");
662           sprintf(filename,"sw_%s_%2.2d.%s", 
663                   time_string,i,file_suffix);
664           printf("Creating: %s\n", filename);
665           make_pathname(filename, pgmdir, pathname);
666           RSL_sweep_to_pgm(sweep, pathname, xdim, ydim, maxr);
667         }
668         if(make_gif) {
669           sprintf(file_suffix,"gif");
670           sprintf(filename,"sw_%s_%2.2d.%s", 
671                   time_string,i,file_suffix);
672           printf("Creating: %s\n", filename);
673           make_pathname(filename, gifdir, pathname);
674           RSL_sweep_to_gif(sweep,pathname,xdim, ydim, maxr);
675         }
676       }
677     }
678     
679 /*
680    Write uf file if requested
681 */
682     if(make_uf) {
683         sprintf(filename,"%s_%s.%s",site_id, time_string,"uf.gz");
684         printf("Creating UF file: %s\n", filename);
685         make_pathname(filename, ufdir, pathname);
686         RSL_radar_to_uf_gzip(radar, pathname);
687     }
688
689     printf("-->> FIELDS: [ ");
690     /* Modified to use RSL_ftype from rsl.h (#define USE_RSL_VARS) and to
691      * loop through volumes. 10/16/2009, BLK
692      */
693     for (i=0; i < MAX_RADAR_VOLUMES; i++) 
694         if (radar->v[i] != NULL) printf("%s ", RSL_ftype[i]);
695      /* 
696     if(radar->v[0] != NULL) printf("DZ ");
697     if(radar->v[1] != NULL) printf("VR ");
698     if(radar->v[2] != NULL) printf("SW ");
699     if(radar->v[3] != NULL) printf("CZ ");
700     if(radar->v[4] != NULL) printf("ZT ");
701     if(radar->v[5] != NULL) printf("DR ");
702     if(radar->v[6] != NULL) printf("LR ");
703     if(radar->v[7] != NULL) printf("ZD ");
704     if(radar->v[8] != NULL) printf("DM ");
705     if(radar->v[9] != NULL) printf("RH ");
706     if(radar->v[10] != NULL) printf("PH ");
707     if(radar->v[11] != NULL) printf("XZ ");
708     if(radar->v[12] != NULL) printf("CR ");
709     if(radar->v[13] != NULL) printf("MZ ");
710     if(radar->v[14] != NULL) printf("MR ");
711     if(radar->v[15] != NULL) printf("ZE ");
712     if(radar->v[16] != NULL) printf("VE ");
713     if(radar->v[17] != NULL) printf("KD ");
714     if(radar->v[18] != NULL) printf("TI ");
715     if(radar->v[19] != NULL) printf("DX ");
716     if(radar->v[20] != NULL) printf("CH ");
717     if(radar->v[21] != NULL) printf("AH ");
718     if(radar->v[22] != NULL) printf("CV ");
719     if(radar->v[23] != NULL) printf("AV ");
720     if(radar->v[24] != NULL) printf("SQ ");
721       */
722     printf("] \n\n");
723 /*
724    Wrap it up!
725 */
726
727     if(verbose)
728         printf("Finished!\n");
729
730     return 0;
731 } /* End of main */
732