Mapper
hourly_rain.c
Go to the documentation of this file.
1 /* possible error returns
2 
3  -1 no report after begin time
4  -2 no report after end time
5  -3 time gap between begin time and first report after begin time too large
6  -4 data not reliable
7 
8  r->rn amount of rain
9  r->tdif time gap of end time and last report
10 
11  */
12 
13 #include "prototypes.h"
14 
16  time_t tstart,time_t tstop,struct rainfall *r)
17 
18 {
19 
20 int j,eflag;
21 int xpctd;
22 
23 r->rn=0.0;
24 r->rel=0;
25 r->obs=0;
26 r->tskips=0;
27 r->tdif=0L;
28 
29 eflag=-1;
30 
31 xpctd=(tstart-tstop)/3600;
32 
33 if(xpctd==0)
34  xpctd=1;
35 
36 for(j=0;j<inum;j++) {
37 
38  /* observation time before start time */
39 
40  if(stn_values[j].clock > tstart)
41  continue;
42 
43  if(stn_values[j].clock <= tstop) {
44 
45  /*
46  printf("pph %d %d %f\n",xpctd,r->obs,
47  (float)r->obs/(float)xpctd);
48  */
49 
50  if((float)r->obs/(float)xpctd > .75)
51  return(1);
52 
53  else
54  return(-1);
55 
56  }
57 
58  if((r->obs==0 || j==0) && (tstart - stn_values[j].clock) > r->maxtdif){
59 
60  r->tdif=tstart-stn_values[j].clock;
61  return(-3);
62 
63  }
64 
65  r->obs++;
66  eflag=-2;
67 
68  if(stn_values[j].value < 0 || stn_values[j].value >= r->maxgap) {
69 
70  r->rel++;
71  if(r->rel >= 2)
72  eflag=-4;
73 
74  }
75 
76  else
77  r->rn=r->rn+stn_values[j].value;
78 
79  }
80 
81 return(eflag);
82 
83 }
84 
hourly_rain(struct stn_values *stn_values, int inum, time_t tstart, time_t tstop, struct rainfall *r)
Definition: hourly_rain.c:15
int j
Definition: mapp2h.h:48
float value
int maxtdif
Definition: hydro_data.h:24
float rn
Definition: hydro_data.h:18
float maxgap
Definition: hydro_data.h:26
int obs
Definition: hydro_data.h:20
int tskips
Definition: hydro_data.h:21
int tdif
Definition: hydro_data.h:22
int rel
Definition: hydro_data.h:19
time_t clock
Definition: hydro_data.h:32
float value
Definition: hydro_data.h:35