-
Notifications
You must be signed in to change notification settings - Fork 0
/
compile_data_gh.py
executable file
·80 lines (60 loc) · 2.19 KB
/
compile_data_gh.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/python
import os
import sys
import math
import login
the_db = login.get_db()
import data_objects as DO
import compile_data as CD1
import compile_data2 as CD2
import queries
import write_table as WT
CONTROLLED_TRIALS = [4537, 5506]
FIELD_TRIALS = [5544, 5541, 5546, 5540, 5542, 5543, 5539, 5545]
DETHLINGEN_TRIALS = [5519]
###
def main(argv):
heat_d, h2o_d = CD2.get_climate_data()
the_db.query(queries.golm_starch_query)
data = the_db.store_result().fetch_row(how=1, maxrows=9999999)
print data[0]
return None
data = [DO.StarchData(d.keys(), d.values()) for d in data]
golm_data = CD1.group_by([d for d in data if d.location_id == 4537],
'sub_id')
dethl_data = CD1.group_by([d for d in data if d.location_id == 5519],
'sub_id')
field_data = [d for d in data if d.location_id in FIELD_TRIALS]
golm_results = CD1.compute_starch_rel_ctrl(golm_data, 4537,
[CD1.DROUGHT_ID])
dethl_results = CD1.compute_starch_rel_ctrl(dethl_data, 5519,
CD1.DETHLINGEN_DROUGHT_IDS)
field_results = CD1.compute_starch_rel_field(field_data,
FIELD_TRIALS, CD1.DROUGHT_ID)
# print field_results
compiled = {}
# compiled.update(golm_results)
# compiled.update(dethl_results)
compiled.update(field_results)
for k, v in sorted(compiled.items()):
if isinstance(k, str): continue
# print k
compiled[k].heat_sum, compiled[k].heat_nmeasures = heat_d[k[0]]
compiled[k].limsloc = k[0]
compiled[k].precipitation, compiled[k].prec_nmeasures = h2o_d[k[0]]
# print v
# print heat_d
WT.write_table(compiled, WT.FIELDS)
return None
"""
results = CD1.compute_starch_rel_controlled(data, 4537)
write_table(results)
# return None
results = CD1.compute_starch_rel_dethlingen(data)
write_table(results)
# return None
"""
# results = CD1.compute_field_trials(data)
# write_table(results[0])
# return None
if __name__ == '__main__': main(sys.argv[1:])