| 1 | #!/usr/bin/python -tti
|
|---|
| 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 | plt.ion()
|
|---|
| 25 |
|
|---|
| 26 | filelist = []
|
|---|
| 27 | if len(sys.argv) > 1:
|
|---|
| 28 | base_path = sys.argv[1]
|
|---|
| 29 | else:
|
|---|
| 30 | print 'Usage:', sys.argv[0], '/your/search/path'
|
|---|
| 31 |
|
|---|
| 32 | for base,subdirs,files in os.walk(base_path):
|
|---|
| 33 | for filename in files:
|
|---|
| 34 | #include only run files
|
|---|
| 35 | regex = re.search(r'\d\d\d\d\d\d\d\d\.FSC_CONTROL_VOLTAGE.fits',filename)
|
|---|
| 36 | #include run files and also the nightly file
|
|---|
| 37 | #regex = re.search(r'FTM_CONTROL_TRIGGER_RATES',filename)
|
|---|
| 38 | if regex:
|
|---|
| 39 | filelist.append(os.path.join(base,filename))
|
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 | plotlist = ['FAD_Ud']
|
|---|
| 43 | plotfmts = ['+:r']
|
|---|
| 44 | per_name = []
|
|---|
| 45 |
|
|---|
| 46 | for filename in filelist:
|
|---|
| 47 |
|
|---|
| 48 | print filename
|
|---|
| 49 |
|
|---|
| 50 | f = SlowData(filename)
|
|---|
| 51 |
|
|---|
| 52 | f.register("all")
|
|---|
| 53 |
|
|---|
| 54 | f.stack()
|
|---|
| 55 | for row in f:
|
|---|
| 56 | pass
|
|---|
| 57 |
|
|---|
| 58 |
|
|---|
| 59 | for name in plotlist:
|
|---|
| 60 | per_name.append(f.columns[name][0])
|
|---|
| 61 |
|
|---|
| 62 | fig = plt.figure()
|
|---|
| 63 | ax = fig.add_subplot(111)
|
|---|
| 64 | plt.hold(True)
|
|---|
| 65 | for i,name in enumerate(plotlist):
|
|---|
| 66 | for number in range(per_name[i]):
|
|---|
| 67 | print name, number
|
|---|
| 68 | Time = f.stacked_cols['Time']
|
|---|
| 69 | data = f.stacked_cols[name][:,number]
|
|---|
| 70 | med = np.median(Time)
|
|---|
| 71 | # get rid of Times of the previous day.
|
|---|
| 72 | Time_today = Time[np.where( Time>med-0.25 )[0]]
|
|---|
| 73 | data_today = data[np.where( Time>med-0.25)[0]]
|
|---|
| 74 | # if number == 0:
|
|---|
| 75 | # ax.plot_date( Time_today, data_today, fmt=plotfmts[i], label=name)
|
|---|
| 76 | # else:
|
|---|
| 77 | # ax.plot_date( Time_today, data_today, fmt=plotfmts[i])
|
|---|
| 78 | ax.plot_date( Time_today, data_today, fmt='.:', label=name+str(number))
|
|---|
| 79 | today_str = time.strftime('%d.%m.' ,time.gmtime(Time_today[0]*24*3600))
|
|---|
| 80 | print today_str
|
|---|
| 81 |
|
|---|
| 82 | for i in range(10):
|
|---|
| 83 | print Time_today[i]
|
|---|
| 84 |
|
|---|
| 85 | plt.title('Voltage \n'+today_str)
|
|---|
| 86 | ax.xaxis.set_major_locator(
|
|---|
| 87 | # matplotlib.dates.HourLocator(byhour=range(24), interval=1)
|
|---|
| 88 | matplotlib.dates.AutoDateLocator()
|
|---|
| 89 | )
|
|---|
| 90 | ax.xaxis.set_major_formatter(
|
|---|
| 91 | matplotlib.dates.DateFormatter('%Hh')
|
|---|
| 92 | # matplotlib.dates.AutoDateFormatter()
|
|---|
| 93 | )
|
|---|
| 94 | plt.legend()
|
|---|
| 95 | plt.draw()
|
|---|
| 96 |
|
|---|
| 97 | # plt.ylim(12,41)
|
|---|
| 98 | plt.savefig(sys.argv[2])
|
|---|