]> Pileus Git - ~andy/rsl/blob - examples/any_to_ppm.c
Initial import
[~andy/rsl] / examples / any_to_ppm.c
1 /*
2  * Ingest NEXRAD (wsr88d) data and output images representing
3  * all field types found.
4  *
5  * This example is the most minimum of coding that you need to do
6  * to achieve good results from using the RSL code.
7  *
8  * This is short and sweet to demonstrate the simplicity of use for
9  * the RSL.
10  *
11  */
12
13 #define USE_RSL_VARS
14 #include "rsl.h"
15
16 void main(int argc, char **argv)
17 {
18   Radar *radar;
19   Sweep *sweep;
20   Ray   *ray;
21   int   i;
22   char fname[100];
23
24   if (argc < 2 || argc > 3) {
25         fprintf(stderr, "Usage: %s infile [callid_or_firstfile]\n", argv[0]);
26         exit(-1);
27   }
28
29   RSL_radar_verbose_on(); /* Not needed; it bides the time. */
30   RSL_select_fields("all", NULL);
31   radar = RSL_anyformat_to_radar(argv[1], argv[2]);
32
33   if (radar == NULL) exit(-1);
34
35   if (0) {
36         RSL_write_radar(radar, "rsl.rsl");
37         exit(0);
38   }
39
40   {
41         char time_string[100];
42         sprintf(time_string,"%2.2d%2.2d%2.2d_%2.2d%2.2d", 
43                     radar->h.month, radar->h.day, radar->h.year-1900, 
44                     radar->h.hour, radar->h.minute);
45   }
46
47   for (i=0; i<MAX_RADAR_VOLUMES; i++) {
48         sweep = RSL_get_first_sweep_of_volume(radar->v[i]);
49         ray   = RSL_get_first_ray_of_volume(radar->v[i]);
50
51         if (sweep) {
52           if (i == SW_INDEX)
53                 RSL_load_sw_color_table();
54           else if (i == VR_INDEX || i == VE_INDEX) {
55                 RSL_load_vel_color_table();
56                 RSL_rebin_velocity_volume(radar->v[i]);
57           } else
58                 RSL_load_refl_color_table();
59
60
61 #undef DO_SWEEP
62 #define DO_SWEEP
63 #ifdef DO_SWEEP
64           sprintf(fname, "%s_sweep.ppm", RSL_ftype[i]);
65           RSL_sweep_to_ppm(sweep, fname, 400, 400, 200.0);
66           fprintf(stderr, "Wrote %s\n", fname);
67 #else   
68           sprintf(fname, "%s_sweep", RSL_ftype[i]);
69           RSL_volume_to_gif(radar->v[i], fname, 400, 400, 200.0);
70 #endif
71         }
72   }
73   exit(0);
74
75 }
76
77
78