Compare commits

..

No commits in common. "88995ebdd194d012671adbb96d804e8f25638751" and "2fa0a9665cae4053f65fbcbe452a68adca5ab986" have entirely different histories.

3 changed files with 25 additions and 49 deletions

View file

@ -14,7 +14,7 @@ import pandas as pd
from datetime import datetime from datetime import datetime
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
parser = argparse.ArgumentParser(description="This script parses EI-data for AHBGOC and returns histogramms of B1,B2 and sum") parser = argparse.ArgumentParser(description="This script parses EI-data for AHBGO... and returns histogramms")
parser.add_argument("-v", "--verbose", choices = ['0','1','2'], help = "when zero only emit serious error messages; when one also emit warnings, when two emit informational messages") parser.add_argument("-v", "--verbose", choices = ['0','1','2'], help = "when zero only emit serious error messages; when one also emit warnings, when two emit informational messages")
parser.add_argument("file", type = str, help="path/file were data is stored in") parser.add_argument("file", type = str, help="path/file were data is stored in")
parser.add_argument("-trigger", type=str, nargs='+', help = "letters of Triggerdiodes to chose") parser.add_argument("-trigger", type=str, nargs='+', help = "letters of Triggerdiodes to chose")
@ -38,7 +38,7 @@ else:
mV = 14000 mV = 14000
minV = -100 minV = -100
maxV = 3500 maxV = 3500
resV = 0.838214/2 resV = 0.838214
def main(): def main():
global thr global thr
@ -106,11 +106,11 @@ def main():
for i in range(len(Bchans)): for i in range(len(Bchans)):
b = CmV(l,ch[Bchans[i]])*u[Bchans[i]] b = CmV(l,ch[Bchans[i]])*u[Bchans[i]]
if b>=minV and b<=maxV: if b>=minV and b<=maxV:
xb = int((b-minV)/resV) xb = int(b-minV/resV)
hist[xb,i+1] += 1 hist[xb,i+1] += 1
s = s + b s = s + b
if s>=minV and s<=maxV: if s>=minV and s<=maxV:
xs = int((s-minV)/resV) xs = int(s-minV/resV)
hist[xs,-1] += 1 hist[xs,-1] += 1
cols = [] cols = []
for c in Bchans: for c in Bchans:

View file

@ -6,11 +6,11 @@ import pandas as pd
from datetime import datetime from datetime import datetime
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
parser = argparse.ArgumentParser(description="This script parses EI-data for AHBGO(C/D/S) and returns histogramms") parser = argparse.ArgumentParser(description="This script parses EI-data for AHBGO(C/D) and return histogramms")
parser.add_argument("-v", "--verbose", choices = ['0','1','2'], help = "when zero only emit serious error messages; when one also emit warnings, when two emit informational messages") parser.add_argument("-v", "--verbose", choices = ['0','1','2'], help = "when zero only emit serious error messages; when one also emit warnings, when two emit informational messages")
parser.add_argument("file", type = str, help="path/file were data is stored in") parser.add_argument("file", type = str, help="path/file were data is stored in")
parser.add_argument('-hist', action='store_true', help = "makes histogramm of all channels") # on/off flag parser.add_argument('-hist', action='store_true', help = "makes histogramm of all channels") # on/off flag
parser.add_argument("-sum", action='store_true', help = "makes histogramms of BGOdiodes and sum (same as 'AHBGOC_vertical.py')") # on/off flag parser.add_argument("-sum", action='store_true', help = "makes histogramms of sum(s) of BGOdiodes") # on/off flag
parser.add_argument('-Itime', action='store_true', help = "if chosen, Itime is calculatet and printet to filename.Itime") # on/off flag parser.add_argument('-Itime', action='store_true', help = "if chosen, Itime is calculatet and printet to filename.Itime") # on/off flag
parser.add_argument("-mV", action='store_true', help = "if chosen, data will be kept in mV changed to keV otherwise") # on/off flag parser.add_argument("-mV", action='store_true', help = "if chosen, data will be kept in mV changed to keV otherwise") # on/off flag
parser.add_argument('-muon', action='store_true', help = "only select muon data") # on/off flag parser.add_argument('-muon', action='store_true', help = "only select muon data") # on/off flag
@ -49,12 +49,11 @@ if 'AHBGOD' in file:
elif 'AHBGOC' in file: elif 'AHBGOC' in file:
x = 'C' x = 'C'
if args.six: if args.six:
x = 'S' x='S'
elif 'AHBGOS' in file: elif 'AHBGOS' in file:
x = 'S' x = 'S'
def main(x): def main():
if args.Itime: if args.Itime:
Itime = find_Itime() Itime = find_Itime()
fname = 'histograms/'+filename+ '.Itime' fname = 'histograms/'+filename+ '.Itime'
@ -74,19 +73,7 @@ def main(x):
global trig global trig
trig=[] trig=[]
nameadd='x' nameadd='x'
if args.sum: if args.sum: nameadd = nameadd + '_sum'
nameadd = nameadd + '_sum'
chans = [0,1]
if x == 'S':
chans =[0,1,5,9,13,17]
channames = []
for c in chans:
channames.append(name[c])
channames = channames + ['sum']
else:
chans = list(range(0, 18))
channames = name
if args.xray: nameadd = nameadd + '_xray' if args.xray: nameadd = nameadd + '_xray'
if args.muon: nameadd = nameadd + '_muon' if args.muon: nameadd = nameadd + '_muon'
if args.trigger: if args.trigger:
@ -112,10 +99,7 @@ def main(x):
trigchan.append(i) trigchan.append(i)
bin = int((maxV-minV)/resV) bin = int((maxV-minV)/resV)
if not args.sum: hist = np.zeros((bin,18+1))
hist = np.zeros((bin,18+1))
else:
hist = np.zeros((bin,len(chans)+2))
for i in range(0,bin): for i in range(0,bin):
hist[i][0]=minV + resV*i hist[i][0]=minV + resV*i
@ -128,23 +112,17 @@ def main(x):
T = adc_to_T(int(l[8])) T = adc_to_T(int(l[8]))
elif l[0] == 'EI' and not T=='unknown': elif l[0] == 'EI' and not T=='unknown':
if conditions(l,args): if conditions(l,args):
s = 0.0 for i in range(18):
for i in range(len(chans)): x = CmV(l,ch[i])*u[i]
b = CmV(l,ch[chans[i]])*u[chans[i]]
if args.zero: if args.zero:
b = b*polynom(0,*pol)/polynom(T,*pol) x = x*polynom(0,*pol)/polynom(T,*pol)
if b>=minV and b<=maxV: if x>=minV and x<=maxV:
xb = int((b-minV)/resV) xx = int(x-minV/resV)
hist[xb,i+1] += 1 hist[xx,i+1] += 1
s = s + b
if args.sum and s>=minV and s<=maxV: frame = pd.DataFrame(hist, columns = [energy] + name)
xs = int((s-minV)/resV)
hist[xs,-1] += 1
frame = pd.DataFrame(hist, columns = [energy] + channames)
frame.to_csv('histograms/'+filename+nameadd+'.hist', sep = ' ', index = False) frame.to_csv('histograms/'+filename+nameadd+'.hist', sep = ' ', index = False)
def channels(): def channels():
ch = np.arange(18) ch = np.arange(18)
@ -258,17 +236,15 @@ def isMuon(l):
#CmV(l,A1) >= thr[0] and CmV(l,A2) >= thr[1]: return True #CmV(l,A1) >= thr[0] and CmV(l,A2) >= thr[1]: return True
elif x == 'C': elif x == 'C':
if CmV(l,17) >= thr[0] and CmV(l,16) >= thr[1]: return True if CmV(l,17) >= thr[0] and CmV(l,16) >= thr[1]: return True
elif x == 'S':
if CmV(l,ch[0]) >= thr[0] and CmV(l,ch[1]) >= thr[1] and CmV(l,ch[5]) >= thr[5] and CmV(l,ch[9]) >= thr[9] and CmV(l,ch[13]) >= thr[13] and CmV(l,ch[17]) >= thr[17]: return True
else: return False else: return False
def isTrigger(l): def isTrigger(l):
if x == 'D': if x == 'D':
if CmV(l,ch[3]) >= thr[3]: return True if CmV(l,ch[3]) >= thr[3]: return True
elif x == 'C' or x == 'S': elif x == 'C':
for t in trigchan: for t in trigchan:
if CmV(l,ch[t]) <= thr[t]: return False if CmV(l,ch[t]) <= thr[t]: return False
return True return True
else: return False else: return False
main(x) main()

View file

@ -12,7 +12,7 @@ import os.path
def main(): def main():
parser = argparse.ArgumentParser(description="This script plots histogramms of given data ending on '.hist'") parser = argparse.ArgumentParser(description="This script plots histogramms of give data ending on '.hist'")
parser.add_argument("-v", "--verbose", choices = ['0','1','2'], help = "when zero only emit serious error messages; when one also emit warnings, when two emit informational messages") parser.add_argument("-v", "--verbose", choices = ['0','1','2'], help = "when zero only emit serious error messages; when one also emit warnings, when two emit informational messages")
parser.add_argument("filepath", type = str, help="path/file were data is stored in") parser.add_argument("filepath", type = str, help="path/file were data is stored in")
parser.add_argument("-t", "--title", type = str, help="title to use in plot; if not given a standard title will be chosen") parser.add_argument("-t", "--title", type = str, help="title to use in plot; if not given a standard title will be chosen")
@ -123,14 +123,14 @@ def read_data(file, end, raw, dhist):
return data, Itime return data, Itime
def print_data(data, Itime, channels, u,energy): def print_data(data, Itime, channels, u,energy):
resV = data[energy][1]-data [energy][0] resV = 0.838214/2
if not u == None: if not u == None:
if len(u) == len(channels): if len(u) == len(channels):
for i in range(0,len(channels)): for i in range(0,len(channels)):
if not Itime==None: if not Itime==None:
plt.step(data[energy]/float(u[i]), np.multiply(data[channels[i]], 3600/resV/Itime*float(u[i])),label=channels[i]) plt.step(data['mV']/float(u[i]), np.multiply(data[channels[i]], 3600/resV/Itime*float(u[i])),label=channels[i])
else: else:
plt.step(data[energy]/float(u[i]), data[channels[i]]*float(u[i]), channels[i]) plt.step(data['mV']/float(u[i]), data[channels[i]]*float(u[i]), channels[i])
else: else:
for ch in channels: for ch in channels:
if not Itime==None: if not Itime==None: