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 * The PRUNE functions eliminate NULL or non-present (no data present)
25 * substructures. This tightens the structures for output. Development
26 * was sparked by failing NCAR UF ingest programs; they cannot handle
27 * 0 sized volumes/sweeps/rays dispite conformity to the UF specification.
29 * These routines free memory that is pruned.
32 * Space Applications Corporation
37 extern int radar_verbose_flag;
39 Ray *RSL_prune_ray(Ray *ray)
41 if (ray == NULL) return NULL;
42 if (ray->h.nbins > 0) return ray;
47 Sweep *RSL_prune_sweep(Sweep *s)
51 if (s == NULL) return NULL;
52 if (s->h.nrays == 0) {
57 * Squash out all dataless rays. 'j' is the index for the squashed (pruned)
60 for (i=0,j=0; i<s->h.nrays; i++)
61 if ((s->ray[i] = RSL_prune_ray(s->ray[i])))
62 s->ray[j++] = s->ray[i]; /* Keep this ray. */
66 return NULL; /* All rays were pruned. */
68 for (i=j; i<s->h.nrays; i++) s->ray[i] = NULL;
73 Volume *RSL_prune_volume(Volume *v)
77 if (v == NULL) return NULL;
78 if (v->h.nsweeps == 0) {
83 * Squash out all dataless sweeps. 'j' is the index for sweep containing data.
85 for (i=0,j=0; i<v->h.nsweeps; i++)
86 if ((v->sweep[i] = RSL_prune_sweep(v->sweep[i])))
87 v->sweep[j++] = v->sweep[i]; /* Keep this sweep. */
91 return NULL; /* All sweeps were pruned. */
93 for (i=j; i<v->h.nsweeps; i++) v->sweep[i] = NULL;
98 Radar *RSL_prune_radar(Radar *radar)
101 /* Volume indexes are fixed so we just prune the substructures. */
102 if (radar == NULL) return NULL;
103 for (i=0; i<radar->h.nvolumes; i++)
104 radar->v[i] = RSL_prune_volume(radar->v[i]);