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 * Fix header fields in ray headers.
26 * This routine is initially written to support 1C-51.
27 * It has been noticed that several radar files contain bad header
28 * information. Herein, we correct it by simple linear interpolation.
31 * Space Applications Corporation
39 Ray *RSL_fix_ray_header(Ray *ray)
44 Sweep *RSL_fix_sweep_header(Sweep *sweep)
48 int needed_to_fix = 0;
51 if (sweep == NULL) return sweep;
53 for (i=0; i<sweep->h.nrays; i++) {
54 /* Here, we check and use more than one ray. */
57 if (ray == NULL) continue;
58 if (ray->h.month < 1 || ray->h.month > 12) {
60 fprintf(stderr, "ray[%3.3d]->h.month = %d\n", i, ray->h.month);
62 if (ray->h.day < 1 || ray->h.day > 31) {
64 fprintf(stderr, "ray[%3.3d]->h.day = %d\n", i, ray->h.day);
66 if (ray->h.year < 1980 || ray->h.year > 2020) {
68 fprintf(stderr, "ray[%3.3d]->h.year = %d\n", i, ray->h.year);
70 if (ray->h.hour < 0 || ray->h.hour > 23) {
72 fprintf(stderr, "ray[%3.3d]->h.hour = %d\n", i, ray->h.hour);
74 if (ray->h.minute < 0 || ray->h.minute > 59) {
76 fprintf(stderr, "ray[%3.3d]->h.minute= %d\n", i, ray->h.minute);
78 if (ray->h.sec < 0 || ray->h.sec > 59) {
80 fprintf(stderr, "ray[%3.3d]->h.sec = %f\n", i, ray->h.sec);
82 if (ray->h.elev < 0 || ray->h.elev > 90) {
84 fprintf(stderr, "ray[%3.3d]->h.elev = %f\n", i, ray->h.elev);
86 if (ray->h.range_bin1 < 0 || ray->h.range_bin1 > 150000) {
88 fprintf(stderr, "ray[%3.3d]->h.range_bin1 = %d\n", i, ray->h.range_bin1);
90 if (ray->h.gate_size < 0 || ray->h.gate_size > 100000) {
92 fprintf(stderr, "ray[%3.3d]->h.gate_size = %d\n", i, ray->h.gate_size);
94 if (ray->h.beam_width <= 0 || ray->h.beam_width > 10) {
96 fprintf(stderr, "ray[%3.3d]->h.beam_width = %f\n", i, ray->h.beam_width);
104 fprintf(stderr, "Repaired %d rays in this sweep.\n", nfixed);
109 Volume *RSL_fix_volume_header(Volume *v)
112 if (v == NULL) return v;
114 for (i=0; i<v->h.nsweeps; i++)
115 RSL_fix_sweep_header(v->sweep[i]);
120 Radar *RSL_fix_radar_header(Radar *radar)
123 if (radar == NULL) return radar;
125 for (i=0; i<radar->h.nvolumes; i++)
126 RSL_fix_volume_header(radar->v[i]);