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