source: branches/trigger_burst_research/plot_rates_and_ratio_for_night.py@ 19290

Last change on this file since 19290 was 18305, checked in by dneise, 9 years ago
used new file name also in plotter
File size: 2.2 KB
Line 
1import sys
2import numpy as np
3import matplotlib as mpl
4mpl.use('Agg')
5import matplotlib.pyplot as plt
6import pandas as pd
7from astropy.io import fits
8from calculate_burst_ratio_file import get_trigger_rates, fjd
9
10
11night_string = sys.argv[1]
12night_int = int(night_string)
13OFFSET=719163
14
15runs = pd.DataFrame.from_csv(
16 'burst_ratio.csv',
17 infer_datetime_format=True,
18 parse_dates=['fRunStart', 'fRunStop']
19 ).dropna()
20
21runs = runs.loc[runs.fNight==night_int]
22
23trigger_rates = get_trigger_rates(night_int,
24 base_path='/fact/aux/')
25
26fig, ax1 = plt.subplots(figsize=(16, 9))
27ax1.set_xlabel("Time")
28ax1.set_yscale('log')
29ax1.set_ylabel("Rate [Hz]")
30ax1.grid()
31
32plt.title("basic Ratescan information from: " + night_string)
33
34plot_0 = ax1.plot_date(
35 trigger_rates['Time']+OFFSET,
36 np.median(trigger_rates['BoardRate'], axis=1),
37 'r.', ms=4.,
38 label="median BoardRate"
39 )
40
41plot_1 = ax1.plot_date(
42 trigger_rates['Time']+OFFSET,
43 trigger_rates['TriggerRate'],
44 'g.', ms=4.,
45 label="Camera TriggerRate"
46 )
47
48for runs_index in range(len(runs)):
49 this_run = runs.iloc[runs_index]
50 run_number = this_run['fRunID']
51
52 a = fjd(this_run['fRunStart'])+OFFSET
53 e = fjd(this_run['fRunStop'])+OFFSET
54
55 ax1.axvline(a, color='g', linestyle='dashed')
56 ax1.axvline(e, color='r', linestyle='dashed')
57 ax1.text(a + (e-a)/2., 900,
58 "{0}".format(run_number),
59 horizontalalignment='center',
60 verticalalignment='center',
61 fontsize=7,
62 )
63
64 med = this_run['median_of_board_rates']
65 std_dev = this_run['std_dev_of_board_rates']
66
67 ax1.plot_date(
68 [a, e],
69 [med+3*std_dev, med+3*std_dev],
70 'm-')
71
72
73
74plt.xlim((
75 fjd(runs.iloc[0]['fRunStart'])+OFFSET,
76 fjd(runs.iloc[-1]['fRunStop'])+OFFSET
77 ))
78plt.ylim(1e-1, 1e6)
79
80plt.legend(
81 handles=[plot_0[0], plot_1[0]],
82 loc='lower left')
83
84plt.tight_layout()
85plt.savefig("board_rate_overview_"+night_string+'.png',
86 dpi=300)
87
88plt.figure()
89plt.title("fHighBoardTriggerRateRatio distribution from {0}".format(night_int))
90plt.hist(runs.fBoardTriggerRateRatioAboveThreshold.values,
91 bins=np.arange(0,0.6,1./60.),
92 log=True )
93plt.grid()
94plt.xlabel("fHighBoardTriggerRateRatio")
95plt.savefig("ratio_dist_"+night_string+'.png')
Note: See TracBrowser for help on using the repository browser.