Compare commits

...

2 commits

Author SHA1 Message Date
ava@asterix
88995ebdd1 CHANGE resV in histplot 2024-05-06 15:57:59 +02:00
ava@asterix
d524be6999 CORRECTED 'AHBGO...' 2024-05-06 15:56:48 +02:00
3 changed files with 49 additions and 25 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 AHBGO... and returns histogramms") parser = argparse.ArgumentParser(description="This script parses EI-data for AHBGOC and returns histogramms of B1,B2 and sum")
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 resV = 0.838214/2
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) and return histogramms") parser = argparse.ArgumentParser(description="This script parses EI-data for AHBGO(C/D/S) 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('-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 sum(s) of BGOdiodes") # 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('-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,11 +49,12 @@ 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(): def main(x):
if args.Itime: if args.Itime:
Itime = find_Itime() Itime = find_Itime()
fname = 'histograms/'+filename+ '.Itime' fname = 'histograms/'+filename+ '.Itime'
@ -73,7 +74,19 @@ def main():
global trig global trig
trig=[] trig=[]
nameadd='x' nameadd='x'
if args.sum: nameadd = nameadd + '_sum' if args.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:
@ -99,7 +112,10 @@ def main():
trigchan.append(i) trigchan.append(i)
bin = int((maxV-minV)/resV) bin = int((maxV-minV)/resV)
hist = np.zeros((bin,18+1)) if not args.sum:
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
@ -112,15 +128,21 @@ def main():
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):
for i in range(18): s = 0.0
x = CmV(l,ch[i])*u[i] for i in range(len(chans)):
b = CmV(l,ch[chans[i]])*u[chans[i]]
if args.zero: if args.zero:
x = x*polynom(0,*pol)/polynom(T,*pol) b = b*polynom(0,*pol)/polynom(T,*pol)
if x>=minV and x<=maxV: if b>=minV and b<=maxV:
xx = int(x-minV/resV) xb = int((b-minV)/resV)
hist[xx,i+1] += 1 hist[xb,i+1] += 1
s = s + b
if args.sum and s>=minV and s<=maxV:
xs = int((s-minV)/resV)
hist[xs,-1] += 1
frame = pd.DataFrame(hist, columns = [energy] + name)
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)
@ -236,15 +258,17 @@ 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': elif x == 'C' or x == 'S':
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() main(x)

View file

@ -12,7 +12,7 @@ import os.path
def main(): def main():
parser = argparse.ArgumentParser(description="This script plots histogramms of give data ending on '.hist'") parser = argparse.ArgumentParser(description="This script plots histogramms of given 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 = 0.838214/2 resV = data[energy][1]-data [energy][0]
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['mV']/float(u[i]), np.multiply(data[channels[i]], 3600/resV/Itime*float(u[i])),label=channels[i]) plt.step(data[energy]/float(u[i]), np.multiply(data[channels[i]], 3600/resV/Itime*float(u[i])),label=channels[i])
else: else:
plt.step(data['mV']/float(u[i]), data[channels[i]]*float(u[i]), channels[i]) plt.step(data[energy]/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: