1 | import sys
|
---|
2 | from pylab import *
|
---|
3 | import pandas as pd
|
---|
4 | from astropy.io import fits
|
---|
5 | from calculate_burst_ratio_file import get_trigger_rates, fjd
|
---|
6 | plt.ion()
|
---|
7 |
|
---|
8 | night_string = sys.argv[1]
|
---|
9 | night_int = int(night_string)
|
---|
10 | OFFSET=719163
|
---|
11 |
|
---|
12 | runs = pd.DataFrame.from_csv(
|
---|
13 | 'foo.bar',
|
---|
14 | infer_datetime_format=True,
|
---|
15 | parse_dates=['fRunStart', 'fRunStop']
|
---|
16 | ).dropna()
|
---|
17 |
|
---|
18 | runs = runs.loc[runs.fNight==night_int]
|
---|
19 |
|
---|
20 | trigger_rates = get_trigger_rates(night_int)
|
---|
21 |
|
---|
22 | fig, ax1 = plt.subplots(figsize=(16, 12))
|
---|
23 | ax1.set_xlabel("Time")
|
---|
24 | ax1.set_yscale('log')
|
---|
25 | ax1.set_ylabel("Rate [Hz]")
|
---|
26 | ax1.grid()
|
---|
27 |
|
---|
28 | plt.title("basic Ratescan information from: " + night_string)
|
---|
29 |
|
---|
30 | plot_0 = ax1.plot_date(
|
---|
31 | trigger_rates['Time']+OFFSET,
|
---|
32 | np.median(trigger_rates['BoardRate'], axis=1),
|
---|
33 | 'r.',
|
---|
34 | label="median BoardRate"
|
---|
35 | )
|
---|
36 |
|
---|
37 | plot_1 = ax1.plot_date(
|
---|
38 | trigger_rates['Time']+OFFSET,
|
---|
39 | trigger_rates['TriggerRate'],
|
---|
40 | 'g.',
|
---|
41 | label="Camera TriggerRate"
|
---|
42 | )
|
---|
43 |
|
---|
44 | for runs_index in range(len(runs)):
|
---|
45 | this_run = runs.iloc[runs_index]
|
---|
46 | run_number = this_run['fRunID']
|
---|
47 |
|
---|
48 | a = fjd(this_run['fRunStart'])+OFFSET
|
---|
49 | e = fjd(this_run['fRunStop'])+OFFSET
|
---|
50 |
|
---|
51 | ax1.axvline(a, color='g', linestyle='dashed')
|
---|
52 | ax1.axvline(e, color='r', linestyle='dashed')
|
---|
53 | ax1.text(a + (e-a)/2., 900,
|
---|
54 | "{0}".format(run_number),
|
---|
55 | horizontalalignment='center',
|
---|
56 | verticalalignment='center',
|
---|
57 | )
|
---|
58 |
|
---|
59 | med = this_run['median_of_board_rates']
|
---|
60 | std_dev = this_run['std_dev_of_board_rates']
|
---|
61 |
|
---|
62 | ax1.plot_date(
|
---|
63 | [a, e],
|
---|
64 | [med+3*std_dev, med+3*std_dev],
|
---|
65 | 'm-')
|
---|
66 |
|
---|
67 |
|
---|
68 |
|
---|
69 | plt.xlim((
|
---|
70 | fact.fjd(runs.iloc[0]['fRunStart'])+OFFSET,
|
---|
71 | fact.fjd(runs.iloc[-1]['fRunStop'])+OFFSET
|
---|
72 | ))
|
---|
73 |
|
---|
74 | plt.legend(
|
---|
75 | handles=[plot_0[0], plot_1[0]],
|
---|
76 | loc='lower left')
|
---|
77 | plt.savefig("board_rate_overview_"+night_string+'.png', dpi=300)
|
---|
78 | #plt.figure()
|
---|
79 | #plt.title("fHighBoardTriggerRateRatio distribution from {0}".format(night_int))
|
---|
80 | #plt.hist(ratio, bins=np.linspace(0,0.3,16), log=True )
|
---|
81 | #plt.grid()
|
---|
82 | #plt.xlabel("fHighBoardTriggerRateRatio") |
---|