3 This is the TRMM Office Radar Software Library.
4 Copyright (C) 1996, 1997
6 Space Applications Corporation
9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Library General Public
11 License as published by the Free Software Foundation; either
12 version 2 of the License, or (at your option) any later version.
14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Library General Public License for more details.
19 You should have received a copy of the GNU Library General Public
20 License along with this library; if not, write to the Free
21 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 * Radar routines coded in this file:
26 * RSL_radar_verbose_on();
27 * RSL_radar_verbose_off();
28 * Radar *RSL_new_radar(int nvolumes);
29 * void RSL_free_radar(Radar *r);
30 * Radar *RSL_clear_radar(Radar *r);
31 * Volume *RSL_get_volume(Radar *r, int type_wanted);
32 * Radar *RSL_wsr88d_to_radar(char *infile, unsigned int data_mask);
35 * print_vect(float v[], int istart, int istop);
36 * void radar_load_date_time(Radar *radar);
37 * int wsr88d_load_sweep_into_volume(Wsr88d_sweep ws,
38 * Volume *v, int nsweep, unsigned int vmask);
40 * Radar routines not coded in this file:
42 * Radar *RSL_read_radar(char *infile);
43 * int RSL_write_radar(Radar *radar, char *outfile);
44 * Radar *RSL_clear_radar(Radar *r);
45 * void RSL_radar_to_uf(Radar *r, char *outfile);
46 * Radar *RSL_uf_to_radar(char *infile);
48 * See the file radar.ez and version.notes for more detailed documentation.
50 * All routines herein coded, unless otherwise stated, by:
52 * Space Applications Corporation
61 void RSL_print_version()
63 printf("RSL version %s.\n", VERSION);
66 /* Debug printing global variable: radar_verbose_flag */
67 int radar_verbose_flag = 0;
69 void RSL_radar_verbose_on()
71 radar_verbose_flag = 1;
73 void RSL_radar_verbose_off()
75 radar_verbose_flag = 0;
78 void print_vect(float v[], int istart, int istop)
81 for (i=istart; i<=istop; i++)
82 fprintf(stderr,"v[%d] = %f\n", i, v[i]);
86 /**********************************************************************/
88 /* RSL_get_nyquist_from_radar */
90 /**********************************************************************/
91 float RSL_get_nyquist_from_radar(Radar *radar)
93 /* Find a velocity volume.
94 * Find first sweep in that volume.
95 * Find first ray in that sweep.
96 * Return the nyquist velocity.
98 * This code required for loading nyquist value in non-velocity
99 * volumes; UF output is affected by this in a good way.
104 if (radar == NULL) return 0.0;
105 if (radar->h.nvolumes <= VR_INDEX) return 0.0;
107 vol = radar->v[VR_INDEX];
108 ray = RSL_get_first_ray_of_volume(vol);
109 if (ray == NULL) return 0.0;
110 return ray->h.nyq_vel;
113 /**********************************************************************/
115 /* done 3/30 new_radar() */
116 /* done 3/30 free_radar() */
117 /* done 4/21 clear_radar() */
119 /**********************************************************************/
120 Radar *RSL_new_radar(int nvolumes)
123 r = (Radar *) calloc(1, sizeof(Radar));
124 r->v = (Volume **) calloc(nvolumes, sizeof(Volume *));
125 r->h.nvolumes = nvolumes;
126 r->h.scan_mode = PPI; /* default PPI is enum constant defined in rsl.h */
130 void RSL_free_radar(Radar *r)
134 /* Chase down all the pointers and free everything in sight. */
136 for (i=0; i<r->h.nvolumes; i++)
137 RSL_free_volume(r->v[i]);
138 if (r->v) free(r->v);
143 Radar *RSL_clear_radar(Radar *r)
147 if (r == NULL) return r;
148 for (i=0; i<r->h.nvolumes; i++)
149 RSL_clear_volume(r->v[i]);
154 /**********************************************************************/
156 /* done 8/26 radar_load_date_time */
158 /**********************************************************************/
159 void radar_load_date_time(Radar *radar)
161 /* Search for the first existing ray of the first sweep of the first
162 * volume; steal that information.
176 for (i=0; i<MAX_RADAR_VOLUMES; i++) {
177 if (radar->v[i] != NULL) {
178 first_ray = RSL_get_first_ray_of_volume(radar->v[i]);
180 radar->h.month = first_ray->h.month;
181 radar->h.day = first_ray->h.day;
182 radar->h.year = first_ray->h.year;
183 radar->h.hour = first_ray->h.hour;
184 radar->h.minute= first_ray->h.minute;
185 radar->h.sec = first_ray->h.sec;
192 /**********************************************************************/
194 /* done 3/30 Volume *RSL_get_volume */
196 /**********************************************************************/
197 Volume *RSL_get_volume(Radar *r, int type_wanted)
199 return r->v[type_wanted];