Mapper
make_fmap.c
Go to the documentation of this file.
1 #include "prototypes.h"
2 
3 void make_fmap(int k)
4 
5 {
6 
7 extern struct map map[500];
8 extern struct pcp *qpf;
9 extern struct hrap_grid *hrap_grid;
10 int m,ib,l;
11 int x,y,ix,iy;
12 int minx,miny,totx,toty,uzpts,lzpts,mzpts,gzpts;
13 float lz,uz,mz,gz;
14 time_t tim;
15 struct tm *gmtim;
16 
17 tim=time(NULL);
18 
19 gmtim=gmtime(&tim);
20 
21 minx=hrap_grid->hrap_minx;
22 miny=hrap_grid->hrap_miny;
23 totx=hrap_grid->maxi;
24 toty=hrap_grid->maxj;
25 
26 read_file("qpf",k,qpf);
27 
28 for(ib=0;map[ib].hb5[0]!=0;ib++) {
29 
30  mz=0;uz=0;lz=0;gz=0;uzpts=0;lzpts=0;mzpts=0;gzpts=0;
31 
32 
33  for(l=0;l<map[ib].hrap_points;l++) {
34 
35  x=map[ib].hrap_data[l].x;
36  y=map[ib].hrap_data[l].y;
37 
38  ix=x-minx;
39  iy=y-miny;
40 
41  if(ix < 0 || iy < 0 || ix > totx || iy > toty) {
42 
43  continue;
44 
45  }
46 
47  if(map[ib].hrap_data[l].zone[3]==1) {
48 
49  gz=gz+(float)qpf->value[ix][iy]/100;
50  gzpts++;
51 
52  }
53 
54  if(map[ib].hrap_data[l].zone[2]==1) {
55 
56  uz=uz+(float)qpf->value[ix][iy]/100;
57  uzpts++;
58 
59  }
60 
61  if(map[ib].hrap_data[l].zone[1]==1) {
62 
63  mz=mz+(float)qpf->value[ix][iy]/100;
64  mzpts++;
65 
66  }
67 
68  if(map[ib].hrap_data[l].zone[0]==1) {
69 
70  lz=lz+(float)qpf->value[ix][iy]/100;
71  lzpts++;
72 
73 
74 
75  }
76 
77  }
78 
79  if(uzpts ==0)
80  uz=-1;
81  else
82  uz=uz/(float)uzpts;
83 
84  if(mzpts==0)
85  mz=-1;
86  else
87  mz=mz/(float)mzpts;
88 
89  if(lzpts==0)
90  lz=-1;
91  else
92  lz=lz/(float)lzpts;
93 
94  if(gzpts==0)
95  gz=-1;
96  else
97  gz=gz/(float)gzpts;
98 
99 
100  map[ib].gz[k]=gz;
101  map[ib].uz[k]=uz;
102  map[ib].mz[k]=mz;
103  map[ib].lz[k]=lz;
104  map[ib].maps_done[k]=1;
105 
106  }
107 
108 }
109 
110 
void read_file(char *, int, struct pcp *)
Definition: read_file.c:5
void make_fmap(int k)
Definition: make_fmap.c:3
int k
Definition: mapp2h.h:48
struct hrap_grid * hrap_grid
Definition: mapper.c:142
ib
Definition: shleap.cc:46
int x
Definition: misc.h:230
int y
Definition: misc.h:231
short int hrap_miny
Definition: misc.h:583
short int hrap_minx
Definition: misc.h:582
short int maxi
Definition: misc.h:580
short int maxj
Definition: misc.h:581
Definition: misc.h:236
char hb5[10]
Definition: misc.h:238
float lz[200]
Definition: misc.h:250
float uz[200]
Definition: misc.h:248
struct hrap_data * hrap_data
Definition: misc.h:245
int hrap_points
Definition: misc.h:244
float gz[200]
Definition: misc.h:247
float mz[200]
Definition: misc.h:249
int maps_done[200]
Definition: misc.h:246
Definition: misc.h:596
short int ** value
Definition: misc.h:599
tim()
Definition: tim.c:4