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 = 43759
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);
([7225443.75, 7354645.3125, 10514565.625, 10787768.75, 10990529.6875, 11159607.8125, 11211409.375, 11219189.0625, 11242985.9375, 11243603.125, 11252700.0, 11252909.375, 11289917.1875, 11301923.4375, 11306578.125, 11307421.875, 11319865.625, 11328634.375, 11330175.0, 11347296.875, 11378798.4375, 11401648.4375, 11428209.375, 11428460.9375, 11434160.9375, 11440370.3125, 11449187.5, 11450198.4375, 11453242.1875, 11474362.5, 11481415.625, 11487462.5, 11487910.9375, 11491171.875, 11491179.6875, 11492176.5625, 11497810.9375, 11500917.1875, 11555445.3125, 11564701.5625, 11565406.25, 11571742.1875, 11594239.0625, 11626467.1875, 11626520.3125, 11626528.125, 11647329.6875, 11647887.5, 11662025.0, 11680039.0625, 11683778.125, 11685957.8125, 11686004.6875, 11686151.5625, 11688940.625, 11696146.875, 11696593.75, 11716671.875, 11741426.5625, 11743132.8125, 11764739.0625, 11768520.3125, 11811012.5, 11877521.875, 11889300.0, 13741643.75, 14475865.625, 15430646.875, 15450451.5625, 15464818.75, 15465517.1875, 15523879.6875, 15536487.5, 15574753.125, 15577204.6875, 15577776.5625, 15577926.5625, 15577928.125, 15578065.625, 15578265.625, 15578298.4375, 15578931.25, 15650187.5, 15650426.5625, 15650657.8125, 15653828.125, 15653854.6875, 15654003.125, 15654039.0625, 15654082.8125, 15662765.625, 15662921.875, 15739668.75, 15855590.625, 15855939.0625, 16602003.125, 16617189.0625, 16656007.8125, 16669871.875, 16696996.875, 16704307.8125, 16704381.25, 16704528.125, 16706070.3125, 16732946.875, 16733790.625, 16758123.4375, 16759157.8125, 16771092.1875, 16771248.4375, 16772340.625, 16774020.3125, 16777043.75, 16797664.0625, 16800943.75, 16801260.9375, 16803057.8125, 16804735.9375, 16809453.125, 16822273.4375, 16852095.3125, 16856051.5625, 16857525.0, 16857581.25, 16880298.4375, 16901653.125, 16905965.625, 16906082.8125, 16919718.75, 16919960.9375, 16958314.0625, 16961159.375, 16986717.1875, 17011410.9375, 17036101.5625, 17046004.6875, 17057162.5, 17057184.375, 17073004.6875, 17104281.25, 17123737.5, 17125314.0625, 17146392.1875, 17148978.125, 17162614.0625, 17174965.625, 17294473.4375, 17294504.6875, 17311446.875, 17311450.0, 17314771.875, 17330337.5, 17332275.0, 17341003.125, 17354029.6875, 17364704.6875, 17365881.25, 17367740.625, 17369884.375, 17372350.0, 17389909.375, 17390239.0625, 17390360.9375, 17391710.9375, 17395309.375, 17403098.4375, 17419001.5625, 17429431.25, 17433026.5625, 17441082.8125, 17442285.9375, 17445206.25, 17446965.625, 17446992.1875, 17448668.75, 17456740.625, 17463476.5625, 17474581.25, 17474595.3125, 17476100.0, 17476617.1875, 17477406.25, 17478351.5625, 17478376.5625, 17478537.5, 17491206.25, 17499129.6875, 17505228.125, 17514435.9375, 17521818.75, 17522020.3125, 17528167.1875, 17531487.5, 17544210.9375, 17544517.1875, 17549643.75, 17559670.3125, 17560989.0625, 17562814.0625, 17572890.625, 17577948.4375, 17583870.3125, 17592068.75, 17592226.5625, 17618668.75, 17625334.375, 17626126.5625, 17627743.75, 17629045.3125, 17630695.3125, 17630695.3125, 17631089.0625, 17631456.25, 17632106.25, 17635237.5, 17636970.3125, 17646996.875, 17647901.5625, 17649979.6875, 17650214.0625, 17654968.75, 17660828.125, 17661823.4375, 17662603.125, 17665201.5625, 17665807.8125, 17667721.875, 17668248.4375, 17668523.4375, 17670231.25, 17671562.5, 17672101.5625, 17675173.4375, 17675325.0, 17675343.75, 17676503.125, 17676565.625, 17678259.375, 17678651.5625, 17678673.4375, 17692223.4375, 17692651.5625, 17693693.75, 17693978.125, 17694081.25, 17694179.6875, 17696673.4375, 17697459.375, 17698065.625, 17698740.625, 17711353.125, 17711439.0625, 17711942.1875, 17711979.6875, 17712368.75, 17712731.25, 17715948.4375, 17715956.25, 17716092.1875, 17716314.0625, 17716873.4375, 17717282.8125, 17718034.375, 17721843.75, 17733181.25, 17735998.4375, 17753037.5, 17753040.625, 17756728.125, 17760331.25, 17763596.875, 17764334.375, 17764417.1875, 17764465.625, 17765896.875, 17767504.6875, 17779032.8125, 17779548.4375, 17780796.875, 17784296.875, 17784746.875, 17785115.625, 17808518.75, 17808910.9375, 17814068.75, 17815035.9375, 17821178.125, 17822156.25, 17825192.1875, 17825857.8125, 17833092.1875, 17833092.1875, 17837365.625, 17838134.375, 17838523.4375, 17840250.0, 17841250.0, 17841590.625, 17843956.25, 17844353.125, 17846937.5, 17847432.8125, 17850312.5, 17850401.5625, 17850764.0625, 17851245.3125, 17851256.25, 17856420.3125, 17875912.5, 17885846.875, 17900768.75, 17902137.5, 17903862.5, 17915753.125, 17927498.4375, 17936806.25, 17937996.875, 17959145.3125, 17961960.9375, 17972126.5625, 17981362.5, 18000140.625, 18011512.5, 18012732.8125, 18023521.875, 18026720.3125, 18026750.0, 18058478.125, 18089401.5625, 18089409.375, 18090498.4375, 18103040.625, 18133229.6875, 18137051.5625], [25.079943966168067, 45.41183659519032, 66.9952293558559, 5.045114151220352, 5.594322681872405, 29.21963093722133, 92.84263191135952, 33.150979885842695, 31.316672706847587, 76.40413306045201, 79.6216468846697, 7.617402423837163, 11.581218287979606, 75.95216140796349, 9.606111430744905, 75.933035659589, 9.30866373440196, 22.726559466059257, 6.842023450885433, 18.6484102830564, 169.94104655570317, 48.783379366370404, 62.28313290130766, 35.766974227667504, 6.760000763117745, 12.095097473201479, 28.823286205113448, 36.784687453117016, 17.781836694037032, 21.05906407900099, 30.12669602380893, 167.89937555537918, 9.730682070696755, 46.8448327775688, 9.448171928667064, 6.941710682632983, 58.511526376547444, 45.724835848104355, 159.82233274648186, 41.49307313427467, 22.832949033460775, 109.92353574169783, 62.54636380915415, 154.66686257555386, 5.39922190906667, 7.113481897556538, 55.56046006832516, 28.11184333499477, 154.8101963839144, 41.32835453861787, 9.71837027580552, 168.86035432211955, 33.14623708654832, 48.60430218583484, 46.43180165240389, 29.152839776889326, 158.94197207659593, 83.09622011735193, 13.445317652608207, 14.169265232536919, 13.974582500942585, 33.251332151002, 7.465639789237608, 19.282100209094303, 29.62040162268728, 45.19637238896805, 32.8098005016462, 10.98296072375742, 67.99771155657608, 50.1405020446506, 21.35927824474815, 56.98137975774323, 31.820409109788812, 15.601810760213548, 27.516314028452747, 63.43393723104188, 26.95034575191436, 5.471451907605757, 14.134005764773303, 5.321408345547334, 13.4948560977214, 75.75711525365473, 90.95076928144326, 23.469670052273507, 7.474086824169526, 15.753646028072456, 21.484738154981564, 49.37203087412799, 22.083266257529484, 7.608501275227704, 44.446530255176356, 75.71101775843441, 34.53628329441822, 79.92877882494045, 76.17898723012912, 6.902775955649058, 90.0149444903536, 16.743688774526056, 74.77243319326857, 42.75623580771344, 25.159612577373153, 57.14481385606953, 23.01163211662491, 25.889917837323658, 25.863402033789036, 56.34039701080896, 23.678182268649692, 13.51532726847177, 51.526420876029746, 17.01821695949446, 14.55331849518841, 17.528630346596614, 36.77314440983688, 29.88287648242592, 7.939830321785075, 63.108305748289474, 33.1209840620639, 72.55381366531772, 7.833452444204532, 38.336293387075344, 29.66173633037616, 87.30057287226363, 15.215071887528467, 6.29311536627628, 33.01214223228442, 47.56509100090303, 10.700484756416623, 69.30499915829299, 10.829805838202752, 14.087599193741056, 21.36709766794041, 14.136275744447861, 125.59815976201203, 46.2935966211555, 14.41212238679773, 12.961729148011878, 41.65400236673909, 13.126546693122478, 10.370314812160352, 65.21114687603543, 21.89453493632259, 114.89990270301335, 19.74959412364388, 72.71897918648529, 61.11213964632362, 129.58672193527846, 8.834849764201504, 8.76366431413893, 9.65713444545376, 50.167810603594404, 33.3023559909756, 6.281473071520781, 14.48667902409079, 15.538408653913171, 17.980850629647378, 74.12511576830804, 30.09553833353079, 51.48671072110193, 5.126768088949038, 27.232470882028302, 59.234598836290594, 14.326366376505726, 49.72700417876128, 28.676212710392463, 45.61977086831721, 19.84639040168051, 42.34026276401974, 76.72091292128766, 17.832351150377782, 26.958601700645097, 33.077474799782514, 60.76279307903262, 17.374706760835124, 26.372156348377054, 11.70097293696403, 82.64089154782509, 7.460000397614895, 25.173994645202217, 27.580794365177795, 17.58877966295711, 54.631510279726065, 35.64893178417083, 45.73814697301862, 25.388622169458067, 51.88268336667072, 79.92764863270033, 29.794879167148718, 6.030556018445816, 13.209485643949778, 86.24450228764667, 65.79063308297046, 74.98185376128217, 45.17491657016097, 10.822074676110855, 14.999944808673606, 81.73837906124821, 11.898230190291006, 31.57924437797535, 21.338905949655942, 18.654357491043967, 19.422518161286188, 5.872375813347534, 7.142008255406928, 34.17871592085354, 11.637363133478948, 35.475413122335596, 29.870561264552265, 25.287398993499664, 28.4939151876816, 49.28726090124877, 53.93370055950074, 52.64242993434023, 15.91073502186053, 15.364038204727631, 107.21088176784178, 44.093789900115524, 11.100561895317078, 38.39256577093843, 21.352756062391038, 68.73728075207205, 64.0452581983334, 17.172399958854538, 27.215063077028624, 8.253788741561388, 7.807790415142733, 52.270646072358325, 77.4563967788716, 141.7079964493904, 45.21544222148737, 17.418192439082638, 43.14669017677113, 12.246844166846483, 39.08113273175127, 56.03204261857214, 31.92157445627113, 20.95460912800877, 5.125528081662552, 12.832789238426574, 23.672019165359632, 23.76396390152281, 22.9092113843158, 7.898689771156603, 15.655827335304943, 24.442316716468817, 69.67086906132516, 75.49662935194831, 25.014094974024996, 98.68850259146217, 41.76442501197293, 57.929788036995134, 44.684066262077764, 123.59662980337554, 41.32287631638138, 20.967762575592726, 31.698884837054003, 7.046012238362297, 16.823482741571663, 46.47031561298104, 7.6704505666637415, 25.50326949170275, 5.126123664149022, 81.08966493512207, 6.219430617740789, 10.00280230075435, 9.133042890672474, 30.52615387667582, 45.61581410733059, 23.31761496370503, 43.085776546834005, 94.07159010681644, 47.49674152632322, 210.9899952404224, 23.089566247525923, 6.785291926333651, 5.446414477029895, 43.02352413562995, 48.90163042594896, 217.13335414425862, 25.171505956165745, 53.31468642136404, 166.36741054745337, 50.72769360399015, 102.6631198562372, 12.175662677974463, 15.934374554860229, 18.414278465151344, 35.637636946027136, 38.30722078563419, 45.88882722871288, 14.264794960592804, 39.72815525219561, 32.23190986293017, 60.03813479925928, 56.74466077416559, 17.185327780457342, 19.3774641983977, 13.3212185017689, 29.580660603577627, 10.329646214463034, 32.80486775279164, 38.72374607361646, 38.90003297549953, 5.892541771389151, 44.13478529012673, 37.666755647416366, 7.177070146147919, 9.950382672353495, 19.09159261216078, 6.084218838871262, 53.64259333299908, 16.825461751219393, 10.779105732964252, 22.702440305255696, 27.149099495384604, 60.69075705262121, 30.17433702088182, 6.845555371723892, 80.09270323321775, 6.181883215240838, 25.71283044275267, 9.668612197010784, 6.263275471265735, 46.22381050833563, 17.571122775418004, 6.220411784929484, 12.178096099962795, 7.887338711937837, 10.642682337427784, 20.9157424507976, 23.178049977688943, 24.703066339825533, 6.524545902754518, 39.26541558857626, 16.879752090780645])
caption, xmean,count, xle, Etot = energy_spectrum(E_tot)
hist_file(E_hist, xmean, count, caption);
([7225443.75, 7354645.3125, 10514565.625, 10787768.75, 10990529.6875, 11159607.8125, 11211409.375, 11219189.0625, 11242985.9375, 11243603.125, 11252700.0, 11252909.375, 11289917.1875, 11301923.4375, 11306578.125, 11307421.875, 11319865.625, 11328634.375, 11330175.0, 11347296.875, 11378798.4375, 11401648.4375, 11428209.375, 11428460.9375, 11434160.9375, 11440370.3125, 11449187.5, 11450198.4375, 11453242.1875, 11474362.5, 11481415.625, 11487462.5, 11487910.9375, 11491171.875, 11491179.6875, 11492176.5625, 11497810.9375, 11500917.1875, 11555445.3125, 11564701.5625, 11565406.25, 11571742.1875, 11594239.0625, 11626467.1875, 11626520.3125, 11626528.125, 11647329.6875, 11647887.5, 11662025.0, 11680039.0625, 11683778.125, 11685957.8125, 11686004.6875, 11686151.5625, 11688940.625, 11696146.875, 11696593.75, 11716671.875, 11741426.5625, 11743132.8125, 11764739.0625, 11768520.3125, 11811012.5, 11877521.875, 11889300.0, 13741643.75, 14475865.625, 15430646.875, 15450451.5625, 15464818.75, 15465517.1875, 15523879.6875, 15536487.5, 15574753.125, 15577204.6875, 15577776.5625, 15577926.5625, 15577928.125, 15578065.625, 15578265.625, 15578298.4375, 15578931.25, 15650187.5, 15650426.5625, 15650657.8125, 15653828.125, 15653854.6875, 15654003.125, 15654039.0625, 15654082.8125, 15662765.625, 15662921.875, 15739668.75, 15855590.625, 15855939.0625, 16602003.125, 16617189.0625, 16656007.8125, 16669871.875, 16696996.875, 16704307.8125, 16704381.25, 16704528.125, 16706070.3125, 16732946.875, 16733790.625, 16758123.4375, 16759157.8125, 16771092.1875, 16771248.4375, 16772340.625, 16774020.3125, 16777043.75, 16797664.0625, 16800943.75, 16801260.9375, 16803057.8125, 16804735.9375, 16809453.125, 16822273.4375, 16852095.3125, 16856051.5625, 16857525.0, 16857581.25, 16880298.4375, 16901653.125, 16905965.625, 16906082.8125, 16919718.75, 16919960.9375, 16958314.0625, 16961159.375, 16986717.1875, 17011410.9375, 17036101.5625, 17046004.6875, 17057162.5, 17057184.375, 17073004.6875, 17104281.25, 17123737.5, 17125314.0625, 17146392.1875, 17148978.125, 17162614.0625, 17174965.625, 17294473.4375, 17294504.6875, 17311446.875, 17311450.0, 17314771.875, 17330337.5, 17332275.0, 17341003.125, 17354029.6875, 17364704.6875, 17365881.25, 17367740.625, 17369884.375, 17372350.0, 17389909.375, 17390239.0625, 17390360.9375, 17391710.9375, 17395309.375, 17403098.4375, 17419001.5625, 17429431.25, 17433026.5625, 17441082.8125, 17442285.9375, 17445206.25, 17446965.625, 17446992.1875, 17448668.75, 17456740.625, 17463476.5625, 17474581.25, 17474595.3125, 17476100.0, 17476617.1875, 17477406.25, 17478351.5625, 17478376.5625, 17478537.5, 17491206.25, 17499129.6875, 17505228.125, 17514435.9375, 17521818.75, 17522020.3125, 17528167.1875, 17531487.5, 17544210.9375, 17544517.1875, 17549643.75, 17559670.3125, 17560989.0625, 17562814.0625, 17572890.625, 17577948.4375, 17583870.3125, 17592068.75, 17592226.5625, 17618668.75, 17625334.375, 17626126.5625, 17627743.75, 17629045.3125, 17630695.3125, 17630695.3125, 17631089.0625, 17631456.25, 17632106.25, 17635237.5, 17636970.3125, 17646996.875, 17647901.5625, 17649979.6875, 17650214.0625, 17654968.75, 17660828.125, 17661823.4375, 17662603.125, 17665201.5625, 17665807.8125, 17667721.875, 17668248.4375, 17668523.4375, 17670231.25, 17671562.5, 17672101.5625, 17675173.4375, 17675325.0, 17675343.75, 17676503.125, 17676565.625, 17678259.375, 17678651.5625, 17678673.4375, 17692223.4375, 17692651.5625, 17693693.75, 17693978.125, 17694081.25, 17694179.6875, 17696673.4375, 17697459.375, 17698065.625, 17698740.625, 17711353.125, 17711439.0625, 17711942.1875, 17711979.6875, 17712368.75, 17712731.25, 17715948.4375, 17715956.25, 17716092.1875, 17716314.0625, 17716873.4375, 17717282.8125, 17718034.375, 17721843.75, 17733181.25, 17735998.4375, 17753037.5, 17753040.625, 17756728.125, 17760331.25, 17763596.875, 17764334.375, 17764417.1875, 17764465.625, 17765896.875, 17767504.6875, 17779032.8125, 17779548.4375, 17780796.875, 17784296.875, 17784746.875, 17785115.625, 17808518.75, 17808910.9375, 17814068.75, 17815035.9375, 17821178.125, 17822156.25, 17825192.1875, 17825857.8125, 17833092.1875, 17833092.1875, 17837365.625, 17838134.375, 17838523.4375, 17840250.0, 17841250.0, 17841590.625, 17843956.25, 17844353.125, 17846937.5, 17847432.8125, 17850312.5, 17850401.5625, 17850764.0625, 17851245.3125, 17851256.25, 17856420.3125, 17875912.5, 17885846.875, 17900768.75, 17902137.5, 17903862.5, 17915753.125, 17927498.4375, 17936806.25, 17937996.875, 17959145.3125, 17961960.9375, 17972126.5625, 17981362.5, 18000140.625, 18011512.5, 18012732.8125, 18023521.875, 18026720.3125, 18026750.0, 18058478.125, 18089401.5625, 18089409.375, 18090498.4375, 18103040.625, 18133229.6875, 18137051.5625], [25.079943966168067, 45.41183659519032, 66.9952293558559, 5.045114151220352, 5.594322681872405, 29.21963093722133, 92.84263191135952, 33.150979885842695, 31.316672706847587, 76.40413306045201, 79.6216468846697, 7.617402423837163, 11.581218287979606, 75.95216140796349, 9.606111430744905, 75.933035659589, 9.30866373440196, 22.726559466059257, 6.842023450885433, 18.6484102830564, 169.94104655570317, 48.783379366370404, 62.28313290130766, 35.766974227667504, 6.760000763117745, 12.095097473201479, 28.823286205113448, 36.784687453117016, 17.781836694037032, 21.05906407900099, 30.12669602380893, 167.89937555537918, 9.730682070696755, 46.8448327775688, 9.448171928667064, 6.941710682632983, 58.511526376547444, 45.724835848104355, 159.82233274648186, 41.49307313427467, 22.832949033460775, 109.92353574169783, 62.54636380915415, 154.66686257555386, 5.39922190906667, 7.113481897556538, 55.56046006832516, 28.11184333499477, 154.8101963839144, 41.32835453861787, 9.71837027580552, 168.86035432211955, 33.14623708654832, 48.60430218583484, 46.43180165240389, 29.152839776889326, 158.94197207659593, 83.09622011735193, 13.445317652608207, 14.169265232536919, 13.974582500942585, 33.251332151002, 7.465639789237608, 19.282100209094303, 29.62040162268728, 45.19637238896805, 32.8098005016462, 10.98296072375742, 67.99771155657608, 50.1405020446506, 21.35927824474815, 56.98137975774323, 31.820409109788812, 15.601810760213548, 27.516314028452747, 63.43393723104188, 26.95034575191436, 5.471451907605757, 14.134005764773303, 5.321408345547334, 13.4948560977214, 75.75711525365473, 90.95076928144326, 23.469670052273507, 7.474086824169526, 15.753646028072456, 21.484738154981564, 49.37203087412799, 22.083266257529484, 7.608501275227704, 44.446530255176356, 75.71101775843441, 34.53628329441822, 79.92877882494045, 76.17898723012912, 6.902775955649058, 90.0149444903536, 16.743688774526056, 74.77243319326857, 42.75623580771344, 25.159612577373153, 57.14481385606953, 23.01163211662491, 25.889917837323658, 25.863402033789036, 56.34039701080896, 23.678182268649692, 13.51532726847177, 51.526420876029746, 17.01821695949446, 14.55331849518841, 17.528630346596614, 36.77314440983688, 29.88287648242592, 7.939830321785075, 63.108305748289474, 33.1209840620639, 72.55381366531772, 7.833452444204532, 38.336293387075344, 29.66173633037616, 87.30057287226363, 15.215071887528467, 6.29311536627628, 33.01214223228442, 47.56509100090303, 10.700484756416623, 69.30499915829299, 10.829805838202752, 14.087599193741056, 21.36709766794041, 14.136275744447861, 125.59815976201203, 46.2935966211555, 14.41212238679773, 12.961729148011878, 41.65400236673909, 13.126546693122478, 10.370314812160352, 65.21114687603543, 21.89453493632259, 114.89990270301335, 19.74959412364388, 72.71897918648529, 61.11213964632362, 129.58672193527846, 8.834849764201504, 8.76366431413893, 9.65713444545376, 50.167810603594404, 33.3023559909756, 6.281473071520781, 14.48667902409079, 15.538408653913171, 17.980850629647378, 74.12511576830804, 30.09553833353079, 51.48671072110193, 5.126768088949038, 27.232470882028302, 59.234598836290594, 14.326366376505726, 49.72700417876128, 28.676212710392463, 45.61977086831721, 19.84639040168051, 42.34026276401974, 76.72091292128766, 17.832351150377782, 26.958601700645097, 33.077474799782514, 60.76279307903262, 17.374706760835124, 26.372156348377054, 11.70097293696403, 82.64089154782509, 7.460000397614895, 25.173994645202217, 27.580794365177795, 17.58877966295711, 54.631510279726065, 35.64893178417083, 45.73814697301862, 25.388622169458067, 51.88268336667072, 79.92764863270033, 29.794879167148718, 6.030556018445816, 13.209485643949778, 86.24450228764667, 65.79063308297046, 74.98185376128217, 45.17491657016097, 10.822074676110855, 14.999944808673606, 81.73837906124821, 11.898230190291006, 31.57924437797535, 21.338905949655942, 18.654357491043967, 19.422518161286188, 5.872375813347534, 7.142008255406928, 34.17871592085354, 11.637363133478948, 35.475413122335596, 29.870561264552265, 25.287398993499664, 28.4939151876816, 49.28726090124877, 53.93370055950074, 52.64242993434023, 15.91073502186053, 15.364038204727631, 107.21088176784178, 44.093789900115524, 11.100561895317078, 38.39256577093843, 21.352756062391038, 68.73728075207205, 64.0452581983334, 17.172399958854538, 27.215063077028624, 8.253788741561388, 7.807790415142733, 52.270646072358325, 77.4563967788716, 141.7079964493904, 45.21544222148737, 17.418192439082638, 43.14669017677113, 12.246844166846483, 39.08113273175127, 56.03204261857214, 31.92157445627113, 20.95460912800877, 5.125528081662552, 12.832789238426574, 23.672019165359632, 23.76396390152281, 22.9092113843158, 7.898689771156603, 15.655827335304943, 24.442316716468817, 69.67086906132516, 75.49662935194831, 25.014094974024996, 98.68850259146217, 41.76442501197293, 57.929788036995134, 44.684066262077764, 123.59662980337554, 41.32287631638138, 20.967762575592726, 31.698884837054003, 7.046012238362297, 16.823482741571663, 46.47031561298104, 7.6704505666637415, 25.50326949170275, 5.126123664149022, 81.08966493512207, 6.219430617740789, 10.00280230075435, 9.133042890672474, 30.52615387667582, 45.61581410733059, 23.31761496370503, 43.085776546834005, 94.07159010681644, 47.49674152632322, 210.9899952404224, 23.089566247525923, 6.785291926333651, 5.446414477029895, 43.02352413562995, 48.90163042594896, 217.13335414425862, 25.171505956165745, 53.31468642136404, 166.36741054745337, 50.72769360399015, 102.6631198562372, 12.175662677974463, 15.934374554860229, 18.414278465151344, 35.637636946027136, 38.30722078563419, 45.88882722871288, 14.264794960592804, 39.72815525219561, 32.23190986293017, 60.03813479925928, 56.74466077416559, 17.185327780457342, 19.3774641983977, 13.3212185017689, 29.580660603577627, 10.329646214463034, 32.80486775279164, 38.72374607361646, 38.90003297549953, 5.892541771389151, 44.13478529012673, 37.666755647416366, 7.177070146147919, 9.950382672353495, 19.09159261216078, 6.084218838871262, 53.64259333299908, 16.825461751219393, 10.779105732964252, 22.702440305255696, 27.149099495384604, 60.69075705262121, 30.17433702088182, 6.845555371723892, 80.09270323321775, 6.181883215240838, 25.71283044275267, 9.668612197010784, 6.263275471265735, 46.22381050833563, 17.571122775418004, 6.220411784929484, 12.178096099962795, 7.887338711937837, 10.642682337427784, 20.9157424507976, 23.178049977688943, 24.703066339825533, 6.524545902754518, 39.26541558857626, 16.879752090780645])
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);
([7225443.75, 7354645.3125, 10514565.625, 10787768.75, 10990529.6875, 11159607.8125, 11211409.375, 11219189.0625, 11242985.9375, 11243603.125, 11252700.0, 11252909.375, 11289917.1875, 11301923.4375, 11306578.125, 11307421.875, 11319865.625, 11328634.375, 11330175.0, 11347296.875, 11378798.4375, 11401648.4375, 11428209.375, 11428460.9375, 11434160.9375, 11440370.3125, 11449187.5, 11450198.4375, 11453242.1875, 11474362.5, 11481415.625, 11487462.5, 11487910.9375, 11491171.875, 11491179.6875, 11492176.5625, 11497810.9375, 11500917.1875, 11555445.3125, 11564701.5625, 11565406.25, 11571742.1875, 11594239.0625, 11626467.1875, 11626520.3125, 11626528.125, 11647329.6875, 11647887.5, 11662025.0, 11680039.0625, 11683778.125, 11685957.8125, 11686004.6875, 11686151.5625, 11688940.625, 11696146.875, 11696593.75, 11716671.875, 11741426.5625, 11743132.8125, 11764739.0625, 11768520.3125, 11811012.5, 11877521.875, 11889300.0, 13741643.75, 14475865.625, 15430646.875, 15450451.5625, 15464818.75, 15465517.1875, 15523879.6875, 15536487.5, 15574753.125, 15577204.6875, 15577776.5625, 15577926.5625, 15577928.125, 15578065.625, 15578265.625, 15578298.4375, 15578931.25, 15650187.5, 15650426.5625, 15650657.8125, 15653828.125, 15653854.6875, 15654003.125, 15654039.0625, 15654082.8125, 15662765.625, 15662921.875, 15739668.75, 15855590.625, 15855939.0625, 16602003.125, 16617189.0625, 16656007.8125, 16669871.875, 16696996.875, 16704307.8125, 16704381.25, 16704528.125, 16706070.3125, 16732946.875, 16733790.625, 16758123.4375, 16759157.8125, 16771092.1875, 16771248.4375, 16772340.625, 16774020.3125, 16777043.75, 16797664.0625, 16800943.75, 16801260.9375, 16803057.8125, 16804735.9375, 16809453.125, 16822273.4375, 16852095.3125, 16856051.5625, 16857525.0, 16857581.25, 16880298.4375, 16901653.125, 16905965.625, 16906082.8125, 16919718.75, 16919960.9375, 16958314.0625, 16961159.375, 16986717.1875, 17011410.9375, 17036101.5625, 17046004.6875, 17057162.5, 17057184.375, 17073004.6875, 17104281.25, 17123737.5, 17125314.0625, 17146392.1875, 17148978.125, 17162614.0625, 17174965.625, 17294473.4375, 17294504.6875, 17311446.875, 17311450.0, 17314771.875, 17330337.5, 17332275.0, 17341003.125, 17354029.6875, 17364704.6875, 17365881.25, 17367740.625, 17369884.375, 17372350.0, 17389909.375, 17390239.0625, 17390360.9375, 17391710.9375, 17395309.375, 17403098.4375, 17419001.5625, 17429431.25, 17433026.5625, 17441082.8125, 17442285.9375, 17445206.25, 17446965.625, 17446992.1875, 17448668.75, 17456740.625, 17463476.5625, 17474581.25, 17474595.3125, 17476100.0, 17476617.1875, 17477406.25, 17478351.5625, 17478376.5625, 17478537.5, 17491206.25, 17499129.6875, 17505228.125, 17514435.9375, 17521818.75, 17522020.3125, 17528167.1875, 17531487.5, 17544210.9375, 17544517.1875, 17549643.75, 17559670.3125, 17560989.0625, 17562814.0625, 17572890.625, 17577948.4375, 17583870.3125, 17592068.75, 17592226.5625, 17618668.75, 17625334.375, 17626126.5625, 17627743.75, 17629045.3125, 17630695.3125, 17630695.3125, 17631089.0625, 17631456.25, 17632106.25, 17635237.5, 17636970.3125, 17646996.875, 17647901.5625, 17649979.6875, 17650214.0625, 17654968.75, 17660828.125, 17661823.4375, 17662603.125, 17665201.5625, 17665807.8125, 17667721.875, 17668248.4375, 17668523.4375, 17670231.25, 17671562.5, 17672101.5625, 17675173.4375, 17675325.0, 17675343.75, 17676503.125, 17676565.625, 17678259.375, 17678651.5625, 17678673.4375, 17692223.4375, 17692651.5625, 17693693.75, 17693978.125, 17694081.25, 17694179.6875, 17696673.4375, 17697459.375, 17698065.625, 17698740.625, 17711353.125, 17711439.0625, 17711942.1875, 17711979.6875, 17712368.75, 17712731.25, 17715948.4375, 17715956.25, 17716092.1875, 17716314.0625, 17716873.4375, 17717282.8125, 17718034.375, 17721843.75, 17733181.25, 17735998.4375, 17753037.5, 17753040.625, 17756728.125, 17760331.25, 17763596.875, 17764334.375, 17764417.1875, 17764465.625, 17765896.875, 17767504.6875, 17779032.8125, 17779548.4375, 17780796.875, 17784296.875, 17784746.875, 17785115.625, 17808518.75, 17808910.9375, 17814068.75, 17815035.9375, 17821178.125, 17822156.25, 17825192.1875, 17825857.8125, 17833092.1875, 17833092.1875, 17837365.625, 17838134.375, 17838523.4375, 17840250.0, 17841250.0, 17841590.625, 17843956.25, 17844353.125, 17846937.5, 17847432.8125, 17850312.5, 17850401.5625, 17850764.0625, 17851245.3125, 17851256.25, 17856420.3125, 17875912.5, 17885846.875, 17900768.75, 17902137.5, 17903862.5, 17915753.125, 17927498.4375, 17936806.25, 17937996.875, 17959145.3125, 17961960.9375, 17972126.5625, 17981362.5, 18000140.625, 18011512.5, 18012732.8125, 18023521.875, 18026720.3125, 18026750.0, 18058478.125, 18089401.5625, 18089409.375, 18090498.4375, 18103040.625, 18133229.6875, 18137051.5625], [25.079943966168067, 45.41183659519032, 66.9952293558559, 5.045114151220352, 5.594322681872405, 29.21963093722133, 92.84263191135952, 33.150979885842695, 31.316672706847587, 76.40413306045201, 79.6216468846697, 7.617402423837163, 11.581218287979606, 75.95216140796349, 9.606111430744905, 75.933035659589, 9.30866373440196, 22.726559466059257, 6.842023450885433, 18.6484102830564, 169.94104655570317, 48.783379366370404, 62.28313290130766, 35.766974227667504, 6.760000763117745, 12.095097473201479, 28.823286205113448, 36.784687453117016, 17.781836694037032, 21.05906407900099, 30.12669602380893, 167.89937555537918, 9.730682070696755, 46.8448327775688, 9.448171928667064, 6.941710682632983, 58.511526376547444, 45.724835848104355, 159.82233274648186, 41.49307313427467, 22.832949033460775, 109.92353574169783, 62.54636380915415, 154.66686257555386, 5.39922190906667, 7.113481897556538, 55.56046006832516, 28.11184333499477, 154.8101963839144, 41.32835453861787, 9.71837027580552, 168.86035432211955, 33.14623708654832, 48.60430218583484, 46.43180165240389, 29.152839776889326, 158.94197207659593, 83.09622011735193, 13.445317652608207, 14.169265232536919, 13.974582500942585, 33.251332151002, 7.465639789237608, 19.282100209094303, 29.62040162268728, 45.19637238896805, 32.8098005016462, 10.98296072375742, 67.99771155657608, 50.1405020446506, 21.35927824474815, 56.98137975774323, 31.820409109788812, 15.601810760213548, 27.516314028452747, 63.43393723104188, 26.95034575191436, 5.471451907605757, 14.134005764773303, 5.321408345547334, 13.4948560977214, 75.75711525365473, 90.95076928144326, 23.469670052273507, 7.474086824169526, 15.753646028072456, 21.484738154981564, 49.37203087412799, 22.083266257529484, 7.608501275227704, 44.446530255176356, 75.71101775843441, 34.53628329441822, 79.92877882494045, 76.17898723012912, 6.902775955649058, 90.0149444903536, 16.743688774526056, 74.77243319326857, 42.75623580771344, 25.159612577373153, 57.14481385606953, 23.01163211662491, 25.889917837323658, 25.863402033789036, 56.34039701080896, 23.678182268649692, 13.51532726847177, 51.526420876029746, 17.01821695949446, 14.55331849518841, 17.528630346596614, 36.77314440983688, 29.88287648242592, 7.939830321785075, 63.108305748289474, 33.1209840620639, 72.55381366531772, 7.833452444204532, 38.336293387075344, 29.66173633037616, 87.30057287226363, 15.215071887528467, 6.29311536627628, 33.01214223228442, 47.56509100090303, 10.700484756416623, 69.30499915829299, 10.829805838202752, 14.087599193741056, 21.36709766794041, 14.136275744447861, 125.59815976201203, 46.2935966211555, 14.41212238679773, 12.961729148011878, 41.65400236673909, 13.126546693122478, 10.370314812160352, 65.21114687603543, 21.89453493632259, 114.89990270301335, 19.74959412364388, 72.71897918648529, 61.11213964632362, 129.58672193527846, 8.834849764201504, 8.76366431413893, 9.65713444545376, 50.167810603594404, 33.3023559909756, 6.281473071520781, 14.48667902409079, 15.538408653913171, 17.980850629647378, 74.12511576830804, 30.09553833353079, 51.48671072110193, 5.126768088949038, 27.232470882028302, 59.234598836290594, 14.326366376505726, 49.72700417876128, 28.676212710392463, 45.61977086831721, 19.84639040168051, 42.34026276401974, 76.72091292128766, 17.832351150377782, 26.958601700645097, 33.077474799782514, 60.76279307903262, 17.374706760835124, 26.372156348377054, 11.70097293696403, 82.64089154782509, 7.460000397614895, 25.173994645202217, 27.580794365177795, 17.58877966295711, 54.631510279726065, 35.64893178417083, 45.73814697301862, 25.388622169458067, 51.88268336667072, 79.92764863270033, 29.794879167148718, 6.030556018445816, 13.209485643949778, 86.24450228764667, 65.79063308297046, 74.98185376128217, 45.17491657016097, 10.822074676110855, 14.999944808673606, 81.73837906124821, 11.898230190291006, 31.57924437797535, 21.338905949655942, 18.654357491043967, 19.422518161286188, 5.872375813347534, 7.142008255406928, 34.17871592085354, 11.637363133478948, 35.475413122335596, 29.870561264552265, 25.287398993499664, 28.4939151876816, 49.28726090124877, 53.93370055950074, 52.64242993434023, 15.91073502186053, 15.364038204727631, 107.21088176784178, 44.093789900115524, 11.100561895317078, 38.39256577093843, 21.352756062391038, 68.73728075207205, 64.0452581983334, 17.172399958854538, 27.215063077028624, 8.253788741561388, 7.807790415142733, 52.270646072358325, 77.4563967788716, 141.7079964493904, 45.21544222148737, 17.418192439082638, 43.14669017677113, 12.246844166846483, 39.08113273175127, 56.03204261857214, 31.92157445627113, 20.95460912800877, 5.125528081662552, 12.832789238426574, 23.672019165359632, 23.76396390152281, 22.9092113843158, 7.898689771156603, 15.655827335304943, 24.442316716468817, 69.67086906132516, 75.49662935194831, 25.014094974024996, 98.68850259146217, 41.76442501197293, 57.929788036995134, 44.684066262077764, 123.59662980337554, 41.32287631638138, 20.967762575592726, 31.698884837054003, 7.046012238362297, 16.823482741571663, 46.47031561298104, 7.6704505666637415, 25.50326949170275, 5.126123664149022, 81.08966493512207, 6.219430617740789, 10.00280230075435, 9.133042890672474, 30.52615387667582, 45.61581410733059, 23.31761496370503, 43.085776546834005, 94.07159010681644, 47.49674152632322, 210.9899952404224, 23.089566247525923, 6.785291926333651, 5.446414477029895, 43.02352413562995, 48.90163042594896, 217.13335414425862, 25.171505956165745, 53.31468642136404, 166.36741054745337, 50.72769360399015, 102.6631198562372, 12.175662677974463, 15.934374554860229, 18.414278465151344, 35.637636946027136, 38.30722078563419, 45.88882722871288, 14.264794960592804, 39.72815525219561, 32.23190986293017, 60.03813479925928, 56.74466077416559, 17.185327780457342, 19.3774641983977, 13.3212185017689, 29.580660603577627, 10.329646214463034, 32.80486775279164, 38.72374607361646, 38.90003297549953, 5.892541771389151, 44.13478529012673, 37.666755647416366, 7.177070146147919, 9.950382672353495, 19.09159261216078, 6.084218838871262, 53.64259333299908, 16.825461751219393, 10.779105732964252, 22.702440305255696, 27.149099495384604, 60.69075705262121, 30.17433702088182, 6.845555371723892, 80.09270323321775, 6.181883215240838, 25.71283044275267, 9.668612197010784, 6.263275471265735, 46.22381050833563, 17.571122775418004, 6.220411784929484, 12.178096099962795, 7.887338711937837, 10.642682337427784, 20.9157424507976, 23.178049977688943, 24.703066339825533, 6.524545902754518, 39.26541558857626, 16.879752090780645])
Detected energies during the discharge + Energy spectrum
multiplot(icon_fig, T_int_first,E,xle,Etot)