source: fact/tools/pyscripts/sandbox/dneise/SlowDataPlotting/plot_temps.py@ 20115

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