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 = 44506
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);
([6290023.4375, 6290448.4375, 6359807.8125, 6361557.8125, 6370353.125, 6420460.9375, 6527839.0625, 6553268.75, 6553587.5, 6601257.8125, 6608748.4375, 6608882.8125, 6609040.625, 6609654.6875, 6633142.1875, 6704865.625, 6708254.6875, 6709690.625, 6710095.3125, 6710693.75, 6735215.625, 6741990.625, 6742750.0, 6756198.4375, 6756203.125, 6756212.5, 6793275.0, 6794398.4375, 6799298.4375, 6799478.125, 6802312.5, 6809620.3125, 6850687.5, 6888515.625, 6890753.125, 6893782.8125, 6893865.625, 6900818.75, 6924139.0625, 6928817.1875, 6930531.25, 6931715.625, 6938595.3125, 6965010.9375, 6968395.3125, 6990468.75, 6990504.6875, 7012562.5, 7013856.25, 7014578.125, 7017248.4375, 7061271.875, 7099342.1875, 7100112.5, 7117554.6875, 7126221.875, 7126732.8125, 7128895.3125, 7129337.5, 7203079.6875, 7210470.3125, 7305618.75, 7663520.3125, 7737573.4375, 7738267.1875, 7760740.625, 7763465.625, 8012203.125, 8012625.0, 8082640.625, 8104521.875, 8168232.8125, 8173409.375, 8245520.3125, 8597253.125, 9982134.375, 9982692.1875, 9983473.4375, 9984271.875, 9984735.9375, 9985875.0, 9987667.1875, 9987846.875, 9988148.4375, 9989173.4375, 9991156.25, 9991156.25, 9992348.4375, 9992554.6875, 9992976.5625, 9993007.8125, 9994735.9375, 9994925.0, 9996157.8125, 10007557.8125, 10014228.125, 10120687.5, 10131071.875, 10135439.0625, 10135681.25, 10135690.625, 10138578.125, 10139204.6875, 10139231.25, 10142132.8125, 10142448.4375, 10142521.875, 10142529.6875, 10142535.9375, 10142768.75, 10142823.4375, 10143164.0625, 10143190.625, 10143400.0, 10143426.5625, 10143432.8125, 10143440.625, 10143454.6875, 10143470.3125, 10143471.875, 10143512.5, 10143621.875, 10143673.4375, 10143725.0, 10143737.5, 10143832.8125, 10143837.5, 10143856.25, 10143892.1875, 10143942.1875, 10143950.0, 10143960.9375, 10144035.9375, 10144046.875, 10144051.5625, 10144054.6875, 10144060.9375, 10144115.625, 10144131.25, 10144195.3125, 10144218.75, 10144257.8125, 10144289.0625, 10144351.5625, 10144359.375, 10144421.875, 10144565.625, 10144659.375, 10144673.4375, 10145095.3125, 10145129.6875, 10145140.625, 10145142.1875, 10145214.0625, 10145385.9375, 10145871.875, 10145929.6875, 10146435.9375, 10146632.8125, 10146798.4375, 10146884.375, 10147020.3125, 10147073.4375, 10147181.25, 10147300.0, 10147442.1875, 10148298.4375, 10148412.5, 10148589.0625, 10148765.625, 10149412.5, 10149723.4375, 10149746.875, 10149765.625, 10149796.875, 10149812.5, 10149900.0, 10150192.1875, 10150554.6875, 10150704.6875, 10151085.9375, 10151731.25, 10151795.3125, 10151857.8125, 10152298.4375, 10153479.6875, 10153592.1875, 10154307.8125, 10155135.9375, 10155300.0, 10156289.0625, 10156837.5, 10157643.75, 10158893.75, 10160260.9375, 10163384.375, 10164745.3125, 10166859.375, 10167929.6875, 10168873.4375, 10170595.3125, 10170678.125, 10172100.0, 10172464.0625, 10173040.625, 10173918.75, 10175704.6875, 10175743.75, 10176001.5625, 10176818.75, 10178915.625, 10179170.3125, 10180550.0, 10181428.125, 10181610.9375, 10181898.4375, 10183603.125, 10183668.75, 10183704.6875, 10189218.75, 10189948.4375, 10193025.0], [9.766316744419898, 5.251516442974003, 69.55512749376862, 49.00643740823214, 43.664766058631834, 21.584428918514433, 78.58734177593003, 74.09175066249496, 22.272412200265787, 26.510499581046474, 11.867819432620863, 21.767325038693144, 35.42152674643406, 61.86492684912672, 49.04633145412035, 15.41623644650278, 7.906359906766605, 72.88078314884376, 29.673093017192514, 38.51044657700519, 148.02449669224688, 133.3021501836184, 35.181107607341794, 132.4283506732665, 48.40964467256184, 14.48500528677138, 61.73129913318913, 36.17621704621773, 12.96958897335559, 6.146274176373145, 97.2223272850807, 71.93684821104652, 20.721714784965542, 31.139932559703656, 12.008854686299957, 18.245223232239496, 5.039677075436522, 33.0941531862099, 66.58475347340202, 89.90078491513881, 12.149677935076443, 17.702075100635696, 358.97887786395415, 21.507487227094437, 61.74481526345869, 7.347588142314386, 20.077064394497, 128.99156660515195, 77.06204214352937, 6.597745857781874, 19.37723860988626, 50.710302890718324, 69.55861241829707, 8.697280316148275, 60.02985239007454, 24.892276066253203, 50.1807478160811, 118.30242281349294, 101.5895894245943, 7.974143397115197, 18.619653074208163, 61.47569170386188, 38.40846066121819, 15.525227360785678, 39.52803324089644, 17.775524835495013, 8.096805194820346, 77.86378919156066, 8.428470721846159, 177.55306314262089, 18.159280589370073, 17.61520303661414, 11.466170078376942, 55.15621706326793, 7.797824315816005, 5.16214221191894, 7.251200536787743, 23.31047104065024, 5.601830384373208, 14.85486219744002, 23.47926409657536, 65.81341973351225, 7.362466563816758, 6.051075688385016, 10.69993127416634, 11.931990871293724, 14.93167110561766, 24.50206877174161, 60.158472537849455, 16.837739791542166, 57.07024513465593, 8.68303961778839, 30.16580874632789, 7.332296146051147, 18.482497447613316, 77.4121947762647, 9.891433552344708, 75.2098766391361, 75.44434379395304, 63.90485093696525, 12.137368875932903, 21.149292761508903, 43.09811912485915, 64.93244475961404, 54.00992877229201, 21.108431314127444, 60.497803046949514, 64.63395097809929, 23.571979714676026, 37.787701872935166, 10.333345653900853, 80.92259912632849, 18.589749517652805, 28.855775935709985, 111.34148495153833, 5.382176677137913, 37.63797061768081, 26.17696456129164, 18.253941335598896, 49.24880230334021, 6.652300378105524, 66.96637652465535, 56.63277473795469, 53.185745996638786, 27.536743252994267, 98.05437108000103, 41.509431406657825, 9.943544103211924, 119.9563364519111, 47.464733456826195, 50.54477308173679, 78.37261295595734, 24.016139923150497, 44.68219134713229, 38.47456701131029, 13.712644071972502, 16.014562435025795, 39.15367320432303, 59.93566244751936, 36.53185746963628, 9.754411238559044, 5.098542644603711, 5.960068989197252, 32.88320005961905, 12.793264925284454, 78.13597429043753, 52.123926313933424, 5.340396582174258, 104.30090890564074, 36.31647193105259, 92.36990188004715, 7.716259912747125, 49.86789194235325, 9.771857514996334, 13.946237797950154, 11.787973101412838, 13.366422805536152, 79.78488883323583, 20.96336704873445, 31.042721385422894, 20.519404940473578, 98.92866578850482, 11.61363813980958, 97.05076514928781, 7.275186610706856, 8.535480374609735, 36.103726948516695, 15.272858564754209, 24.894488187868962, 59.14815198681429, 10.126551588535044, 72.44536547588082, 16.467859949931295, 14.506529530063862, 19.379874286180485, 18.35846948021706, 56.783376636057916, 75.56376252392423, 7.498567647924987, 34.28570779886293, 9.881375920993378, 7.1925728616425255, 12.596925913313353, 33.10489328844698, 48.26191161382881, 137.8282550940909, 29.24803402468174, 23.106534074219695, 73.28157509665697, 22.096922938385575, 14.450476666595115, 39.7801870070879, 35.1534444120056, 40.55369806511425, 6.8732297017606845, 51.06987150699486, 20.974939572547413, 13.62401555182235, 101.07857803316378, 57.85310944266747, 34.22945281307218, 97.50775399915355, 19.476555407509622, 7.058923506745892, 17.687100072527357, 5.821081922719817, 51.245580012284606, 7.446785654523594, 12.436653509098496, 20.978290248566136, 43.55490350982112, 59.29134719645371, 29.536142510643195, 29.535654716179682, 40.44442404224918, 10.317072232100339, 47.45163980354711, 5.126282151562193, 5.67287658608626, 46.2443189534569, 9.301738297390582, 48.04014320083657])
caption, xmean,count, xle, Etot = energy_spectrum(E_tot)
hist_file(E_hist, xmean, count, caption);
([6290023.4375, 6290448.4375, 6359807.8125, 6361557.8125, 6370353.125, 6420460.9375, 6527839.0625, 6553268.75, 6553587.5, 6601257.8125, 6608748.4375, 6608882.8125, 6609040.625, 6609654.6875, 6633142.1875, 6704865.625, 6708254.6875, 6709690.625, 6710095.3125, 6710693.75, 6735215.625, 6741990.625, 6742750.0, 6756198.4375, 6756203.125, 6756212.5, 6793275.0, 6794398.4375, 6799298.4375, 6799478.125, 6802312.5, 6809620.3125, 6850687.5, 6888515.625, 6890753.125, 6893782.8125, 6893865.625, 6900818.75, 6924139.0625, 6928817.1875, 6930531.25, 6931715.625, 6938595.3125, 6965010.9375, 6968395.3125, 6990468.75, 6990504.6875, 7012562.5, 7013856.25, 7014578.125, 7017248.4375, 7061271.875, 7099342.1875, 7100112.5, 7117554.6875, 7126221.875, 7126732.8125, 7128895.3125, 7129337.5, 7203079.6875, 7210470.3125, 7305618.75, 7663520.3125, 7737573.4375, 7738267.1875, 7760740.625, 7763465.625, 8012203.125, 8012625.0, 8082640.625, 8104521.875, 8168232.8125, 8173409.375, 8245520.3125, 8597253.125, 9982134.375, 9982692.1875, 9983473.4375, 9984271.875, 9984735.9375, 9985875.0, 9987667.1875, 9987846.875, 9988148.4375, 9989173.4375, 9991156.25, 9991156.25, 9992348.4375, 9992554.6875, 9992976.5625, 9993007.8125, 9994735.9375, 9994925.0, 9996157.8125, 10007557.8125, 10014228.125, 10120687.5, 10131071.875, 10135439.0625, 10135681.25, 10135690.625, 10138578.125, 10139204.6875, 10139231.25, 10142132.8125, 10142448.4375, 10142521.875, 10142529.6875, 10142535.9375, 10142768.75, 10142823.4375, 10143164.0625, 10143190.625, 10143400.0, 10143426.5625, 10143432.8125, 10143440.625, 10143454.6875, 10143470.3125, 10143471.875, 10143512.5, 10143621.875, 10143673.4375, 10143725.0, 10143737.5, 10143832.8125, 10143837.5, 10143856.25, 10143892.1875, 10143942.1875, 10143950.0, 10143960.9375, 10144035.9375, 10144046.875, 10144051.5625, 10144054.6875, 10144060.9375, 10144115.625, 10144131.25, 10144195.3125, 10144218.75, 10144257.8125, 10144289.0625, 10144351.5625, 10144359.375, 10144421.875, 10144565.625, 10144659.375, 10144673.4375, 10145095.3125, 10145129.6875, 10145140.625, 10145142.1875, 10145214.0625, 10145385.9375, 10145871.875, 10145929.6875, 10146435.9375, 10146632.8125, 10146798.4375, 10146884.375, 10147020.3125, 10147073.4375, 10147181.25, 10147300.0, 10147442.1875, 10148298.4375, 10148412.5, 10148589.0625, 10148765.625, 10149412.5, 10149723.4375, 10149746.875, 10149765.625, 10149796.875, 10149812.5, 10149900.0, 10150192.1875, 10150554.6875, 10150704.6875, 10151085.9375, 10151731.25, 10151795.3125, 10151857.8125, 10152298.4375, 10153479.6875, 10153592.1875, 10154307.8125, 10155135.9375, 10155300.0, 10156289.0625, 10156837.5, 10157643.75, 10158893.75, 10160260.9375, 10163384.375, 10164745.3125, 10166859.375, 10167929.6875, 10168873.4375, 10170595.3125, 10170678.125, 10172100.0, 10172464.0625, 10173040.625, 10173918.75, 10175704.6875, 10175743.75, 10176001.5625, 10176818.75, 10178915.625, 10179170.3125, 10180550.0, 10181428.125, 10181610.9375, 10181898.4375, 10183603.125, 10183668.75, 10183704.6875, 10189218.75, 10189948.4375, 10193025.0], [9.766316744419898, 5.251516442974003, 69.55512749376862, 49.00643740823214, 43.664766058631834, 21.584428918514433, 78.58734177593003, 74.09175066249496, 22.272412200265787, 26.510499581046474, 11.867819432620863, 21.767325038693144, 35.42152674643406, 61.86492684912672, 49.04633145412035, 15.41623644650278, 7.906359906766605, 72.88078314884376, 29.673093017192514, 38.51044657700519, 148.02449669224688, 133.3021501836184, 35.181107607341794, 132.4283506732665, 48.40964467256184, 14.48500528677138, 61.73129913318913, 36.17621704621773, 12.96958897335559, 6.146274176373145, 97.2223272850807, 71.93684821104652, 20.721714784965542, 31.139932559703656, 12.008854686299957, 18.245223232239496, 5.039677075436522, 33.0941531862099, 66.58475347340202, 89.90078491513881, 12.149677935076443, 17.702075100635696, 358.97887786395415, 21.507487227094437, 61.74481526345869, 7.347588142314386, 20.077064394497, 128.99156660515195, 77.06204214352937, 6.597745857781874, 19.37723860988626, 50.710302890718324, 69.55861241829707, 8.697280316148275, 60.02985239007454, 24.892276066253203, 50.1807478160811, 118.30242281349294, 101.5895894245943, 7.974143397115197, 18.619653074208163, 61.47569170386188, 38.40846066121819, 15.525227360785678, 39.52803324089644, 17.775524835495013, 8.096805194820346, 77.86378919156066, 8.428470721846159, 177.55306314262089, 18.159280589370073, 17.61520303661414, 11.466170078376942, 55.15621706326793, 7.797824315816005, 5.16214221191894, 7.251200536787743, 23.31047104065024, 5.601830384373208, 14.85486219744002, 23.47926409657536, 65.81341973351225, 7.362466563816758, 6.051075688385016, 10.69993127416634, 11.931990871293724, 14.93167110561766, 24.50206877174161, 60.158472537849455, 16.837739791542166, 57.07024513465593, 8.68303961778839, 30.16580874632789, 7.332296146051147, 18.482497447613316, 77.4121947762647, 9.891433552344708, 75.2098766391361, 75.44434379395304, 63.90485093696525, 12.137368875932903, 21.149292761508903, 43.09811912485915, 64.93244475961404, 54.00992877229201, 21.108431314127444, 60.497803046949514, 64.63395097809929, 23.571979714676026, 37.787701872935166, 10.333345653900853, 80.92259912632849, 18.589749517652805, 28.855775935709985, 111.34148495153833, 5.382176677137913, 37.63797061768081, 26.17696456129164, 18.253941335598896, 49.24880230334021, 6.652300378105524, 66.96637652465535, 56.63277473795469, 53.185745996638786, 27.536743252994267, 98.05437108000103, 41.509431406657825, 9.943544103211924, 119.9563364519111, 47.464733456826195, 50.54477308173679, 78.37261295595734, 24.016139923150497, 44.68219134713229, 38.47456701131029, 13.712644071972502, 16.014562435025795, 39.15367320432303, 59.93566244751936, 36.53185746963628, 9.754411238559044, 5.098542644603711, 5.960068989197252, 32.88320005961905, 12.793264925284454, 78.13597429043753, 52.123926313933424, 5.340396582174258, 104.30090890564074, 36.31647193105259, 92.36990188004715, 7.716259912747125, 49.86789194235325, 9.771857514996334, 13.946237797950154, 11.787973101412838, 13.366422805536152, 79.78488883323583, 20.96336704873445, 31.042721385422894, 20.519404940473578, 98.92866578850482, 11.61363813980958, 97.05076514928781, 7.275186610706856, 8.535480374609735, 36.103726948516695, 15.272858564754209, 24.894488187868962, 59.14815198681429, 10.126551588535044, 72.44536547588082, 16.467859949931295, 14.506529530063862, 19.379874286180485, 18.35846948021706, 56.783376636057916, 75.56376252392423, 7.498567647924987, 34.28570779886293, 9.881375920993378, 7.1925728616425255, 12.596925913313353, 33.10489328844698, 48.26191161382881, 137.8282550940909, 29.24803402468174, 23.106534074219695, 73.28157509665697, 22.096922938385575, 14.450476666595115, 39.7801870070879, 35.1534444120056, 40.55369806511425, 6.8732297017606845, 51.06987150699486, 20.974939572547413, 13.62401555182235, 101.07857803316378, 57.85310944266747, 34.22945281307218, 97.50775399915355, 19.476555407509622, 7.058923506745892, 17.687100072527357, 5.821081922719817, 51.245580012284606, 7.446785654523594, 12.436653509098496, 20.978290248566136, 43.55490350982112, 59.29134719645371, 29.536142510643195, 29.535654716179682, 40.44442404224918, 10.317072232100339, 47.45163980354711, 5.126282151562193, 5.67287658608626, 46.2443189534569, 9.301738297390582, 48.04014320083657])
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);
([6290023.4375, 6290448.4375, 6359807.8125, 6361557.8125, 6370353.125, 6420460.9375, 6527839.0625, 6553268.75, 6553587.5, 6601257.8125, 6608748.4375, 6608882.8125, 6609040.625, 6609654.6875, 6633142.1875, 6704865.625, 6708254.6875, 6709690.625, 6710095.3125, 6710693.75, 6735215.625, 6741990.625, 6742750.0, 6756198.4375, 6756203.125, 6756212.5, 6793275.0, 6794398.4375, 6799298.4375, 6799478.125, 6802312.5, 6809620.3125, 6850687.5, 6888515.625, 6890753.125, 6893782.8125, 6893865.625, 6900818.75, 6924139.0625, 6928817.1875, 6930531.25, 6931715.625, 6938595.3125, 6965010.9375, 6968395.3125, 6990468.75, 6990504.6875, 7012562.5, 7013856.25, 7014578.125, 7017248.4375, 7061271.875, 7099342.1875, 7100112.5, 7117554.6875, 7126221.875, 7126732.8125, 7128895.3125, 7129337.5, 7203079.6875, 7210470.3125, 7305618.75, 7663520.3125, 7737573.4375, 7738267.1875, 7760740.625, 7763465.625, 8012203.125, 8012625.0, 8082640.625, 8104521.875, 8168232.8125, 8173409.375, 8245520.3125, 8597253.125, 9982134.375, 9982692.1875, 9983473.4375, 9984271.875, 9984735.9375, 9985875.0, 9987667.1875, 9987846.875, 9988148.4375, 9989173.4375, 9991156.25, 9991156.25, 9992348.4375, 9992554.6875, 9992976.5625, 9993007.8125, 9994735.9375, 9994925.0, 9996157.8125, 10007557.8125, 10014228.125, 10120687.5, 10131071.875, 10135439.0625, 10135681.25, 10135690.625, 10138578.125, 10139204.6875, 10139231.25, 10142132.8125, 10142448.4375, 10142521.875, 10142529.6875, 10142535.9375, 10142768.75, 10142823.4375, 10143164.0625, 10143190.625, 10143400.0, 10143426.5625, 10143432.8125, 10143440.625, 10143454.6875, 10143470.3125, 10143471.875, 10143512.5, 10143621.875, 10143673.4375, 10143725.0, 10143737.5, 10143832.8125, 10143837.5, 10143856.25, 10143892.1875, 10143942.1875, 10143950.0, 10143960.9375, 10144035.9375, 10144046.875, 10144051.5625, 10144054.6875, 10144060.9375, 10144115.625, 10144131.25, 10144195.3125, 10144218.75, 10144257.8125, 10144289.0625, 10144351.5625, 10144359.375, 10144421.875, 10144565.625, 10144659.375, 10144673.4375, 10145095.3125, 10145129.6875, 10145140.625, 10145142.1875, 10145214.0625, 10145385.9375, 10145871.875, 10145929.6875, 10146435.9375, 10146632.8125, 10146798.4375, 10146884.375, 10147020.3125, 10147073.4375, 10147181.25, 10147300.0, 10147442.1875, 10148298.4375, 10148412.5, 10148589.0625, 10148765.625, 10149412.5, 10149723.4375, 10149746.875, 10149765.625, 10149796.875, 10149812.5, 10149900.0, 10150192.1875, 10150554.6875, 10150704.6875, 10151085.9375, 10151731.25, 10151795.3125, 10151857.8125, 10152298.4375, 10153479.6875, 10153592.1875, 10154307.8125, 10155135.9375, 10155300.0, 10156289.0625, 10156837.5, 10157643.75, 10158893.75, 10160260.9375, 10163384.375, 10164745.3125, 10166859.375, 10167929.6875, 10168873.4375, 10170595.3125, 10170678.125, 10172100.0, 10172464.0625, 10173040.625, 10173918.75, 10175704.6875, 10175743.75, 10176001.5625, 10176818.75, 10178915.625, 10179170.3125, 10180550.0, 10181428.125, 10181610.9375, 10181898.4375, 10183603.125, 10183668.75, 10183704.6875, 10189218.75, 10189948.4375, 10193025.0], [9.766316744419898, 5.251516442974003, 69.55512749376862, 49.00643740823214, 43.664766058631834, 21.584428918514433, 78.58734177593003, 74.09175066249496, 22.272412200265787, 26.510499581046474, 11.867819432620863, 21.767325038693144, 35.42152674643406, 61.86492684912672, 49.04633145412035, 15.41623644650278, 7.906359906766605, 72.88078314884376, 29.673093017192514, 38.51044657700519, 148.02449669224688, 133.3021501836184, 35.181107607341794, 132.4283506732665, 48.40964467256184, 14.48500528677138, 61.73129913318913, 36.17621704621773, 12.96958897335559, 6.146274176373145, 97.2223272850807, 71.93684821104652, 20.721714784965542, 31.139932559703656, 12.008854686299957, 18.245223232239496, 5.039677075436522, 33.0941531862099, 66.58475347340202, 89.90078491513881, 12.149677935076443, 17.702075100635696, 358.97887786395415, 21.507487227094437, 61.74481526345869, 7.347588142314386, 20.077064394497, 128.99156660515195, 77.06204214352937, 6.597745857781874, 19.37723860988626, 50.710302890718324, 69.55861241829707, 8.697280316148275, 60.02985239007454, 24.892276066253203, 50.1807478160811, 118.30242281349294, 101.5895894245943, 7.974143397115197, 18.619653074208163, 61.47569170386188, 38.40846066121819, 15.525227360785678, 39.52803324089644, 17.775524835495013, 8.096805194820346, 77.86378919156066, 8.428470721846159, 177.55306314262089, 18.159280589370073, 17.61520303661414, 11.466170078376942, 55.15621706326793, 7.797824315816005, 5.16214221191894, 7.251200536787743, 23.31047104065024, 5.601830384373208, 14.85486219744002, 23.47926409657536, 65.81341973351225, 7.362466563816758, 6.051075688385016, 10.69993127416634, 11.931990871293724, 14.93167110561766, 24.50206877174161, 60.158472537849455, 16.837739791542166, 57.07024513465593, 8.68303961778839, 30.16580874632789, 7.332296146051147, 18.482497447613316, 77.4121947762647, 9.891433552344708, 75.2098766391361, 75.44434379395304, 63.90485093696525, 12.137368875932903, 21.149292761508903, 43.09811912485915, 64.93244475961404, 54.00992877229201, 21.108431314127444, 60.497803046949514, 64.63395097809929, 23.571979714676026, 37.787701872935166, 10.333345653900853, 80.92259912632849, 18.589749517652805, 28.855775935709985, 111.34148495153833, 5.382176677137913, 37.63797061768081, 26.17696456129164, 18.253941335598896, 49.24880230334021, 6.652300378105524, 66.96637652465535, 56.63277473795469, 53.185745996638786, 27.536743252994267, 98.05437108000103, 41.509431406657825, 9.943544103211924, 119.9563364519111, 47.464733456826195, 50.54477308173679, 78.37261295595734, 24.016139923150497, 44.68219134713229, 38.47456701131029, 13.712644071972502, 16.014562435025795, 39.15367320432303, 59.93566244751936, 36.53185746963628, 9.754411238559044, 5.098542644603711, 5.960068989197252, 32.88320005961905, 12.793264925284454, 78.13597429043753, 52.123926313933424, 5.340396582174258, 104.30090890564074, 36.31647193105259, 92.36990188004715, 7.716259912747125, 49.86789194235325, 9.771857514996334, 13.946237797950154, 11.787973101412838, 13.366422805536152, 79.78488883323583, 20.96336704873445, 31.042721385422894, 20.519404940473578, 98.92866578850482, 11.61363813980958, 97.05076514928781, 7.275186610706856, 8.535480374609735, 36.103726948516695, 15.272858564754209, 24.894488187868962, 59.14815198681429, 10.126551588535044, 72.44536547588082, 16.467859949931295, 14.506529530063862, 19.379874286180485, 18.35846948021706, 56.783376636057916, 75.56376252392423, 7.498567647924987, 34.28570779886293, 9.881375920993378, 7.1925728616425255, 12.596925913313353, 33.10489328844698, 48.26191161382881, 137.8282550940909, 29.24803402468174, 23.106534074219695, 73.28157509665697, 22.096922938385575, 14.450476666595115, 39.7801870070879, 35.1534444120056, 40.55369806511425, 6.8732297017606845, 51.06987150699486, 20.974939572547413, 13.62401555182235, 101.07857803316378, 57.85310944266747, 34.22945281307218, 97.50775399915355, 19.476555407509622, 7.058923506745892, 17.687100072527357, 5.821081922719817, 51.245580012284606, 7.446785654523594, 12.436653509098496, 20.978290248566136, 43.55490350982112, 59.29134719645371, 29.536142510643195, 29.535654716179682, 40.44442404224918, 10.317072232100339, 47.45163980354711, 5.126282151562193, 5.67287658608626, 46.2443189534569, 9.301738297390582, 48.04014320083657])
Detected energies during the discharge + Energy spectrum
multiplot(icon_fig, T_int_first,E,xle,Etot)