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 = 44425
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);
([6856478.125, 6867804.6875, 6965815.625, 7595515.625, 7731400.0, 7754934.375, 7777234.375, 7792050.0, 7844835.9375, 7845384.375, 7860287.5, 7860289.0625, 7902785.9375, 7916137.5, 7921164.0625, 7921993.75, 7925037.5, 7949015.625, 7986017.1875, 7988895.3125, 7990645.3125, 8019998.4375, 8027542.1875, 8028601.5625, 8030759.375, 8036970.3125, 8039045.3125, 8043692.1875, 8078804.6875, 8078831.25, 8080679.6875, 8080690.625, 8080823.4375, 8102985.9375, 8103182.8125, 8106851.5625, 8136715.625, 8138678.125, 8145839.0625, 8152154.6875, 8161337.5, 8172164.0625, 8172171.875, 8172187.5, 8183639.0625, 8228507.8125, 8230718.75, 8232004.6875, 8233046.875, 8233446.875, 8234835.9375, 8239326.5625, 8239340.625, 8245034.375, 8246929.6875, 8272481.25, 8293639.0625, 8295056.25, 8296981.25, 8330160.9375, 8330164.0625, 8351701.5625, 8358415.625, 8360264.0625, 8360343.75, 8361531.25, 8362225.0, 8367057.8125, 8376328.125, 8388028.125, 8402179.6875, 8420879.6875, 8457168.75, 8479400.0, 8480248.4375, 8509685.9375, 8525218.75, 8528878.125, 8531335.9375, 8535954.6875, 8539750.0, 8556070.3125, 8566771.875, 8566825.0, 8589864.0625, 8591756.25, 8592234.375, 8630778.125, 8633885.9375, 8635028.125, 8637531.25, 8660753.125, 8661070.3125, 8666185.9375, 8669081.25, 8676981.25, 8681496.875, 8719221.875, 8719231.25, 8768017.1875, 8769012.5, 8771342.1875, 8773923.4375, 8774250.0, 8778876.5625, 8779362.5, 8786662.5, 8786729.6875, 8786732.8125, 8788692.1875, 8808087.5, 8813134.375, 8819245.3125, 8841109.375, 8848892.1875, 8850932.8125, 8852164.0625, 8864687.5, 8876826.5625, 8890948.4375, 8890951.5625, 8893457.8125, 8893851.5625, 8893868.75, 8896418.75, 8901164.0625, 8901892.1875, 8905573.4375, 8907292.1875, 8910328.125, 8915112.5, 8934243.75, 8960271.875, 8963051.5625, 8964432.8125, 8966828.125, 8971478.125, 8972600.0, 8973912.5, 8974204.6875, 8979001.5625, 8988062.5, 8988073.4375, 8988990.625, 8990639.0625, 9009103.125, 9011050.0, 9011235.9375, 9012400.0, 9012551.5625, 9044628.125, 9045039.0625, 9045842.1875, 9047367.1875, 9049343.75, 9049723.4375, 9052064.0625, 9052223.4375, 9052276.5625, 9061076.5625, 9072717.1875, 9083110.9375, 9083689.0625, 9084412.5, 9085040.625, 9085242.1875, 9086590.625, 9086707.8125, 9086845.3125, 9088785.9375, 9090164.0625, 9091721.875, 9092067.1875, 9111037.5, 9122014.0625, 9122204.6875, 9122779.6875, 9126559.375, 9148692.1875, 9164518.75, 9167742.1875, 9167771.875, 9173492.1875, 9180881.25, 9233404.6875, 9237426.5625, 9240067.1875, 9240087.5, 9259278.125, 9280760.9375, 9288998.4375, 9299800.0, 9304256.25, 9304945.3125, 9307054.6875, 9307115.625, 9308648.4375, 9309128.125, 9312359.375, 9312550.0, 9315989.0625, 9317031.25, 9331923.4375, 9337496.875, 9353179.6875, 9354771.875, 9361815.625, 9363039.0625, 9392139.0625, 9414815.625, 9421542.1875, 9451926.5625, 9458014.0625, 9460357.8125, 9461521.875, 9462142.1875, 9474523.4375, 9510189.0625, 9511459.375, 9512796.875, 9540051.5625, 9542842.1875, 9547056.25, 9547409.375, 9549121.875, 9549395.3125, 9549835.9375, 9550114.0625, 9550521.875, 9551107.8125, 9553235.9375, 9570695.3125, 9572692.1875, 9579915.625, 9582417.1875, 9584107.8125, 9586323.4375, 9587068.75, 9608812.5, 9618478.125, 9618517.1875, 9619135.9375, 9635645.3125, 9775050.0, 9805932.8125, 9807646.875, 9983214.0625, 10273057.8125, 10276978.125, 10290579.6875, 10309939.0625, 10311246.875, 10311300.0, 10311489.0625, 10311578.125, 10336748.4375, 10344457.8125, 10375412.5, 10401542.1875, 10409095.3125, 10409989.0625, 10411781.25, 10416621.875, 10420207.8125, 10420262.5, 10562553.125, 10570112.5, 10633623.4375, 10635214.0625, 11099389.0625, 11207303.125, 11255789.0625, 323333342.1875], [23.09088607893333, 19.3439676783111, 73.57871318817703, 6.008949552800621, 110.62770042365892, 5.228682915769502, 33.18710853749953, 17.841888235832556, 10.995020781708424, 25.104264712832652, 13.193851432516801, 11.129180386223902, 68.9224299783567, 119.41140810422758, 65.79878739040662, 99.18191491300001, 20.92648506070238, 184.5177734035084, 42.56305218308973, 84.2569834968389, 21.744860010459334, 32.940199715402635, 76.10813277620477, 16.368516750719518, 14.75415164754775, 27.840419025082447, 24.867742425979696, 164.69206397509302, 71.88933764171398, 21.590234680426686, 17.193705170986956, 43.60993693253131, 24.987996519986687, 84.75151280379492, 28.718266799692373, 24.2484185414952, 15.077012710554193, 6.91900253546227, 35.066478617317046, 68.86737458586609, 46.4215733123197, 84.47580183058281, 13.018994696480183, 15.799538938319357, 136.55069097037293, 34.03110994169995, 26.62961748991006, 20.318002048321567, 6.099791244004699, 66.58886330334553, 204.81529135354273, 88.06405619090647, 112.47832989126982, 30.220904596206832, 5.5025537879930875, 75.21828779747337, 26.783125568785643, 27.660223585642278, 75.27143790901586, 10.416886431804986, 65.6952787479086, 14.224322734335633, 17.420374027591656, 71.09160480365088, 51.33065014480772, 52.27154250611991, 35.30339933465013, 11.03221260540057, 160.57353666868576, 79.16633450285389, 97.69124263907013, 22.364971529545493, 260.5814403135662, 6.110425889923384, 118.67640082153372, 25.143117919426007, 132.757653515104, 91.72305881820927, 145.88057496914857, 67.26342623131171, 56.814777644076806, 8.19860394301721, 16.414803528674877, 5.395705710769181, 15.398464889010189, 12.696078200264918, 58.966189739474615, 26.60386546395698, 72.4504443393338, 23.2771539928334, 114.60860219103795, 25.656080452232363, 36.63248674718507, 20.530270906740913, 70.72716615770908, 20.585667591855618, 26.508100816273497, 95.4439351289416, 21.33684455463171, 10.109484806037873, 27.736180016325964, 11.552578229412731, 51.52936511711073, 109.43564323252478, 7.489109937854234, 10.644793296165183, 6.232045434154875, 34.683390257272876, 22.989927695872417, 62.52000947257372, 30.06297164985601, 74.218033375645, 108.6010130188688, 26.067197544562767, 81.16512350497965, 71.34008898843351, 8.258081032126364, 50.0784216822352, 18.759736378223007, 150.93097629563175, 55.35903582586742, 32.89598316170399, 44.38111836236544, 43.45207914509104, 19.487926490740847, 44.5731635761771, 27.42171857623031, 27.75125593743037, 34.002484595436414, 53.33245135031471, 7.250713852107464, 9.907590337111982, 48.2993126097717, 9.077571481218568, 61.626687625011606, 32.05412279949106, 103.04894747071805, 24.47754512862522, 105.48521367739905, 10.01724800767968, 30.1066779012735, 23.03722054355883, 13.531889906167525, 209.8951845995675, 80.97488823949567, 23.212839473147362, 17.767184142283963, 20.616856240261, 96.68476224029962, 5.118348673061259, 61.064623892757254, 12.921867804452452, 117.93211032006897, 62.829226871497426, 128.4490999419832, 56.30349100994586, 22.22040886073934, 19.885460772992968, 5.879983226596867, 52.83112215827224, 6.014936693878156, 76.39768324797205, 100.64885332558637, 139.45140342134965, 35.03270693713265, 11.735737041467162, 12.343558347730578, 16.86190092930421, 23.334011025393842, 84.30279452636819, 45.72152303223071, 192.85340465748314, 20.525364248146868, 29.971167532557878, 138.70007445929878, 118.48112266413271, 50.48464964850978, 18.847766405038954, 10.895240535774144, 40.95278998576894, 61.789295996282476, 45.40211353940856, 22.0953582373284, 91.19744488206568, 81.7618447251198, 10.202663859923659, 103.91051414228693, 31.475064923243863, 7.31947264427269, 29.600668443734723, 83.46164824943989, 23.01651845412031, 188.77493421497638, 36.56988588133127, 101.13234742886554, 5.886406331503017, 23.43249106226837, 101.95442849259597, 22.766136554318, 58.34514630408759, 73.95993870240564, 59.47938116256129, 13.76663394330341, 17.347650181458466, 25.381208214443888, 113.95669927197108, 84.20490356167703, 11.342593896933007, 118.0431792862484, 21.449789026172606, 88.56885573890303, 52.64333132139797, 43.09097978378045, 53.71937111996523, 58.315015046200344, 26.037778042155555, 71.15177801434534, 42.6042461377013, 28.616665046940188, 49.771360825596304, 13.923373517026683, 29.47149656210217, 94.72425318022118, 8.19579995636307, 8.470143734809849, 11.843251916205267, 19.715963557392755, 67.01294351875072, 49.00036215095503, 24.043687249998904, 15.993406613643781, 9.727235240989225, 17.438021177623725, 71.78033029501053, 8.555910264160191, 7.836201424382587, 60.13504445069866, 42.20579105021795, 73.87481639121083, 78.60743249931642, 16.206767958237176, 32.73521194412466, 38.90606652749951, 68.92503478041769, 64.44494841113838, 67.95285697630635, 16.365259718969362, 56.644681559788225, 46.17861408273316, 37.388647719004275, 71.87929318182226, 25.224051128631533, 91.73572127790412, 38.807523258874795, 5.34272622074612, 32.98407950125647, 17.877162530956806, 19.850215436871697, 8.36950234994073, 39.376685676902, 12.205968145320583, 105.8112276526972, 52.854905226695635, 106.78815883731569, 6.009930000728329, 76.04386840028069, 92.067695643578, 95.28770821760895, 6.595394372931474, 16.314996817140695, 8.108331253632825, 5.285553545426673, 224.08764728221965])
caption, xmean,count, xle, Etot = energy_spectrum(E_tot)
hist_file(E_hist, xmean, count, caption);
([6856478.125, 6867804.6875, 6965815.625, 7595515.625, 7731400.0, 7754934.375, 7777234.375, 7792050.0, 7844835.9375, 7845384.375, 7860287.5, 7860289.0625, 7902785.9375, 7916137.5, 7921164.0625, 7921993.75, 7925037.5, 7949015.625, 7986017.1875, 7988895.3125, 7990645.3125, 8019998.4375, 8027542.1875, 8028601.5625, 8030759.375, 8036970.3125, 8039045.3125, 8043692.1875, 8078804.6875, 8078831.25, 8080679.6875, 8080690.625, 8080823.4375, 8102985.9375, 8103182.8125, 8106851.5625, 8136715.625, 8138678.125, 8145839.0625, 8152154.6875, 8161337.5, 8172164.0625, 8172171.875, 8172187.5, 8183639.0625, 8228507.8125, 8230718.75, 8232004.6875, 8233046.875, 8233446.875, 8234835.9375, 8239326.5625, 8239340.625, 8245034.375, 8246929.6875, 8272481.25, 8293639.0625, 8295056.25, 8296981.25, 8330160.9375, 8330164.0625, 8351701.5625, 8358415.625, 8360264.0625, 8360343.75, 8361531.25, 8362225.0, 8367057.8125, 8376328.125, 8388028.125, 8402179.6875, 8420879.6875, 8457168.75, 8479400.0, 8480248.4375, 8509685.9375, 8525218.75, 8528878.125, 8531335.9375, 8535954.6875, 8539750.0, 8556070.3125, 8566771.875, 8566825.0, 8589864.0625, 8591756.25, 8592234.375, 8630778.125, 8633885.9375, 8635028.125, 8637531.25, 8660753.125, 8661070.3125, 8666185.9375, 8669081.25, 8676981.25, 8681496.875, 8719221.875, 8719231.25, 8768017.1875, 8769012.5, 8771342.1875, 8773923.4375, 8774250.0, 8778876.5625, 8779362.5, 8786662.5, 8786729.6875, 8786732.8125, 8788692.1875, 8808087.5, 8813134.375, 8819245.3125, 8841109.375, 8848892.1875, 8850932.8125, 8852164.0625, 8864687.5, 8876826.5625, 8890948.4375, 8890951.5625, 8893457.8125, 8893851.5625, 8893868.75, 8896418.75, 8901164.0625, 8901892.1875, 8905573.4375, 8907292.1875, 8910328.125, 8915112.5, 8934243.75, 8960271.875, 8963051.5625, 8964432.8125, 8966828.125, 8971478.125, 8972600.0, 8973912.5, 8974204.6875, 8979001.5625, 8988062.5, 8988073.4375, 8988990.625, 8990639.0625, 9009103.125, 9011050.0, 9011235.9375, 9012400.0, 9012551.5625, 9044628.125, 9045039.0625, 9045842.1875, 9047367.1875, 9049343.75, 9049723.4375, 9052064.0625, 9052223.4375, 9052276.5625, 9061076.5625, 9072717.1875, 9083110.9375, 9083689.0625, 9084412.5, 9085040.625, 9085242.1875, 9086590.625, 9086707.8125, 9086845.3125, 9088785.9375, 9090164.0625, 9091721.875, 9092067.1875, 9111037.5, 9122014.0625, 9122204.6875, 9122779.6875, 9126559.375, 9148692.1875, 9164518.75, 9167742.1875, 9167771.875, 9173492.1875, 9180881.25, 9233404.6875, 9237426.5625, 9240067.1875, 9240087.5, 9259278.125, 9280760.9375, 9288998.4375, 9299800.0, 9304256.25, 9304945.3125, 9307054.6875, 9307115.625, 9308648.4375, 9309128.125, 9312359.375, 9312550.0, 9315989.0625, 9317031.25, 9331923.4375, 9337496.875, 9353179.6875, 9354771.875, 9361815.625, 9363039.0625, 9392139.0625, 9414815.625, 9421542.1875, 9451926.5625, 9458014.0625, 9460357.8125, 9461521.875, 9462142.1875, 9474523.4375, 9510189.0625, 9511459.375, 9512796.875, 9540051.5625, 9542842.1875, 9547056.25, 9547409.375, 9549121.875, 9549395.3125, 9549835.9375, 9550114.0625, 9550521.875, 9551107.8125, 9553235.9375, 9570695.3125, 9572692.1875, 9579915.625, 9582417.1875, 9584107.8125, 9586323.4375, 9587068.75, 9608812.5, 9618478.125, 9618517.1875, 9619135.9375, 9635645.3125, 9775050.0, 9805932.8125, 9807646.875, 9983214.0625, 10273057.8125, 10276978.125, 10290579.6875, 10309939.0625, 10311246.875, 10311300.0, 10311489.0625, 10311578.125, 10336748.4375, 10344457.8125, 10375412.5, 10401542.1875, 10409095.3125, 10409989.0625, 10411781.25, 10416621.875, 10420207.8125, 10420262.5, 10562553.125, 10570112.5, 10633623.4375, 10635214.0625, 11099389.0625, 11207303.125, 11255789.0625, 323333342.1875], [23.09088607893333, 19.3439676783111, 73.57871318817703, 6.008949552800621, 110.62770042365892, 5.228682915769502, 33.18710853749953, 17.841888235832556, 10.995020781708424, 25.104264712832652, 13.193851432516801, 11.129180386223902, 68.9224299783567, 119.41140810422758, 65.79878739040662, 99.18191491300001, 20.92648506070238, 184.5177734035084, 42.56305218308973, 84.2569834968389, 21.744860010459334, 32.940199715402635, 76.10813277620477, 16.368516750719518, 14.75415164754775, 27.840419025082447, 24.867742425979696, 164.69206397509302, 71.88933764171398, 21.590234680426686, 17.193705170986956, 43.60993693253131, 24.987996519986687, 84.75151280379492, 28.718266799692373, 24.2484185414952, 15.077012710554193, 6.91900253546227, 35.066478617317046, 68.86737458586609, 46.4215733123197, 84.47580183058281, 13.018994696480183, 15.799538938319357, 136.55069097037293, 34.03110994169995, 26.62961748991006, 20.318002048321567, 6.099791244004699, 66.58886330334553, 204.81529135354273, 88.06405619090647, 112.47832989126982, 30.220904596206832, 5.5025537879930875, 75.21828779747337, 26.783125568785643, 27.660223585642278, 75.27143790901586, 10.416886431804986, 65.6952787479086, 14.224322734335633, 17.420374027591656, 71.09160480365088, 51.33065014480772, 52.27154250611991, 35.30339933465013, 11.03221260540057, 160.57353666868576, 79.16633450285389, 97.69124263907013, 22.364971529545493, 260.5814403135662, 6.110425889923384, 118.67640082153372, 25.143117919426007, 132.757653515104, 91.72305881820927, 145.88057496914857, 67.26342623131171, 56.814777644076806, 8.19860394301721, 16.414803528674877, 5.395705710769181, 15.398464889010189, 12.696078200264918, 58.966189739474615, 26.60386546395698, 72.4504443393338, 23.2771539928334, 114.60860219103795, 25.656080452232363, 36.63248674718507, 20.530270906740913, 70.72716615770908, 20.585667591855618, 26.508100816273497, 95.4439351289416, 21.33684455463171, 10.109484806037873, 27.736180016325964, 11.552578229412731, 51.52936511711073, 109.43564323252478, 7.489109937854234, 10.644793296165183, 6.232045434154875, 34.683390257272876, 22.989927695872417, 62.52000947257372, 30.06297164985601, 74.218033375645, 108.6010130188688, 26.067197544562767, 81.16512350497965, 71.34008898843351, 8.258081032126364, 50.0784216822352, 18.759736378223007, 150.93097629563175, 55.35903582586742, 32.89598316170399, 44.38111836236544, 43.45207914509104, 19.487926490740847, 44.5731635761771, 27.42171857623031, 27.75125593743037, 34.002484595436414, 53.33245135031471, 7.250713852107464, 9.907590337111982, 48.2993126097717, 9.077571481218568, 61.626687625011606, 32.05412279949106, 103.04894747071805, 24.47754512862522, 105.48521367739905, 10.01724800767968, 30.1066779012735, 23.03722054355883, 13.531889906167525, 209.8951845995675, 80.97488823949567, 23.212839473147362, 17.767184142283963, 20.616856240261, 96.68476224029962, 5.118348673061259, 61.064623892757254, 12.921867804452452, 117.93211032006897, 62.829226871497426, 128.4490999419832, 56.30349100994586, 22.22040886073934, 19.885460772992968, 5.879983226596867, 52.83112215827224, 6.014936693878156, 76.39768324797205, 100.64885332558637, 139.45140342134965, 35.03270693713265, 11.735737041467162, 12.343558347730578, 16.86190092930421, 23.334011025393842, 84.30279452636819, 45.72152303223071, 192.85340465748314, 20.525364248146868, 29.971167532557878, 138.70007445929878, 118.48112266413271, 50.48464964850978, 18.847766405038954, 10.895240535774144, 40.95278998576894, 61.789295996282476, 45.40211353940856, 22.0953582373284, 91.19744488206568, 81.7618447251198, 10.202663859923659, 103.91051414228693, 31.475064923243863, 7.31947264427269, 29.600668443734723, 83.46164824943989, 23.01651845412031, 188.77493421497638, 36.56988588133127, 101.13234742886554, 5.886406331503017, 23.43249106226837, 101.95442849259597, 22.766136554318, 58.34514630408759, 73.95993870240564, 59.47938116256129, 13.76663394330341, 17.347650181458466, 25.381208214443888, 113.95669927197108, 84.20490356167703, 11.342593896933007, 118.0431792862484, 21.449789026172606, 88.56885573890303, 52.64333132139797, 43.09097978378045, 53.71937111996523, 58.315015046200344, 26.037778042155555, 71.15177801434534, 42.6042461377013, 28.616665046940188, 49.771360825596304, 13.923373517026683, 29.47149656210217, 94.72425318022118, 8.19579995636307, 8.470143734809849, 11.843251916205267, 19.715963557392755, 67.01294351875072, 49.00036215095503, 24.043687249998904, 15.993406613643781, 9.727235240989225, 17.438021177623725, 71.78033029501053, 8.555910264160191, 7.836201424382587, 60.13504445069866, 42.20579105021795, 73.87481639121083, 78.60743249931642, 16.206767958237176, 32.73521194412466, 38.90606652749951, 68.92503478041769, 64.44494841113838, 67.95285697630635, 16.365259718969362, 56.644681559788225, 46.17861408273316, 37.388647719004275, 71.87929318182226, 25.224051128631533, 91.73572127790412, 38.807523258874795, 5.34272622074612, 32.98407950125647, 17.877162530956806, 19.850215436871697, 8.36950234994073, 39.376685676902, 12.205968145320583, 105.8112276526972, 52.854905226695635, 106.78815883731569, 6.009930000728329, 76.04386840028069, 92.067695643578, 95.28770821760895, 6.595394372931474, 16.314996817140695, 8.108331253632825, 5.285553545426673, 224.08764728221965])
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);
([6856478.125, 6867804.6875, 6965815.625, 7595515.625, 7731400.0, 7754934.375, 7777234.375, 7792050.0, 7844835.9375, 7845384.375, 7860287.5, 7860289.0625, 7902785.9375, 7916137.5, 7921164.0625, 7921993.75, 7925037.5, 7949015.625, 7986017.1875, 7988895.3125, 7990645.3125, 8019998.4375, 8027542.1875, 8028601.5625, 8030759.375, 8036970.3125, 8039045.3125, 8043692.1875, 8078804.6875, 8078831.25, 8080679.6875, 8080690.625, 8080823.4375, 8102985.9375, 8103182.8125, 8106851.5625, 8136715.625, 8138678.125, 8145839.0625, 8152154.6875, 8161337.5, 8172164.0625, 8172171.875, 8172187.5, 8183639.0625, 8228507.8125, 8230718.75, 8232004.6875, 8233046.875, 8233446.875, 8234835.9375, 8239326.5625, 8239340.625, 8245034.375, 8246929.6875, 8272481.25, 8293639.0625, 8295056.25, 8296981.25, 8330160.9375, 8330164.0625, 8351701.5625, 8358415.625, 8360264.0625, 8360343.75, 8361531.25, 8362225.0, 8367057.8125, 8376328.125, 8388028.125, 8402179.6875, 8420879.6875, 8457168.75, 8479400.0, 8480248.4375, 8509685.9375, 8525218.75, 8528878.125, 8531335.9375, 8535954.6875, 8539750.0, 8556070.3125, 8566771.875, 8566825.0, 8589864.0625, 8591756.25, 8592234.375, 8630778.125, 8633885.9375, 8635028.125, 8637531.25, 8660753.125, 8661070.3125, 8666185.9375, 8669081.25, 8676981.25, 8681496.875, 8719221.875, 8719231.25, 8768017.1875, 8769012.5, 8771342.1875, 8773923.4375, 8774250.0, 8778876.5625, 8779362.5, 8786662.5, 8786729.6875, 8786732.8125, 8788692.1875, 8808087.5, 8813134.375, 8819245.3125, 8841109.375, 8848892.1875, 8850932.8125, 8852164.0625, 8864687.5, 8876826.5625, 8890948.4375, 8890951.5625, 8893457.8125, 8893851.5625, 8893868.75, 8896418.75, 8901164.0625, 8901892.1875, 8905573.4375, 8907292.1875, 8910328.125, 8915112.5, 8934243.75, 8960271.875, 8963051.5625, 8964432.8125, 8966828.125, 8971478.125, 8972600.0, 8973912.5, 8974204.6875, 8979001.5625, 8988062.5, 8988073.4375, 8988990.625, 8990639.0625, 9009103.125, 9011050.0, 9011235.9375, 9012400.0, 9012551.5625, 9044628.125, 9045039.0625, 9045842.1875, 9047367.1875, 9049343.75, 9049723.4375, 9052064.0625, 9052223.4375, 9052276.5625, 9061076.5625, 9072717.1875, 9083110.9375, 9083689.0625, 9084412.5, 9085040.625, 9085242.1875, 9086590.625, 9086707.8125, 9086845.3125, 9088785.9375, 9090164.0625, 9091721.875, 9092067.1875, 9111037.5, 9122014.0625, 9122204.6875, 9122779.6875, 9126559.375, 9148692.1875, 9164518.75, 9167742.1875, 9167771.875, 9173492.1875, 9180881.25, 9233404.6875, 9237426.5625, 9240067.1875, 9240087.5, 9259278.125, 9280760.9375, 9288998.4375, 9299800.0, 9304256.25, 9304945.3125, 9307054.6875, 9307115.625, 9308648.4375, 9309128.125, 9312359.375, 9312550.0, 9315989.0625, 9317031.25, 9331923.4375, 9337496.875, 9353179.6875, 9354771.875, 9361815.625, 9363039.0625, 9392139.0625, 9414815.625, 9421542.1875, 9451926.5625, 9458014.0625, 9460357.8125, 9461521.875, 9462142.1875, 9474523.4375, 9510189.0625, 9511459.375, 9512796.875, 9540051.5625, 9542842.1875, 9547056.25, 9547409.375, 9549121.875, 9549395.3125, 9549835.9375, 9550114.0625, 9550521.875, 9551107.8125, 9553235.9375, 9570695.3125, 9572692.1875, 9579915.625, 9582417.1875, 9584107.8125, 9586323.4375, 9587068.75, 9608812.5, 9618478.125, 9618517.1875, 9619135.9375, 9635645.3125, 9775050.0, 9805932.8125, 9807646.875, 9983214.0625, 10273057.8125, 10276978.125, 10290579.6875, 10309939.0625, 10311246.875, 10311300.0, 10311489.0625, 10311578.125, 10336748.4375, 10344457.8125, 10375412.5, 10401542.1875, 10409095.3125, 10409989.0625, 10411781.25, 10416621.875, 10420207.8125, 10420262.5, 10562553.125, 10570112.5, 10633623.4375, 10635214.0625, 11099389.0625, 11207303.125, 11255789.0625, 323333342.1875], [23.09088607893333, 19.3439676783111, 73.57871318817703, 6.008949552800621, 110.62770042365892, 5.228682915769502, 33.18710853749953, 17.841888235832556, 10.995020781708424, 25.104264712832652, 13.193851432516801, 11.129180386223902, 68.9224299783567, 119.41140810422758, 65.79878739040662, 99.18191491300001, 20.92648506070238, 184.5177734035084, 42.56305218308973, 84.2569834968389, 21.744860010459334, 32.940199715402635, 76.10813277620477, 16.368516750719518, 14.75415164754775, 27.840419025082447, 24.867742425979696, 164.69206397509302, 71.88933764171398, 21.590234680426686, 17.193705170986956, 43.60993693253131, 24.987996519986687, 84.75151280379492, 28.718266799692373, 24.2484185414952, 15.077012710554193, 6.91900253546227, 35.066478617317046, 68.86737458586609, 46.4215733123197, 84.47580183058281, 13.018994696480183, 15.799538938319357, 136.55069097037293, 34.03110994169995, 26.62961748991006, 20.318002048321567, 6.099791244004699, 66.58886330334553, 204.81529135354273, 88.06405619090647, 112.47832989126982, 30.220904596206832, 5.5025537879930875, 75.21828779747337, 26.783125568785643, 27.660223585642278, 75.27143790901586, 10.416886431804986, 65.6952787479086, 14.224322734335633, 17.420374027591656, 71.09160480365088, 51.33065014480772, 52.27154250611991, 35.30339933465013, 11.03221260540057, 160.57353666868576, 79.16633450285389, 97.69124263907013, 22.364971529545493, 260.5814403135662, 6.110425889923384, 118.67640082153372, 25.143117919426007, 132.757653515104, 91.72305881820927, 145.88057496914857, 67.26342623131171, 56.814777644076806, 8.19860394301721, 16.414803528674877, 5.395705710769181, 15.398464889010189, 12.696078200264918, 58.966189739474615, 26.60386546395698, 72.4504443393338, 23.2771539928334, 114.60860219103795, 25.656080452232363, 36.63248674718507, 20.530270906740913, 70.72716615770908, 20.585667591855618, 26.508100816273497, 95.4439351289416, 21.33684455463171, 10.109484806037873, 27.736180016325964, 11.552578229412731, 51.52936511711073, 109.43564323252478, 7.489109937854234, 10.644793296165183, 6.232045434154875, 34.683390257272876, 22.989927695872417, 62.52000947257372, 30.06297164985601, 74.218033375645, 108.6010130188688, 26.067197544562767, 81.16512350497965, 71.34008898843351, 8.258081032126364, 50.0784216822352, 18.759736378223007, 150.93097629563175, 55.35903582586742, 32.89598316170399, 44.38111836236544, 43.45207914509104, 19.487926490740847, 44.5731635761771, 27.42171857623031, 27.75125593743037, 34.002484595436414, 53.33245135031471, 7.250713852107464, 9.907590337111982, 48.2993126097717, 9.077571481218568, 61.626687625011606, 32.05412279949106, 103.04894747071805, 24.47754512862522, 105.48521367739905, 10.01724800767968, 30.1066779012735, 23.03722054355883, 13.531889906167525, 209.8951845995675, 80.97488823949567, 23.212839473147362, 17.767184142283963, 20.616856240261, 96.68476224029962, 5.118348673061259, 61.064623892757254, 12.921867804452452, 117.93211032006897, 62.829226871497426, 128.4490999419832, 56.30349100994586, 22.22040886073934, 19.885460772992968, 5.879983226596867, 52.83112215827224, 6.014936693878156, 76.39768324797205, 100.64885332558637, 139.45140342134965, 35.03270693713265, 11.735737041467162, 12.343558347730578, 16.86190092930421, 23.334011025393842, 84.30279452636819, 45.72152303223071, 192.85340465748314, 20.525364248146868, 29.971167532557878, 138.70007445929878, 118.48112266413271, 50.48464964850978, 18.847766405038954, 10.895240535774144, 40.95278998576894, 61.789295996282476, 45.40211353940856, 22.0953582373284, 91.19744488206568, 81.7618447251198, 10.202663859923659, 103.91051414228693, 31.475064923243863, 7.31947264427269, 29.600668443734723, 83.46164824943989, 23.01651845412031, 188.77493421497638, 36.56988588133127, 101.13234742886554, 5.886406331503017, 23.43249106226837, 101.95442849259597, 22.766136554318, 58.34514630408759, 73.95993870240564, 59.47938116256129, 13.76663394330341, 17.347650181458466, 25.381208214443888, 113.95669927197108, 84.20490356167703, 11.342593896933007, 118.0431792862484, 21.449789026172606, 88.56885573890303, 52.64333132139797, 43.09097978378045, 53.71937111996523, 58.315015046200344, 26.037778042155555, 71.15177801434534, 42.6042461377013, 28.616665046940188, 49.771360825596304, 13.923373517026683, 29.47149656210217, 94.72425318022118, 8.19579995636307, 8.470143734809849, 11.843251916205267, 19.715963557392755, 67.01294351875072, 49.00036215095503, 24.043687249998904, 15.993406613643781, 9.727235240989225, 17.438021177623725, 71.78033029501053, 8.555910264160191, 7.836201424382587, 60.13504445069866, 42.20579105021795, 73.87481639121083, 78.60743249931642, 16.206767958237176, 32.73521194412466, 38.90606652749951, 68.92503478041769, 64.44494841113838, 67.95285697630635, 16.365259718969362, 56.644681559788225, 46.17861408273316, 37.388647719004275, 71.87929318182226, 25.224051128631533, 91.73572127790412, 38.807523258874795, 5.34272622074612, 32.98407950125647, 17.877162530956806, 19.850215436871697, 8.36950234994073, 39.376685676902, 12.205968145320583, 105.8112276526972, 52.854905226695635, 106.78815883731569, 6.009930000728329, 76.04386840028069, 92.067695643578, 95.28770821760895, 6.595394372931474, 16.314996817140695, 8.108331253632825, 5.285553545426673, 224.08764728221965])
Detected energies during the discharge + Energy spectrum
multiplot(icon_fig, T_int_first,E,xle,Etot)