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 = 43706
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);
([4577712.5, 4607143.75, 4607248.4375, 4802818.75, 4909501.5625, 5079318.75, 5090706.25, 5200559.375, 5216920.3125, 5981921.875, 6092965.625, 6173626.5625, 6548681.25, 6548682.8125, 6582332.8125, 6813843.75, 7002518.75, 7009607.8125, 7014171.875, 7033260.9375, 7076998.4375, 7077075.0, 7099589.0625, 7109379.6875, 7125893.75, 7133965.625, 7137726.5625, 7146393.75, 7161725.0, 7221232.8125, 7241000.0, 7241054.6875, 7245075.0, 7245550.0, 7246096.875, 7248354.6875, 7282662.5, 7306179.6875, 7313918.75, 7317017.1875, 7320635.9375, 7326901.5625, 7338301.5625, 7344284.375, 7346420.3125, 7357529.6875, 7361042.1875, 7369332.8125, 7374515.625, 7376545.3125, 7388998.4375, 7401089.0625, 7408682.8125, 7427987.5, 7466640.625, 7468075.0, 7474660.9375, 7489331.25, 7495731.25, 7506010.9375, 7508607.8125, 7510104.6875, 7516512.5, 7657335.9375, 7658009.375, 7714570.3125, 7729125.0, 7743529.6875, 7804601.5625, 7806185.9375, 7809603.125, 7848053.125, 7848060.9375, 7884104.6875, 7937764.0625, 7956173.4375, 7992976.5625, 8010323.4375, 8069828.125, 8116657.8125, 8152371.875, 8152381.25, 8152423.4375, 8152454.6875, 8154501.5625, 8173990.625, 8186864.0625, 8198385.9375, 8202196.875, 8208634.375, 8238960.9375, 8253325.0, 8257310.9375, 8269810.9375, 8271612.5, 8273464.0625, 8275337.5, 8284795.3125, 8288104.6875, 8288967.1875, 8348117.1875, 8364153.125, 8397362.5, 8400960.9375, 8400987.5, 8436121.875, 8469142.1875, 8515707.8125, 8535415.625, 8559004.6875, 8638737.5, 8681556.25, 8736448.4375, 8790328.125, 8798237.5, 8827460.9375, 8854246.875, 8870403.125, 8922503.125, 8964737.5, 9031442.1875, 9154907.8125, 9205448.4375, 9221432.8125, 9250717.1875, 9350435.9375, 9404104.6875, 9423453.125, 9454534.375, 9491475.0, 9531609.375, 9578245.3125, 9632395.3125, 9706675.0, 9736685.9375, 9790156.25, 9791785.9375, 9809979.6875, 9835239.0625, 9835250.0, 9863859.375, 9900523.4375, 9981289.0625, 9984023.4375, 10001717.1875, 10010125.0, 10011395.3125, 10042503.125, 10056678.125, 10091742.1875, 10107350.0, 10113039.0625, 10118381.25, 10141395.3125, 10178956.25, 10261757.8125, 10303310.9375, 10307826.5625, 10341031.25, 10347090.625, 10392879.6875, 10403190.625, 10425587.5, 10427600.0, 10432125.0, 10455312.5, 10459707.8125, 10470662.5, 10471689.0625, 10497081.25, 10507189.0625, 10507257.8125, 10517496.875, 10519087.5, 10524351.5625, 10564495.3125, 10585829.6875, 10589437.5, 10597542.1875, 10597618.75, 10599673.4375, 10614804.6875, 10627728.125, 10627751.5625, 10630557.8125, 10641123.4375, 10651367.1875, 10675053.125, 10748610.9375, 10756817.1875, 10758589.0625, 10762495.3125, 10783350.0, 10797537.5, 10800025.0, 10812206.25, 10817532.8125, 10832257.8125, 10834967.1875, 10841826.5625, 10852417.1875, 10855156.25, 10858048.4375, 10860235.9375, 10866495.3125, 10888182.8125, 10892629.6875, 10892678.125, 10903314.0625, 10906678.125, 10918617.1875, 10918629.6875, 10925448.4375, 10926081.25, 10926300.0, 10926314.0625, 10927725.0, 10934754.6875, 10948617.1875, 10948967.1875, 10950290.625, 10968079.6875, 10970462.5, 10972806.25, 10979342.1875, 10979735.9375, 10982068.75, 10992701.5625, 10998756.25, 10999884.375, 11006445.3125, 11009914.0625, 11018590.625, 11027390.625, 11029470.3125, 11037060.9375, 11037857.8125, 11042618.75, 11053945.3125, 11056982.8125, 11076153.125, 11081657.8125, 11082698.4375, 11083023.4375, 11084250.0, 11089798.4375, 11089800.0, 11089829.6875, 11090715.625, 11106820.3125, 11116671.875, 11187478.125, 11191018.75, 11196620.3125, 11201017.1875, 11210631.25, 11219962.5, 11220079.6875, 11220082.8125, 11226323.4375, 11233603.125, 11239087.5, 11266631.25, 11278192.1875, 11302818.75, 11303190.625, 11319328.125, 11332450.0, 11344160.9375, 11344309.375, 11351606.25, 11356834.375, 11362667.1875, 11362673.4375, 11389162.5, 11389357.8125, 11423425.0, 11425867.1875, 11432215.625, 11446260.9375, 11446328.125, 11462456.25, 11481660.9375, 11482050.0, 11482146.875, 11501378.125, 11531045.3125, 11534817.1875, 11550548.4375, 11571845.3125, 11578215.625, 11587381.25, 11596560.9375, 11604029.6875, 11626940.625, 11628909.375, 11646585.9375, 11652740.625, 11660243.75, 11679825.0, 11685965.625, 11704131.25, 11737890.625, 11743750.0, 11831823.4375, 11889598.4375, 11968398.4375, 11973914.0625, 12015914.0625, 12058895.3125, 12068934.375, 12081190.625, 12084271.875, 12097981.25, 12185910.9375, 12197729.6875, 12217573.4375, 12438070.3125, 12560660.9375, 12639492.1875, 12661300.0, 12698648.4375, 13335090.625, 13357551.5625, 13412295.3125], [75.86018726965703, 7.056848008224574, 66.87720538412911, 15.698907477716908, 5.956691771570146, 13.83743824399155, 100.77156477032675, 116.61267023952311, 70.53327495800013, 15.272231029474904, 21.306846467700566, 21.92892054076549, 60.027474375674814, 11.635416307337659, 94.34251151800393, 28.94443645084793, 13.815628300115828, 26.94518213061678, 50.92575942790441, 16.991452003502793, 21.33901730090103, 5.071383218865692, 18.353735329663444, 24.457183104900707, 73.6856437665765, 25.630693546476277, 36.97443173691895, 10.858556449382371, 19.504320044867434, 14.25870562986098, 18.7901038156499, 5.200932933679213, 30.574281999977906, 22.986514496158065, 115.3612421459965, 21.799203299523775, 34.79511153885396, 10.555992561795158, 11.863065246697861, 20.39763960467439, 16.18920085498347, 10.653870146877228, 15.9593836775901, 15.941681114022284, 12.159460216989958, 50.55825292658857, 56.122756677128734, 5.607023045520955, 40.15707565289411, 50.25498635252087, 70.70980848563536, 23.305448502639013, 20.379030245610874, 21.69220022562367, 9.768872311456521, 16.496423580975105, 32.048532775849395, 5.649681361077376, 103.28316901638294, 15.471426151866854, 29.637989922515892, 75.4038982961189, 33.25087957183156, 38.340791871563724, 32.781910519568385, 7.3367154330115705, 54.46779689023438, 7.154822759731693, 14.069639905056864, 36.72672830644803, 22.221172994955765, 60.2599159056021, 10.025796097735483, 101.55198698565326, 75.79943332946003, 60.449607990203496, 54.82722787711789, 45.685023562199255, 22.89827770013309, 39.19864847339653, 173.59871801749458, 8.27015703158479, 5.401977910790928, 6.211043643898679, 56.83138833153633, 23.773473814840845, 28.384339212192927, 27.536092447147215, 17.984465652522807, 7.65013669872024, 12.580910252467993, 16.39461892512102, 121.1789667218013, 24.498599828210413, 8.489693318456503, 90.88908757802041, 37.218589749244664, 7.389847752898608, 74.78934195073472, 20.814587581169317, 15.431274160479509, 19.973105032560188, 65.97473638554976, 15.649597250599626, 18.864523946038645, 75.31736471817612, 57.95823256021508, 19.490457101576407, 10.60153623508135, 10.937344819103078, 76.04313643068622, 12.193492467833183, 16.06987701996922, 95.33951218859485, 125.53335669211302, 122.33000640608915, 19.222023312671634, 25.042517357438044, 17.252604202979526, 17.335938516969033, 28.245289490254464, 13.893531723482653, 42.025287717310086, 21.549028246128422, 8.277443140146605, 15.645941159474386, 126.1976223725352, 91.0521931832261, 6.274818705454386, 25.45362120907185, 126.39324721860771, 15.597869264124466, 14.942872374327418, 14.91736544526118, 7.915927574563909, 19.356118545369853, 18.793843426554012, 14.818181801080947, 77.37683217706595, 8.67096190007381, 10.179935233066532, 15.377107504356358, 34.899280708311416, 99.28436026139352, 17.342974182328877, 59.98817404381597, 121.59170743312363, 5.8364621508383285, 32.800223392099724, 24.898850328167832, 16.700529214027387, 18.011891263853194, 34.56302729811179, 37.11009958198357, 27.979755927962792, 58.92083061376707, 10.654379257312716, 77.3512437736049, 38.73144177118168, 6.121525465212945, 20.347518797595193, 20.533318419846704, 6.511178209147018, 12.82039413318391, 25.977629442152175, 26.201387603408307, 93.09836480735329, 30.766991225482787, 16.567154782770615, 25.424939571453617, 70.47254318381036, 6.331007774108627, 92.81203311140095, 80.20260682504035, 16.544765513056998, 38.96215940520732, 24.230652235694784, 115.50579767596253, 10.434467378134144, 8.51331946878669, 68.082729131446, 31.107317954113807, 58.36401910884066, 6.3958538545656385, 25.43927919656026, 26.55079416409661, 9.024497091873435, 19.494843196484496, 19.116909021730617, 22.55215465690328, 6.448303670945447, 7.566269046653245, 55.72927699141577, 19.39869963711185, 16.72667900996109, 27.59219144408757, 38.41419788430561, 100.03022598009659, 69.75991444513934, 38.383868675290806, 128.81972395920099, 47.88313242819518, 84.26742466542422, 20.60331192261805, 13.348499557552408, 106.72561634708818, 51.99875880596204, 6.672059334059408, 28.69773555987112, 22.37902226700468, 5.737887521973894, 34.5386605548912, 20.907731011903607, 41.40109277770796, 38.75972377294537, 26.23400195127407, 5.282997114588104, 10.487723938540693, 19.835923834646525, 25.418840864889273, 6.931495377544365, 80.47209392819423, 15.123938763775604, 16.874290829149786, 22.82114632009636, 79.94201989090506, 10.048192646311161, 36.73634389696822, 31.018447329874856, 27.684887934532846, 80.25364910801251, 19.53519442702745, 13.773950448186344, 14.971210161513802, 23.31375460092235, 73.68663431847546, 14.373687433716789, 26.835074131351867, 19.301830774085218, 68.1103028921013, 24.733801353266742, 12.155731016719734, 77.62767501056547, 65.1020353673756, 37.54123432352366, 37.982183899309504, 88.70948370331145, 10.915124211680142, 58.77052345118165, 58.888199138740454, 7.998657417318382, 11.727078473205934, 5.512470421108228, 40.547262528980156, 22.77188654691657, 73.47767373657355, 24.62943686031786, 107.25225260249462, 21.095930447889057, 9.259880848370107, 22.764869251151225, 5.113429014132966, 81.42945236739834, 249.6801743222273, 22.787164689020422, 22.349189318411096, 21.798309383420712, 6.30155404336665, 41.504649239819535, 54.47249008007358, 10.855817961987285, 92.31333941670778, 73.69388284160428, 68.07944187756088, 9.984338091221442, 5.07263160525116, 114.79118163301415, 25.481595149218226, 18.97011927473273, 30.663897563384957, 15.378543591378087, 9.792520561801002, 16.14499364430649, 15.65793830177574, 5.075103383747311, 18.424002646296394, 76.23465245782444, 13.204512231173117, 10.265290476902681, 17.607303169500707, 6.033264353149368, 56.20997821665327, 22.137446697354143, 18.094494382178723, 73.5909507271615, 66.23740286202072, 52.18824671667035, 11.722097555179671, 64.37258252207738, 26.694820345449607, 15.429253631899343, 117.17459126745622, 30.352879454548017, 55.84562757728452, 17.42567150164256, 74.92666766658765, 78.2542060200521, 79.81439120943264, 40.64894113187791, 15.87755506648988, 74.31938658534574, 24.264940583631663, 47.62861316287448, 148.1913181467053, 31.529523378239304, 30.160773214250508, 17.359300580773574, 127.42794490670278, 10.250634241924555, 29.03105457968184, 8.702556793041328, 20.00856205296669, 19.044887361283397, 100.17514765738116, 37.40409948956661])
caption, xmean,count, xle, Etot = energy_spectrum(E_tot)
hist_file(E_hist, xmean, count, caption);
([4577712.5, 4607143.75, 4607248.4375, 4802818.75, 4909501.5625, 5079318.75, 5090706.25, 5200559.375, 5216920.3125, 5981921.875, 6092965.625, 6173626.5625, 6548681.25, 6548682.8125, 6582332.8125, 6813843.75, 7002518.75, 7009607.8125, 7014171.875, 7033260.9375, 7076998.4375, 7077075.0, 7099589.0625, 7109379.6875, 7125893.75, 7133965.625, 7137726.5625, 7146393.75, 7161725.0, 7221232.8125, 7241000.0, 7241054.6875, 7245075.0, 7245550.0, 7246096.875, 7248354.6875, 7282662.5, 7306179.6875, 7313918.75, 7317017.1875, 7320635.9375, 7326901.5625, 7338301.5625, 7344284.375, 7346420.3125, 7357529.6875, 7361042.1875, 7369332.8125, 7374515.625, 7376545.3125, 7388998.4375, 7401089.0625, 7408682.8125, 7427987.5, 7466640.625, 7468075.0, 7474660.9375, 7489331.25, 7495731.25, 7506010.9375, 7508607.8125, 7510104.6875, 7516512.5, 7657335.9375, 7658009.375, 7714570.3125, 7729125.0, 7743529.6875, 7804601.5625, 7806185.9375, 7809603.125, 7848053.125, 7848060.9375, 7884104.6875, 7937764.0625, 7956173.4375, 7992976.5625, 8010323.4375, 8069828.125, 8116657.8125, 8152371.875, 8152381.25, 8152423.4375, 8152454.6875, 8154501.5625, 8173990.625, 8186864.0625, 8198385.9375, 8202196.875, 8208634.375, 8238960.9375, 8253325.0, 8257310.9375, 8269810.9375, 8271612.5, 8273464.0625, 8275337.5, 8284795.3125, 8288104.6875, 8288967.1875, 8348117.1875, 8364153.125, 8397362.5, 8400960.9375, 8400987.5, 8436121.875, 8469142.1875, 8515707.8125, 8535415.625, 8559004.6875, 8638737.5, 8681556.25, 8736448.4375, 8790328.125, 8798237.5, 8827460.9375, 8854246.875, 8870403.125, 8922503.125, 8964737.5, 9031442.1875, 9154907.8125, 9205448.4375, 9221432.8125, 9250717.1875, 9350435.9375, 9404104.6875, 9423453.125, 9454534.375, 9491475.0, 9531609.375, 9578245.3125, 9632395.3125, 9706675.0, 9736685.9375, 9790156.25, 9791785.9375, 9809979.6875, 9835239.0625, 9835250.0, 9863859.375, 9900523.4375, 9981289.0625, 9984023.4375, 10001717.1875, 10010125.0, 10011395.3125, 10042503.125, 10056678.125, 10091742.1875, 10107350.0, 10113039.0625, 10118381.25, 10141395.3125, 10178956.25, 10261757.8125, 10303310.9375, 10307826.5625, 10341031.25, 10347090.625, 10392879.6875, 10403190.625, 10425587.5, 10427600.0, 10432125.0, 10455312.5, 10459707.8125, 10470662.5, 10471689.0625, 10497081.25, 10507189.0625, 10507257.8125, 10517496.875, 10519087.5, 10524351.5625, 10564495.3125, 10585829.6875, 10589437.5, 10597542.1875, 10597618.75, 10599673.4375, 10614804.6875, 10627728.125, 10627751.5625, 10630557.8125, 10641123.4375, 10651367.1875, 10675053.125, 10748610.9375, 10756817.1875, 10758589.0625, 10762495.3125, 10783350.0, 10797537.5, 10800025.0, 10812206.25, 10817532.8125, 10832257.8125, 10834967.1875, 10841826.5625, 10852417.1875, 10855156.25, 10858048.4375, 10860235.9375, 10866495.3125, 10888182.8125, 10892629.6875, 10892678.125, 10903314.0625, 10906678.125, 10918617.1875, 10918629.6875, 10925448.4375, 10926081.25, 10926300.0, 10926314.0625, 10927725.0, 10934754.6875, 10948617.1875, 10948967.1875, 10950290.625, 10968079.6875, 10970462.5, 10972806.25, 10979342.1875, 10979735.9375, 10982068.75, 10992701.5625, 10998756.25, 10999884.375, 11006445.3125, 11009914.0625, 11018590.625, 11027390.625, 11029470.3125, 11037060.9375, 11037857.8125, 11042618.75, 11053945.3125, 11056982.8125, 11076153.125, 11081657.8125, 11082698.4375, 11083023.4375, 11084250.0, 11089798.4375, 11089800.0, 11089829.6875, 11090715.625, 11106820.3125, 11116671.875, 11187478.125, 11191018.75, 11196620.3125, 11201017.1875, 11210631.25, 11219962.5, 11220079.6875, 11220082.8125, 11226323.4375, 11233603.125, 11239087.5, 11266631.25, 11278192.1875, 11302818.75, 11303190.625, 11319328.125, 11332450.0, 11344160.9375, 11344309.375, 11351606.25, 11356834.375, 11362667.1875, 11362673.4375, 11389162.5, 11389357.8125, 11423425.0, 11425867.1875, 11432215.625, 11446260.9375, 11446328.125, 11462456.25, 11481660.9375, 11482050.0, 11482146.875, 11501378.125, 11531045.3125, 11534817.1875, 11550548.4375, 11571845.3125, 11578215.625, 11587381.25, 11596560.9375, 11604029.6875, 11626940.625, 11628909.375, 11646585.9375, 11652740.625, 11660243.75, 11679825.0, 11685965.625, 11704131.25, 11737890.625, 11743750.0, 11831823.4375, 11889598.4375, 11968398.4375, 11973914.0625, 12015914.0625, 12058895.3125, 12068934.375, 12081190.625, 12084271.875, 12097981.25, 12185910.9375, 12197729.6875, 12217573.4375, 12438070.3125, 12560660.9375, 12639492.1875, 12661300.0, 12698648.4375, 13335090.625, 13357551.5625, 13412295.3125], [75.86018726965703, 7.056848008224574, 66.87720538412911, 15.698907477716908, 5.956691771570146, 13.83743824399155, 100.77156477032675, 116.61267023952311, 70.53327495800013, 15.272231029474904, 21.306846467700566, 21.92892054076549, 60.027474375674814, 11.635416307337659, 94.34251151800393, 28.94443645084793, 13.815628300115828, 26.94518213061678, 50.92575942790441, 16.991452003502793, 21.33901730090103, 5.071383218865692, 18.353735329663444, 24.457183104900707, 73.6856437665765, 25.630693546476277, 36.97443173691895, 10.858556449382371, 19.504320044867434, 14.25870562986098, 18.7901038156499, 5.200932933679213, 30.574281999977906, 22.986514496158065, 115.3612421459965, 21.799203299523775, 34.79511153885396, 10.555992561795158, 11.863065246697861, 20.39763960467439, 16.18920085498347, 10.653870146877228, 15.9593836775901, 15.941681114022284, 12.159460216989958, 50.55825292658857, 56.122756677128734, 5.607023045520955, 40.15707565289411, 50.25498635252087, 70.70980848563536, 23.305448502639013, 20.379030245610874, 21.69220022562367, 9.768872311456521, 16.496423580975105, 32.048532775849395, 5.649681361077376, 103.28316901638294, 15.471426151866854, 29.637989922515892, 75.4038982961189, 33.25087957183156, 38.340791871563724, 32.781910519568385, 7.3367154330115705, 54.46779689023438, 7.154822759731693, 14.069639905056864, 36.72672830644803, 22.221172994955765, 60.2599159056021, 10.025796097735483, 101.55198698565326, 75.79943332946003, 60.449607990203496, 54.82722787711789, 45.685023562199255, 22.89827770013309, 39.19864847339653, 173.59871801749458, 8.27015703158479, 5.401977910790928, 6.211043643898679, 56.83138833153633, 23.773473814840845, 28.384339212192927, 27.536092447147215, 17.984465652522807, 7.65013669872024, 12.580910252467993, 16.39461892512102, 121.1789667218013, 24.498599828210413, 8.489693318456503, 90.88908757802041, 37.218589749244664, 7.389847752898608, 74.78934195073472, 20.814587581169317, 15.431274160479509, 19.973105032560188, 65.97473638554976, 15.649597250599626, 18.864523946038645, 75.31736471817612, 57.95823256021508, 19.490457101576407, 10.60153623508135, 10.937344819103078, 76.04313643068622, 12.193492467833183, 16.06987701996922, 95.33951218859485, 125.53335669211302, 122.33000640608915, 19.222023312671634, 25.042517357438044, 17.252604202979526, 17.335938516969033, 28.245289490254464, 13.893531723482653, 42.025287717310086, 21.549028246128422, 8.277443140146605, 15.645941159474386, 126.1976223725352, 91.0521931832261, 6.274818705454386, 25.45362120907185, 126.39324721860771, 15.597869264124466, 14.942872374327418, 14.91736544526118, 7.915927574563909, 19.356118545369853, 18.793843426554012, 14.818181801080947, 77.37683217706595, 8.67096190007381, 10.179935233066532, 15.377107504356358, 34.899280708311416, 99.28436026139352, 17.342974182328877, 59.98817404381597, 121.59170743312363, 5.8364621508383285, 32.800223392099724, 24.898850328167832, 16.700529214027387, 18.011891263853194, 34.56302729811179, 37.11009958198357, 27.979755927962792, 58.92083061376707, 10.654379257312716, 77.3512437736049, 38.73144177118168, 6.121525465212945, 20.347518797595193, 20.533318419846704, 6.511178209147018, 12.82039413318391, 25.977629442152175, 26.201387603408307, 93.09836480735329, 30.766991225482787, 16.567154782770615, 25.424939571453617, 70.47254318381036, 6.331007774108627, 92.81203311140095, 80.20260682504035, 16.544765513056998, 38.96215940520732, 24.230652235694784, 115.50579767596253, 10.434467378134144, 8.51331946878669, 68.082729131446, 31.107317954113807, 58.36401910884066, 6.3958538545656385, 25.43927919656026, 26.55079416409661, 9.024497091873435, 19.494843196484496, 19.116909021730617, 22.55215465690328, 6.448303670945447, 7.566269046653245, 55.72927699141577, 19.39869963711185, 16.72667900996109, 27.59219144408757, 38.41419788430561, 100.03022598009659, 69.75991444513934, 38.383868675290806, 128.81972395920099, 47.88313242819518, 84.26742466542422, 20.60331192261805, 13.348499557552408, 106.72561634708818, 51.99875880596204, 6.672059334059408, 28.69773555987112, 22.37902226700468, 5.737887521973894, 34.5386605548912, 20.907731011903607, 41.40109277770796, 38.75972377294537, 26.23400195127407, 5.282997114588104, 10.487723938540693, 19.835923834646525, 25.418840864889273, 6.931495377544365, 80.47209392819423, 15.123938763775604, 16.874290829149786, 22.82114632009636, 79.94201989090506, 10.048192646311161, 36.73634389696822, 31.018447329874856, 27.684887934532846, 80.25364910801251, 19.53519442702745, 13.773950448186344, 14.971210161513802, 23.31375460092235, 73.68663431847546, 14.373687433716789, 26.835074131351867, 19.301830774085218, 68.1103028921013, 24.733801353266742, 12.155731016719734, 77.62767501056547, 65.1020353673756, 37.54123432352366, 37.982183899309504, 88.70948370331145, 10.915124211680142, 58.77052345118165, 58.888199138740454, 7.998657417318382, 11.727078473205934, 5.512470421108228, 40.547262528980156, 22.77188654691657, 73.47767373657355, 24.62943686031786, 107.25225260249462, 21.095930447889057, 9.259880848370107, 22.764869251151225, 5.113429014132966, 81.42945236739834, 249.6801743222273, 22.787164689020422, 22.349189318411096, 21.798309383420712, 6.30155404336665, 41.504649239819535, 54.47249008007358, 10.855817961987285, 92.31333941670778, 73.69388284160428, 68.07944187756088, 9.984338091221442, 5.07263160525116, 114.79118163301415, 25.481595149218226, 18.97011927473273, 30.663897563384957, 15.378543591378087, 9.792520561801002, 16.14499364430649, 15.65793830177574, 5.075103383747311, 18.424002646296394, 76.23465245782444, 13.204512231173117, 10.265290476902681, 17.607303169500707, 6.033264353149368, 56.20997821665327, 22.137446697354143, 18.094494382178723, 73.5909507271615, 66.23740286202072, 52.18824671667035, 11.722097555179671, 64.37258252207738, 26.694820345449607, 15.429253631899343, 117.17459126745622, 30.352879454548017, 55.84562757728452, 17.42567150164256, 74.92666766658765, 78.2542060200521, 79.81439120943264, 40.64894113187791, 15.87755506648988, 74.31938658534574, 24.264940583631663, 47.62861316287448, 148.1913181467053, 31.529523378239304, 30.160773214250508, 17.359300580773574, 127.42794490670278, 10.250634241924555, 29.03105457968184, 8.702556793041328, 20.00856205296669, 19.044887361283397, 100.17514765738116, 37.40409948956661])
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);
([4577712.5, 4607143.75, 4607248.4375, 4802818.75, 4909501.5625, 5079318.75, 5090706.25, 5200559.375, 5216920.3125, 5981921.875, 6092965.625, 6173626.5625, 6548681.25, 6548682.8125, 6582332.8125, 6813843.75, 7002518.75, 7009607.8125, 7014171.875, 7033260.9375, 7076998.4375, 7077075.0, 7099589.0625, 7109379.6875, 7125893.75, 7133965.625, 7137726.5625, 7146393.75, 7161725.0, 7221232.8125, 7241000.0, 7241054.6875, 7245075.0, 7245550.0, 7246096.875, 7248354.6875, 7282662.5, 7306179.6875, 7313918.75, 7317017.1875, 7320635.9375, 7326901.5625, 7338301.5625, 7344284.375, 7346420.3125, 7357529.6875, 7361042.1875, 7369332.8125, 7374515.625, 7376545.3125, 7388998.4375, 7401089.0625, 7408682.8125, 7427987.5, 7466640.625, 7468075.0, 7474660.9375, 7489331.25, 7495731.25, 7506010.9375, 7508607.8125, 7510104.6875, 7516512.5, 7657335.9375, 7658009.375, 7714570.3125, 7729125.0, 7743529.6875, 7804601.5625, 7806185.9375, 7809603.125, 7848053.125, 7848060.9375, 7884104.6875, 7937764.0625, 7956173.4375, 7992976.5625, 8010323.4375, 8069828.125, 8116657.8125, 8152371.875, 8152381.25, 8152423.4375, 8152454.6875, 8154501.5625, 8173990.625, 8186864.0625, 8198385.9375, 8202196.875, 8208634.375, 8238960.9375, 8253325.0, 8257310.9375, 8269810.9375, 8271612.5, 8273464.0625, 8275337.5, 8284795.3125, 8288104.6875, 8288967.1875, 8348117.1875, 8364153.125, 8397362.5, 8400960.9375, 8400987.5, 8436121.875, 8469142.1875, 8515707.8125, 8535415.625, 8559004.6875, 8638737.5, 8681556.25, 8736448.4375, 8790328.125, 8798237.5, 8827460.9375, 8854246.875, 8870403.125, 8922503.125, 8964737.5, 9031442.1875, 9154907.8125, 9205448.4375, 9221432.8125, 9250717.1875, 9350435.9375, 9404104.6875, 9423453.125, 9454534.375, 9491475.0, 9531609.375, 9578245.3125, 9632395.3125, 9706675.0, 9736685.9375, 9790156.25, 9791785.9375, 9809979.6875, 9835239.0625, 9835250.0, 9863859.375, 9900523.4375, 9981289.0625, 9984023.4375, 10001717.1875, 10010125.0, 10011395.3125, 10042503.125, 10056678.125, 10091742.1875, 10107350.0, 10113039.0625, 10118381.25, 10141395.3125, 10178956.25, 10261757.8125, 10303310.9375, 10307826.5625, 10341031.25, 10347090.625, 10392879.6875, 10403190.625, 10425587.5, 10427600.0, 10432125.0, 10455312.5, 10459707.8125, 10470662.5, 10471689.0625, 10497081.25, 10507189.0625, 10507257.8125, 10517496.875, 10519087.5, 10524351.5625, 10564495.3125, 10585829.6875, 10589437.5, 10597542.1875, 10597618.75, 10599673.4375, 10614804.6875, 10627728.125, 10627751.5625, 10630557.8125, 10641123.4375, 10651367.1875, 10675053.125, 10748610.9375, 10756817.1875, 10758589.0625, 10762495.3125, 10783350.0, 10797537.5, 10800025.0, 10812206.25, 10817532.8125, 10832257.8125, 10834967.1875, 10841826.5625, 10852417.1875, 10855156.25, 10858048.4375, 10860235.9375, 10866495.3125, 10888182.8125, 10892629.6875, 10892678.125, 10903314.0625, 10906678.125, 10918617.1875, 10918629.6875, 10925448.4375, 10926081.25, 10926300.0, 10926314.0625, 10927725.0, 10934754.6875, 10948617.1875, 10948967.1875, 10950290.625, 10968079.6875, 10970462.5, 10972806.25, 10979342.1875, 10979735.9375, 10982068.75, 10992701.5625, 10998756.25, 10999884.375, 11006445.3125, 11009914.0625, 11018590.625, 11027390.625, 11029470.3125, 11037060.9375, 11037857.8125, 11042618.75, 11053945.3125, 11056982.8125, 11076153.125, 11081657.8125, 11082698.4375, 11083023.4375, 11084250.0, 11089798.4375, 11089800.0, 11089829.6875, 11090715.625, 11106820.3125, 11116671.875, 11187478.125, 11191018.75, 11196620.3125, 11201017.1875, 11210631.25, 11219962.5, 11220079.6875, 11220082.8125, 11226323.4375, 11233603.125, 11239087.5, 11266631.25, 11278192.1875, 11302818.75, 11303190.625, 11319328.125, 11332450.0, 11344160.9375, 11344309.375, 11351606.25, 11356834.375, 11362667.1875, 11362673.4375, 11389162.5, 11389357.8125, 11423425.0, 11425867.1875, 11432215.625, 11446260.9375, 11446328.125, 11462456.25, 11481660.9375, 11482050.0, 11482146.875, 11501378.125, 11531045.3125, 11534817.1875, 11550548.4375, 11571845.3125, 11578215.625, 11587381.25, 11596560.9375, 11604029.6875, 11626940.625, 11628909.375, 11646585.9375, 11652740.625, 11660243.75, 11679825.0, 11685965.625, 11704131.25, 11737890.625, 11743750.0, 11831823.4375, 11889598.4375, 11968398.4375, 11973914.0625, 12015914.0625, 12058895.3125, 12068934.375, 12081190.625, 12084271.875, 12097981.25, 12185910.9375, 12197729.6875, 12217573.4375, 12438070.3125, 12560660.9375, 12639492.1875, 12661300.0, 12698648.4375, 13335090.625, 13357551.5625, 13412295.3125], [75.86018726965703, 7.056848008224574, 66.87720538412911, 15.698907477716908, 5.956691771570146, 13.83743824399155, 100.77156477032675, 116.61267023952311, 70.53327495800013, 15.272231029474904, 21.306846467700566, 21.92892054076549, 60.027474375674814, 11.635416307337659, 94.34251151800393, 28.94443645084793, 13.815628300115828, 26.94518213061678, 50.92575942790441, 16.991452003502793, 21.33901730090103, 5.071383218865692, 18.353735329663444, 24.457183104900707, 73.6856437665765, 25.630693546476277, 36.97443173691895, 10.858556449382371, 19.504320044867434, 14.25870562986098, 18.7901038156499, 5.200932933679213, 30.574281999977906, 22.986514496158065, 115.3612421459965, 21.799203299523775, 34.79511153885396, 10.555992561795158, 11.863065246697861, 20.39763960467439, 16.18920085498347, 10.653870146877228, 15.9593836775901, 15.941681114022284, 12.159460216989958, 50.55825292658857, 56.122756677128734, 5.607023045520955, 40.15707565289411, 50.25498635252087, 70.70980848563536, 23.305448502639013, 20.379030245610874, 21.69220022562367, 9.768872311456521, 16.496423580975105, 32.048532775849395, 5.649681361077376, 103.28316901638294, 15.471426151866854, 29.637989922515892, 75.4038982961189, 33.25087957183156, 38.340791871563724, 32.781910519568385, 7.3367154330115705, 54.46779689023438, 7.154822759731693, 14.069639905056864, 36.72672830644803, 22.221172994955765, 60.2599159056021, 10.025796097735483, 101.55198698565326, 75.79943332946003, 60.449607990203496, 54.82722787711789, 45.685023562199255, 22.89827770013309, 39.19864847339653, 173.59871801749458, 8.27015703158479, 5.401977910790928, 6.211043643898679, 56.83138833153633, 23.773473814840845, 28.384339212192927, 27.536092447147215, 17.984465652522807, 7.65013669872024, 12.580910252467993, 16.39461892512102, 121.1789667218013, 24.498599828210413, 8.489693318456503, 90.88908757802041, 37.218589749244664, 7.389847752898608, 74.78934195073472, 20.814587581169317, 15.431274160479509, 19.973105032560188, 65.97473638554976, 15.649597250599626, 18.864523946038645, 75.31736471817612, 57.95823256021508, 19.490457101576407, 10.60153623508135, 10.937344819103078, 76.04313643068622, 12.193492467833183, 16.06987701996922, 95.33951218859485, 125.53335669211302, 122.33000640608915, 19.222023312671634, 25.042517357438044, 17.252604202979526, 17.335938516969033, 28.245289490254464, 13.893531723482653, 42.025287717310086, 21.549028246128422, 8.277443140146605, 15.645941159474386, 126.1976223725352, 91.0521931832261, 6.274818705454386, 25.45362120907185, 126.39324721860771, 15.597869264124466, 14.942872374327418, 14.91736544526118, 7.915927574563909, 19.356118545369853, 18.793843426554012, 14.818181801080947, 77.37683217706595, 8.67096190007381, 10.179935233066532, 15.377107504356358, 34.899280708311416, 99.28436026139352, 17.342974182328877, 59.98817404381597, 121.59170743312363, 5.8364621508383285, 32.800223392099724, 24.898850328167832, 16.700529214027387, 18.011891263853194, 34.56302729811179, 37.11009958198357, 27.979755927962792, 58.92083061376707, 10.654379257312716, 77.3512437736049, 38.73144177118168, 6.121525465212945, 20.347518797595193, 20.533318419846704, 6.511178209147018, 12.82039413318391, 25.977629442152175, 26.201387603408307, 93.09836480735329, 30.766991225482787, 16.567154782770615, 25.424939571453617, 70.47254318381036, 6.331007774108627, 92.81203311140095, 80.20260682504035, 16.544765513056998, 38.96215940520732, 24.230652235694784, 115.50579767596253, 10.434467378134144, 8.51331946878669, 68.082729131446, 31.107317954113807, 58.36401910884066, 6.3958538545656385, 25.43927919656026, 26.55079416409661, 9.024497091873435, 19.494843196484496, 19.116909021730617, 22.55215465690328, 6.448303670945447, 7.566269046653245, 55.72927699141577, 19.39869963711185, 16.72667900996109, 27.59219144408757, 38.41419788430561, 100.03022598009659, 69.75991444513934, 38.383868675290806, 128.81972395920099, 47.88313242819518, 84.26742466542422, 20.60331192261805, 13.348499557552408, 106.72561634708818, 51.99875880596204, 6.672059334059408, 28.69773555987112, 22.37902226700468, 5.737887521973894, 34.5386605548912, 20.907731011903607, 41.40109277770796, 38.75972377294537, 26.23400195127407, 5.282997114588104, 10.487723938540693, 19.835923834646525, 25.418840864889273, 6.931495377544365, 80.47209392819423, 15.123938763775604, 16.874290829149786, 22.82114632009636, 79.94201989090506, 10.048192646311161, 36.73634389696822, 31.018447329874856, 27.684887934532846, 80.25364910801251, 19.53519442702745, 13.773950448186344, 14.971210161513802, 23.31375460092235, 73.68663431847546, 14.373687433716789, 26.835074131351867, 19.301830774085218, 68.1103028921013, 24.733801353266742, 12.155731016719734, 77.62767501056547, 65.1020353673756, 37.54123432352366, 37.982183899309504, 88.70948370331145, 10.915124211680142, 58.77052345118165, 58.888199138740454, 7.998657417318382, 11.727078473205934, 5.512470421108228, 40.547262528980156, 22.77188654691657, 73.47767373657355, 24.62943686031786, 107.25225260249462, 21.095930447889057, 9.259880848370107, 22.764869251151225, 5.113429014132966, 81.42945236739834, 249.6801743222273, 22.787164689020422, 22.349189318411096, 21.798309383420712, 6.30155404336665, 41.504649239819535, 54.47249008007358, 10.855817961987285, 92.31333941670778, 73.69388284160428, 68.07944187756088, 9.984338091221442, 5.07263160525116, 114.79118163301415, 25.481595149218226, 18.97011927473273, 30.663897563384957, 15.378543591378087, 9.792520561801002, 16.14499364430649, 15.65793830177574, 5.075103383747311, 18.424002646296394, 76.23465245782444, 13.204512231173117, 10.265290476902681, 17.607303169500707, 6.033264353149368, 56.20997821665327, 22.137446697354143, 18.094494382178723, 73.5909507271615, 66.23740286202072, 52.18824671667035, 11.722097555179671, 64.37258252207738, 26.694820345449607, 15.429253631899343, 117.17459126745622, 30.352879454548017, 55.84562757728452, 17.42567150164256, 74.92666766658765, 78.2542060200521, 79.81439120943264, 40.64894113187791, 15.87755506648988, 74.31938658534574, 24.264940583631663, 47.62861316287448, 148.1913181467053, 31.529523378239304, 30.160773214250508, 17.359300580773574, 127.42794490670278, 10.250634241924555, 29.03105457968184, 8.702556793041328, 20.00856205296669, 19.044887361283397, 100.17514765738116, 37.40409948956661])
Detected energies during the discharge + Energy spectrum
multiplot(icon_fig, T_int_first,E,xle,Etot)