Commit 1f9dab0f authored by Matheus Müller's avatar Matheus Müller

Versao para commitdiff debug

parent 369633e2
......@@ -159,7 +159,7 @@ def ewin_build(window, OFlabentries, mainwindow, calcbutton, distvar, modevar, L
# Declaration of interpolation and distribution method variables
methodvar = tk.StringVar()
methodvar.set('reta')
methodvar.set('step')
##############################################################################
......@@ -261,37 +261,36 @@ def ewin_build(window, OFlabentries, mainwindow, calcbutton, distvar, modevar, L
# Distribution
def changestate():
if str(distvar.get()) == 'layer':
BLayer['state']='normal'
BUpdateD['state']='disabled'
RS['state']='disabled'
RL['state']='disabled'
OFlabentries[9]['state']='disabled'
OFlabentries[10]['state']='disabled'
for i in arange(6, 12):
Labentrys[i]['state']='disabled'
but['state']='disabled'
butrmv['state']='disabled'
butPTE['state']='disabled'
BUpdate['state']='disabled'
for n in arange(0, len(Ebuttons)):
Ebuttons[n]['state'] = 'disabled'
elif str(distvar.get()) == 'drawing':
BLayer['state']='disabled'
BUpdateD['state']='normal'
RS['state']='normal'
RL['state']='normal'
OFlabentries[9]['state']='normal'
OFlabentries[10]['state']='normal'
for i in arange(6, 12):
Labentrys[i]['state']='normal'
but['state']='normal'
butrmv['state']='normal'
butPTE['state']='normal'
BUpdate['state']='normal'
for n in arange(0, len(Ebuttons)):
Ebuttons[n]['state'] = 'normal'
BLayer['state']='normal'
BUpdateD['state']='disabled'
RS['state']='disabled'
RL['state']='disabled'
OFlabentries[9]['state']='disabled'
OFlabentries[10]['state']='disabled'
for i in arange(6, 12):
Labentrys[i]['state']='disabled'
but['state']='disabled'
butrmv['state']='disabled'
butPTE['state']='disabled'
BUpdate['state']='disabled'
for n in arange(0, len(Ebuttons)):
Ebuttons[n]['state'] = 'disabled'
def changestate2():
BLayer['state']='disabled'
BUpdateD['state']='normal'
RS['state']='normal'
RL['state']='normal'
OFlabentries[9]['state']='normal'
OFlabentries[10]['state']='normal'
for i in arange(6, 12):
Labentrys[i]['state']='normal'
but['state']='normal'
butrmv['state']='normal'
butPTE['state']='normal'
BUpdate['state']='normal'
for n in arange(0, len(Ebuttons)):
Ebuttons[n]['state'] = 'normal'
def call_layers():
layers()
......@@ -308,43 +307,42 @@ def ewin_build(window, OFlabentries, mainwindow, calcbutton, distvar, modevar, L
RL = tk.Radiobutton(Labeldist, text="Lines", variable=methodvar, value='reta')
RL.pack(side='right')
# Distribution methods
RLay = tk.Radiobutton(Frames[7], text="Layers", command=lambda i=int(Econtrol) :changestate(), variable=distvar, value='layer')
RLay = tk.Radiobutton(Frames[7], text="Layers", command=lambda i=int(Econtrol) :changestate(), variable=distvar, value=0)
RLay.pack(side='left')
RDra = tk.Radiobutton(Frames[7], text="Drawing", command=lambda i=int(Econtrol) :changestate(), variable=distvar, value='drawing')
RDra = tk.Radiobutton(Frames[7], text="Drawing", command=lambda i=int(Econtrol) :changestate2(), variable=distvar, value=1)
RDra.pack(side='right')
##############################################################################
# Experiment variations
def changemode():
if str(modevar.get()) == 'IONS':
for n in range(len(Ebuttons)):
Ebuttons[n]['state']='normal'
but['state'] = 'normal'
butrmv['state'] = 'normal'
butPTE['state'] = 'normal'
RLay['state'] = 'normal'
Labentrys[12]['state'] = 'disabled'
elif str(modevar.get()) == 'RRNA':
RDra.invoke()
elem_select(0,Ebuttons)
but['state'] = 'disabled'
butrmv['state'] = 'disabled'
RLay['state'] = 'disabled'
Labentrys[12]['state'] = 'normal'
for n in arange(1, len(Ebuttons)):
Ebuttons[n]['state'] = 'disabled'
Rions = tk.Radiobutton(Labelframe, text="Ion Scattering", command=lambda i=i :changemode(), variable=modevar, value='IONS', width=18)
for n in range(len(Ebuttons)):
Ebuttons[n]['state']='normal'
but['state'] = 'normal'
butrmv['state'] = 'normal'
butPTE['state'] = 'normal'
RLay['state'] = 'normal'
Labentrys[12]['state'] = 'disabled'
def changemode2():
RDra.invoke()
elem_select(0,Ebuttons)
but['state'] = 'disabled'
butrmv['state'] = 'disabled'
RLay['state'] = 'disabled'
Labentrys[12]['state'] = 'normal'
for n in arange(1, len(Ebuttons)):
Ebuttons[n]['state'] = 'disabled'
Rions = tk.Radiobutton(Labelframe, text="Ion Scattering", variable=modevar, value=0, width=18, command=lambda i=i :changemode())
Rions.pack()
Rrrna = tk.Radiobutton(Labelframe, text="Resonant RNA", command=lambda i=i :changemode(), variable=modevar, value='RRNA', width=18)
Rrrna = tk.Radiobutton(Labelframe, text="Resonant RNA", variable=modevar, value=1, width=18, command=lambda i=i :changemode2())
Rrrna.pack()
Rions.invoke()
##############################################################################
# Init
Rions.invoke()
RDra.invoke()
RS.select()
Ebuttons[0].invoke()
......
No preview for this file type
0 0
1.9523573201 0.00520408163265
2.84863523573 0.842704081633
7.2129032258 0.932270408162
9.37667493796 0.960612244896
10.0 0
This diff is collapsed.
......@@ -10,6 +10,8 @@ ax = fig.add_subplot(111)
fig.canvas.set_window_title("Signal")
xx = arange(0,1, 0.1)
temp, = plot(xx,xx*0)
xlabel("Enegy (eV)")
ylabel("Yield")
doseold = 12e34
##############################################################################
......@@ -34,8 +36,9 @@ def loadexp():
# Adjust graphic
def adjust():
temp.set_xdata(arange(OFlabentries[14].get(),OFlabentries[15].get(),OFlabentries[16].get()))
temp.set_ydata(temp.ydata/doseold*float(OFlabentries[24].get()))
fraction = float(OFlabentries[24].get())/doseold
newdata = temp.ydata*fraction
temp.set_ydata(newdata)
doseold = float(OFlabentries[24].get())
show()
......@@ -53,16 +56,16 @@ def init_calc():
param['FWHM0'] = float(OFlabentries[13].get())
ionb['mass'] = float(OFlabentries[22].get())
ionb['Z'] = float(OFlabentries[23].get())
if str(modevar.get()) == 'IONS':
if str(distvar.get()) == 'drawing':
print distvar.get()
if int(modevar.get()) == 0:
if int(distvar.get()) == 1:
for i in range(len(Edict)):
Edict[i]['dist'] = np.loadtxt(Edict[i]['symbol']+".prof")
spectro(param, str(modelvar.get()), ionb, OFlabentries, int(LSvar.get()), int(CGvar.get()), temp)
elif str(distvar.get()) == 'layer':
elif int(distvar.get()) == 0:
spectrolayer(param, str(modelvar.get()), ionb, OFlabentries, int(LSvar.get()), int(CGvar.get()), temp)
elif str(modevar.get()) == 'RRNA':
elif int(modevar.get()) == 1:
spectroRNA(param, str(modelvar.get()), ionb, OFlabentries, int(LSvar.get()), int(CGvar.get()), temp)
##############################################################################
......@@ -128,20 +131,16 @@ OFlabentries.insert(1, tk.Label(Pframel, width=9, text='dω²/dx', pady=2))
OFlabentries.insert(2, tk.Label(Pframel, width=9, text='θ out', pady=2))
OFlabentries.insert(3, tk.Label(Pframel, width=9, text='θ in', pady=2))
OFlabentries.insert(4, tk.Label(Pframel, width=9, text='FWHM0', pady=2))
OFlabentries.insert(5, tk.Label(Gframel, width=9, text='Emin', pady=2))
OFlabentries.insert(6, tk.Label(Gframel, width=9, text='Emax', pady=2))
OFlabentries.insert(5, tk.Label(Pframel, width=9, text='Emin', pady=2))
OFlabentries.insert(6, tk.Label(Pframel, width=9, text='Emax', pady=2))
OFlabentries.insert(7, tk.Label(Pframel, width=9, text='Estep', pady=2))
OFlabentries.insert(8, tk.Label(Pframel, width=9, text='Depth step', pady=2))
OFlabentries.insert(24, tk.Entry(Gframee, width=11))
OFlabentries.insert(25, tk.Label(Gframel, width=9, text='Dose', pady=2))
# Entries
for n in arange(9,18):
if n == 14 or n == 15:
OFlabentries.insert(n, tk.Entry(Gframee, width=11))
else:
OFlabentries.insert(n, tk.Entry(Pframee, width=11))
OFlabentries.insert(n, tk.Entry(Pframee, width=11))
#Ion
# Labels // Entries numbers:
......@@ -173,8 +172,7 @@ OFlabentries[17].insert(0,0.01)
OFlabentries[21].insert(0,param['E0'])
OFlabentries[22].insert(0, ionb['mass'])
OFlabentries[23].insert(0, ionb['Z'])
OFlabentries[24].insert(0, 12e34)
doseold = float(OFlabentries[24].get())
OFlabentries[24].insert(0, "12e34")
##############################################################################
# Grahical parameters buttons
......@@ -187,8 +185,6 @@ Databut.pack()
##############################################################################
# Energy loss models
modevar = tk.StringVar()
modevar.set('IONS')
modelvar = tk.StringVar()
modelvar.set('bessel')
R1 = tk.Radiobutton(Label4, text="Gaussian", variable=modelvar, value='gaussiana')
......@@ -220,8 +216,8 @@ CalcButton.pack()
##############################################################################
# Elements callback
distvar = tk.StringVar()
distvar.set('drawing')
modevar = tk.IntVar()
distvar = tk.IntVar()
ewin_build(Label1, OFlabentries, root, CalcButton, distvar, modevar, Label0)
##############################################################################
......
......@@ -76,6 +76,20 @@ def convoluiGaussdev(espectro, Sigma,passoE):
return temp*areaantes/temp.sum(), wg4_step*passoE
####################################################################################################################################################
####################################################################################################################################################
# Funcoes em comum
def spect_file(x, y, shift, dose):
data2 = open('temp.sim', 'w')
for i in range(len(y)):
print>>data2, x[i]-shift,y[i]*dose
data2.close()
def set_lim(x, y, shift, dose):
ylim([0,max(y*dose)*1.1])
xlim([min(x-shift)*0.95,max(x-shift)*1.05])
####################################################################################################################################################
####################################################################################################################################################
......@@ -85,9 +99,9 @@ def spectro(p, modelo, ion, OFlabentries, LScontrol, CGausscontrol, tempor):
passox = float(OFlabentries[17].get())
e = arange(float(OFlabentries[14].get()), float(OFlabentries[15].get()), EPasso)
resol = float(OFlabentries[13].get())
X = e*0.
dose = float(OFlabentries[24].get())
gshift=0
X = e*0.
Theta_s = PI - (p['Theta_in'] + p['Theta_out'])*PI/180
mi = ion['mass']
......@@ -151,27 +165,12 @@ def spectro(p, modelo, ion, OFlabentries, LScontrol, CGausscontrol, tempor):
if CGausscontrol == 1:
X, gshift = convoluiGauss(X,resol/2.35482,EPasso)
#plt.plot(e-gshift,X*dose, linecolor)
tempor.set_xdata(e-gshift)
tempor.set_ydata(X*dose)
#tempor.set_color(linecolor)
#draw()
ylim([0,max(X*dose)*1.1])
xlim([0,max(e-gshift)*1.05])
#suptitle('Signal received', fontsize=12)
xlabel("Enegy (eV)")
ylabel("Yield")
data2 = open('temp.sim', 'w')
for i in range(len(X)):
print>>data2, e[i]-gshift,X[i]*dose
data2.close()
amostra = np.loadtxt('H2.py')
xxx= amostra[:,0]*1000
ccc=amostra[:,1]
plot (xxx, ccc, 'r.')
set_lim(e, X, gshift, dose)
spect_file(e, X, gshift, dose)
show()
####################################################################################################################################################
......@@ -183,8 +182,8 @@ def spectrolayer(p, modelo, ion, OFlabentries, LScontrol, CGausscontrol, tempor)
passox = float(OFlabentries[17].get())
e = arange(float(OFlabentries[14].get()), float(OFlabentries[15].get()), EPasso)
resol = float(OFlabentries[13].get())
X = e*0.
dose = float(OFlabentries[24].get())
X = e*0.
gshift=0.
curdepht=passox #Avoid zero division
......@@ -249,18 +248,14 @@ def spectrolayer(p, modelo, ion, OFlabentries, LScontrol, CGausscontrol, tempor)
curdepht = xfinal
if CGausscontrol == 1:
X, gshift = convoluiGauss(X,resol/2.35482,EPasso)
plt.plot(e-gshift,X*dose, linecolor)
ylim([0,max(X*dose)*1.1])
suptitle('Signal received', fontsize=12)
xlabel("Enegy (eV)")
ylabel("Yield")
X, gshift = convoluiGauss(X,resol/2.35482,EPasso)
tempor.set_xdata(e-gshift)
tempor.set_ydata(X*dose)
data2 = open('temp.sim', 'w')
for i in range(len(X)):
print>>data2, e[i]-gshift,X[i]*dose
data2.close()
set_lim(e, X, gshift, dose)
spect_file(e, X, gshift, dose)
show()
####################################################################################################################################################
......@@ -272,8 +267,8 @@ def spectroRNA(p, modelo, ion, OFlabentries, LScontrol, CGausscontrol, tempor):
passox = float(OFlabentries[17].get())
e = arange(float(OFlabentries[14].get()), float(OFlabentries[15].get()), EPasso)
resol = float(OFlabentries[13].get())
X = e*0.
dose = float(OFlabentries[24].get())
X = e*0.
gshift=0
Theta_s = PI - (p['Theta_in'] + p['Theta_out'])*PI/180
......@@ -300,13 +295,6 @@ def spectroRNA(p, modelo, ion, OFlabentries, LScontrol, CGausscontrol, tempor):
# É multiplicada pelo passo para manter a escala do gráfico independente do mesmo.
# Bessel:
# Ainda falta incluir a delta de Dirac na origem
# Existe um valor máximo em energia no qual a função de Bessel pode ser computada em função
# da precisão numérica. Uma possível solução pode ser trabalhar em outras unidades que não
# resultem em argumentos tão grandes para a função exponencial.
# Também temos um problema com a primeira camada, que tem profundidade zero.
# Perceba que os cálculos de Bessel correspondentes às camadas mais fundas estão truncados
# para uma perda de energia maior que 25 keV. (Observado com Theta_in=70, para x > 30)
if modelo == 'bessel':
alpha=dedxef*(2./dw2dxef)
m=alpha*dedxef
......@@ -339,22 +327,10 @@ def spectroRNA(p, modelo, ion, OFlabentries, LScontrol, CGausscontrol, tempor):
tempor.set_xdata(e-gshift)
tempor.set_ydata(X*dose)
#tempor.set_color(linecolor)
ylim([0,max(X*dose)*1.1])
xlim([0,max(e-gshift)*1.05])
xlabel("Enegy (eV)")
ylabel("Yield")
data2 = open('temp.sim', 'w')
for i in range(len(X)):
print>>data2, e[i]-gshift,X[i]*dose
data2.close()
set_lim(e, X, gshift, dose)
spect_file(e, X, gshift, dose)
amostra = np.loadtxt('H2.py')
xxx= amostra[:,0]*1000
ccc=amostra[:,1]
#plot (xxx, ccc, 'r.')
show()
####################################################################################################################################################
......
No preview for this file type
......@@ -16,7 +16,7 @@ profundidademax = float(sys.argv[3])
dxstep = float(sys.argv[4])
print "nome dos arquivos "+filename+" e "+ filename2
fig.canvas.set_window_title(filename)
xx = arange(0,profundidademax, dxstep)
xx = arange(0, profundidademax, dxstep)
temp, = plot(xx,xx*0)
#######################################################################################################
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment