3 This is the TRMM Office Radar Software Library.
4 Copyright (C) 1995 Dennis F. Flanigan Jr. of Applied Research Corporation,
5 Landover, Maryland, a NASA/GSFC on-site contractor.
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
17 You should have received a copy of the GNU Library General Public
18 License along with this library; if not, write to the Free
19 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 * Version 0.29 updates
32 extern int radar_verbose_flag;
35 /*********************************************************************/
37 /* RSL_get_value_from_cappi */
39 /*********************************************************************/
40 float RSL_get_value_from_cappi(Cappi *cappi, float rng, float azm)
42 return RSL_get_value_from_sweep(cappi->sweep, azm, rng);
45 /*********************************************************************/
51 /* Mods by John Merritt 6/14/95 */
52 /*********************************************************************/
54 Cappi *RSL_new_cappi(Sweep *sweep, float height)
56 /* Modeled after a sweep structure. */
62 float start_bin, size_bin;
64 if((c = (Cappi *)calloc(1, sizeof(Cappi))) == NULL)
66 fprintf(stderr,"RSL_new_cappi: Calloc failed for Cappi data structure.\n");
71 ray = RSL_get_first_ray_of_sweep(sweep);
72 num_bin = ray->h.nbins;
73 start_bin = ray->h.range_bin1/1000.0;
74 size_bin = ray->h.gate_size/1000.0;
76 /* Allocate space for elev angle,range array */
77 if((c->loc =(Er_loc *)calloc(num_bin,sizeof(Er_loc))) == NULL)
79 fprintf(stderr,"RSL_new_cappi: Calloc failed for er_loc array. \n");
84 /* Calculate elevation angle verse range array */
85 for(a=0;a<num_bin;a++)
87 grange = start_bin + (a * size_bin);
88 RSL_get_slantr_and_elev(grange,height,
89 &c->loc[a].srange,&c->loc[a].elev);
92 /* Allocate Space for the data */
93 c->sweep = RSL_copy_sweep(sweep);
94 RSL_clear_sweep(c->sweep); /* This maintains header info. */
99 void RSL_free_cappi(Cappi *c)
101 if (c == NULL) return;
102 RSL_free_sweep(c->sweep);
110 /*********************************************************************/
115 /* Modified by John Merritt 6/14/95 */
116 /*********************************************************************/
117 Cappi *RSL_cappi_at_h(Volume *v, float height, float max_range)
119 * h and max_range in KM.
126 if (v == NULL) return NULL;
127 sweep = RSL_get_first_sweep_of_volume(v); /* 1st non-NULL sweep */
129 if((c = RSL_new_cappi(sweep, height)) == NULL)
131 fprintf(stderr,"RSL_cappi_at_h: Vnew_cappi failed\n");
135 if((n = RSL_fill_cappi(v,c,0)) < 0)
137 fprintf(stderr,"RSL_cappi_at_h: Vfill_cappi_at_h failed: returned: %d\n",n);
146 /*********************************************************************/
150 /*********************************************************************/
151 int RSL_fill_cappi(Volume *v, Cappi *cap, int method)
158 if (v == NULL) return(-1);
159 if (cap == NULL) return(-1);
161 /* get data from frist ray. */
162 ray = RSL_get_first_ray_of_volume(v);
163 cap->month = ray->h.month;
164 cap->day = ray->h.day;
165 cap->year = ray->h.year;
166 cap->hour = ray->h.hour;
167 cap->minute = ray->h.minute;
168 cap->sec = ray->h.sec;
169 cap->field_type = 1; /** default setting -- PAK **/
170 cap->interp_method = method; /* ?? nearest neighbor */
172 ray = RSL_get_first_ray_of_sweep(cap->sweep);
174 for(a=0;a < sweep->h.nrays; a++)
177 for(b=0; b < ray->h.nbins; b++)
181 cap->sweep->ray[a]->h.azimuth,
184 ray->range[b] = ray->h.invf(x);