]> Pileus Git - ~andy/rsl/blob - examples/any_to_ppm.c
RSL v1.44
[~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 #include <stdlib.h>
13
14 #define USE_RSL_VARS
15 #include "rsl.h"
16
17 int main(int argc, char **argv)
18 {
19   Radar *radar;
20   Sweep *sweep;
21   Ray   *ray;
22   int   i;
23   char fname[100];
24
25   if (argc < 2 || argc > 3) {
26         fprintf(stderr, "Usage: %s infile [callid_or_firstfile]\n", argv[0]);
27         exit(-1);
28   }
29
30   RSL_radar_verbose_on(); /* Not needed; it bides the time. */
31   RSL_select_fields("all", NULL);
32   radar = RSL_anyformat_to_radar(argv[1], argv[2]);
33
34   if (radar == NULL) exit(-1);
35
36   if (0) {
37         RSL_write_radar(radar, "rsl.rsl");
38         exit(0);
39   }
40
41   {
42         char time_string[100];
43         sprintf(time_string,"%2.2d%2.2d%2.2d_%2.2d%2.2d", 
44                     radar->h.month, radar->h.day, radar->h.year-1900, 
45                     radar->h.hour, radar->h.minute);
46   }
47
48   for (i=0; i<MAX_RADAR_VOLUMES; i++) {
49         sweep = RSL_get_first_sweep_of_volume(radar->v[i]);
50         ray   = RSL_get_first_ray_of_volume(radar->v[i]);
51
52         if (sweep) {
53           if (i == SW_INDEX)
54                 RSL_load_sw_color_table();
55           else if (i == VR_INDEX || i == VE_INDEX) {
56                 RSL_load_vel_color_table();
57                 RSL_rebin_velocity_volume(radar->v[i]);
58           } else
59                 RSL_load_refl_color_table();
60
61
62 #undef DO_SWEEP
63 #define DO_SWEEP
64 #ifdef DO_SWEEP
65           sprintf(fname, "%s_sweep.ppm", RSL_ftype[i]);
66           RSL_sweep_to_ppm(sweep, fname, 400, 400, 200.0);
67           fprintf(stderr, "Wrote %s\n", fname);
68 #else   
69           sprintf(fname, "%s_sweep", RSL_ftype[i]);
70           RSL_volume_to_gif(radar->v[i], fname, 400, 400, 200.0);
71 #endif
72         }
73   }
74   exit(0);
75
76 }
77
78
79