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