Mapper
libraries
common
stuff.c
Go to the documentation of this file.
1
2
int
read_cqpf
(time_t
tim
,
int
st,
int
fi)
3
4
{
5
6
struct
tm *gmtim;
7
char
points[100],kbuf[100],*p;
8
long
r,s;
9
float
conv=.0174;
10
float
lat
,
lon
,
pcp
;
11
int
k
,ier,
i
,numpoints;
12
struct
abogus
*cbogus;
13
FILE *
fp
;
14
int
m;
15
16
wfobogus
[0].
owner
=-1;
17
18
gmtim=gmtime(&
tim
);
19
20
for
(m=0;m<20;m++){
21
22
for
(
k
=st;
k
<fi;
k
++) {
23
24
for
(
i
=0;
i
<100;
i
++) {
25
wfobogus
[m].
bogus
[
k
].
inuse
[
i
]=-1;
26
}
27
}
28
29
}
30
31
32
for
(m=0;m<20;m++){
33
34
for
(
k
=st;
k
<fi;
k
++)
35
wfobogus
[m].bogus_flag[
k
]=-1;
36
37
}
38
39
/* memory leak need to free bbogus area */
40
41
sprintf
(points,
"%s/fpointa.%s.%02d-%02d-%02d"
,scratch_file,arfc,
42
gmtim->tm_mon+1,gmtim->tm_mday,gmtim->tm_year);
43
44
fp
=fopen(points,
"r"
);
45
46
if
(
fp
==NULL)
47
return
(-1);
48
49
m=0;
50
for
(;;) {
51
52
p=fgets(kbuf,100,
fp
);
53
54
if
(p==NULL)
55
break
;
56
57
p=strchr(kbuf,
'\n'
);
58
if
(p!=NULL)
59
*p=0;
60
61
if
(strcmp(kbuf,
".END"
)==0)
62
continue
;
63
64
/* get owner here */
65
66
wfobogus
[m].
owner
=-1;
67
68
for
(
k
=0;
k
<20;
k
++) {
69
70
if
(
valid_list
[
k
].wfo[0]==0)
71
break
;
72
73
if
(strcmp(
valid_list
[
k
].wfo,kbuf)==0) {
74
75
if
(strcmp(wfo,kbuf)==0)
76
continue
;
77
78
wfobogus
[m].
owner
=
valid_list
[
k
].
alias
;
79
80
break
;
81
82
}
83
84
}
85
86
if
(
wfobogus
[m].owner==-1)
87
continue
;
88
89
90
91
for
(
k
=st;
k
<fi;
k
++) {
92
93
wfobogus
[m].
bbogus
[
k
]=NULL;
94
95
numpoints=0;
96
97
for
(;;) {
98
99
p=fgets(kbuf,100,
fp
);
100
if
(p==NULL)
101
return
(1);
102
103
if
(strncmp(
"END"
,kbuf,3)==0)
104
break
;
105
106
if
(
wfobogus
[m].bbogus[
k
]==NULL){
107
108
wfobogus
[m].
bogus_flag
[
k
]=0;
109
wfobogus
[m].
bbogus
[
k
]=calloc(1,
sizeof
(
struct
abogus
));
110
cbogus=
wfobogus
[m].
bbogus
[
k
];
111
112
}
113
114
else
{
115
116
cbogus->
next
=calloc(1,
sizeof
(
struct
abogus
));
117
cbogus=cbogus->
next
;
118
119
}
120
121
numpoints++;
122
ier=sscanf(kbuf,
"%f %f"
,&
lat
,&
lon
);
123
124
r=
dval
.
a
* cos(
lat
*conv)/(1+sin(
lat
*conv))
125
* cos((
lon
-
dval
.
lo
-90)*conv) +
dval
.
xo
+.5;
126
127
s=
dval
.
a
* cos(
lat
*conv)/(1+sin(
lat
*conv))
128
* sin((
lon
-
dval
.
lo
-90)*conv) +
dval
.
yo
+ .5;
129
130
cbogus->
x
=r;
131
cbogus->
y
=s;
132
cbogus->
next
=NULL;
133
134
}
135
136
for
(
i
=0;
i
<20;
i
++) {
137
138
p=fgets(kbuf,100,
fp
);
139
if
(p==NULL)
140
return
(1);
141
142
if
(strncmp(
"END"
,kbuf,3)==0)
143
break
;
144
145
ier=sscanf(kbuf,
"%f %f %f"
,&
lat
,&
lon
,&
pcp
);
146
147
r=
dval
.
a
* cos(
lat
*conv)/(1+sin(
lat
*conv))
148
* cos((
lon
-
dval
.
lo
-90)*conv) +
dval
.
xo
+.5;
149
150
s=
dval
.
a
* cos(
lat
*conv)/(1+sin(
lat
*conv))
151
* sin((
lon
-
dval
.
lo
-90)*conv) +
dval
.
yo
+ .5;
152
153
wfobogus
[m].
bogus_flag
[
k
]=1;
154
wfobogus
[m].
bogus
[
k
].
inuse
[
i
]=1;
155
wfobogus
[m].
bogus
[
k
].
x
[
i
]=r;
156
wfobogus
[m].
bogus
[
k
].
y
[
i
]=s;
157
wfobogus
[m].
bogus
[
k
].
value
[
i
]=
pcp
;
158
159
}
160
161
if
(numpoints==0)
162
wfobogus
[m].
bogus_flag
[
k
]=-1;
163
164
}
165
166
m++;
167
168
}
169
170
wfobogus
[m].
owner
=-1;
171
172
173
fclose
(
fp
);
174
175
}
i
static int i
Definition:
get_apps_defaults.c:110
fclose
fclose(fp)
sprintf
sprintf(fbuf,"/usr/mapper/nexrad/ngrid.%02d-%02d-%02d-%02d", year, month, day, hour)
fp
fp
Definition:
make_NEXRAD.c:339
lat
double lat
Definition:
mapp2h.h:41
lon
double lon
Definition:
mapp2h.h:41
k
int k
Definition:
mapp2h.h:48
pcp
struct pcp * pcp
Definition:
mapper.c:140
abogus
Definition:
misc.h:330
abogus::x
short int x
Definition:
misc.h:332
abogus::y
short int y
Definition:
misc.h:333
abogus::next
struct abogus * next
Definition:
misc.h:334
bogus::value
float value[500]
Definition:
misc.h:344
bogus::y
short int y[500]
Definition:
misc.h:343
bogus::inuse
short int inuse[500]
Definition:
misc.h:341
bogus::x
short int x[500]
Definition:
misc.h:342
dval
Definition:
misc.h:470
dval::lo
double lo
Definition:
misc.h:475
dval::a
double a
Definition:
misc.h:472
dval::yo
double yo
Definition:
misc.h:474
dval::xo
double xo
Definition:
misc.h:473
pcp
Definition:
misc.h:596
valid_list
Definition:
misc_new.h:52
valid_list::alias
int alias
Definition:
misc_new.h:55
wfobogus
Definition:
misc.h:348
wfobogus::bbogus
struct abogus * bbogus
Definition:
misc.h:353
wfobogus::bogus_flag
int bogus_flag[10]
Definition:
misc.h:352
wfobogus::owner
int owner
Definition:
misc.h:351
wfobogus::bogus
struct bogus bogus[20]
Definition:
misc.h:354
read_cqpf
int read_cqpf(time_t tim, int st, int fi)
Definition:
stuff.c:2
tim
tim()
Definition:
tim.c:4
Generated by
1.9.1