Mapper
render_pcp.c
Go to the documentation of this file.
1 #include "prototypes.h"
2 
4 
5 {
6 
7 extern Widget top_level;
8 extern int pcp_in_use[50];
9 extern int pcp_flag;
10 extern Cursor watch_cursor;
11 extern int method;
12 int i,j,h,hh,time_pos,htotal;
13 double distance,dist1,dist2,dist,value;
14 double temp;
15 extern struct hrap_grid *hrap_grid;
16 extern struct pcp *pcp;
17 extern Window window;
18 extern Display *display;
19 extern int max_stations;
20 
21 XDefineCursor(display,window,watch_cursor);
22 XmUpdateDisplay(top_level);
23 
24 if(pcpn_time_step==0)
25  time_pos=pcpn_time;
26 
27 else
28  time_pos=4;
29 
30 for(i=0;i<hrap_grid->maxi;i++) {
31 
32 for(j=0;j<hrap_grid->maxj;j++) {
33 
34  value=0.0;
35  distance=0.0;
36  htotal=0;
37 
38  for(h=0;h<20;h++) {
39 
40  hh=hrap_grid->gage[i][j].index[h];
41 
42  htotal++;
43 /*
44  dist1=(double)(hrap_grid->coord[i][j].x-
45  station[hh].x);
46  dist2=(double)(hrap_grid->coord[i][j].y-
47  station[hh].y);
48 */
49  dist=pow(dist1,2)+pow(dist2,2);
50 
51  if(dist < 1.0)
52  dist=1.0;
53 
54  dist=1/dist;
55 /*
56  temp=pdata[pcpn_day].stn[hh].frain[time_pos].data*dist;
57 
58  if(method==2 && station[hh].isoh > 0)
59  temp=temp*(float)hrap_grid->isoh[i][j]/station[hh].isoh;
60 */
62 
63  distance=distance+dist;
64 
65  }
66 
67  if(htotal==0) {
68 
69  for(h=0;h<max_stations;h++) {
70 
71  htotal++;
72 /*
73  dist1=(double)(hrap_grid->coord[i][j].x-
74  station[h].x);
75  dist2=(double)(hrap_grid->coord[i][j].y-
76  station[h].y);
77 */
78  dist=pow(dist1,2)+pow(dist2,2);
79 
80  if(dist < 1.0)
81  dist=1.0;
82 
83  dist=1/dist;
84 /*
85  temp=pdata[pcpn_day].stn[h].frain[time_pos].data*dist;
86 
87  if(method==2 && station[h].isoh > 0)
88  temp=temp*(float)hrap_grid->isoh[i][j]/station[h].isoh;
89 */
91 
92  distance=distance+dist;
93 
94  }
95 
96  }
97 
98  if(htotal == 0)
99  pcp->value[i][j]=0;
100 
101  else
102  pcp->value[i][j]=(int)(value/distance*100);
103 
104  if(pcp->value[i][j] < .01)
105  pcp->value[i][j]=0.0;
106 
107 
108  }
109 
110 }
111 
112 
113 if(pcpn_time_step==0)
114  time_pos=pcp_flag;
115 
116 else
117  time_pos=pcp_flag+pcpn_day;
118 
119 pcp_in_use[time_pos]=1;
120 
121 write_file("pcp",time_pos,pcp);
122 
123 }
static int i
Display * display
Definition: mapper.c:159
Widget top_level
Definition: display_rec.c:5
void write_file(char *, int, struct pcp *)
Definition: write_file.c:5
void render_pcp(int pcpn_day, int pcpn_time, int pcpn_time_step)
Definition: render_pcp.c:12
int j
Definition: mapp2h.h:48
char temp[9]
Definition: mapp2h.h:66
int pcpn_time
Definition: mapper.c:83
int pcpn_time_step
Definition: mapper.c:75
int max_stations
Definition: mapper.c:64
int pcpn_day
Definition: mapper.c:83
int pcp_flag
Definition: mapper.c:81
Window window
Definition: mapper.c:190
Cursor watch_cursor
Definition: mapper.c:153
float value
struct pcp * pcp
Definition: mapper.c:140
int pcp_in_use[50]
Definition: mapper.c:78
struct hrap_grid * hrap_grid
Definition: mapper.c:142
short int index[20]
Definition: misc.h:592
short int maxi
Definition: misc.h:580
short int maxj
Definition: misc.h:581
struct gage ** gage
Definition: misc.h:585
Definition: misc.h:596
short int ** value
Definition: misc.h:599