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 = 44423
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);
([3413348.4375, 3830425.0, 3865653.125, 3973731.25, 4032006.25, 4055457.8125, 4274229.6875, 4325915.625, 4396300.0, 4401604.6875, 4417001.5625, 4421971.875, 4516415.625, 4541515.625, 4556556.25, 5667445.3125, 5859959.375, 5978557.8125, 5983373.4375, 5991364.0625, 5993746.875, 5994925.0, 5994935.9375, 6046979.6875, 6049559.375, 6050109.375, 6057265.625, 6093746.875, 6095389.0625, 6104454.6875, 6125468.75, 6142892.1875, 6145176.5625, 6148239.0625, 6156535.9375, 6160671.875, 6161309.375, 6163539.0625, 6171151.5625, 6184487.5, 6189801.5625, 6191120.3125, 6196235.9375, 6199134.375, 6203046.875, 6203440.625, 6216156.25, 6218071.875, 6237460.9375, 6238532.8125, 6252206.25, 6253359.375, 6255675.0, 6257154.6875, 6261431.25, 6261521.875, 6272895.3125, 6280589.0625, 6294518.75, 6329532.8125, 6339037.5, 6367451.5625, 6371884.375, 6387317.1875, 6389206.25, 6480543.75, 6500918.75, 6526631.25, 6551957.8125, 6601379.6875, 6608940.625, 6637893.75, 6687893.75, 6754926.5625, 6917273.4375, 6920865.625, 6983443.75, 6993632.8125, 7138332.8125, 7151628.125, 7153985.9375, 7217275.0, 7257368.75, 7343131.25, 7567315.625, 7599912.5, 7611832.8125, 7622189.0625, 7656931.25, 7668585.9375, 7683484.375, 7695345.3125, 7695940.625, 7763962.5, 7781978.125, 7786212.5, 7799318.75, 7802153.125, 7804984.375, 7805053.125, 7807017.1875, 7807281.25, 7814906.25, 7836287.5, 7865121.875, 7877695.3125, 7881937.5, 7911171.875, 7957871.875, 7958276.5625, 7958648.4375, 7963875.0, 7964217.1875, 7967317.1875, 8057651.5625, 8063732.8125, 8077035.9375, 8123970.3125, 8130595.3125, 8133298.4375, 8138492.1875, 8162451.5625, 8219389.0625, 8258482.8125, 8261795.3125, 8331740.625, 8332240.625, 8332467.1875, 8334712.5, 8334764.0625, 8388215.625, 8430540.625, 8557107.8125, 8629910.9375, 8706534.375, 8708726.5625, 8920859.375, 8995204.6875, 8996200.0, 8998976.5625, 8998979.6875, 8998990.625, 9000645.3125, 9049201.5625, 9098207.8125, 9098221.875, 9101793.75, 9181746.875, 9460012.5, 9797834.375, 9839976.5625, 9850979.6875, 9910793.75, 9950028.125, 10040387.5, 10319810.9375, 10405329.6875, 10444270.3125, 10464160.9375, 10559131.25, 10562185.9375, 10591492.1875, 10596889.0625, 10658387.5, 10746273.4375, 10746823.4375, 11275318.75, 11276973.4375, 11281376.5625, 11282575.0, 11282589.0625, 11283806.25, 11283865.625, 11285385.9375, 11287200.0, 11288832.8125, 11290271.875, 11290839.0625, 11293132.8125, 11295031.25, 11297728.125, 11299390.625, 11299751.5625, 11299946.875, 11301162.5, 11305390.625, 11306943.75, 11307537.5, 11308232.8125, 11308278.125, 11309495.3125, 11310142.1875, 11310960.9375, 11312914.0625, 11312992.1875, 11313012.5, 11316087.5, 11317546.875, 11318128.125, 11318790.625, 11319039.0625, 11324645.3125, 11324700.0, 11325667.1875, 11332767.1875, 11334479.6875, 11334651.5625, 11338784.375, 11342850.0, 11343578.125, 11346623.4375, 11347204.6875, 11348973.4375, 11349087.5, 11349256.25, 11349325.0, 11349370.3125, 11350000.0, 11350129.6875, 11350812.5, 11350865.625, 11351309.375, 11352007.8125, 11352346.875, 11352946.875, 11355548.4375, 11355690.625, 11355698.4375, 11356079.6875, 11356242.1875, 11356621.875, 11357054.6875, 11357154.6875, 11357557.8125, 11357831.25, 11357906.25, 11358117.1875, 11358376.5625, 11358475.0, 11359165.625, 11359245.3125, 11360340.625, 11360379.6875, 11361260.9375, 11361453.125, 11361873.4375, 11362704.6875, 11363309.375, 11363448.4375, 11363881.25, 11364831.25, 11364882.8125, 11367326.5625, 11367334.375, 11368268.75, 11368671.875, 11368760.9375, 11369106.25, 11369476.5625, 11370162.5, 11371679.6875, 11373700.0, 11374120.3125, 11374267.1875, 11376612.5, 11377393.75, 11379307.8125, 11380739.0625, 11381207.8125, 11381951.5625, 11382581.25, 11382703.125, 11383767.1875, 11385412.5, 11386075.0, 11388865.625, 11388865.625, 278647243.75], [63.05533017327792, 48.139437881827334, 45.27572341386138, 42.810043045750284, 5.769326853429245, 18.628866116177864, 53.29343092939192, 9.263393749018064, 7.654875997793165, 26.98811918543853, 14.469858380015868, 6.248138185202868, 62.04034127019015, 37.654404381574324, 44.11307991389439, 32.233110337852246, 30.842092527607324, 63.752203283282626, 8.92988755661887, 90.5563553026239, 27.385719167330404, 5.61787421056738, 19.786606237582568, 40.65431447007129, 29.743958458401583, 21.457243419652674, 22.410335831892592, 17.003871125388727, 10.93984407546454, 43.26920733515806, 57.73531729672744, 169.10631976302298, 50.024270816482925, 25.670938918292904, 7.593323404305299, 24.751559479362726, 25.817651927909186, 59.94630506104319, 113.55859240198339, 8.269743038943265, 8.587371311235874, 23.041380572279284, 38.143350796161144, 48.26849795631076, 47.76080356765259, 116.28923058537183, 9.754722118796645, 40.24421720016101, 141.896956576063, 25.864845404502532, 87.76988409399944, 5.5008248962599895, 19.802934773460798, 212.70700402582705, 37.97737013288285, 14.670202525500137, 82.85667544355303, 46.631558106273744, 14.838443157050946, 14.630647491916426, 84.63892281383839, 14.557763649607274, 44.19149148862374, 17.33438834144662, 15.754754986702087, 10.714590721034382, 330.8056839440816, 55.86685759848494, 121.38769220184486, 50.031553576967106, 43.820641236681766, 75.08201937531979, 56.48119793547711, 8.044032960427506, 75.0689254886257, 96.09207871630126, 105.07224671037356, 8.676360317996163, 143.6497293943851, 6.96357879080195, 7.900361534518297, 11.529372315033108, 172.9975352687577, 20.86729147896555, 12.08835386029519, 20.64954115459554, 46.73416365807291, 63.5743018258164, 8.594059780474922, 11.664247541322402, 48.19535859893601, 46.27773494257524, 23.982528207168414, 43.04835827095002, 37.68451933529895, 7.894805785740222, 14.600056973053164, 105.1457498594768, 28.927693812973665, 5.030036749310782, 5.878259029587923, 42.3906552183746, 7.167390640534358, 38.86101085468495, 86.0370792147308, 11.325624170485288, 64.46289678818646, 6.350356638436064, 19.891403679338204, 33.77842431089838, 11.886465411569414, 37.51428659192514, 6.918214731967706, 61.79158524657338, 5.311030080277874, 21.73367705247204, 7.049096633195168, 65.82545962958154, 70.35659521313863, 35.08622880190491, 30.435425083703084, 23.73330030154428, 22.453693605493484, 21.076465331537126, 10.341852539632416, 36.304891703440795, 16.388258150051165, 5.195360162435696, 57.623212548342785, 6.010482229809198, 30.489890934896774, 11.674742973293274, 37.40050920743224, 14.151461964027304, 14.769441903323836, 11.896591077479158, 83.74400171959934, 42.2929340466538, 15.869357858687035, 149.05347013378548, 106.70060507942573, 13.551347920779987, 7.046869219351534, 41.50766036215816, 14.521699916980644, 25.77339858157033, 15.919588125181907, 27.175564778419027, 19.55563411872124, 15.212966180667193, 12.295095453514175, 14.6058937068743, 25.88151448608311, 13.221350726896633, 79.41546902161546, 17.69575280559358, 6.536256058422299, 14.284660541917425, 27.175479577748053, 11.341205751868277, 68.75641062756542, 11.608424708020964, 43.97316598899498, 11.477163167252096, 71.37548614780222, 167.71104877367642, 7.636325752737037, 60.58136633901365, 72.40131334380568, 18.325782485186743, 11.483443124284094, 32.987827836697875, 5.195770550198954, 15.95372079607067, 136.4164597964792, 70.06616185161607, 9.258580810931223, 5.783383360350553, 15.952618148279798, 15.86883413032226, 11.42759036347198, 10.750639745932574, 26.549183565812818, 25.63090787205127, 82.28528202824144, 13.446397710705952, 23.536655560444455, 55.304929827824324, 11.75306063334677, 9.848885302892166, 41.106132356770416, 10.802795571757725, 82.49427775818829, 6.67459309052046, 16.147178338776804, 73.11595575401245, 99.06045368425586, 46.13474337474617, 32.547479494523756, 89.11644074755964, 74.04703399493471, 8.665332275694478, 60.138052200605635, 62.7348720777288, 6.082937390746994, 28.35217787955017, 47.67261680601905, 7.8573185883111165, 9.003453817410588, 22.74666783297664, 9.484370152358139, 30.245395083951273, 42.905814996506045, 28.76619621300734, 7.276340972378053, 21.75509054064061, 51.57805976115067, 52.6900890619375, 26.420754001913338, 54.03070268775791, 5.909442970972344, 45.48462164716632, 10.103438832897362, 12.125576907367648, 16.79196723351869, 79.5215181265404, 48.81700062770027, 16.34700930585123, 21.304755098172258, 60.820247418704, 19.23406012416015, 13.253345442038908, 9.182320922711169, 11.045848112405066, 24.689454524744818, 6.312688479657684, 12.21447909510526, 126.94688157503094, 81.46028449392475, 15.65652039411968, 12.369655871246422, 11.39123224436518, 11.365606002070695, 6.075296448659065, 70.75882151681945, 8.109111305393846, 17.673472450546914, 11.180924544121458, 57.903148148879374, 8.238007229766163, 52.065875724477, 8.896021807878558, 47.35112627348774, 8.25585551945218, 17.069470101173792, 5.778322315056487, 14.798270076960984, 15.892983229659874, 15.428705984357913, 9.331315807218546, 79.97077289058633, 18.37212382433242, 15.43569176654424, 12.055014337803785, 24.80321711582477, 33.34486955829114, 72.46117386082541, 59.435367512401214, 77.72552117953869, 6.907093986341133, 34.78933333778231, 20.822777202290375, 5.17019630098155, 73.62485802593136, 45.826011716351026, 11.058716167789639, 14.105064550373736, 106.98531802593277])
caption, xmean,count, xle, Etot = energy_spectrum(E_tot)
hist_file(E_hist, xmean, count, caption);
([3413348.4375, 3830425.0, 3865653.125, 3973731.25, 4032006.25, 4055457.8125, 4274229.6875, 4325915.625, 4396300.0, 4401604.6875, 4417001.5625, 4421971.875, 4516415.625, 4541515.625, 4556556.25, 5667445.3125, 5859959.375, 5978557.8125, 5983373.4375, 5991364.0625, 5993746.875, 5994925.0, 5994935.9375, 6046979.6875, 6049559.375, 6050109.375, 6057265.625, 6093746.875, 6095389.0625, 6104454.6875, 6125468.75, 6142892.1875, 6145176.5625, 6148239.0625, 6156535.9375, 6160671.875, 6161309.375, 6163539.0625, 6171151.5625, 6184487.5, 6189801.5625, 6191120.3125, 6196235.9375, 6199134.375, 6203046.875, 6203440.625, 6216156.25, 6218071.875, 6237460.9375, 6238532.8125, 6252206.25, 6253359.375, 6255675.0, 6257154.6875, 6261431.25, 6261521.875, 6272895.3125, 6280589.0625, 6294518.75, 6329532.8125, 6339037.5, 6367451.5625, 6371884.375, 6387317.1875, 6389206.25, 6480543.75, 6500918.75, 6526631.25, 6551957.8125, 6601379.6875, 6608940.625, 6637893.75, 6687893.75, 6754926.5625, 6917273.4375, 6920865.625, 6983443.75, 6993632.8125, 7138332.8125, 7151628.125, 7153985.9375, 7217275.0, 7257368.75, 7343131.25, 7567315.625, 7599912.5, 7611832.8125, 7622189.0625, 7656931.25, 7668585.9375, 7683484.375, 7695345.3125, 7695940.625, 7763962.5, 7781978.125, 7786212.5, 7799318.75, 7802153.125, 7804984.375, 7805053.125, 7807017.1875, 7807281.25, 7814906.25, 7836287.5, 7865121.875, 7877695.3125, 7881937.5, 7911171.875, 7957871.875, 7958276.5625, 7958648.4375, 7963875.0, 7964217.1875, 7967317.1875, 8057651.5625, 8063732.8125, 8077035.9375, 8123970.3125, 8130595.3125, 8133298.4375, 8138492.1875, 8162451.5625, 8219389.0625, 8258482.8125, 8261795.3125, 8331740.625, 8332240.625, 8332467.1875, 8334712.5, 8334764.0625, 8388215.625, 8430540.625, 8557107.8125, 8629910.9375, 8706534.375, 8708726.5625, 8920859.375, 8995204.6875, 8996200.0, 8998976.5625, 8998979.6875, 8998990.625, 9000645.3125, 9049201.5625, 9098207.8125, 9098221.875, 9101793.75, 9181746.875, 9460012.5, 9797834.375, 9839976.5625, 9850979.6875, 9910793.75, 9950028.125, 10040387.5, 10319810.9375, 10405329.6875, 10444270.3125, 10464160.9375, 10559131.25, 10562185.9375, 10591492.1875, 10596889.0625, 10658387.5, 10746273.4375, 10746823.4375, 11275318.75, 11276973.4375, 11281376.5625, 11282575.0, 11282589.0625, 11283806.25, 11283865.625, 11285385.9375, 11287200.0, 11288832.8125, 11290271.875, 11290839.0625, 11293132.8125, 11295031.25, 11297728.125, 11299390.625, 11299751.5625, 11299946.875, 11301162.5, 11305390.625, 11306943.75, 11307537.5, 11308232.8125, 11308278.125, 11309495.3125, 11310142.1875, 11310960.9375, 11312914.0625, 11312992.1875, 11313012.5, 11316087.5, 11317546.875, 11318128.125, 11318790.625, 11319039.0625, 11324645.3125, 11324700.0, 11325667.1875, 11332767.1875, 11334479.6875, 11334651.5625, 11338784.375, 11342850.0, 11343578.125, 11346623.4375, 11347204.6875, 11348973.4375, 11349087.5, 11349256.25, 11349325.0, 11349370.3125, 11350000.0, 11350129.6875, 11350812.5, 11350865.625, 11351309.375, 11352007.8125, 11352346.875, 11352946.875, 11355548.4375, 11355690.625, 11355698.4375, 11356079.6875, 11356242.1875, 11356621.875, 11357054.6875, 11357154.6875, 11357557.8125, 11357831.25, 11357906.25, 11358117.1875, 11358376.5625, 11358475.0, 11359165.625, 11359245.3125, 11360340.625, 11360379.6875, 11361260.9375, 11361453.125, 11361873.4375, 11362704.6875, 11363309.375, 11363448.4375, 11363881.25, 11364831.25, 11364882.8125, 11367326.5625, 11367334.375, 11368268.75, 11368671.875, 11368760.9375, 11369106.25, 11369476.5625, 11370162.5, 11371679.6875, 11373700.0, 11374120.3125, 11374267.1875, 11376612.5, 11377393.75, 11379307.8125, 11380739.0625, 11381207.8125, 11381951.5625, 11382581.25, 11382703.125, 11383767.1875, 11385412.5, 11386075.0, 11388865.625, 11388865.625, 278647243.75], [63.05533017327792, 48.139437881827334, 45.27572341386138, 42.810043045750284, 5.769326853429245, 18.628866116177864, 53.29343092939192, 9.263393749018064, 7.654875997793165, 26.98811918543853, 14.469858380015868, 6.248138185202868, 62.04034127019015, 37.654404381574324, 44.11307991389439, 32.233110337852246, 30.842092527607324, 63.752203283282626, 8.92988755661887, 90.5563553026239, 27.385719167330404, 5.61787421056738, 19.786606237582568, 40.65431447007129, 29.743958458401583, 21.457243419652674, 22.410335831892592, 17.003871125388727, 10.93984407546454, 43.26920733515806, 57.73531729672744, 169.10631976302298, 50.024270816482925, 25.670938918292904, 7.593323404305299, 24.751559479362726, 25.817651927909186, 59.94630506104319, 113.55859240198339, 8.269743038943265, 8.587371311235874, 23.041380572279284, 38.143350796161144, 48.26849795631076, 47.76080356765259, 116.28923058537183, 9.754722118796645, 40.24421720016101, 141.896956576063, 25.864845404502532, 87.76988409399944, 5.5008248962599895, 19.802934773460798, 212.70700402582705, 37.97737013288285, 14.670202525500137, 82.85667544355303, 46.631558106273744, 14.838443157050946, 14.630647491916426, 84.63892281383839, 14.557763649607274, 44.19149148862374, 17.33438834144662, 15.754754986702087, 10.714590721034382, 330.8056839440816, 55.86685759848494, 121.38769220184486, 50.031553576967106, 43.820641236681766, 75.08201937531979, 56.48119793547711, 8.044032960427506, 75.0689254886257, 96.09207871630126, 105.07224671037356, 8.676360317996163, 143.6497293943851, 6.96357879080195, 7.900361534518297, 11.529372315033108, 172.9975352687577, 20.86729147896555, 12.08835386029519, 20.64954115459554, 46.73416365807291, 63.5743018258164, 8.594059780474922, 11.664247541322402, 48.19535859893601, 46.27773494257524, 23.982528207168414, 43.04835827095002, 37.68451933529895, 7.894805785740222, 14.600056973053164, 105.1457498594768, 28.927693812973665, 5.030036749310782, 5.878259029587923, 42.3906552183746, 7.167390640534358, 38.86101085468495, 86.0370792147308, 11.325624170485288, 64.46289678818646, 6.350356638436064, 19.891403679338204, 33.77842431089838, 11.886465411569414, 37.51428659192514, 6.918214731967706, 61.79158524657338, 5.311030080277874, 21.73367705247204, 7.049096633195168, 65.82545962958154, 70.35659521313863, 35.08622880190491, 30.435425083703084, 23.73330030154428, 22.453693605493484, 21.076465331537126, 10.341852539632416, 36.304891703440795, 16.388258150051165, 5.195360162435696, 57.623212548342785, 6.010482229809198, 30.489890934896774, 11.674742973293274, 37.40050920743224, 14.151461964027304, 14.769441903323836, 11.896591077479158, 83.74400171959934, 42.2929340466538, 15.869357858687035, 149.05347013378548, 106.70060507942573, 13.551347920779987, 7.046869219351534, 41.50766036215816, 14.521699916980644, 25.77339858157033, 15.919588125181907, 27.175564778419027, 19.55563411872124, 15.212966180667193, 12.295095453514175, 14.6058937068743, 25.88151448608311, 13.221350726896633, 79.41546902161546, 17.69575280559358, 6.536256058422299, 14.284660541917425, 27.175479577748053, 11.341205751868277, 68.75641062756542, 11.608424708020964, 43.97316598899498, 11.477163167252096, 71.37548614780222, 167.71104877367642, 7.636325752737037, 60.58136633901365, 72.40131334380568, 18.325782485186743, 11.483443124284094, 32.987827836697875, 5.195770550198954, 15.95372079607067, 136.4164597964792, 70.06616185161607, 9.258580810931223, 5.783383360350553, 15.952618148279798, 15.86883413032226, 11.42759036347198, 10.750639745932574, 26.549183565812818, 25.63090787205127, 82.28528202824144, 13.446397710705952, 23.536655560444455, 55.304929827824324, 11.75306063334677, 9.848885302892166, 41.106132356770416, 10.802795571757725, 82.49427775818829, 6.67459309052046, 16.147178338776804, 73.11595575401245, 99.06045368425586, 46.13474337474617, 32.547479494523756, 89.11644074755964, 74.04703399493471, 8.665332275694478, 60.138052200605635, 62.7348720777288, 6.082937390746994, 28.35217787955017, 47.67261680601905, 7.8573185883111165, 9.003453817410588, 22.74666783297664, 9.484370152358139, 30.245395083951273, 42.905814996506045, 28.76619621300734, 7.276340972378053, 21.75509054064061, 51.57805976115067, 52.6900890619375, 26.420754001913338, 54.03070268775791, 5.909442970972344, 45.48462164716632, 10.103438832897362, 12.125576907367648, 16.79196723351869, 79.5215181265404, 48.81700062770027, 16.34700930585123, 21.304755098172258, 60.820247418704, 19.23406012416015, 13.253345442038908, 9.182320922711169, 11.045848112405066, 24.689454524744818, 6.312688479657684, 12.21447909510526, 126.94688157503094, 81.46028449392475, 15.65652039411968, 12.369655871246422, 11.39123224436518, 11.365606002070695, 6.075296448659065, 70.75882151681945, 8.109111305393846, 17.673472450546914, 11.180924544121458, 57.903148148879374, 8.238007229766163, 52.065875724477, 8.896021807878558, 47.35112627348774, 8.25585551945218, 17.069470101173792, 5.778322315056487, 14.798270076960984, 15.892983229659874, 15.428705984357913, 9.331315807218546, 79.97077289058633, 18.37212382433242, 15.43569176654424, 12.055014337803785, 24.80321711582477, 33.34486955829114, 72.46117386082541, 59.435367512401214, 77.72552117953869, 6.907093986341133, 34.78933333778231, 20.822777202290375, 5.17019630098155, 73.62485802593136, 45.826011716351026, 11.058716167789639, 14.105064550373736, 106.98531802593277])
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);
([3413348.4375, 3830425.0, 3865653.125, 3973731.25, 4032006.25, 4055457.8125, 4274229.6875, 4325915.625, 4396300.0, 4401604.6875, 4417001.5625, 4421971.875, 4516415.625, 4541515.625, 4556556.25, 5667445.3125, 5859959.375, 5978557.8125, 5983373.4375, 5991364.0625, 5993746.875, 5994925.0, 5994935.9375, 6046979.6875, 6049559.375, 6050109.375, 6057265.625, 6093746.875, 6095389.0625, 6104454.6875, 6125468.75, 6142892.1875, 6145176.5625, 6148239.0625, 6156535.9375, 6160671.875, 6161309.375, 6163539.0625, 6171151.5625, 6184487.5, 6189801.5625, 6191120.3125, 6196235.9375, 6199134.375, 6203046.875, 6203440.625, 6216156.25, 6218071.875, 6237460.9375, 6238532.8125, 6252206.25, 6253359.375, 6255675.0, 6257154.6875, 6261431.25, 6261521.875, 6272895.3125, 6280589.0625, 6294518.75, 6329532.8125, 6339037.5, 6367451.5625, 6371884.375, 6387317.1875, 6389206.25, 6480543.75, 6500918.75, 6526631.25, 6551957.8125, 6601379.6875, 6608940.625, 6637893.75, 6687893.75, 6754926.5625, 6917273.4375, 6920865.625, 6983443.75, 6993632.8125, 7138332.8125, 7151628.125, 7153985.9375, 7217275.0, 7257368.75, 7343131.25, 7567315.625, 7599912.5, 7611832.8125, 7622189.0625, 7656931.25, 7668585.9375, 7683484.375, 7695345.3125, 7695940.625, 7763962.5, 7781978.125, 7786212.5, 7799318.75, 7802153.125, 7804984.375, 7805053.125, 7807017.1875, 7807281.25, 7814906.25, 7836287.5, 7865121.875, 7877695.3125, 7881937.5, 7911171.875, 7957871.875, 7958276.5625, 7958648.4375, 7963875.0, 7964217.1875, 7967317.1875, 8057651.5625, 8063732.8125, 8077035.9375, 8123970.3125, 8130595.3125, 8133298.4375, 8138492.1875, 8162451.5625, 8219389.0625, 8258482.8125, 8261795.3125, 8331740.625, 8332240.625, 8332467.1875, 8334712.5, 8334764.0625, 8388215.625, 8430540.625, 8557107.8125, 8629910.9375, 8706534.375, 8708726.5625, 8920859.375, 8995204.6875, 8996200.0, 8998976.5625, 8998979.6875, 8998990.625, 9000645.3125, 9049201.5625, 9098207.8125, 9098221.875, 9101793.75, 9181746.875, 9460012.5, 9797834.375, 9839976.5625, 9850979.6875, 9910793.75, 9950028.125, 10040387.5, 10319810.9375, 10405329.6875, 10444270.3125, 10464160.9375, 10559131.25, 10562185.9375, 10591492.1875, 10596889.0625, 10658387.5, 10746273.4375, 10746823.4375, 11275318.75, 11276973.4375, 11281376.5625, 11282575.0, 11282589.0625, 11283806.25, 11283865.625, 11285385.9375, 11287200.0, 11288832.8125, 11290271.875, 11290839.0625, 11293132.8125, 11295031.25, 11297728.125, 11299390.625, 11299751.5625, 11299946.875, 11301162.5, 11305390.625, 11306943.75, 11307537.5, 11308232.8125, 11308278.125, 11309495.3125, 11310142.1875, 11310960.9375, 11312914.0625, 11312992.1875, 11313012.5, 11316087.5, 11317546.875, 11318128.125, 11318790.625, 11319039.0625, 11324645.3125, 11324700.0, 11325667.1875, 11332767.1875, 11334479.6875, 11334651.5625, 11338784.375, 11342850.0, 11343578.125, 11346623.4375, 11347204.6875, 11348973.4375, 11349087.5, 11349256.25, 11349325.0, 11349370.3125, 11350000.0, 11350129.6875, 11350812.5, 11350865.625, 11351309.375, 11352007.8125, 11352346.875, 11352946.875, 11355548.4375, 11355690.625, 11355698.4375, 11356079.6875, 11356242.1875, 11356621.875, 11357054.6875, 11357154.6875, 11357557.8125, 11357831.25, 11357906.25, 11358117.1875, 11358376.5625, 11358475.0, 11359165.625, 11359245.3125, 11360340.625, 11360379.6875, 11361260.9375, 11361453.125, 11361873.4375, 11362704.6875, 11363309.375, 11363448.4375, 11363881.25, 11364831.25, 11364882.8125, 11367326.5625, 11367334.375, 11368268.75, 11368671.875, 11368760.9375, 11369106.25, 11369476.5625, 11370162.5, 11371679.6875, 11373700.0, 11374120.3125, 11374267.1875, 11376612.5, 11377393.75, 11379307.8125, 11380739.0625, 11381207.8125, 11381951.5625, 11382581.25, 11382703.125, 11383767.1875, 11385412.5, 11386075.0, 11388865.625, 11388865.625, 278647243.75], [63.05533017327792, 48.139437881827334, 45.27572341386138, 42.810043045750284, 5.769326853429245, 18.628866116177864, 53.29343092939192, 9.263393749018064, 7.654875997793165, 26.98811918543853, 14.469858380015868, 6.248138185202868, 62.04034127019015, 37.654404381574324, 44.11307991389439, 32.233110337852246, 30.842092527607324, 63.752203283282626, 8.92988755661887, 90.5563553026239, 27.385719167330404, 5.61787421056738, 19.786606237582568, 40.65431447007129, 29.743958458401583, 21.457243419652674, 22.410335831892592, 17.003871125388727, 10.93984407546454, 43.26920733515806, 57.73531729672744, 169.10631976302298, 50.024270816482925, 25.670938918292904, 7.593323404305299, 24.751559479362726, 25.817651927909186, 59.94630506104319, 113.55859240198339, 8.269743038943265, 8.587371311235874, 23.041380572279284, 38.143350796161144, 48.26849795631076, 47.76080356765259, 116.28923058537183, 9.754722118796645, 40.24421720016101, 141.896956576063, 25.864845404502532, 87.76988409399944, 5.5008248962599895, 19.802934773460798, 212.70700402582705, 37.97737013288285, 14.670202525500137, 82.85667544355303, 46.631558106273744, 14.838443157050946, 14.630647491916426, 84.63892281383839, 14.557763649607274, 44.19149148862374, 17.33438834144662, 15.754754986702087, 10.714590721034382, 330.8056839440816, 55.86685759848494, 121.38769220184486, 50.031553576967106, 43.820641236681766, 75.08201937531979, 56.48119793547711, 8.044032960427506, 75.0689254886257, 96.09207871630126, 105.07224671037356, 8.676360317996163, 143.6497293943851, 6.96357879080195, 7.900361534518297, 11.529372315033108, 172.9975352687577, 20.86729147896555, 12.08835386029519, 20.64954115459554, 46.73416365807291, 63.5743018258164, 8.594059780474922, 11.664247541322402, 48.19535859893601, 46.27773494257524, 23.982528207168414, 43.04835827095002, 37.68451933529895, 7.894805785740222, 14.600056973053164, 105.1457498594768, 28.927693812973665, 5.030036749310782, 5.878259029587923, 42.3906552183746, 7.167390640534358, 38.86101085468495, 86.0370792147308, 11.325624170485288, 64.46289678818646, 6.350356638436064, 19.891403679338204, 33.77842431089838, 11.886465411569414, 37.51428659192514, 6.918214731967706, 61.79158524657338, 5.311030080277874, 21.73367705247204, 7.049096633195168, 65.82545962958154, 70.35659521313863, 35.08622880190491, 30.435425083703084, 23.73330030154428, 22.453693605493484, 21.076465331537126, 10.341852539632416, 36.304891703440795, 16.388258150051165, 5.195360162435696, 57.623212548342785, 6.010482229809198, 30.489890934896774, 11.674742973293274, 37.40050920743224, 14.151461964027304, 14.769441903323836, 11.896591077479158, 83.74400171959934, 42.2929340466538, 15.869357858687035, 149.05347013378548, 106.70060507942573, 13.551347920779987, 7.046869219351534, 41.50766036215816, 14.521699916980644, 25.77339858157033, 15.919588125181907, 27.175564778419027, 19.55563411872124, 15.212966180667193, 12.295095453514175, 14.6058937068743, 25.88151448608311, 13.221350726896633, 79.41546902161546, 17.69575280559358, 6.536256058422299, 14.284660541917425, 27.175479577748053, 11.341205751868277, 68.75641062756542, 11.608424708020964, 43.97316598899498, 11.477163167252096, 71.37548614780222, 167.71104877367642, 7.636325752737037, 60.58136633901365, 72.40131334380568, 18.325782485186743, 11.483443124284094, 32.987827836697875, 5.195770550198954, 15.95372079607067, 136.4164597964792, 70.06616185161607, 9.258580810931223, 5.783383360350553, 15.952618148279798, 15.86883413032226, 11.42759036347198, 10.750639745932574, 26.549183565812818, 25.63090787205127, 82.28528202824144, 13.446397710705952, 23.536655560444455, 55.304929827824324, 11.75306063334677, 9.848885302892166, 41.106132356770416, 10.802795571757725, 82.49427775818829, 6.67459309052046, 16.147178338776804, 73.11595575401245, 99.06045368425586, 46.13474337474617, 32.547479494523756, 89.11644074755964, 74.04703399493471, 8.665332275694478, 60.138052200605635, 62.7348720777288, 6.082937390746994, 28.35217787955017, 47.67261680601905, 7.8573185883111165, 9.003453817410588, 22.74666783297664, 9.484370152358139, 30.245395083951273, 42.905814996506045, 28.76619621300734, 7.276340972378053, 21.75509054064061, 51.57805976115067, 52.6900890619375, 26.420754001913338, 54.03070268775791, 5.909442970972344, 45.48462164716632, 10.103438832897362, 12.125576907367648, 16.79196723351869, 79.5215181265404, 48.81700062770027, 16.34700930585123, 21.304755098172258, 60.820247418704, 19.23406012416015, 13.253345442038908, 9.182320922711169, 11.045848112405066, 24.689454524744818, 6.312688479657684, 12.21447909510526, 126.94688157503094, 81.46028449392475, 15.65652039411968, 12.369655871246422, 11.39123224436518, 11.365606002070695, 6.075296448659065, 70.75882151681945, 8.109111305393846, 17.673472450546914, 11.180924544121458, 57.903148148879374, 8.238007229766163, 52.065875724477, 8.896021807878558, 47.35112627348774, 8.25585551945218, 17.069470101173792, 5.778322315056487, 14.798270076960984, 15.892983229659874, 15.428705984357913, 9.331315807218546, 79.97077289058633, 18.37212382433242, 15.43569176654424, 12.055014337803785, 24.80321711582477, 33.34486955829114, 72.46117386082541, 59.435367512401214, 77.72552117953869, 6.907093986341133, 34.78933333778231, 20.822777202290375, 5.17019630098155, 73.62485802593136, 45.826011716351026, 11.058716167789639, 14.105064550373736, 106.98531802593277])
Detected energies during the discharge + Energy spectrum
multiplot(icon_fig, T_int_first,E,xle,Etot)