This repository has been archived by the owner on Jan 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
histos.py
60 lines (50 loc) · 2.99 KB
/
histos.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# *************************************************************************************
# * Written by : Jon Ringuette
# * Started : January 13 2021 - Still during the plague..
# * Purpose : Create histograms from output of decay spec sorter both raw and otherwise..
# * Requirements : Python 3, matplotlib, probably something other stuff numpy,scipy...
# *************************************************************************************
import argparse
from read_in_data import input_handler
from histogram_generator import hist_gen
def parse_and_run(args):
myinput = input_handler(args.input_filename)
mydata_df = myinput.read_in_data()
if args.bin_number > (args.max_pulse_height-args.min_pulse_height):
bin_number = args.max_pulse_height-args.min_pulse_height
else:
bin_number = args.bin_number
if args.plot_title is None:
title = args.input_filename
else:
title = args.plot_title
myhist = hist_gen(args.channel_num, args.max_pulse_height, args.min_pulse_height, bin_number, title, args.xlabel, args.ylabel)
if args.channel_num is None:
myhist.create_multi_chan_histogram(mydata_df)
else:
myhist.create_single_chan_histogram(mydata_df)
return
def main():
parser = argparse.ArgumentParser(description='Histogram Generator')
parser.add_argument('--data_file', dest='input_filename', required=True,
help="path to data file from mds_sort")
parser.add_argument('--chan', dest='channel_num', nargs='+', type=int, required=False, # wont' require forever..
help="channel or list of channels to graph --chan 0 1 3")
parser.add_argument('--xmax', dest='max_pulse_height', type=int, default=65536, required=False, # wont' require forever..
help="Max Pulse Height")
parser.add_argument('--xmin', dest='min_pulse_height', type=int, default=0, required=False, # wont' require forever..
help="Min Pulse Height")
parser.add_argument('--nbins', dest='bin_number', type=int, default=1000, required=False, # wont' require forever..
help="Number of bins, will default to the smaller of 1000 or max_pulse_height - min_pulse_height")
parser.add_argument('--type', dest='data_type', required=False, default='raw', # wont' require forever..
help="Data input type, RAW 'raw' or EVENT 'event', raw is the default")
parser.add_argument('--title', dest='plot_title', required=False, default=None, # wont' require forever..
help="Title for Histogram")
parser.add_argument('--xlabel', dest='xlabel', required=False, default='Pulse Height', # wont' require forever..
help="X Axis Label")
parser.add_argument('--ylabel', dest='ylabel', required=False, default='Counts', # wont' require forever..
help="Y Axis Label")
args, unknown = parser.parse_known_args()
parse_and_run(args)
if __name__ == "__main__":
main()