]> Pileus Git - ~andy/rsl/blob - examples/qlook.c
RSL v1.41
[~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 /* 
272    Print the radar/volume info.
273 */
274
275 /*
276  * DZ     Reflectivity (dBZ), may contain some   DZ_INDEX
277  *        signal-processor level QC and/or      
278  *        filters. This field would contain 
279  *        Darwin's CZ, or WSR88D's standard 
280  *        reflectivity. In other words, unless
281  *        the field is described otherwise, it
282  *        should always go here. In essence, this
283  *        is the "cleanest" reflectivity field
284  *        for a radar.
285  *
286  * VR     Radial Velocity (m/s)                  VR_INDEX
287  *
288  * SW     Spectral Width (m2/s2)                 SW_INDEX
289  *
290  * CZ     QC Reflectivity (dBZ), contains
291  *        post-processed QC'd data               CZ_INDEX
292  *
293  * ZT     Total Reflectivity (dBZ)               ZT_INDEX
294  *        May be uncommon, but important
295  *
296  * DR     Differential reflectivity              DR_INDEX
297  *        DR and LR are for dual-polarization
298  *        radars only. Unitless or in dB.
299  *
300  * LR     Another form of differential ref       LR_INDEX
301  *        called LDR, not sure of units
302  *
303  * ZD     ZDR: Reflectivity Depolarization Ratio ZD_INDEX
304  *        ZDR = 10log(ZH/ZV)  (dB)
305  *
306  * DM     Received power measured by the radar.  DM_INDEX
307  *        Units are dBm.
308  *
309  * RH     Rho : Correlation coefficient          RH_INDEX
310  *
311  * PH     Phi (MCTEX parameter)                  PH_INDEX
312  *
313  * XZ     X-band reflectivity                    XZ_INDEX
314  *
315  * CR     Corrected DR reflectivity (differential) CR_INDEX
316  *
317  * MZ     DZ mask volume for HDF 1C-51 product.  MZ_INDEX
318  *
319  * MR     DR mask volume for HDF 1C-51 product.  MR_INDEX
320  *
321  * ZE     Edited Reflectivity.                   ZE_INDEX
322  *
323  * VE     Edited Velocity.                       VE_INDEX
324  *
325  *
326                       * 0 = DZ_INDEX = reflectivity.
327                       * 1 = VR_INDEX = velocity.
328                       * 2 = SW_INDEX = spectrum_width.
329                       * 3 = CZ_INDEX = corrected reflectivity.
330                       * 4 = ZT_INDEX = uncorrected reflectivity.
331                       * 5 = DR_INDEX = differential refl.
332                       * 6 = LR_INDEX = another differential refl.
333                       * 7 = ZD_INDEX = another differential refl.
334                       * 8 = DM_INDEX = received power.
335                       * 9 = RH_INDEX = RhoHV: Horz-Vert power corr coeff
336                       *10 = PH_INDEX = PhiDP: Differential phase angle
337                       *11 = XZ_INDEX = X-band reflectivity.
338                       *12 = CR_INDEX = Corrected DR.
339                       *13 = MZ_INDEX = DZ mask for 1C-51 HDF.
340                       *14 = MR_INDEX = DR mask for 1C-51 HDF.
341                       *15 = ZE_INDEX = Edited reflectivity.
342                       *16 = VE_INDEX = Edited velocity.
343                       *17 = KD_INDEX = KDP deg/km.
344                       *18 = TI_INDEX = TIME (unknown)  for MCTEX data.
345                       *19 = DX_INDEX
346                       *20 = CH_INDEX
347                       *21 = AH_INDEX
348                       *22 = CV_INDEX
349                       *23 = AV_INDEX
350 */
351
352
353     if(verbose) {
354       for(i=0; i< radar->h.nvolumes; i++) {
355         if(radar->v[i] != NULL) {
356           printf("Vol[%2.2d] has %d sweeps\n",i,radar->v[i]->h.nsweeps);
357         } else {
358           printf("Vol[%2.2d] == NULL\n",i);
359         }
360       }
361       printf("--------------------------------------------\n");
362       printf("Number of volumes in radar: %d\n",radar->h.nvolumes);
363     }
364     
365     /* DZ_INDEX */
366     if(radar->v[DZ_INDEX] == NULL) {
367         printf("DZ_INDEX == NULL\n");
368         reflectivity = FALSE;
369     } else {
370         dz_volume = radar->v[DZ_INDEX];
371         if(verbose) printf("Number of sweeps in dz_volume = %d\n",
372                dz_volume->h.nsweeps);
373     }
374     
375     /* CZ_INDEX */
376     if(radar->v[CZ_INDEX] == NULL) {
377         if(verbose) printf("CZ_INDEX == NULL\n");
378         qc_reflectivity = FALSE;
379     } else {
380         qc_volume = radar->v[CZ_INDEX];
381         if(verbose) printf("Number of sweeps in qc_volume = %d\n",
382                qc_volume->h.nsweeps);
383     }
384     
385     /* ZT_INDEX */
386     if(radar->v[ZT_INDEX] == NULL) {
387         if(verbose) printf("ZT_INDEX == NULL\n");
388         total_reflectivity = FALSE;
389     } else {
390         zt_volume = radar->v[ZT_INDEX];
391         if(verbose) printf("Number of sweeps in zt_volume = %d\n", 
392                zt_volume->h.nsweeps);
393     }
394     /* DR_INDEX */
395     if(radar->v[DR_INDEX] == NULL) {
396         if(verbose) printf("DR_INDEX == NULL\n");
397         differential_reflectivity = FALSE;
398     } else {
399         dr_volume = radar->v[DR_INDEX];
400         if(verbose) printf("Number of sweeps in dr_volume = %d\n", 
401                dr_volume->h.nsweeps);
402     }
403     /* VR_INDEX */
404     if(radar->v[VR_INDEX] == NULL) {
405         if(verbose) printf("VR_INDEX == NULL\n");
406         velocity = FALSE;
407     } else {
408         vr_volume = radar->v[VR_INDEX];
409         if(verbose) printf("Number of sweeps in vr_volume = %d\n",
410                vr_volume->h.nsweeps);
411     }
412         
413     /* SW_INDEX */
414     if(radar->v[SW_INDEX] == NULL) {
415         if(verbose) printf("SW_INDEX == NULL\n");
416         spectral_width = FALSE;
417     } else {
418         sw_volume = radar->v[SW_INDEX];
419         if(verbose) printf("Number of sweeps in sw_volume = %d\n",
420                sw_volume->h.nsweeps);
421     }
422     if(verbose) printf("--------------------------------------------\n");
423
424 /*
425    Print out the elevation angles
426 */
427     if(verbose) {
428       if(reflectivity) {
429         printf("Reflectivity Tilts\n");
430         printf("----------------------\n");
431         if(dz_volume != NULL) {
432           for(i=0; i<dz_volume->h.nsweeps; i++) {
433         sweep = dz_volume->sweep[i];
434         if(sweep == NULL) {
435           printf("sweep[%d]==NULL\n",i);
436           continue;
437         }
438         printf("Tilt %2d, Elev=%4.1f\n",i,sweep->h.elev);
439           }
440           printf("----------------------\n");
441         }
442       }
443     }
444       /*
445         Print out the values of the rays in each sweep requsted
446       */
447       
448     if(print_azim) {
449       printf("Ray angles\n");
450       if(reflectivity) {
451         for(i=0; i<dz_volume->h.nsweeps; i++) {
452           if(dz_volume->sweep[i] != NULL) sweep = dz_volume->sweep[i];
453           printf("Elevation angle: %f\n",sweep->h.elev);
454           printf("Number of rays in sweep[%d] = %d\n",i,sweep->h.nrays);
455           
456           for(j=0; j<sweep->h.nrays-1; j++) {
457         if(sweep->ray[j] != NULL) {
458           ray = sweep->ray[j];
459           printf("%d: %7.2f\n  ",j,sweep->ray[j]->h.azimuth);
460         }
461           }
462         }
463       }
464     }
465 /* 
466    Write out some volume statistics
467 */
468     if(verbose) {
469       printf("******************* Volume Statistics *******************\n");
470       if(reflectivity) {
471         sweep = RSL_get_first_sweep_of_volume(dz_volume);
472         if(sweep != NULL) {
473           printf("Number rays        = %d\n", sweep->h.nrays);
474           printf("Beam width         = %.2f deg\n", sweep->h.beam_width);
475           ray = RSL_get_first_ray_of_sweep(sweep);
476           if(ray!= NULL) {
477             max_range = ray->h.range_bin1/1000.0 + 
478               ray->h.nbins*ray->h.gate_size/1000.0;
479             printf("Number of bins     = %d\n",ray->h.nbins);
480             printf("Max range          = %.1f km\n", max_range);
481             printf("Range to first bin = %d m\n",ray->h.range_bin1);
482             printf("Gate size          = %d m\n",ray->h.gate_size);
483             printf("Pulse Rep. Freq.   = %d Hz\n",ray->h.prf);
484             printf("Pulse width        = %.2f us\n",ray->h.pulse_width);
485             printf("Wavelength         = %.2f m\n",ray->h.wavelength);
486             printf("Frequency          = %.2f \n",ray->h.frequency);
487           }
488         }
489       }
490     }
491
492 /*  
493     Add a dBZ offset if requested. The offset can be positive or negative.
494     if(dbz_offset != 0.0) {
495       printf("Adding dbz_offset to dz_volume: %.2f\n", dbz_offset);
496       RSL_add_dbzoffset_to_volume(dz_volume, dbz_offset);
497       printf("Added dbz_offset to dz_volume: %.2f\n", dbz_offset);
498       exit(0);
499     }
500 */
501
502 /* 
503  ****************************************************************
504  *  Make images                                                 *
505  ****************************************************************
506 */
507
508
509     /* CZ_INDEX */
510     if(qc_reflectivity) {
511       if(verbose) printf("Loading refl colortable...\n");
512       RSL_load_refl_color_table();
513       for(i=0; i<num_sweeps; i++) {
514         sweep = qc_volume->sweep[i];
515         if(sweep == NULL) {
516           printf("sweep[%d]==NULL\n",i);
517           continue;
518         }
519         if(make_pgm) {
520           sprintf(file_suffix,"pgm");
521           sprintf(filename,"qc_%s_%2.2d.%s", time_string,i,file_suffix);
522           printf("Creating: %s\n", filename);
523           make_pathname(filename, pgmdir, pathname);
524           RSL_sweep_to_pgm(sweep, pathname, xdim, ydim, maxr);
525         }
526         if(make_gif) {
527           sprintf(file_suffix,"gif");
528           sprintf(filename,"qc_%s_%2.2d.%s", time_string,i,file_suffix);
529           printf("Creating: %s\n", filename);
530           make_pathname(filename, gifdir, pathname);
531           RSL_sweep_to_gif(sweep,pathname,xdim, ydim, maxr);
532         }
533       }
534     }
535
536     /* DZ_INDEX */
537     if(reflectivity) {
538       if(verbose) printf("Loading refl colortable...\n");
539       RSL_load_refl_color_table();
540       for(i=0; i<num_sweeps; i++) {
541         sweep = dz_volume->sweep[i];
542         if(sweep == NULL) {
543           printf("sweep[%d]==NULL\n",i);
544           continue;
545         }
546         if(make_pgm) {
547           sprintf(file_suffix,"pgm");
548           sprintf(filename,"dz_%s_%2.2d.%s", 
549               time_string,i,file_suffix);
550           printf("Creating: %s\n", filename);
551           make_pathname(filename, pgmdir, pathname);
552           RSL_sweep_to_pgm(sweep, pathname, xdim, ydim, maxr);
553         }
554         if(make_gif) {
555           sprintf(file_suffix,"gif");
556           sprintf(filename,"dz_%s_%2.2d.%s", time_string,i,file_suffix); 
557 /*        
558           sprintf(filename,"dz_%s.%s.%s", time_string,in_file,file_suffix); 
559 */
560           printf("Creating: %s\n", filename);
561           make_pathname(filename, gifdir, pathname);
562           RSL_sweep_to_gif(sweep,pathname,xdim, ydim, maxr);
563         }
564       }
565     }
566     
567     /* ZT_INDEX */
568     if(total_reflectivity) {
569       if(verbose) printf("Loading refl colortable...\n");
570       RSL_load_refl_color_table();
571       for(i=0; i<num_sweeps; i++) {
572         sweep = zt_volume->sweep[i];
573         if(sweep == NULL) {
574           printf("sweep[%d]==NULL\n",i);
575           continue;
576         }
577         if(make_pgm) {
578           sprintf(file_suffix,"pgm");
579           sprintf(filename,"zt_%s_%2.2d.%s", 
580                   time_string,i,file_suffix);
581           printf("Creating: %s\n", filename);
582           make_pathname(filename, pgmdir, pathname);
583           RSL_sweep_to_pgm(sweep, pathname, xdim, ydim, maxr);
584         }
585         if(make_gif) {
586           sprintf(file_suffix,"gif");
587           sprintf(filename,"zt_%s_%2.2d.%s", 
588                   time_string,i,file_suffix);
589           printf("Creating: %s\n", filename);
590           make_pathname(filename, gifdir, pathname);
591           RSL_sweep_to_gif(sweep,pathname,xdim, ydim, maxr);
592         }
593       }
594     }
595     
596     /* DR_INDEX */
597     if(differential_reflectivity) {
598         scale = 0.5;
599         ncbins = 21;
600         width = 10;
601         printf("Calling RSL_rebin, %d\n", width);
602         RSL_rebin_volume(dr_volume, width);
603         if(verbose) printf("Loading zdr colortable...\n");
604         RSL_load_zdr_color_table(); 
605         for(i=0; i<num_sweeps; i++) {
606           sweep = dr_volume->sweep[i];
607           if(sweep == NULL) {
608             printf("sweep[%d]==NULL\n",i);
609             continue;
610           }
611           if(make_pgm) {
612             sprintf(file_suffix,"pgm");
613             sprintf(filename,"dr_%s_%2.2d.%s", 
614                     time_string,i,file_suffix);
615             printf("Creating: %s\n", filename);
616             make_pathname(filename, pgmdir, pathname);
617             RSL_sweep_to_pgm(sweep, pathname, xdim, ydim, maxr);
618           }
619           if(make_gif) {
620             sprintf(file_suffix,"gif");
621             sprintf(filename,"dr_%s_%2.2d.%s", 
622                     time_string,i,file_suffix);
623             printf("Creating: %s\n", filename);
624             make_pathname(filename, gifdir, pathname);
625             RSL_sweep_to_gif(sweep,pathname,xdim, ydim, maxr);
626           }
627         }
628     }
629
630     
631     /* VR_INDEX */
632     if(velocity) {
633       if(verbose) printf("Loading vel colortable...\n");
634       RSL_load_vel_color_table();
635       for(i=0; i<num_sweeps; i++) {
636         sweep = vr_volume->sweep[i];
637         if(sweep == NULL) {
638           printf("sweep[%d]==NULL\n",i);
639           continue;
640         }
641         if(make_pgm) {
642           sprintf(file_suffix,"pgm");
643           sprintf(filename,"vr_%s_%2.2d.%s", time_string,i,file_suffix);
644           printf("Creating: %s\n", filename);
645           make_pathname(filename, pgmdir, pathname);
646           RSL_sweep_to_pgm(sweep, pathname, xdim, ydim, maxr);
647         }
648         if(make_gif) {
649           sprintf(file_suffix,"gif");
650           sprintf(filename,"vr_%s_%2.2d.%s", time_string,i,file_suffix);
651           printf("Creating: %s\n", filename);
652           make_pathname(filename, gifdir, pathname);
653           RSL_sweep_to_gif(sweep,pathname,xdim, ydim, maxr);
654         }
655       }
656     }
657     
658     /* SW_INDEX */
659     if(spectral_width) {
660       if(verbose) printf("Loading sw colortable...\n");
661       RSL_load_sw_color_table();
662       for(i=0; i<num_sweeps; i++) {
663         sweep = sw_volume->sweep[i];
664         if(sweep == NULL) {
665           printf("sweep[%d]==NULL\n",i);
666           continue;
667         }
668         if(make_pgm) {
669           sprintf(file_suffix,"pgm");
670           sprintf(filename,"sw_%s_%2.2d.%s", 
671                   time_string,i,file_suffix);
672           printf("Creating: %s\n", filename);
673           make_pathname(filename, pgmdir, pathname);
674           RSL_sweep_to_pgm(sweep, pathname, xdim, ydim, maxr);
675         }
676         if(make_gif) {
677           sprintf(file_suffix,"gif");
678           sprintf(filename,"sw_%s_%2.2d.%s", 
679                   time_string,i,file_suffix);
680           printf("Creating: %s\n", filename);
681           make_pathname(filename, gifdir, pathname);
682           RSL_sweep_to_gif(sweep,pathname,xdim, ydim, maxr);
683         }
684       }
685     }
686     
687 /*
688    Write uf file if requested
689 */
690     if(make_uf) {
691         sprintf(filename,"%s_%s.%s",site_id, time_string,"uf.gz");
692         printf("Creating UF file: %s\n", filename);
693         make_pathname(filename, ufdir, pathname);
694         RSL_radar_to_uf_gzip(radar, pathname);
695     }
696
697     printf("-->> FIELDS: [ ");
698     /* Modified to use RSL_ftype from rsl.h (#define USE_RSL_VARS) and to
699      * loop through volumes. 10/16/2009, BLK
700      */
701     for (i=0; i < MAX_RADAR_VOLUMES; i++) 
702         if (radar->v[i] != NULL) printf("%s ", RSL_ftype[i]);
703      /* 
704     if(radar->v[0] != NULL) printf("DZ ");
705     if(radar->v[1] != NULL) printf("VR ");
706     if(radar->v[2] != NULL) printf("SW ");
707     if(radar->v[3] != NULL) printf("CZ ");
708     if(radar->v[4] != NULL) printf("ZT ");
709     if(radar->v[5] != NULL) printf("DR ");
710     if(radar->v[6] != NULL) printf("LR ");
711     if(radar->v[7] != NULL) printf("ZD ");
712     if(radar->v[8] != NULL) printf("DM ");
713     if(radar->v[9] != NULL) printf("RH ");
714     if(radar->v[10] != NULL) printf("PH ");
715     if(radar->v[11] != NULL) printf("XZ ");
716     if(radar->v[12] != NULL) printf("CR ");
717     if(radar->v[13] != NULL) printf("MZ ");
718     if(radar->v[14] != NULL) printf("MR ");
719     if(radar->v[15] != NULL) printf("ZE ");
720     if(radar->v[16] != NULL) printf("VE ");
721     if(radar->v[17] != NULL) printf("KD ");
722     if(radar->v[18] != NULL) printf("TI ");
723     if(radar->v[19] != NULL) printf("DX ");
724     if(radar->v[20] != NULL) printf("CH ");
725     if(radar->v[21] != NULL) printf("AH ");
726     if(radar->v[22] != NULL) printf("CV ");
727     if(radar->v[23] != NULL) printf("AV ");
728     if(radar->v[24] != NULL) printf("SQ ");
729       */
730     printf("] \n\n");
731 /*
732    Wrap it up!
733 */
734
735     if(verbose)
736         printf("Finished!\n");
737     exit (0);
738
739 } /* End of main */
740