1 | import sys
|
---|
2 | import numpy as np
|
---|
3 | import matplotlib as mpl
|
---|
4 | mpl.use('Agg')
|
---|
5 | import matplotlib.pyplot as plt
|
---|
6 | import pandas as pd
|
---|
7 | from astropy.io import fits
|
---|
8 | from calculate_burst_ratio_file import get_trigger_rates, fjd
|
---|
9 |
|
---|
10 |
|
---|
11 | night_string = sys.argv[1]
|
---|
12 | night_int = int(night_string)
|
---|
13 | OFFSET=719163
|
---|
14 |
|
---|
15 | runs = pd.DataFrame.from_csv(
|
---|
16 | 'foo.bar',
|
---|
17 | infer_datetime_format=True,
|
---|
18 | parse_dates=['fRunStart', 'fRunStop']
|
---|
19 | ).dropna()
|
---|
20 |
|
---|
21 | runs = runs.loc[runs.fNight==night_int]
|
---|
22 |
|
---|
23 | trigger_rates = get_trigger_rates(night_int,
|
---|
24 | base_path='/fact/aux/')
|
---|
25 |
|
---|
26 | fig, ax1 = plt.subplots(figsize=(16, 9))
|
---|
27 | ax1.set_xlabel("Time")
|
---|
28 | ax1.set_yscale('log')
|
---|
29 | ax1.set_ylabel("Rate [Hz]")
|
---|
30 | ax1.grid()
|
---|
31 |
|
---|
32 | plt.title("basic Ratescan information from: " + night_string)
|
---|
33 |
|
---|
34 | plot_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 |
|
---|
41 | plot_1 = ax1.plot_date(
|
---|
42 | trigger_rates['Time']+OFFSET,
|
---|
43 | trigger_rates['TriggerRate'],
|
---|
44 | 'g.', ms=4.,
|
---|
45 | label="Camera TriggerRate"
|
---|
46 | )
|
---|
47 |
|
---|
48 | for 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 |
|
---|
74 | plt.xlim((
|
---|
75 | fjd(runs.iloc[0]['fRunStart'])+OFFSET,
|
---|
76 | fjd(runs.iloc[-1]['fRunStop'])+OFFSET
|
---|
77 | ))
|
---|
78 | plt.ylim(1e-1, 1e6)
|
---|
79 |
|
---|
80 | plt.legend(
|
---|
81 | handles=[plot_0[0], plot_1[0]],
|
---|
82 | loc='lower left')
|
---|
83 |
|
---|
84 | plt.tight_layout()
|
---|
85 | plt.savefig("board_rate_overview_"+night_string+'.png',
|
---|
86 | dpi=300)
|
---|
87 |
|
---|
88 | plt.figure()
|
---|
89 | plt.title("fHighBoardTriggerRateRatio distribution from {0}".format(night_int))
|
---|
90 | plt.hist(runs.fBoardTriggerRateRatioAboveThreshold.values,
|
---|
91 | bins=np.arange(0,0.6,1./60.),
|
---|
92 | log=True )
|
---|
93 | plt.grid()
|
---|
94 | plt.xlabel("fHighBoardTriggerRateRatio")
|
---|
95 | plt.savefig("ratio_dist_"+night_string+'.png')
|
---|