Goose Management Model ODdox  1.02
weather.h
Go to the documentation of this file.
1 //
2 // weather.h
3 //
4 
5 
6 #ifndef WEATHER_H
7 #define WEATHER_H
8 
9 #include <vector>
10 using namespace std;
11 
12 extern class Weather *g_weather;
13 
14 // Below is the data for insolation in MJ per m2 for ødum fitted to 1961-1990
15 // by Olesen (1991)
16 const double c_insolation [365] = {
17  0.91,
18  0.921585,
19  0.935138,
20  0.950669,
21  0.968188,
22  0.987706,
23  1.009231,
24  1.032774,
25  1.058346,
26  1.085956,
27  1.115614,
28  1.14733,
29  1.181113,
30  1.216974,
31  1.254921,
32  1.294964,
33  1.337112,
34  1.381373,
35  1.427757,
36  1.476271,
37  1.526923,
38  1.57972,
39  1.634671,
40  1.691781,
41  1.751057,
42  1.812504,
43  1.876128,
44  1.941934,
45  2.009926,
46  2.080107,
47  2.15248,
48  2.227048,
49  2.303812,
50  2.382774,
51  2.463933,
52  2.547289,
53  2.63284,
54  2.720585,
55  2.81052,
56  2.902642,
57  2.996945,
58  3.093425,
59  3.192073,
60  3.292884,
61  3.395847,
62  3.500954,
63  3.608194,
64  3.717555,
65  3.829024,
66  3.942587,
67  4.05823,
68  4.175935,
69  4.295687,
70  4.417465,
71  4.541252,
72  4.667024,
73  4.794762,
74  4.924441,
75  5.056036,
76  5.189522,
77  5.324873,
78  5.462059,
79  5.601051,
80  5.741819,
81  5.884329,
82  6.02855,
83  6.174446,
84  6.321981,
85  6.471118,
86  6.621819,
87  6.774044,
88  6.927753,
89  7.082902,
90  7.239449,
91  7.397349,
92  7.556555,
93  7.717022,
94  7.8787,
95  8.041541,
96  8.205493,
97  8.370505,
98  8.536524,
99  8.703496,
100  8.871365,
101  9.040077,
102  9.209573,
103  9.379796,
104  9.550686,
105  9.722183,
106  9.894227,
107  10.06675,
108  10.2397,
109  10.41301,
110  10.58661,
111  10.76044,
112  10.93443,
113  11.10852,
114  11.28264,
115  11.45671,
116  11.63068,
117  11.80448,
118  11.97802,
119  12.15125,
120  12.3241,
121  12.49648,
122  12.66834,
123  12.8396,
124  13.01019,
125  13.18004,
126  13.34907,
127  13.51721,
128  13.6844,
129  13.85056,
130  14.01561,
131  14.17949,
132  14.34212,
133  14.50344,
134  14.66337,
135  14.82184,
136  14.97877,
137  15.13411,
138  15.28778,
139  15.43971,
140  15.58983,
141  15.73807,
142  15.88437,
143  16.02866,
144  16.17087,
145  16.31093,
146  16.44879,
147  16.58439,
148  16.71764,
149  16.8485,
150  16.97691,
151  17.1028,
152  17.22612,
153  17.3468,
154  17.46479,
155  17.58005,
156  17.6925,
157  17.80211,
158  17.90881,
159  18.01256,
160  18.11332,
161  18.21102,
162  18.30564,
163  18.39712,
164  18.48542,
165  18.5705,
166  18.65233,
167  18.73086,
168  18.80605,
169  18.87788,
170  18.94632,
171  19.01132,
172  19.07286,
173  19.13092,
174  19.18546,
175  19.23647,
176  19.28393,
177  19.3278,
178  19.36809,
179  19.40475,
180  19.4378,
181  19.4672,
182  19.49296,
183  19.51506,
184  19.53349,
185  19.54825,
186  19.55934,
187  19.56676,
188  19.5705,
189  19.57058,
190  19.56698,
191  19.55973,
192  19.54883,
193  19.53428,
194  19.51611,
195  19.49432,
196  19.46893,
197  19.43996,
198  19.40743,
199  19.37136,
200  19.33177,
201  19.28868,
202  19.24213,
203  19.19214,
204  19.13873,
205  19.08195,
206  19.02183,
207  18.95839,
208  18.89168,
209  18.82173,
210  18.74858,
211  18.67228,
212  18.59286,
213  18.51036,
214  18.42484,
215  18.33634,
216  18.2449,
217  18.15058,
218  18.05342,
219  17.95348,
220  17.8508,
221  17.74545,
222  17.63746,
223  17.52691,
224  17.41384,
225  17.29832,
226  17.18039,
227  17.06012,
228  16.93757,
229  16.8128,
230  16.68586,
231  16.55683,
232  16.42576,
233  16.29271,
234  16.15775,
235  16.02094,
236  15.88235,
237  15.74203,
238  15.60006,
239  15.4565,
240  15.3114,
241  15.16485,
242  15.0169,
243  14.86762,
244  14.71707,
245  14.56532,
246  14.41243,
247  14.25848,
248  14.10352,
249  13.94762,
250  13.79084,
251  13.63325,
252  13.47491,
253  13.31588,
254  13.15624,
255  12.99604,
256  12.83534,
257  12.6742,
258  12.5127,
259  12.35088,
260  12.18881,
261  12.02654,
262  11.86415,
263  11.70167,
264  11.53918,
265  11.37673,
266  11.21437,
267  11.05216,
268  10.89016,
269  10.72841,
270  10.56697,
271  10.40589,
272  10.24522,
273  10.08502,
274  9.925323,
275  9.766186,
276  9.607653,
277  9.449772,
278  9.292586,
279  9.13614,
280  8.980476,
281  8.825635,
282  8.67166,
283  8.518588,
284  8.366459,
285  8.215311,
286  8.06518,
287  7.916101,
288  7.768108,
289  7.621236,
290  7.475515,
291  7.330978,
292  7.187655,
293  7.045573,
294  6.904763,
295  6.765249,
296  6.62706,
297  6.490218,
298  6.35475,
299  6.220676,
300  6.088021,
301  5.956804,
302  5.827045,
303  5.698765,
304  5.571981,
305  5.44671,
306  5.32297,
307  5.200776,
308  5.080142,
309  4.961083,
310  4.843613,
311  4.727743,
312  4.613485,
313  4.50085,
314  4.38985,
315  4.280492,
316  4.172788,
317  4.066743,
318  3.962368,
319  3.859668,
320  3.758651,
321  3.659322,
322  3.561687,
323  3.465753,
324  3.371522,
325  3.279,
326  3.18819,
327  3.099097,
328  3.011723,
329  2.926071,
330  2.842145,
331  2.759946,
332  2.679477,
333  2.600739,
334  2.523735,
335  2.448466,
336  2.374933,
337  2.303139,
338  2.233084,
339  2.16477,
340  2.098198,
341  2.033369,
342  1.970285,
343  1.908946,
344  1.849355,
345  1.791512,
346  1.735419,
347  1.681077,
348  1.628489,
349  1.577656,
350  1.528581,
351  1.481264,
352  1.43571,
353  1.391919,
354  1.349896,
355  1.309643,
356  1.271164,
357  1.234461,
358  1.199539,
359  1.166401,
360  1.135053,
361  1.105497,
362  1.07774,
363  1.051786,
364  1.02764,
365  1.005309,
366  0.984798,
367  0.966113,
368  0.94926,
369  0.934248,
370  0.921081,
371  0.909769,
372  0.900317,
373  0.892735,
374  0.88703,
375  0.88321,
376  0.881284,
377  0.881261,
378  0.883149,
379  0.886958,
380  0.892696,
381  0.900374
382 };
383 
384 
385 class Weather
386 {
387  vector<double> m_rain;
388  vector<double> m_wind;
389  vector<double> m_winddir;
390  vector<double> m_temp;
391 
392  double m_temptoday;
393  double m_raintoday;
394  double m_windtoday;
398  double m_insolation;
400 
403 
405 
407  double m_snowdepth;
408 
409 public:
410  Weather( const char* a_weatherdatafile );
411  ~Weather( void );
412 
413  double GetDDDegs( long a_date );
414  double GetGlobalRadiation(long a_date) { return (double)c_insolation[a_date % m_datemodulus]; }
415  double GetGlobalRadiation( void ) { return m_insolation; }
417  double GetTemp(long a_date) { return m_temp[a_date % m_datemodulus]; }
419  double GetTemp(void) { return m_temptoday; }
421  double GetHumidity(void) { return m_humiditytoday; }
422  double GetMeanTemp(long a_date, unsigned int a_period);
423  double GetRain(long a_date) { return m_rain[a_date %m_datemodulus]; }
424  double GetRain( void ) { return m_raintoday; }
425  double GetWind(long a_date) { return m_wind[a_date % m_datemodulus]; }
426  double GetWind( void ) { return m_windtoday; }
427  int GetWindDirection( void ) { return m_winddirtoday; }
428  bool GetSnow( long a_date );
429  bool GetSnow( void ) { return m_snowtoday; }
431  double GetSnowDepth( void ) { return m_snowdepth; }
432  bool Raining( void ) { return m_rainingtoday; }
433 
434  // Returns total amount of rain from a_date and a_period of days
435  // *backwards*! Normally a_date is equal to g_date->Date() when one
436  // want to check for rain before doing a crop management step.
437  // a_period should be at least one and positive.
438  // --FN--, 29/11-2000.
439  double GetRainPeriod( long a_date, unsigned int a_period );
440  double GetWindPeriod( long a_date, unsigned int a_period );
441  double GetTempPeriod( long a_date, unsigned int a_period );
442 
443  void Tick( void );
444 };
445 
446 #endif // WEATHER_H
447 
448 
449 
450 
451 
452 
Weather::GetGlobalRadiation
double GetGlobalRadiation(void)
Definition: weather.h:415
Weather::m_snowdepth
double m_snowdepth
The snow depth in cm.
Definition: weather.h:407
Weather::GetSnow
bool GetSnow(void)
Definition: weather.h:429
Weather::GetWind
double GetWind(void)
Definition: weather.h:426
Weather::m_temp
vector< double > m_temp
Definition: weather.h:390
Weather::m_temptoday
double m_temptoday
Definition: weather.h:392
Weather::m_humiditytoday
double m_humiditytoday
Definition: weather.h:399
Weather::GetRain
double GetRain(void)
Definition: weather.h:424
Weather::Raining
bool Raining(void)
Definition: weather.h:432
Weather::m_datemodulus
long m_datemodulus
Definition: weather.h:404
Weather::GetWind
double GetWind(long a_date)
Definition: weather.h:425
Weather::m_rain
vector< double > m_rain
Definition: weather.h:387
Weather::m_snowtoday
bool m_snowtoday
Definition: weather.h:396
Weather::GetTemp
double GetTemp(void)
Get the temperature today.
Definition: weather.h:419
Weather::GetSnowDepth
double GetSnowDepth(void)
Get the current snow depth.
Definition: weather.h:431
Weather::GetTemp
double GetTemp(long a_date)
Get the temperature on a particular date.
Definition: weather.h:417
Weather::GetHumidity
double GetHumidity(void)
Get the humidity score today.
Definition: weather.h:421
c_insolation
const double c_insolation[365]
Definition: weather.h:16
Weather::m_rainingtoday
bool m_rainingtoday
Definition: weather.h:397
Weather::m_windtoday
double m_windtoday
Definition: weather.h:394
Weather::m_winddir
vector< double > m_winddir
Definition: weather.h:389
Weather::m_wind_valid
bool m_wind_valid
Definition: weather.h:401
Weather::GetGlobalRadiation
double GetGlobalRadiation(long a_date)
Definition: weather.h:414
Weather::m_wind
vector< double > m_wind
Definition: weather.h:388
Weather::m_insolation
double m_insolation
Definition: weather.h:398
Weather::m_raintoday
double m_raintoday
Definition: weather.h:393
Weather::GetRain
double GetRain(long a_date)
Definition: weather.h:423
Weather::GetWindDirection
int GetWindDirection(void)
Definition: weather.h:427
Weather::m_winddir_valid
bool m_winddir_valid
Definition: weather.h:402
Weather
Definition: weather.h:385
g_weather
class Weather * g_weather
Definition: weather.cpp:41
Weather::m_winddirtoday
int m_winddirtoday
Definition: weather.h:395