1 | #!/usr/bin/python -tt
|
---|
2 |
|
---|
3 | ##############################################
|
---|
4 | # based on plot_trigger_rate.py by QW and TPK
|
---|
5 | ##############################################
|
---|
6 |
|
---|
7 | from array import array
|
---|
8 | import os
|
---|
9 | import re
|
---|
10 | import sys
|
---|
11 | import numpy as np
|
---|
12 | import time
|
---|
13 |
|
---|
14 | from pyfact import SlowData
|
---|
15 |
|
---|
16 | #from ROOT import TCanvas, TGraph, TGraphErrors, TH2F
|
---|
17 | #from ROOT import gROOT
|
---|
18 | #from ROOT import gStyle
|
---|
19 |
|
---|
20 | import matplotlib.pyplot as plt
|
---|
21 | import matplotlib.dates
|
---|
22 |
|
---|
23 | gROOT.SetStyle("Plain")
|
---|
24 |
|
---|
25 | filelist = []
|
---|
26 | if len(sys.argv) > 1:
|
---|
27 | base_path = sys.argv[1]
|
---|
28 | else:
|
---|
29 | print 'Usage:', sys.argv[0], '/your/search/path'
|
---|
30 |
|
---|
31 | for base,subdirs,files in os.walk(base_path):
|
---|
32 | for filename in files:
|
---|
33 | #include only run files
|
---|
34 | regex = re.search(r'\d\d\d\d\d\d\d\d\.FSC_CONTROL_TEMPERATURE.fits',filename)
|
---|
35 | #include run files and also the nightly file
|
---|
36 | #regex = re.search(r'FTM_CONTROL_TRIGGER_RATES',filename)
|
---|
37 | if regex:
|
---|
38 | filelist.append(os.path.join(base,filename))
|
---|
39 |
|
---|
40 |
|
---|
41 | plotlist = ['T_aux', 'T_back', 'T_crate', 'T_eth', 'T_ps', 'T_sens']
|
---|
42 | plotfmts = ['.:g', '.:k', '.:r', '.:y', '.:b', '.:m']
|
---|
43 | per_name = []
|
---|
44 |
|
---|
45 | for filename in filelist:
|
---|
46 |
|
---|
47 | print filename
|
---|
48 |
|
---|
49 | f = SlowData(filename)
|
---|
50 | # 'columns': {'QoS': (1L, 4L, 'J', ''),
|
---|
51 | # 'T_aux': (4L, 4L, 'E', 'deg'),
|
---|
52 | # 'T_back': (4L, 4L, 'E', 'deg'),
|
---|
53 | # 'T_crate': (8L, 4L, 'E', 'deg'),
|
---|
54 | # 'T_eth': (4L, 4L, 'E', 'deg'),
|
---|
55 | # 'T_ps': (8L, 4L, 'E', 'deg'),
|
---|
56 | # 'T_sens': (31L, 4L, 'E', 'deg'),
|
---|
57 | # 'Time': (1L, 8L, 'D', 'MJD'),
|
---|
58 | # 't': (1L, 4L, 'E', 's')},
|
---|
59 |
|
---|
60 | f.register("all")
|
---|
61 |
|
---|
62 | f.stack()
|
---|
63 | for row in f:
|
---|
64 | pass
|
---|
65 |
|
---|
66 |
|
---|
67 | for name in plotlist:
|
---|
68 | per_name.append(f.columns[name][0])
|
---|
69 |
|
---|
70 | fig = plt.figure()
|
---|
71 | ax = fig.add_subplot(111)
|
---|
72 | plt.hold(True)
|
---|
73 | for i,name in enumerate(plotlist):
|
---|
74 | for number in range(per_name[i]):
|
---|
75 | print name, number
|
---|
76 | Time = f.stacked_cols['Time']
|
---|
77 | data = f.stacked_cols[name][:,number]
|
---|
78 | med = np.median(Time)
|
---|
79 | # get rid of Times of the previous day.
|
---|
80 | Time_today = Time[np.where( Time>med-0.25 )[0]]
|
---|
81 | data_today = data[np.where( Time>med-0.25)[0]]
|
---|
82 |
|
---|
83 | ax.plot_date( Time_today, data_today, fmt=plotfmts[i])
|
---|
84 | today_str = time.strftime('%d.%m.' ,time.gmtime(Time_today[0]*24*3600))
|
---|
85 | print today_str
|
---|
86 | plt.title('T_ps:blue T_eth:yellow T_aux:green T_crate:red T_back:black T_sens:magenta \n'+today_str)
|
---|
87 | ax.xaxis.set_major_locator(
|
---|
88 | matplotlib.dates.HourLocator(byhour=range(24), interval=1)
|
---|
89 | )
|
---|
90 | ax.xaxis.set_major_formatter(
|
---|
91 | matplotlib.dates.DateFormatter('%Hh')
|
---|
92 | )
|
---|
93 |
|
---|
94 | plt.ylim(12,41)
|
---|
95 | plt.savefig(sys.argv[2])
|
---|