-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathfix_headers.c
131 lines (112 loc) · 3.5 KB
/
fix_headers.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*
NASA/TRMM, Code 910.1.
This is the TRMM Office Radar Software Library.
Copyright (C) 1996, 1997
John H. Merritt
Space Applications Corporation
Vienna, Virginia
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* Fix header fields in ray headers.
*
* This routine is initially written to support 1C-51.
* It has been noticed that several radar files contain bad header
* information. Herein, we correct it by simple linear interpolation.
*
* By: John Merritt
* Space Applications Corporation
* Copyright 7/16/96
*
*/
#include <stdio.h>
#include "rsl.h"
Ray *RSL_fix_ray_header(Ray *ray)
{
return ray;
}
Sweep *RSL_fix_sweep_header(Sweep *sweep)
{
int i;
int nfixed = 0;
int needed_to_fix = 0;
Ray *ray;
if (sweep == NULL) return sweep;
for (i=0; i<sweep->h.nrays; i++) {
/* Here, we check and use more than one ray. */
ray = sweep->ray[i];
if (ray == NULL) continue;
if (ray->h.month < 1 || ray->h.month > 12) {
needed_to_fix = 1;
fprintf(stderr, "ray[%3.3d]->h.month = %d\n", i, ray->h.month);
}
if (ray->h.day < 1 || ray->h.day > 31) {
needed_to_fix = 1;
fprintf(stderr, "ray[%3.3d]->h.day = %d\n", i, ray->h.day);
}
if (ray->h.year < 1980 || ray->h.year > 2020) {
needed_to_fix = 1;
fprintf(stderr, "ray[%3.3d]->h.year = %d\n", i, ray->h.year);
}
if (ray->h.hour < 0 || ray->h.hour > 23) {
needed_to_fix = 1;
fprintf(stderr, "ray[%3.3d]->h.hour = %d\n", i, ray->h.hour);
}
if (ray->h.minute < 0 || ray->h.minute > 59) {
needed_to_fix = 1;
fprintf(stderr, "ray[%3.3d]->h.minute= %d\n", i, ray->h.minute);
}
if (ray->h.sec < 0 || ray->h.sec > 59) {
needed_to_fix = 1;
fprintf(stderr, "ray[%3.3d]->h.sec = %f\n", i, ray->h.sec);
}
if (ray->h.elev < 0 || ray->h.elev > 90) {
needed_to_fix = 1;
fprintf(stderr, "ray[%3.3d]->h.elev = %f\n", i, ray->h.elev);
}
if (ray->h.range_bin1 < 0 || ray->h.range_bin1 > 150000) {
needed_to_fix = 1;
fprintf(stderr, "ray[%3.3d]->h.range_bin1 = %d\n", i, ray->h.range_bin1);
}
if (ray->h.gate_size < 0 || ray->h.gate_size > 100000) {
needed_to_fix = 1;
fprintf(stderr, "ray[%3.3d]->h.gate_size = %d\n", i, ray->h.gate_size);
}
if (ray->h.beam_width <= 0 || ray->h.beam_width > 10) {
needed_to_fix = 1;
fprintf(stderr, "ray[%3.3d]->h.beam_width = %f\n", i, ray->h.beam_width);
}
if (needed_to_fix) {
needed_to_fix = 0;
nfixed++;
}
}
fprintf(stderr, "Repaired %d rays in this sweep.\n", nfixed);
return sweep;
}
Volume *RSL_fix_volume_header(Volume *v)
{
int i;
if (v == NULL) return v;
for (i=0; i<v->h.nsweeps; i++)
RSL_fix_sweep_header(v->sweep[i]);
return v;
}
Radar *RSL_fix_radar_header(Radar *radar)
{
int i;
if (radar == NULL) return radar;
for (i=0; i<radar->h.nvolumes; i++)
RSL_fix_volume_header(radar->v[i]);
return radar;
}