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