-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImprove.py
More file actions
94 lines (78 loc) · 4 KB
/
Improve.py
File metadata and controls
94 lines (78 loc) · 4 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import ROOT
from YearInReview import YearInReview
from IsigStudy import IsigStudy
import PlotFunctions as plotfunc
from SampleEarlyBolus import SampleEarlyBolus
from SuppliesSummary import SuppliesSummary
from PyBGSuggestHelpers import PredictionCanvas
from ScatterPlot import GetOverview
import datetime
def main(options,args) :
plotfunc.SetupStyle()
f = ROOT.TFile('output_LongTermSummary.root')
e = f.Get('LongTermSummary')
f_shortterm = ROOT.TFile('output.root')
e_shortterm = f_shortterm.Get('DetailedResults')
canvases = []
if options.overview :
canvases.append(GetOverview(e_shortterm,options.week,options.week))
if options.detailed :
canvases.append(PredictionCanvas(e_shortterm,options.day_of_week,-options.week,rootfile=f_shortterm))
if options.yir :
canvases.append(YearInReview(e))
if options.example :
canvases.append(SampleEarlyBolus())
if False :
rewind,supplies,test_frequency = SuppliesSummary(e)
if options.isig :
canvases.append(IsigStudy(e))
if (not options.autogenerated) and (not options.batch) :
raw_input('Pausing. Press enter to exit.')
if options.save :
for i in canvases :
auto = '_auto' if options.autogenerated else ''
name = i.GetName()
if options.detailed :
name = '%s_%d_%s%s'%(i.GetName(),options.day_of_week,options.dow_str,auto)
i.Print('plots/%s.pdf'%(name))
i.Print('plots/%s.eps'%(name))
return
if __name__ == '__main__':
from optparse import OptionParser
p = OptionParser()
p.add_option('--save',action='store_true',default=False,dest='save',help='save cans to pdf')
p.add_option('--detailed',action='store_true',default=False,dest='detailed',help='Detailed one-day view')
p.add_option('--overview',action='store_true',default=False,dest='overview',help='Overview (scatter plot)')
p.add_option('--yir',action='store_true',default=False,dest='yir',help='save cans to pdf')
p.add_option('--isig',action='store_true',default=False,dest='isig',help='Study the isig values of the CGM')
p.add_option('--example',action='store_true',default=False,dest='example',help='Run SampleEarlyBonus example')
p.add_option('--m' ,action='store_true',default=False,dest='m' ,help='Monday')
p.add_option('--t' ,action='store_true',default=False,dest='t' ,help='Tuesday')
p.add_option('--w' ,action='store_true',default=False,dest='w' ,help='Wednesday')
p.add_option('--th',action='store_true',default=False,dest='th',help='Thursday')
p.add_option('--f' ,action='store_true',default=False,dest='f' ,help='Friday')
p.add_option('--s' ,action='store_true',default=False,dest='s' ,help='Saturday')
p.add_option('--su',action='store_true',default=False,dest='su',help='Sunday')
p.add_option('--today',action='store_true',default=False,dest='today',help='Today')
p.add_option('--week',type='int',default=0,dest='week',help='Number of weeks ago (0)')
p.add_option('--autogenerated',action='store_true',default=False,dest='autogenerated',help='Sunday')
p.add_option('--batch',action='store_true',default=False,dest='batch',help='run in batch mode')
options,args = p.parse_args()
ROOT.gROOT.SetBatch(options.batch)
options.day_of_week = -1
if options.m : options.day_of_week = 0
if options.t : options.day_of_week = 1
if options.w : options.day_of_week = 2
if options.th : options.day_of_week = 3
if options.f : options.day_of_week = 4
if options.s : options.day_of_week = 5
if options.su : options.day_of_week = 6
if options.today :
options.day_of_week = datetime.date.today().weekday()
options.dow_str = {0:'Monday',1:'Tuesday',2:'Wednesday',3:'Thursday' ,
4:'Friday',5:'Saturday',6:'Sunday'}.get(options.day_of_week)
if options.detailed and options.day_of_week < 0 :
print 'Error! Please specify day (e.g. --m). Exiting.'
import sys
sys.exit()
main(options,args)