script for convert .t3pa files to .t3pa_cls
.t3pa file example:
Index $\quad$ Matrix $\quad$ Index $\quad$ ToA $\quad$ ToT $\quad$ FToA $\quad$ Overflow
0 $\quad$ 4574 $\quad$ 832 $\quad$ 29 $\quad$ 6 $\quad$ 0
1 $\quad$ 4831 $\quad$ 832 $\quad$ 35 $\quad$ 7 $\quad$ 0
2 $\quad$ 4575 $\quad$ 832 $\quad$ 100 $\quad$ 8 $\quad$ 0
3 $\quad$ 31031 $\quad$ 1745 $\quad$ 22 $\quad$ 11 $\quad$ 0
.
.
.
.t3pa_cls file example:
% Index $\quad$ Matrix Index $\quad$ [ RowNo, ClmNo ] $\quad$ ToA $\quad$ FToA $\quad$ ( ToA_in_ns ) $\quad$ ToT ( ToT_in_keV ) $\quad$ Overflow
# 1, $\quad$ Nunmasked = 3, $\quad$ Nmasked = 0, $\quad$ Ntot = 3 # Tfirst = 2.0787500000000000e+04 ns, $\quad$ Tlast = 2.0790625000000000e+04 ns, $\quad$ dT = 3.125000 ns, $\quad$ Etot = 64.428148 keV
2 $\quad$ 4575 $\quad$ [ 17, 223 ] $\quad$ 832 $\quad$ 8 $\quad$ ( 2.0787500000000000e+04 ns ) $\quad$ 100 $\quad$ ( 37.867914 keV ) $\quad$ 0
1 $\quad$ 4831 $\quad$ [ 18, 223 ] $\quad$ 832 $\quad$ 7 $\quad$ ( 2.0789062500000000e+04 ns ) $\quad$ 35 $\quad$ ( 14.733453 keV ) $\quad$ 0
0 $\quad$ 4574 $\quad$ [ 17, 222 ] $\quad$ 832 $\quad$ 6 $\quad$ ( 2.0790625000000000e+04 ns ) $\quad$ 29 $\quad$ ( 11.826781 keV ) $\quad$ 0
# 2, $\quad$ Nunmasked = 3, $\quad$ Nmasked = 0, $\quad$ Ntot = 3 # Tfirst = 4.3601562500000000e+04 ns, $\quad$ Tlast = 4.3607812500000000e+04 ns, $\quad$ dT = 6.250000 ns, $\quad$ Etot = 63.577435 keV
5 $\quad$ 30775 $\quad$ [ 120, 55 ] $\quad$ 1745 $\quad$ 15 $\quad$ ( 4.3601562500000000e+04 ns ) $\quad$ 99 $\quad$ ( 37.617059 keV ) $\quad$ 0
4 $\quad$ 30776 $\quad$ [ 120, 56 ] $\quad$ 1745 $\quad$ 13 $\quad$ ( 4.3604687500000000e+04 ns ) $\quad$ 44 $\quad$ ( 14.715446 keV ) $\quad$ 0
3 $\quad$ 31031 $\quad$ [ 121, 55 ] $\quad$ 1745 $\quad$ 11 $\quad$ ( 4.3607812500000000e+04 ns ) $\quad$2 2 $\quad$ ( 11.244929 keV ) $\quad$ 0
.
.
.
import numpy as np
import math
#import pandas as pd
import matplotlib.pyplot as plt
from urllib.error import HTTPError # recognise the error stemming from missing data
#import urllib
import urllib.request
t3pa2cls_XII - upravena fce energy(a, b, c, t, ToT, pocet_udalosti, RowNo, ClmNo) - nyni je se pocita i s pripadem "nan"
#Define an exception which will be raised if the data is missing and stop the notebook execution
class StopExecution(Exception):
def _render_traceback_(self):
pass
#shot_no = 36529 #test discharge for which the notebook will definitely work
shot_no = 44522
shot = shot_no
identifier='H03-W0051_shot_'+str(shot)+'_450V'
detector = 'H03-W0051'
ds = np.DataSource('/tmp') # temporary storage for downloaded files
scalars_URL = 'http://golem.fjfi.cvut.cz/shots/{shot_no}/Diagnostics/PlasmaDetection/Results/{name}'
def get_scalar(shot_no, name):
return float(ds.open(scalars_URL.format(shot_no=shot_no, name=name)).read())
t_plasma_start = get_scalar(shot_no, 't_plasma_start')
t_plasma_end = get_scalar(shot_no, 't_plasma_end')
is_plasma = get_scalar(shot_no, 'b_plasma')
def get_file(shot, identifier):
#Pick the discharge to analyse
URL = 'http://golem.fjfi.cvut.cz/shots/{shot}/Diagnostics/TimepixDetector/H03/{identifier}.t3pa'
url = URL.format(shot=shot, identifier=identifier)
try:
file_name_t3pa=url
with urllib.request.urlopen(file_name_t3pa) as ft3pa:
line = ft3pa.readline()
line = line.decode('utf‐8')
ft3pa.close
except HTTPError:
print('File not found at %s. Aborting notebook execution.' % url)
raise StopExecution
return file_name_t3pa
def get_file_calib(name_calib):
#Pick the discharge to analyse
URL = 'http://golem.fjfi.cvut.cz/shots/{shot}/Diagnostics/TimepixDetector/calib_matrix_H03/{name_calib}.txt'
url = URL.format(shot=shot, name_calib=name_calib)
#print(url)
try:
file_calib=url
with urllib.request.urlopen(file_calib) as calib:
line = calib.readline()
line = line.decode('utf‐8')
calib.close
except HTTPError:
print('File not found at %s. Aborting notebook execution.' % url)
raise StopExecution
return file_calib
def load_calib(file_calib):
with urllib.request.urlopen(file_calib) as fc:
calib=[] #vytvoreni 1D pole
for i in range(0,256): #tj. rozsah 0-255
temp = [] # docasne pole
for j in range(0,256):
temp.append(0) #naplneni docasneho pole 0
calib.append(temp) #naplneni pole a[] docasnym polem temp
for i in range(0,256): #nacteni calib matice do pole calib
line = fc.readline()
line = line.decode('utf‐8')
word=line.strip().split(' ')
for j in range(0,256):
calib[i][j]=float(word[j]) #i = radek, j = sloupec0
fc.close
return calib
def load_t3pa_file(file_t3pa):
index=[]
matrix_index=[]
ToA=[]
ToT=[]
FToA=[]
overflow=[]
pocet_udalosti = 0
with urllib.request.urlopen(file_t3pa) as ft3pa:
line = ft3pa.readline()
line = line.decode('utf‐8')
while True:
line = ft3pa.readline()
line = line.decode('utf‐8')
word=line.strip().split('\t') #v t3pa souboru je oddelovac \t
if line == '':
break
index.append(word[0])
matrix_index.append(word[1])
ToA.append(float(word[2]))
ToT.append(float(word[3]))
FToA.append(float(word[4]))
overflow.append(float(word[5]))
pocet_udalosti = pocet_udalosti + 1
ft3pa.close
return index, matrix_index, ToA, ToT, FToA, overflow, pocet_udalosti
def noise(index, matrix_index, ToA, ToT, FToA, overflow, pocet_udalosti): #tuto fci nemus9m explicitn2 volat - volam ji v fci load_t3pa
pocet=int(0) #pocet sumicich pixelu
konst=int(len(index)/1000)+1
noise_matrix_index=[]
for i in range(0,konst):
pom = [] # pomocne pole
k=0 #pomocna promenna - udava, kolik je v czklu ve skutecnosti udalosti - aby nebyla chyba 'list index out of range'
for j in range(0,1001):
if i*1000+j>=len(index):
break
pom.append(matrix_index[i*1000+j])
k=k+1
for m in range(0,k):
count=int(0) #pocet vvyskytu stejneho matrix index behem 1000 udalosti
index_=int(-1) #budu testovat, jestli pixel na ktery koukam je sumici (abych ho nezapocital 2x)
for p in range(0,pocet):
#index=int(p)
if pom[m]==noise_matrix_index[p]:
index_=p #pixel na ktery jsem uz koukal a byl sumici
break
if index_ >=0 and pom[m]==noise_matrix_index[index_]:
continue
for l in range(0,k):
if pom[m]==pom[l]:
count=count+1
####podminka na sumici pixely
if count>=50: #kdyz se pixel vyskytne behem tisice udalosti vicekrat nez toto cislo, je sumici
noise_matrix_index.append(pom[m])
#noise_matrix_index[pocet]=pom[i]
pocet=pocet+1
pom.clear()
pocet_udalosti=len(index)
for n in range (0,pocet_udalosti):
for o in range(0,len(noise_matrix_index)):
if n >=pocet_udalosti:
break
if(matrix_index[n]==noise_matrix_index[o]):
del matrix_index[n]
del index[n]
del ToA[n]
del ToT[n]
del FToA[n]
del overflow[n]
pocet_udalosti=pocet_udalosti-1
continue
return pocet_udalosti,index, matrix_index, ToA, ToT, FToA, overflow
def t3pa_data(pocet_udalosti,index, matrix_index, ToA, ToT, FToA, overflow):
#rovnou vyhodim sumici pixely
pocet_udalosti,index, matrix_index, ToA, ToT, FToA, overflow=noise(index, matrix_index, ToA, ToT, FToA, overflow, pocet_udalosti)
RowNo=[]
ClmNo=[]
for i in range(0,len(matrix_index)):
RowNo.append(int(int(matrix_index[i]))//int(256))
ClmNo.append(int(int(matrix_index[i]))%int(256))
return index, matrix_index, ToA, ToT, FToA, overflow, pocet_udalosti, RowNo, ClmNo
def hit_map(detector,hit_map_fig,RowNo,ClmNo):
plt.hist2d(RowNo,ClmNo,bins=(256,256),cmap='Blues')
cb=plt.colorbar()
cb.set_label('Counts in pixel')
plt.xlabel('x [pixel]')
plt.ylabel('y [pixel]')
plt.title(detector)
plt.savefig(hit_map_fig, dpi = 1000)
return
def energy(a, b, c, t, ToT, pocet_udalosti, RowNo, ClmNo):
E=[] #energy in keV
#for i in range (0,pocet_udalosti):
pom=0
for i in range (0,len(ToT)):
sqrt=float(0.0)
e1=float(0.0)
e2=float(0.0)
# promenna sqrt je vnitrek odmocniny
sqrt = (((float(b[RowNo[i]][ClmNo[i]])+float(a[RowNo[i]][ClmNo[i]])*float(t[RowNo[i]][ClmNo[i]])-float(ToT[i])))*(((float(b[RowNo[i]][ClmNo[i]])+float(a[RowNo[i]][ClmNo[i]])*float(t[RowNo[i]][ClmNo[i]])-float(ToT[i])))) + (float(4)*float(a[RowNo[i]][ClmNo[i]])*float(c[RowNo[i]][ClmNo[i]]))) #zmena oproti verzi VI
if float(sqrt)<float(0):
E.append(float(0))
else:
'''
V kalibracni matici a se obcas vyskytne 0 -> ve vypoctu energie
je tim padem deleni nulou -> energie diverguje. Jak to vyresit?
zatim polozim energii = 0 (kdyz a=0), pak se uvidi
nakonec udelam limitu vyrazu energie pro a->0 (L'hopital)
'''
if a[RowNo[i]][ClmNo[i]]==0:
e1=((float(t[RowNo[i]][ClmNo[i]]))/float(2)) + ((((float(b[RowNo[i]][ClmNo[i]])+float(a[RowNo[i]][ClmNo[i]])*float(t[RowNo[i]][ClmNo[i]])-float(ToT[i]))*(float(t[RowNo[i]][ClmNo[i]]))) - 2*(float(c[RowNo[i]][ClmNo[i]])))/(float(2)*np.sqrt(float(sqrt))))
e2=((float(t[RowNo[i]][ClmNo[i]]))/float(2)) - ((((float(b[RowNo[i]][ClmNo[i]])+float(a[RowNo[i]][ClmNo[i]])*float(t[RowNo[i]][ClmNo[i]])-float(ToT[i]))*(float(t[RowNo[i]][ClmNo[i]]))) - 2*(float(c[RowNo[i]][ClmNo[i]])))/(float(2)*np.sqrt(float(sqrt))))
else:
e1=((-(float(b[RowNo[i]][ClmNo[i]]) - (float(a[RowNo[i]][ClmNo[i]])*float(t[RowNo[i]][ClmNo[i]]))-float(ToT[i])))+np.sqrt(float(sqrt)))/(float(2)*float(a[RowNo[i]][ClmNo[i]]))
e2=((-(float(b[RowNo[i]][ClmNo[i]]) - (float(a[RowNo[i]][ClmNo[i]])*float(t[RowNo[i]][ClmNo[i]]))-float(ToT[i])))-np.sqrt(float(sqrt)))/(float(2)*float(a[RowNo[i]][ClmNo[i]]))
if a[RowNo[i]][ClmNo[i]]<0:
e1=-1
e2=-1
if math.isnan(e1):
e1=-1
if math.isnan(e2):
e2=-1
if e1<0 and e2<0:
E.append(float(0))
if e1>=0 and e1>e2:
E.append(float(e1))
if e2>=0 and e2>e1:
E.append(float(e2))
if e1>=0 and e2==e1:
E.append(float(e1))
return E
def Time(ToA, FToA, pocet_udalosti, RowNo, ClmNo):
T=[] #time in ns
for i in range (0,pocet_udalosti):
Time=float(0.0)
Time=(float(ToA[i])-((float(FToA[i])/float(16))))*float(25)
T.append(float(Time))
return T
def remove_interactions_with_zero_energy(index, matrix_index, ToA, ToT, FToA, overflow, RowNo, ClmNo, E, T):
i=0
treshold=5.015347
while i < len(T):
if E[i]<treshold: #E[i] < energy treshold
index.pop(i)
matrix_index.pop(i)
ToA.pop(i)
ToT.pop(i)
FToA.pop(i)
overflow.pop(i)
RowNo.pop(i)
ClmNo.pop(i)
E.pop(i)
T.pop(i)
continue
i=i+1
return index, matrix_index, ToA, ToT, FToA, overflow, RowNo, ClmNo, E, T
def clustering_new(index, matrix_index, ToA, ToT, FToA, overflow, RowNo, ClmNo, E, T):
dT=float(50)
indexCl, TCl,ECl, matrix_indexCl, ToACl,ToTCl,FToACl,RowNoCl,ClmNoCl,overflowCl=[],[],[],[],[],[],[],[],[],[]
StartLastElem=len(T)-1
indexCl.append(int(index[StartLastElem]))
TCl.append(float(T[StartLastElem]))
ECl.append(float(E[StartLastElem]))
matrix_indexCl.append(int(matrix_index[StartLastElem]))
RowNoCl.append(int(RowNo[StartLastElem]))
ClmNoCl.append(int(ClmNo[StartLastElem]))
ToACl.append(float(ToA[StartLastElem]))
ToTCl.append(float(ToT[StartLastElem]))
FToACl.append(float(FToA[StartLastElem]))
overflowCl.append(float(overflow[StartLastElem]))
del index[StartLastElem]
del T[StartLastElem]
del E[StartLastElem]
del matrix_index[StartLastElem]
del RowNo[StartLastElem]
del ClmNo[StartLastElem]
del ToA[StartLastElem]
del ToT[StartLastElem]
del FToA[StartLastElem]
del overflow[StartLastElem]
j=1
pom=float(TCl[0]+dT)
while(j >0):
if(len(T) == 0):
break
k=0
j=0
while (k<=(len(TCl)-1)):
i=len(T)-1
if(len(T) == 0):
break
pocet_sousedu=0 #pocet sousednich pixelu - mohou byt maximalne 4
delka=0
# verze X
count=0 #pomocna promanna, kterou urcuji, ze se ma nasledujici cyklus while projit jeste jednou, pokud je i = -1
while(float(T[i])<=(pom)):
delka=delka+1
if(((((int(RowNoCl[k]))==(int(RowNo[i])+1))or((int(RowNoCl[k]))==(int(RowNo[i])-1))) and ((int(ClmNoCl[k]))==(int(ClmNo[i])))) or (((int(RowNoCl[k]))==(int(RowNo[i]))) and (((int(ClmNoCl[k]))==(int(ClmNo[i])+1))or((int(ClmNoCl[k]))==(int(ClmNo[i])-1))))):
#beru jen pixely, které mají společnou jednu stranu.
#pixely, kter0 spolu sousedí přes roh neuvažuji
indexCl.append(int(index[i]))
TCl.append(float(T[i]))
ECl.append(float(E[i]))
matrix_indexCl.append(int(matrix_index[i]))
RowNoCl.append(int(RowNo[i]))
ClmNoCl.append(int(ClmNo[i]))
ToACl.append(float(ToA[i]))
ToTCl.append(float(ToT[i]))
FToACl.append(float(FToA[i]))
overflowCl.append(float(overflow[i]))
# Removes i-th Row
del index[i]
del T[i]
del E[i]
del matrix_index[i]
del RowNo[i]
del ClmNo[i]
del ToA[i]
del ToT[i]
del FToA[i]
del overflow[i]
j=j+1
i=len(T)-1
pocet_sousedu=pocet_sousedu+1
if(len(T) == 0):
break
if(pocet_sousedu==4):
break
continue
i=i-1
if(i==-1): # verze X
count=count+1
if(i<0 and len(T)>0): # verze X
i=0
if(count>1):
break
if(i>=len(T)):
break
k=k+1
if(len(TCl)>2):
indexCl, TCl, ECl, matrix_indexCl, RowNoCl, ClmNoCl, ToACl, ToTCl, FToACl, overflowCl = insertionSort(indexCl, TCl, ECl, matrix_indexCl, RowNoCl, ClmNoCl, ToACl, ToTCl, FToACl, overflowCl)
return T, indexCl,TCl, ECl, matrix_indexCl, RowNoCl, ClmNoCl, ToACl, ToTCl, FToACl, overflowCl
def insertionSort(indexCl, TCl, ECl, matrix_indexCl, RowNoCl, ClmNoCl, ToACl, ToTCl, FToACl, overflowCl):
# Function to do insertion sort
# Traverse through 1 to len(arr)
for i in range(1, len(TCl)):
key = TCl[i]
# Move elements of arr[0..i-1], that are
# greater than key, to one position ahead
# of their current position
#ostatni
key1 = indexCl[i]
key2 = ECl[i]
key3 = matrix_indexCl[i]
key4 = RowNoCl[i]
key5 = ClmNoCl[i]
key6 = ToACl[i]
key7 = ToTCl[i]
key8 = FToACl[i]
key9 = overflowCl[i]
j = i-1
while j >= 0 and key < TCl[j] :
TCl[j + 1] = TCl[j]
#ostatni
indexCl[j + 1] = indexCl[j]
ECl[j + 1] = ECl[j]
matrix_indexCl[j + 1] = matrix_indexCl[j]
RowNoCl[j + 1] = RowNoCl[j]
ClmNoCl[j + 1] = ClmNoCl[j]
ToACl[j + 1] = ToACl[j]
ToTCl[j + 1] = ToTCl[j]
FToACl[j + 1] = FToACl[j]
overflowCl[j + 1] = overflowCl[j]
j -= 1
TCl[j + 1] = key
#ostatni
indexCl[j + 1] = key1
ECl[j + 1] = key2
matrix_indexCl[j + 1] = key3
RowNoCl[j + 1] =key4
ClmNoCl[j + 1] = key5
ToACl[j + 1] = key6
ToTCl[j + 1] = key7
FToACl[j + 1] = key8
overflowCl [j + 1] = key9
return indexCl, TCl, ECl, matrix_indexCl, RowNoCl, ClmNoCl, ToACl, ToTCl, FToACl, overflowCl
def file_t3pa_cls_new(file_t3pa_cls,T):
with open(file_t3pa_cls, "w", encoding="utf-8") as t3pa_cls:
t3pa_cls.write('%\n')
t3pa_cls.write('% Index Matrix Index [ RowNo, ClmNo ] ToA FToA ( ToA_in_ns ) ToT ( ToT_in_keV ) Overflow\n')
t3pa_cls.write('\n')
i=1
T_first=[]
E_tot=[]
while(len(T) > 0):
T, indexCl,TCl, ECl, matrix_indexCl, RowNoCl, ClmNoCl, ToACl, ToTCl, FToACl, overflowCl = clustering_new(index, matrix_index, ToA, ToT, FToA, overflow, RowNo, ClmNo, E, T)
Tfirst=float(TCl[0])
Tlast=float(TCl[len(TCl)-1])
dT=Tlast-Tfirst
Etot=float(0)
for k in range(0,len(TCl)):
Etot=Etot+float(ECl[k])
T_first.append(float(Tfirst))
dT=Tlast-Tfirst
E_tot.append(float(Etot))
t3pa_cls.write('# '+str(i)+', Nunmasked = '+str(len(TCl))+', Nmasked = 0, Ntot = '+str(len(TCl))+'\n')
t3pa_cls.write('# Tfirst = '+str(Tfirst)+' ns, Tlast = '+str(Tlast)+' ns, dT = '+str(dT)+' ns, Etot = '+str(Etot)+' keV\n')
for j in range(0,len(TCl)):
t3pa_cls.write(str(indexCl[j])+' '+str(matrix_indexCl[j])+' [ '+str(RowNoCl[j])+', '+str(ClmNoCl[j])+' ] '+str(ToACl[j])+' '+str(FToACl[j])+' ( '+str(TCl[j])+' ns ) '+str(ToTCl[j])+' ( '+str(ECl[j])+' keV ) '+str(overflowCl[j])+'\n')
t3pa_cls.write('\n')
i=i+1
t3pa_cls.close
return T_first, E_tot
def energy_spectrum_in_time(Tfirst, Etot): #dela histogram - energie zaznamenana v case
pom = 0
dt=100 #(ns) time width of 1 bin
T_first=0 #cas, kdy prisel trigger a yacalo mereni
T_last=(max(Tfirst)) #posledni z Tfirst
Delta_T = T_last - T_first
poc = int(int(Delta_T) / float(dt)) + 1 #pocet casovych oken
T_int_first=[] #cas
E=[] #energie
for i in range(0,poc):
T_int_first.append((i*dt) + dt/2)
E.append(0)
#XII
for j in range(0,len(Tfirst)):
time_index=0
time_index=int(((Tfirst[j]-T_first)/dt))
if float(Tfirst[j]-T_first) >= (T_int_first[time_index] - dt / 2) and float(Tfirst[j]-T_first) < (T_int_first[time_index] + dt / 2):
E[time_index]=float(E[time_index])+float(Etot[j])
pom=pom+1
for l in range(0,len(T_int_first)):
T_int_first[l]=T_int_first[l]+T_first
caption, T_int_first = energy_in_time_hist(T_int_first, E, figure_E_in_time_hist, t_plasma_start, t_plasma_end, is_plasma, dt)
return dt, caption, T_int_first, E
def energy_in_time_hist(T_int_first, E,figure_E_in_time_hist, t_plasma_start, t_plasma_end, is_plasma, dt):
plt.rcParams.update({'font.size': 20})
fig, ax = plt.subplots(figsize =(10, 7))
for k in range(0,len(T_int_first)):
T_int_first[k] = T_int_first[k] / 1000000
plt.plot(T_int_first, E)
plt.title(detector+', #'+str(shot_no))
plt.xlabel('Time [ms]')
plt.ylabel('Energy [keV]')
if is_plasma == 1:
for t in (t_plasma_start, t_plasma_end):
plt.axvline(t, color='k', linestyle='--')
plt.xlim([0, (t_plasma_start + t_plasma_end)])
else:
plt.xlim(0,)
plt.ylim(0,) #10 000 keV
plt.savefig(figure_E_in_time_hist, dpi = 1000)
caption = '# x = time in ms, count = energy in keV, dT= '+str(dt)+' ns'
return caption, T_int_first
def hits_in_time_hist_new(T, dt, t_plasma_start, t_plasma_end, is_plasma,figure_count_in_time_hist):
pom = 0
T_first=0 #cas, kdy prisel trigger a yacalo mereni
T_last=(max(T)) #posledni z Tfirst
Delta_T = T_last - T_first
poc = int(int(Delta_T) / float(dt)) + 1 #pocet casovych oken
T_hit=[] #cas
count=[] #energie
for i in range(0,poc):
T_hit.append((i*dt) + dt/2)
count.append(0)
for j in range(0,len(T)):
time_index=0
time_index=int(((T[j]-T_first)/dt))
k=time_index
for j in range(0,len(T)):
time_index=0
time_index=int(((T[j]-T_first)/dt))
if float(T[j]-T_first) >= (T_hit[time_index] - dt / 2) and float(T[j]-T_first) < (T_hit[time_index] + dt / 2):
count[time_index] = count[time_index] + 1
pom=pom+1
for l in range(0,len(T_hit)):
T_hit[l]=T_hit[l]+T_first
plt.rcParams.update({'font.size': 20})
fig, ax = plt.subplots(figsize =(10, 7))
for k in range(0,len(T_hit)):
T_hit[k] = T_hit[k] / 1000000
plt.plot(T_hit, count)
plt.title(detector+', #'+str(shot_no))
plt.xlabel('Time [ms]')
plt.ylabel('Count')
if is_plasma == 1:
for t in (t_plasma_start, t_plasma_end):
plt.axvline(t, color='k', linestyle='--')
plt.xlim([0, (t_plasma_start + t_plasma_end)])
else:
plt.xlim(0,)
plt.ylim(0,) #10 000 keV
plt.savefig(figure_count_in_time_hist, dpi = 1000)
caption = '# x = time in ms, dT= '+str(dt)+' ns'
return caption, T_hit,count
def energy_spectrum(Etot):
E_min=0
dE=5 #keV
E_max=max(Etot)
pocet=(E_max//dE) + 3
pocet=int(pocet)
E_max=float(dE*pocet)
xle=[]
xre=[]
xmean=[]
for p in range (0,pocet):
xle.append(E_min + (p * (E_max - E_min)) / pocet)
xre.append(xle[p]+dE)
xmean.append((xle[p] + xre[p]) / 2)
count=[]
for l in range(0,pocet):
count.append(0)
#XII
for i in range(0,len(Etot)):
E_index=int(((Etot[i]-E_min)/dE))
if ((xle[E_index] <= Etot[i]) and (Etot[i] < xre[E_index])):
count[E_index]=count[E_index]+1
plt.rcParams.update({'font.size': 20})
fig, ax = plt.subplots(figsize =(10, 7))
ax.hist(Etot, bins = xle)
plt.title(detector+', #'+str(shot_no))
plt.xlabel('Energy [keV]')
plt.ylabel('Count')
plt.xlim(0,)
ax.set_yscale('log') #log scale y
caption = '# x = energy in keV, dE= '+str(dE)+' keV'
plt.savefig(figure_E_hist, dpi = 1000)
return caption, xmean,count, xle, Etot
def hist_file(file_hist, xmean, count, caption ):
with open(file_hist, "w", encoding="utf-8") as hist:
hist.write('#\n')
hist.write('#'+str(caption)+'\n')
hist.write('# x_mean count\n')
hist.write('\n')
for m in range(0,len(xmean)):
hist.write(str(xmean[m])+' '+str(count[m])+'\n')
hist.close
return T_first, E_tot
def multiplot(icon_fig, x1,y1,x2,y2):
plt.rcParams.update({'font.size': 20})
fig, ax = plt.subplots(nrows=2,figsize =(10, 7))
ax[0].plot(x1, y1)
ax[0].set_xlabel('Time [ms]')
ax[0].set_ylabel('Energy [keV]')
if is_plasma == 1:
for t in (t_plasma_start, t_plasma_end):
ax[0].axvline(t, color='k', linestyle='--')
ax[0].set_xlim([0, (t_plasma_start + t_plasma_end)])
else:
ax[0].set_xlim(0,)
ax[0].set_ylim(0,) #keV
ax[1].hist(y2, bins = x2)
ax[1].set_xlabel('Energy [keV]')
ax[1].set_ylabel('Count')
ax[1].set_xlim(0,)
#ax[1].set_ylim(0,)
ax[1].set_yscale('log') #log scale y
fig.subplots_adjust(hspace=0.3)
plt.savefig(icon_fig, dpi = 1000)
return
#soubory, ktere ctu
#read files
t3pa=get_file(shot, identifier)
name_calib='caliba'
caliba=get_file_calib(name_calib)
name_calib='calibb'
calibb=get_file_calib(name_calib)
name_calib='calibc'
calibc=get_file_calib(name_calib)
name_calib='calibt'
calibt=get_file_calib(name_calib)
#vytvorene soubory:
#created files
t3pa_cls='H03-W0051_shot_'+str(shot)+'_450V.t3pa_cls'
E_hist='H03-W0051_shot_'+str(shot)+'_450V_E_hist.txt'
E_in_time_hist='H03-W0051_shot_'+str(shot)+'_450V_discharge_energy.txt'
count_in_time_hist= 'H03-W0051_shot_'+str(shot)+'_450V_discharge_hits.txt'
#created figures
icon_fig='icon-fig'
figure_E_in_time_hist='discharge_energy'
figure_count_in_time_hist='discharge_hits'
figure_E_hist='Energy_spectrum'
hit_map_fig='hit-map'
#nactu jednotlive kalibracni matice - abych to nemusel delat v kazde funkci
a=load_calib(caliba)
b=load_calib(calibb)
c=load_calib(calibc)
t=load_calib(calibt)
#nactu a urcim jednotlive hodnoty - abych to nemusel delat v kazde funkci
index, matrix_index, ToA, ToT, FToA, overflow, pocet_udalosti = load_t3pa_file(t3pa)
index, matrix_index, ToA, ToT, FToA, overflow, pocet_udalosti, RowNo, ClmNo = t3pa_data(pocet_udalosti,index, matrix_index, ToA, ToT, FToA, overflow)
raw data
#hit map
hit_map(detector,hit_map_fig,RowNo,ClmNo)
Energy and time calculation from raw data.
E=energy(a, b, c, t, ToT, pocet_udalosti, RowNo, ClmNo)
T=Time(ToA, FToA, pocet_udalosti, RowNo, ClmNo)
index, matrix_index, ToA, ToT, FToA, overflow, RowNo, ClmNo, E, T = remove_interactions_with_zero_energy(index, matrix_index, ToA, ToT, FToA, overflow, RowNo, ClmNo, E, T)
#sort by time
T, index, matrix_index, ToA, ToT, FToA, overflow, RowNo, ClmNo, E = (list(t) for t in zip(*sorted(zip(T, index, matrix_index, ToA, ToT, FToA, overflow, RowNo, ClmNo, E), reverse=True))) #serazeni od nejvetsiho po nejmensi
T_pom=T.copy()
#save to file
T_first, E_tot = file_t3pa_cls_new(t3pa_cls,T)
dt, caption, T_int_first, E = energy_spectrum_in_time(T_first, E_tot)
hist_file(E_in_time_hist, T_int_first, E, caption);
([5916420.3125, 7211512.5, 7211557.8125, 7852950.0, 7912729.6875, 8493917.1875, 8897857.8125, 8897898.4375, 8931248.4375, 8947617.1875, 8956618.75, 8956751.5625, 9076801.5625, 9076864.0625, 9108768.75, 9111825.0, 9112765.625, 9115084.375, 9121910.9375, 9126657.8125, 9130817.1875, 9130903.125, 9132096.875, 9135435.9375, 9135445.3125, 9135457.8125, 9137775.0, 9137842.1875, 9138121.875, 9138328.125, 9138828.125, 9138881.25, 9139506.25, 9139506.25, 9139531.25, 9140165.625, 9140684.375, 9141164.0625, 9141579.6875, 9152759.375, 9156903.125, 9171971.875, 9181237.5, 9188664.0625, 9188729.6875, 9189796.875, 9193229.6875, 9195962.5, 9196754.6875, 9203617.1875, 9223992.1875, 9224853.125, 9254518.75, 9256398.4375, 9256773.4375, 9256901.5625, 9257478.125, 9257484.375, 9257856.25, 9257954.6875, 9258254.6875, 9258304.6875, 9258439.0625, 9258659.375, 9259189.0625, 9259673.4375, 9260335.9375, 9262409.375, 9262420.3125, 9262785.9375, 9266745.3125, 9266853.125, 9269579.6875, 9269587.5, 9269629.6875, 9272309.375, 9273390.625, 9277821.875, 9278921.875, 9294943.75, 9300712.5, 9301817.1875, 9301984.375, 9302690.625, 9303115.625, 9304429.6875, 9323639.0625, 9327520.3125, 9328215.625, 9334356.25, 9339328.125, 9341629.6875, 9345848.4375, 9347776.5625, 9377117.1875, 9377123.4375, 9381801.5625, 9389864.0625, 9393576.5625, 9395740.625, 9399140.625, 9400823.4375, 9403803.125, 9406407.8125, 9406426.5625, 9406948.4375, 9411760.9375, 9447414.0625, 9449421.875, 9453957.8125, 9454017.1875, 9454379.6875, 9458596.875, 9463100.0, 9466618.75, 9508065.625, 9508689.0625, 9513689.0625, 9524193.75, 9527251.5625, 9528693.75, 9530932.8125, 9531221.875, 9532271.875, 9532956.25, 9534101.5625, 9535051.5625, 9537131.25, 9537503.125, 9538368.75, 9540053.125, 9544410.9375, 9554393.75, 9557362.5, 9558418.75, 9559414.0625, 9560429.6875, 9560735.9375, 9561923.4375, 9562301.5625, 9564182.8125, 9583131.25, 9587050.0, 9588970.3125, 9589250.0, 9590829.6875, 9594187.5, 9594209.375, 9594267.1875, 9594276.5625, 9594978.125, 9608404.6875, 9639428.125, 9639634.375, 9640140.625, 9641395.3125, 9646439.0625, 9655867.1875, 9668023.4375, 9674087.5, 9678103.125, 9728600.0, 9755431.25, 9758751.5625, 9802314.0625, 9804106.25, 9804293.75, 9804989.0625, 9805073.4375, 9805250.0, 9806179.6875, 9806746.875, 9806934.375, 9808214.0625, 9812307.8125, 9815065.625, 9823315.625, 9825228.125, 9825509.375, 9826603.125, 9826898.4375, 9828164.0625, 9829757.8125, 9830375.0, 9835165.625, 9896264.0625, 9908989.0625, 9912737.5, 9948298.4375, 9948768.75, 9949609.375, 9949900.0, 9951996.875, 9975998.4375, 9991450.0, 10016520.3125, 10074290.625, 10097850.0, 10145598.4375, 10181940.625, 10182439.0625, 10204826.5625, 10215110.9375, 10238659.375, 10247553.125, 10249906.25, 10329289.0625, 10332453.125, 10360801.5625, 10364296.875, 10366056.25, 10402096.875, 10405603.125, 10409975.0, 10410035.9375, 10422965.625, 10439060.9375, 10445087.5, 10461562.5, 10467334.375, 10469407.8125, 10475340.625, 10481673.4375, 10482057.8125, 10529612.5, 10562381.25, 10562706.25, 10563117.1875, 10572110.9375, 10613946.875, 11127910.9375, 11133442.1875, 11137665.625, 11142325.0, 11143101.5625, 11143262.5, 11144562.5, 11147409.375, 11147929.6875, 11149539.0625, 11150985.9375, 11152171.875, 11153251.5625, 11157546.875, 11158820.3125, 11160123.4375, 11161229.6875, 11162084.375, 11162228.125, 11162360.9375, 11162456.25, 11162473.4375, 11162478.125, 11162509.375, 11162546.875, 11162689.0625, 11162690.625, 11162710.9375, 11162765.625, 11162984.375, 11163028.125, 11163081.25, 11163129.6875, 11163296.875, 11163387.5, 11163440.625, 11163756.25, 11163992.1875, 11164017.1875, 11164153.125, 11164360.9375, 11164389.0625, 11164540.625, 11164625.0, 11164631.25, 11164778.125, 11164989.0625, 11165032.8125, 11165073.4375, 11165429.6875, 11165731.25, 11166115.625, 11166181.25, 11166193.75, 11166254.6875, 11166956.25, 11167268.75, 11167854.6875, 11168285.9375, 11170101.5625, 11170115.625, 11170375.0, 11170814.0625, 11171246.875, 11171509.375, 11171887.5, 11172751.5625, 11172792.1875, 11173067.1875, 11173075.0, 11173650.0, 11174520.3125, 11174523.4375, 11174934.375, 11175323.4375, 11175360.9375, 11175431.25, 11175643.75, 11175715.625, 11176443.75, 11176539.0625, 11177365.625, 11177960.9375, 11178128.125, 11178168.75, 11178173.4375, 11178496.875, 11178737.5, 11178760.9375, 11178848.4375, 11179048.4375, 11179189.0625, 11179407.8125, 11180792.1875, 11180940.625, 11181250.0, 11181262.5, 11181851.5625, 11182512.5, 11182512.5, 11182609.375, 11183489.0625, 11183787.5, 11183909.375, 11185468.75, 11186031.25, 11186496.875, 11187256.25, 11187257.8125, 11187264.0625, 11187353.125, 11188239.0625, 11190325.0, 11190543.75, 11190589.0625, 11190826.5625, 11192706.25, 11194556.25, 11194896.875, 11197553.125, 11197931.25, 11199409.375, 11202331.25, 11204007.8125, 11204120.3125, 11206721.875, 11207037.5], [18.679893899764718, 43.845252347569854, 13.433411084520493, 15.782810792556935, 14.207119332236875, 49.69462946364623, 12.360511228680227, 11.26307150392768, 8.807992515129264, 24.88312596360584, 16.969443168055598, 39.095725198358416, 13.872146832901132, 6.24950116079917, 12.187320498941151, 33.14288082822723, 54.67564864386779, 26.97331493376732, 6.678251576369009, 6.716645169378606, 64.19051946541173, 31.237328780379777, 46.21740716308604, 30.81105060330966, 47.35073148174725, 10.584928092430657, 8.54371981833221, 19.719572487368367, 92.17309300154486, 155.56847130702766, 44.54591789587778, 5.180248619442479, 15.753293367263238, 27.286859654671638, 51.496089177286734, 6.892141496079307, 24.855225473967543, 29.330724331428623, 9.523249960787254, 128.88993579412545, 52.94323643254676, 31.37189308068486, 18.534057752558624, 144.87149762919404, 16.840992008286676, 26.38672352383917, 37.99346202521522, 132.8391161866309, 34.553514871654215, 28.55620096603153, 18.3390625196466, 12.166799311176979, 14.783974254418354, 84.39205137305363, 15.572849507411762, 41.68893452855643, 17.521888636418378, 7.984308146980803, 28.98518235034306, 41.09886297082661, 38.40429914230702, 19.290165522089474, 99.21203935021651, 9.007882743290542, 6.6516640290393925, 88.90678093317109, 66.89156484768192, 22.849263621841033, 7.550297184201069, 12.8082153045777, 39.819658321095474, 5.276805663943318, 69.4625468236896, 25.139230305886464, 13.152074069704632, 6.046089639238439, 82.43422321057423, 6.879267303401667, 12.940267337534415, 45.595075075339466, 101.27458911056813, 80.01304135723427, 60.0311418940106, 85.88721246184971, 12.346372551622261, 80.88778391372375, 14.344001538713874, 13.0747761740264, 36.400136607890666, 153.18540895333203, 10.966589161235659, 18.68666919009698, 63.255953972076064, 25.04464236675414, 63.3831899985029, 49.14667654481673, 30.88218128099382, 23.592877763750334, 68.30071407673925, 11.630031322754377, 18.363014400615306, 64.74678744659735, 73.29738617157395, 26.17360349541964, 23.26587141475089, 82.30521953948397, 23.294300910531845, 14.647423248874684, 43.401357617754826, 53.70751451332246, 80.37449719929877, 11.996217980037825, 49.62613493867917, 59.771921849494525, 18.96070306265655, 51.96842193863016, 6.686258987343324, 73.21664031286718, 20.39615840293744, 150.2862500252548, 8.514554589922687, 74.58250897110659, 10.7054329403293, 80.0306532693598, 39.59601052033948, 29.161461052057625, 19.31418433858314, 24.663533171698482, 93.30485457152871, 109.98244723546648, 32.24953662408639, 13.913181135802546, 33.11781450235349, 82.7852049558468, 67.93862384460799, 16.033031501376495, 65.82494495454877, 31.45516222331424, 9.332973339508001, 33.098402646035716, 44.66854834359262, 122.3903310831005, 69.74528894713752, 6.60534335818413, 7.4854038440978465, 61.35044798824343, 40.193245603246794, 6.7881517281072155, 33.76084027058198, 5.07084165053347, 43.427595690429726, 8.188417251210087, 14.732570308727217, 29.33263641473227, 8.962291656926954, 117.0675874448622, 158.03156177503917, 38.012059433221715, 12.712149758182084, 10.663869506914365, 24.363550868144007, 26.59684942727088, 21.667445511599293, 38.174293193866305, 12.951029870567679, 24.84054459414038, 351.1631980704507, 7.140652568364349, 46.2481643748188, 8.616237633491552, 125.0289969989907, 62.903581194307456, 37.45302532944274, 95.34576859150326, 6.644437382392122, 14.921973934833021, 9.149463967276597, 60.89691036147398, 20.210420135436998, 15.190501749731881, 18.875325215921627, 17.672058264590827, 6.246342747204335, 31.783207881688153, 87.31614695827103, 25.871690435990267, 46.386913480638896, 6.824469256581657, 88.87602075649991, 14.125494506336114, 15.080515076957301, 67.11912167125908, 50.46788159731711, 29.361145328817084, 18.3266075956138, 35.915642989945844, 59.96849533577167, 19.26562697557611, 45.104179460766204, 33.52003535000775, 31.18831147954725, 110.69778881940147, 78.51031733214636, 24.063630917523895, 32.24198489912487, 62.1769774355189, 38.086315308454274, 15.720086005778665, 46.478317260501186, 18.504098267229196, 6.176436243934203, 19.177674364938554, 13.081241327356686, 46.57689301670887, 6.8770306640775285, 24.18491856021853, 6.271475042557742, 67.26451963913706, 170.20288116583197, 74.00109032805632, 5.475626818179884, 47.80391857974736, 15.168792272505637, 84.47037019865706, 27.68242892282675, 34.22160965266714, 97.1012712560622, 54.190577513529675, 94.06932344963491, 21.83900950879034, 5.440255971112203, 74.6366699051838, 53.823258158818106, 6.993579537309667, 24.17791550216845, 19.831690166795173, 25.059897090959105, 65.51536550395079, 41.21685670056854, 26.12086550646299, 6.2029555723050755, 57.71151831442883, 9.557637723610586, 10.176154712337787, 7.378559616928279, 47.340819340968565, 20.659095450347913, 87.3452893636532, 37.744893233747305, 71.37341390566931, 61.03220592642987, 5.650157291465318, 16.783518808943796, 41.49939707452832, 18.107979478769696, 31.566702861606053, 51.831685298786496, 11.105653571992095, 16.480979819465386, 106.36380554551644, 92.03139316985569, 5.22282595856162, 50.28209518509887, 112.9891313596412, 16.5425186487527, 9.44134924084085, 40.9229380866676, 7.62824191022587, 36.07370060726079, 103.75476742183423, 9.023889954923698, 81.68835466032057, 46.317022279308006, 23.37472771106987, 11.620991596136102, 23.705348493076603, 9.4194769392854, 5.212307473638161, 37.58447711719804, 6.564470073303093, 12.073473545660798, 85.05409647747501, 70.6457906252777, 18.481144068398777, 5.144836221875527, 26.635763705636215, 15.189775822332447, 20.311129737385386, 6.884709212358896, 15.462662810511068, 5.273171465265256, 36.99460684814983, 9.225479375162315, 97.58120961834773, 74.64146214627533, 62.9216768679842, 73.97638888040606, 24.512535514609446, 13.42149567950129, 14.43543201666305, 18.0898701142303, 81.32192807772648, 40.18556961256605, 20.213212765043266, 6.048760180904985, 51.75559246572299, 22.103811610613402, 7.652615916502223, 10.165404411172418, 16.691208683180204, 13.499563973489014, 78.46713940230583, 15.84945345075796, 32.612155414071026, 13.796849868860154, 12.197001590833171, 74.5738962836656, 92.21889776510615, 23.620098724147702, 9.854609109181919, 13.841125411801501, 8.584205010599005, 33.606328490343216, 14.985941364982542, 14.662606528916054, 8.092822576129462, 20.330770647303204, 16.215669038007682, 13.400417374758405, 32.83691221998936, 39.444884393993384, 123.71450876687958, 19.030657927369262, 13.18920856935968, 79.37229663530375, 6.394592903194093, 15.619389277400082, 29.269903427994162, 122.59147714990883, 54.92030127186041, 9.3773973705904, 43.5022531776178, 10.80378023640395, 9.043463054285333, 15.072993892271759, 5.393938376602311, 9.366759920788168, 8.037717556656249, 34.2021513440949, 77.33096147835442, 20.126958503194604, 32.1148706470171, 32.004957759128494, 6.684406942469101, 46.77904828317542, 20.869912472728625, 9.934595833060714])
caption, xmean,count, xle, Etot = energy_spectrum(E_tot)
hist_file(E_hist, xmean, count, caption);
([5916420.3125, 7211512.5, 7211557.8125, 7852950.0, 7912729.6875, 8493917.1875, 8897857.8125, 8897898.4375, 8931248.4375, 8947617.1875, 8956618.75, 8956751.5625, 9076801.5625, 9076864.0625, 9108768.75, 9111825.0, 9112765.625, 9115084.375, 9121910.9375, 9126657.8125, 9130817.1875, 9130903.125, 9132096.875, 9135435.9375, 9135445.3125, 9135457.8125, 9137775.0, 9137842.1875, 9138121.875, 9138328.125, 9138828.125, 9138881.25, 9139506.25, 9139506.25, 9139531.25, 9140165.625, 9140684.375, 9141164.0625, 9141579.6875, 9152759.375, 9156903.125, 9171971.875, 9181237.5, 9188664.0625, 9188729.6875, 9189796.875, 9193229.6875, 9195962.5, 9196754.6875, 9203617.1875, 9223992.1875, 9224853.125, 9254518.75, 9256398.4375, 9256773.4375, 9256901.5625, 9257478.125, 9257484.375, 9257856.25, 9257954.6875, 9258254.6875, 9258304.6875, 9258439.0625, 9258659.375, 9259189.0625, 9259673.4375, 9260335.9375, 9262409.375, 9262420.3125, 9262785.9375, 9266745.3125, 9266853.125, 9269579.6875, 9269587.5, 9269629.6875, 9272309.375, 9273390.625, 9277821.875, 9278921.875, 9294943.75, 9300712.5, 9301817.1875, 9301984.375, 9302690.625, 9303115.625, 9304429.6875, 9323639.0625, 9327520.3125, 9328215.625, 9334356.25, 9339328.125, 9341629.6875, 9345848.4375, 9347776.5625, 9377117.1875, 9377123.4375, 9381801.5625, 9389864.0625, 9393576.5625, 9395740.625, 9399140.625, 9400823.4375, 9403803.125, 9406407.8125, 9406426.5625, 9406948.4375, 9411760.9375, 9447414.0625, 9449421.875, 9453957.8125, 9454017.1875, 9454379.6875, 9458596.875, 9463100.0, 9466618.75, 9508065.625, 9508689.0625, 9513689.0625, 9524193.75, 9527251.5625, 9528693.75, 9530932.8125, 9531221.875, 9532271.875, 9532956.25, 9534101.5625, 9535051.5625, 9537131.25, 9537503.125, 9538368.75, 9540053.125, 9544410.9375, 9554393.75, 9557362.5, 9558418.75, 9559414.0625, 9560429.6875, 9560735.9375, 9561923.4375, 9562301.5625, 9564182.8125, 9583131.25, 9587050.0, 9588970.3125, 9589250.0, 9590829.6875, 9594187.5, 9594209.375, 9594267.1875, 9594276.5625, 9594978.125, 9608404.6875, 9639428.125, 9639634.375, 9640140.625, 9641395.3125, 9646439.0625, 9655867.1875, 9668023.4375, 9674087.5, 9678103.125, 9728600.0, 9755431.25, 9758751.5625, 9802314.0625, 9804106.25, 9804293.75, 9804989.0625, 9805073.4375, 9805250.0, 9806179.6875, 9806746.875, 9806934.375, 9808214.0625, 9812307.8125, 9815065.625, 9823315.625, 9825228.125, 9825509.375, 9826603.125, 9826898.4375, 9828164.0625, 9829757.8125, 9830375.0, 9835165.625, 9896264.0625, 9908989.0625, 9912737.5, 9948298.4375, 9948768.75, 9949609.375, 9949900.0, 9951996.875, 9975998.4375, 9991450.0, 10016520.3125, 10074290.625, 10097850.0, 10145598.4375, 10181940.625, 10182439.0625, 10204826.5625, 10215110.9375, 10238659.375, 10247553.125, 10249906.25, 10329289.0625, 10332453.125, 10360801.5625, 10364296.875, 10366056.25, 10402096.875, 10405603.125, 10409975.0, 10410035.9375, 10422965.625, 10439060.9375, 10445087.5, 10461562.5, 10467334.375, 10469407.8125, 10475340.625, 10481673.4375, 10482057.8125, 10529612.5, 10562381.25, 10562706.25, 10563117.1875, 10572110.9375, 10613946.875, 11127910.9375, 11133442.1875, 11137665.625, 11142325.0, 11143101.5625, 11143262.5, 11144562.5, 11147409.375, 11147929.6875, 11149539.0625, 11150985.9375, 11152171.875, 11153251.5625, 11157546.875, 11158820.3125, 11160123.4375, 11161229.6875, 11162084.375, 11162228.125, 11162360.9375, 11162456.25, 11162473.4375, 11162478.125, 11162509.375, 11162546.875, 11162689.0625, 11162690.625, 11162710.9375, 11162765.625, 11162984.375, 11163028.125, 11163081.25, 11163129.6875, 11163296.875, 11163387.5, 11163440.625, 11163756.25, 11163992.1875, 11164017.1875, 11164153.125, 11164360.9375, 11164389.0625, 11164540.625, 11164625.0, 11164631.25, 11164778.125, 11164989.0625, 11165032.8125, 11165073.4375, 11165429.6875, 11165731.25, 11166115.625, 11166181.25, 11166193.75, 11166254.6875, 11166956.25, 11167268.75, 11167854.6875, 11168285.9375, 11170101.5625, 11170115.625, 11170375.0, 11170814.0625, 11171246.875, 11171509.375, 11171887.5, 11172751.5625, 11172792.1875, 11173067.1875, 11173075.0, 11173650.0, 11174520.3125, 11174523.4375, 11174934.375, 11175323.4375, 11175360.9375, 11175431.25, 11175643.75, 11175715.625, 11176443.75, 11176539.0625, 11177365.625, 11177960.9375, 11178128.125, 11178168.75, 11178173.4375, 11178496.875, 11178737.5, 11178760.9375, 11178848.4375, 11179048.4375, 11179189.0625, 11179407.8125, 11180792.1875, 11180940.625, 11181250.0, 11181262.5, 11181851.5625, 11182512.5, 11182512.5, 11182609.375, 11183489.0625, 11183787.5, 11183909.375, 11185468.75, 11186031.25, 11186496.875, 11187256.25, 11187257.8125, 11187264.0625, 11187353.125, 11188239.0625, 11190325.0, 11190543.75, 11190589.0625, 11190826.5625, 11192706.25, 11194556.25, 11194896.875, 11197553.125, 11197931.25, 11199409.375, 11202331.25, 11204007.8125, 11204120.3125, 11206721.875, 11207037.5], [18.679893899764718, 43.845252347569854, 13.433411084520493, 15.782810792556935, 14.207119332236875, 49.69462946364623, 12.360511228680227, 11.26307150392768, 8.807992515129264, 24.88312596360584, 16.969443168055598, 39.095725198358416, 13.872146832901132, 6.24950116079917, 12.187320498941151, 33.14288082822723, 54.67564864386779, 26.97331493376732, 6.678251576369009, 6.716645169378606, 64.19051946541173, 31.237328780379777, 46.21740716308604, 30.81105060330966, 47.35073148174725, 10.584928092430657, 8.54371981833221, 19.719572487368367, 92.17309300154486, 155.56847130702766, 44.54591789587778, 5.180248619442479, 15.753293367263238, 27.286859654671638, 51.496089177286734, 6.892141496079307, 24.855225473967543, 29.330724331428623, 9.523249960787254, 128.88993579412545, 52.94323643254676, 31.37189308068486, 18.534057752558624, 144.87149762919404, 16.840992008286676, 26.38672352383917, 37.99346202521522, 132.8391161866309, 34.553514871654215, 28.55620096603153, 18.3390625196466, 12.166799311176979, 14.783974254418354, 84.39205137305363, 15.572849507411762, 41.68893452855643, 17.521888636418378, 7.984308146980803, 28.98518235034306, 41.09886297082661, 38.40429914230702, 19.290165522089474, 99.21203935021651, 9.007882743290542, 6.6516640290393925, 88.90678093317109, 66.89156484768192, 22.849263621841033, 7.550297184201069, 12.8082153045777, 39.819658321095474, 5.276805663943318, 69.4625468236896, 25.139230305886464, 13.152074069704632, 6.046089639238439, 82.43422321057423, 6.879267303401667, 12.940267337534415, 45.595075075339466, 101.27458911056813, 80.01304135723427, 60.0311418940106, 85.88721246184971, 12.346372551622261, 80.88778391372375, 14.344001538713874, 13.0747761740264, 36.400136607890666, 153.18540895333203, 10.966589161235659, 18.68666919009698, 63.255953972076064, 25.04464236675414, 63.3831899985029, 49.14667654481673, 30.88218128099382, 23.592877763750334, 68.30071407673925, 11.630031322754377, 18.363014400615306, 64.74678744659735, 73.29738617157395, 26.17360349541964, 23.26587141475089, 82.30521953948397, 23.294300910531845, 14.647423248874684, 43.401357617754826, 53.70751451332246, 80.37449719929877, 11.996217980037825, 49.62613493867917, 59.771921849494525, 18.96070306265655, 51.96842193863016, 6.686258987343324, 73.21664031286718, 20.39615840293744, 150.2862500252548, 8.514554589922687, 74.58250897110659, 10.7054329403293, 80.0306532693598, 39.59601052033948, 29.161461052057625, 19.31418433858314, 24.663533171698482, 93.30485457152871, 109.98244723546648, 32.24953662408639, 13.913181135802546, 33.11781450235349, 82.7852049558468, 67.93862384460799, 16.033031501376495, 65.82494495454877, 31.45516222331424, 9.332973339508001, 33.098402646035716, 44.66854834359262, 122.3903310831005, 69.74528894713752, 6.60534335818413, 7.4854038440978465, 61.35044798824343, 40.193245603246794, 6.7881517281072155, 33.76084027058198, 5.07084165053347, 43.427595690429726, 8.188417251210087, 14.732570308727217, 29.33263641473227, 8.962291656926954, 117.0675874448622, 158.03156177503917, 38.012059433221715, 12.712149758182084, 10.663869506914365, 24.363550868144007, 26.59684942727088, 21.667445511599293, 38.174293193866305, 12.951029870567679, 24.84054459414038, 351.1631980704507, 7.140652568364349, 46.2481643748188, 8.616237633491552, 125.0289969989907, 62.903581194307456, 37.45302532944274, 95.34576859150326, 6.644437382392122, 14.921973934833021, 9.149463967276597, 60.89691036147398, 20.210420135436998, 15.190501749731881, 18.875325215921627, 17.672058264590827, 6.246342747204335, 31.783207881688153, 87.31614695827103, 25.871690435990267, 46.386913480638896, 6.824469256581657, 88.87602075649991, 14.125494506336114, 15.080515076957301, 67.11912167125908, 50.46788159731711, 29.361145328817084, 18.3266075956138, 35.915642989945844, 59.96849533577167, 19.26562697557611, 45.104179460766204, 33.52003535000775, 31.18831147954725, 110.69778881940147, 78.51031733214636, 24.063630917523895, 32.24198489912487, 62.1769774355189, 38.086315308454274, 15.720086005778665, 46.478317260501186, 18.504098267229196, 6.176436243934203, 19.177674364938554, 13.081241327356686, 46.57689301670887, 6.8770306640775285, 24.18491856021853, 6.271475042557742, 67.26451963913706, 170.20288116583197, 74.00109032805632, 5.475626818179884, 47.80391857974736, 15.168792272505637, 84.47037019865706, 27.68242892282675, 34.22160965266714, 97.1012712560622, 54.190577513529675, 94.06932344963491, 21.83900950879034, 5.440255971112203, 74.6366699051838, 53.823258158818106, 6.993579537309667, 24.17791550216845, 19.831690166795173, 25.059897090959105, 65.51536550395079, 41.21685670056854, 26.12086550646299, 6.2029555723050755, 57.71151831442883, 9.557637723610586, 10.176154712337787, 7.378559616928279, 47.340819340968565, 20.659095450347913, 87.3452893636532, 37.744893233747305, 71.37341390566931, 61.03220592642987, 5.650157291465318, 16.783518808943796, 41.49939707452832, 18.107979478769696, 31.566702861606053, 51.831685298786496, 11.105653571992095, 16.480979819465386, 106.36380554551644, 92.03139316985569, 5.22282595856162, 50.28209518509887, 112.9891313596412, 16.5425186487527, 9.44134924084085, 40.9229380866676, 7.62824191022587, 36.07370060726079, 103.75476742183423, 9.023889954923698, 81.68835466032057, 46.317022279308006, 23.37472771106987, 11.620991596136102, 23.705348493076603, 9.4194769392854, 5.212307473638161, 37.58447711719804, 6.564470073303093, 12.073473545660798, 85.05409647747501, 70.6457906252777, 18.481144068398777, 5.144836221875527, 26.635763705636215, 15.189775822332447, 20.311129737385386, 6.884709212358896, 15.462662810511068, 5.273171465265256, 36.99460684814983, 9.225479375162315, 97.58120961834773, 74.64146214627533, 62.9216768679842, 73.97638888040606, 24.512535514609446, 13.42149567950129, 14.43543201666305, 18.0898701142303, 81.32192807772648, 40.18556961256605, 20.213212765043266, 6.048760180904985, 51.75559246572299, 22.103811610613402, 7.652615916502223, 10.165404411172418, 16.691208683180204, 13.499563973489014, 78.46713940230583, 15.84945345075796, 32.612155414071026, 13.796849868860154, 12.197001590833171, 74.5738962836656, 92.21889776510615, 23.620098724147702, 9.854609109181919, 13.841125411801501, 8.584205010599005, 33.606328490343216, 14.985941364982542, 14.662606528916054, 8.092822576129462, 20.330770647303204, 16.215669038007682, 13.400417374758405, 32.83691221998936, 39.444884393993384, 123.71450876687958, 19.030657927369262, 13.18920856935968, 79.37229663530375, 6.394592903194093, 15.619389277400082, 29.269903427994162, 122.59147714990883, 54.92030127186041, 9.3773973705904, 43.5022531776178, 10.80378023640395, 9.043463054285333, 15.072993892271759, 5.393938376602311, 9.366759920788168, 8.037717556656249, 34.2021513440949, 77.33096147835442, 20.126958503194604, 32.1148706470171, 32.004957759128494, 6.684406942469101, 46.77904828317542, 20.869912472728625, 9.934595833060714])
caption, T_hit,count = hits_in_time_hist_new(T_pom, dt, t_plasma_start, t_plasma_end, is_plasma, figure_count_in_time_hist)
hist_file(count_in_time_hist, T_hit, count, caption);
([5916420.3125, 7211512.5, 7211557.8125, 7852950.0, 7912729.6875, 8493917.1875, 8897857.8125, 8897898.4375, 8931248.4375, 8947617.1875, 8956618.75, 8956751.5625, 9076801.5625, 9076864.0625, 9108768.75, 9111825.0, 9112765.625, 9115084.375, 9121910.9375, 9126657.8125, 9130817.1875, 9130903.125, 9132096.875, 9135435.9375, 9135445.3125, 9135457.8125, 9137775.0, 9137842.1875, 9138121.875, 9138328.125, 9138828.125, 9138881.25, 9139506.25, 9139506.25, 9139531.25, 9140165.625, 9140684.375, 9141164.0625, 9141579.6875, 9152759.375, 9156903.125, 9171971.875, 9181237.5, 9188664.0625, 9188729.6875, 9189796.875, 9193229.6875, 9195962.5, 9196754.6875, 9203617.1875, 9223992.1875, 9224853.125, 9254518.75, 9256398.4375, 9256773.4375, 9256901.5625, 9257478.125, 9257484.375, 9257856.25, 9257954.6875, 9258254.6875, 9258304.6875, 9258439.0625, 9258659.375, 9259189.0625, 9259673.4375, 9260335.9375, 9262409.375, 9262420.3125, 9262785.9375, 9266745.3125, 9266853.125, 9269579.6875, 9269587.5, 9269629.6875, 9272309.375, 9273390.625, 9277821.875, 9278921.875, 9294943.75, 9300712.5, 9301817.1875, 9301984.375, 9302690.625, 9303115.625, 9304429.6875, 9323639.0625, 9327520.3125, 9328215.625, 9334356.25, 9339328.125, 9341629.6875, 9345848.4375, 9347776.5625, 9377117.1875, 9377123.4375, 9381801.5625, 9389864.0625, 9393576.5625, 9395740.625, 9399140.625, 9400823.4375, 9403803.125, 9406407.8125, 9406426.5625, 9406948.4375, 9411760.9375, 9447414.0625, 9449421.875, 9453957.8125, 9454017.1875, 9454379.6875, 9458596.875, 9463100.0, 9466618.75, 9508065.625, 9508689.0625, 9513689.0625, 9524193.75, 9527251.5625, 9528693.75, 9530932.8125, 9531221.875, 9532271.875, 9532956.25, 9534101.5625, 9535051.5625, 9537131.25, 9537503.125, 9538368.75, 9540053.125, 9544410.9375, 9554393.75, 9557362.5, 9558418.75, 9559414.0625, 9560429.6875, 9560735.9375, 9561923.4375, 9562301.5625, 9564182.8125, 9583131.25, 9587050.0, 9588970.3125, 9589250.0, 9590829.6875, 9594187.5, 9594209.375, 9594267.1875, 9594276.5625, 9594978.125, 9608404.6875, 9639428.125, 9639634.375, 9640140.625, 9641395.3125, 9646439.0625, 9655867.1875, 9668023.4375, 9674087.5, 9678103.125, 9728600.0, 9755431.25, 9758751.5625, 9802314.0625, 9804106.25, 9804293.75, 9804989.0625, 9805073.4375, 9805250.0, 9806179.6875, 9806746.875, 9806934.375, 9808214.0625, 9812307.8125, 9815065.625, 9823315.625, 9825228.125, 9825509.375, 9826603.125, 9826898.4375, 9828164.0625, 9829757.8125, 9830375.0, 9835165.625, 9896264.0625, 9908989.0625, 9912737.5, 9948298.4375, 9948768.75, 9949609.375, 9949900.0, 9951996.875, 9975998.4375, 9991450.0, 10016520.3125, 10074290.625, 10097850.0, 10145598.4375, 10181940.625, 10182439.0625, 10204826.5625, 10215110.9375, 10238659.375, 10247553.125, 10249906.25, 10329289.0625, 10332453.125, 10360801.5625, 10364296.875, 10366056.25, 10402096.875, 10405603.125, 10409975.0, 10410035.9375, 10422965.625, 10439060.9375, 10445087.5, 10461562.5, 10467334.375, 10469407.8125, 10475340.625, 10481673.4375, 10482057.8125, 10529612.5, 10562381.25, 10562706.25, 10563117.1875, 10572110.9375, 10613946.875, 11127910.9375, 11133442.1875, 11137665.625, 11142325.0, 11143101.5625, 11143262.5, 11144562.5, 11147409.375, 11147929.6875, 11149539.0625, 11150985.9375, 11152171.875, 11153251.5625, 11157546.875, 11158820.3125, 11160123.4375, 11161229.6875, 11162084.375, 11162228.125, 11162360.9375, 11162456.25, 11162473.4375, 11162478.125, 11162509.375, 11162546.875, 11162689.0625, 11162690.625, 11162710.9375, 11162765.625, 11162984.375, 11163028.125, 11163081.25, 11163129.6875, 11163296.875, 11163387.5, 11163440.625, 11163756.25, 11163992.1875, 11164017.1875, 11164153.125, 11164360.9375, 11164389.0625, 11164540.625, 11164625.0, 11164631.25, 11164778.125, 11164989.0625, 11165032.8125, 11165073.4375, 11165429.6875, 11165731.25, 11166115.625, 11166181.25, 11166193.75, 11166254.6875, 11166956.25, 11167268.75, 11167854.6875, 11168285.9375, 11170101.5625, 11170115.625, 11170375.0, 11170814.0625, 11171246.875, 11171509.375, 11171887.5, 11172751.5625, 11172792.1875, 11173067.1875, 11173075.0, 11173650.0, 11174520.3125, 11174523.4375, 11174934.375, 11175323.4375, 11175360.9375, 11175431.25, 11175643.75, 11175715.625, 11176443.75, 11176539.0625, 11177365.625, 11177960.9375, 11178128.125, 11178168.75, 11178173.4375, 11178496.875, 11178737.5, 11178760.9375, 11178848.4375, 11179048.4375, 11179189.0625, 11179407.8125, 11180792.1875, 11180940.625, 11181250.0, 11181262.5, 11181851.5625, 11182512.5, 11182512.5, 11182609.375, 11183489.0625, 11183787.5, 11183909.375, 11185468.75, 11186031.25, 11186496.875, 11187256.25, 11187257.8125, 11187264.0625, 11187353.125, 11188239.0625, 11190325.0, 11190543.75, 11190589.0625, 11190826.5625, 11192706.25, 11194556.25, 11194896.875, 11197553.125, 11197931.25, 11199409.375, 11202331.25, 11204007.8125, 11204120.3125, 11206721.875, 11207037.5], [18.679893899764718, 43.845252347569854, 13.433411084520493, 15.782810792556935, 14.207119332236875, 49.69462946364623, 12.360511228680227, 11.26307150392768, 8.807992515129264, 24.88312596360584, 16.969443168055598, 39.095725198358416, 13.872146832901132, 6.24950116079917, 12.187320498941151, 33.14288082822723, 54.67564864386779, 26.97331493376732, 6.678251576369009, 6.716645169378606, 64.19051946541173, 31.237328780379777, 46.21740716308604, 30.81105060330966, 47.35073148174725, 10.584928092430657, 8.54371981833221, 19.719572487368367, 92.17309300154486, 155.56847130702766, 44.54591789587778, 5.180248619442479, 15.753293367263238, 27.286859654671638, 51.496089177286734, 6.892141496079307, 24.855225473967543, 29.330724331428623, 9.523249960787254, 128.88993579412545, 52.94323643254676, 31.37189308068486, 18.534057752558624, 144.87149762919404, 16.840992008286676, 26.38672352383917, 37.99346202521522, 132.8391161866309, 34.553514871654215, 28.55620096603153, 18.3390625196466, 12.166799311176979, 14.783974254418354, 84.39205137305363, 15.572849507411762, 41.68893452855643, 17.521888636418378, 7.984308146980803, 28.98518235034306, 41.09886297082661, 38.40429914230702, 19.290165522089474, 99.21203935021651, 9.007882743290542, 6.6516640290393925, 88.90678093317109, 66.89156484768192, 22.849263621841033, 7.550297184201069, 12.8082153045777, 39.819658321095474, 5.276805663943318, 69.4625468236896, 25.139230305886464, 13.152074069704632, 6.046089639238439, 82.43422321057423, 6.879267303401667, 12.940267337534415, 45.595075075339466, 101.27458911056813, 80.01304135723427, 60.0311418940106, 85.88721246184971, 12.346372551622261, 80.88778391372375, 14.344001538713874, 13.0747761740264, 36.400136607890666, 153.18540895333203, 10.966589161235659, 18.68666919009698, 63.255953972076064, 25.04464236675414, 63.3831899985029, 49.14667654481673, 30.88218128099382, 23.592877763750334, 68.30071407673925, 11.630031322754377, 18.363014400615306, 64.74678744659735, 73.29738617157395, 26.17360349541964, 23.26587141475089, 82.30521953948397, 23.294300910531845, 14.647423248874684, 43.401357617754826, 53.70751451332246, 80.37449719929877, 11.996217980037825, 49.62613493867917, 59.771921849494525, 18.96070306265655, 51.96842193863016, 6.686258987343324, 73.21664031286718, 20.39615840293744, 150.2862500252548, 8.514554589922687, 74.58250897110659, 10.7054329403293, 80.0306532693598, 39.59601052033948, 29.161461052057625, 19.31418433858314, 24.663533171698482, 93.30485457152871, 109.98244723546648, 32.24953662408639, 13.913181135802546, 33.11781450235349, 82.7852049558468, 67.93862384460799, 16.033031501376495, 65.82494495454877, 31.45516222331424, 9.332973339508001, 33.098402646035716, 44.66854834359262, 122.3903310831005, 69.74528894713752, 6.60534335818413, 7.4854038440978465, 61.35044798824343, 40.193245603246794, 6.7881517281072155, 33.76084027058198, 5.07084165053347, 43.427595690429726, 8.188417251210087, 14.732570308727217, 29.33263641473227, 8.962291656926954, 117.0675874448622, 158.03156177503917, 38.012059433221715, 12.712149758182084, 10.663869506914365, 24.363550868144007, 26.59684942727088, 21.667445511599293, 38.174293193866305, 12.951029870567679, 24.84054459414038, 351.1631980704507, 7.140652568364349, 46.2481643748188, 8.616237633491552, 125.0289969989907, 62.903581194307456, 37.45302532944274, 95.34576859150326, 6.644437382392122, 14.921973934833021, 9.149463967276597, 60.89691036147398, 20.210420135436998, 15.190501749731881, 18.875325215921627, 17.672058264590827, 6.246342747204335, 31.783207881688153, 87.31614695827103, 25.871690435990267, 46.386913480638896, 6.824469256581657, 88.87602075649991, 14.125494506336114, 15.080515076957301, 67.11912167125908, 50.46788159731711, 29.361145328817084, 18.3266075956138, 35.915642989945844, 59.96849533577167, 19.26562697557611, 45.104179460766204, 33.52003535000775, 31.18831147954725, 110.69778881940147, 78.51031733214636, 24.063630917523895, 32.24198489912487, 62.1769774355189, 38.086315308454274, 15.720086005778665, 46.478317260501186, 18.504098267229196, 6.176436243934203, 19.177674364938554, 13.081241327356686, 46.57689301670887, 6.8770306640775285, 24.18491856021853, 6.271475042557742, 67.26451963913706, 170.20288116583197, 74.00109032805632, 5.475626818179884, 47.80391857974736, 15.168792272505637, 84.47037019865706, 27.68242892282675, 34.22160965266714, 97.1012712560622, 54.190577513529675, 94.06932344963491, 21.83900950879034, 5.440255971112203, 74.6366699051838, 53.823258158818106, 6.993579537309667, 24.17791550216845, 19.831690166795173, 25.059897090959105, 65.51536550395079, 41.21685670056854, 26.12086550646299, 6.2029555723050755, 57.71151831442883, 9.557637723610586, 10.176154712337787, 7.378559616928279, 47.340819340968565, 20.659095450347913, 87.3452893636532, 37.744893233747305, 71.37341390566931, 61.03220592642987, 5.650157291465318, 16.783518808943796, 41.49939707452832, 18.107979478769696, 31.566702861606053, 51.831685298786496, 11.105653571992095, 16.480979819465386, 106.36380554551644, 92.03139316985569, 5.22282595856162, 50.28209518509887, 112.9891313596412, 16.5425186487527, 9.44134924084085, 40.9229380866676, 7.62824191022587, 36.07370060726079, 103.75476742183423, 9.023889954923698, 81.68835466032057, 46.317022279308006, 23.37472771106987, 11.620991596136102, 23.705348493076603, 9.4194769392854, 5.212307473638161, 37.58447711719804, 6.564470073303093, 12.073473545660798, 85.05409647747501, 70.6457906252777, 18.481144068398777, 5.144836221875527, 26.635763705636215, 15.189775822332447, 20.311129737385386, 6.884709212358896, 15.462662810511068, 5.273171465265256, 36.99460684814983, 9.225479375162315, 97.58120961834773, 74.64146214627533, 62.9216768679842, 73.97638888040606, 24.512535514609446, 13.42149567950129, 14.43543201666305, 18.0898701142303, 81.32192807772648, 40.18556961256605, 20.213212765043266, 6.048760180904985, 51.75559246572299, 22.103811610613402, 7.652615916502223, 10.165404411172418, 16.691208683180204, 13.499563973489014, 78.46713940230583, 15.84945345075796, 32.612155414071026, 13.796849868860154, 12.197001590833171, 74.5738962836656, 92.21889776510615, 23.620098724147702, 9.854609109181919, 13.841125411801501, 8.584205010599005, 33.606328490343216, 14.985941364982542, 14.662606528916054, 8.092822576129462, 20.330770647303204, 16.215669038007682, 13.400417374758405, 32.83691221998936, 39.444884393993384, 123.71450876687958, 19.030657927369262, 13.18920856935968, 79.37229663530375, 6.394592903194093, 15.619389277400082, 29.269903427994162, 122.59147714990883, 54.92030127186041, 9.3773973705904, 43.5022531776178, 10.80378023640395, 9.043463054285333, 15.072993892271759, 5.393938376602311, 9.366759920788168, 8.037717556656249, 34.2021513440949, 77.33096147835442, 20.126958503194604, 32.1148706470171, 32.004957759128494, 6.684406942469101, 46.77904828317542, 20.869912472728625, 9.934595833060714])
Detected energies during the discharge + Energy spectrum
multiplot(icon_fig, T_int_first,E,xle,Etot)