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