Commit c017ed87 authored by Matheus Müller's avatar Matheus Müller

Tentativa mais bem sucedida do metedo monocamadas

parent 03422c89
......@@ -189,12 +189,12 @@ def ewin_build(window, OFlabentries, mainwindow, calcbutton, distvar, modevar, L
def cursor_draw_click(event):
global Econtrol
if event.inaxes != a.axes: return
if event.button == 1:
Control['drawing']=True
if event.button == 3:
Control['shifting']=True
elif event.button == 2:
Control['scaling']=True
elif event.button == 3:
Control['shifting']=True
elif event.button == 1:
Control['drawing']=True
Control['x'] = float(event.xdata)
Control['y'] = float(event.ydata)
if Control['y'] > 1:
......@@ -225,6 +225,9 @@ def ewin_build(window, OFlabentries, mainwindow, calcbutton, distvar, modevar, L
for y in range(len(Edict[Econtrol]['dist'].data)):
if Edict[Econtrol]['dist'].data[y] > 1:
Edict[Econtrol]['dist'].data[y] = 1.
grafico.set_xdata(Edict[Econtrol]['dist'].axisdepth())
grafico.set_ydata(Edict[Econtrol]['dist'].data)
f.canvas.draw()
def abrupt(event):pass
......
No preview for this file type
......@@ -247,18 +247,22 @@ def loadexp():
# Adjust graphic
def adjust():
global doseold, Pcontrol, Plot, f
fraction = float(OFlabentries[24].get())/doseold
newdata = temp.ydata*fraction
temp.set_ydata(newdata)
newdata = list()
for x in range(len(Plot[Pcontrol].get_ydata())):
newdata.insert(x, Plot[Pcontrol].get_ydata()[x]*fraction)
Plot[Pcontrol].set_ydata(newdata)
doseold = float(OFlabentries[24].get())
show()
ylim([0,max(Plot[Pcontrol].get_ydata())*1.1])
f2.canvas.draw()
##############################################################################
# Calculation callback
# Get parameters
def init_calc():
global modelvar, FT
global modelvar, FT, doseold
param['dedx'] = float(OFlabentries[9].get())
param['dW2dx'] = float(OFlabentries[10].get())
param['Theta_out'] = float(OFlabentries[11].get())
......@@ -268,7 +272,9 @@ def init_calc():
ionb['mass'] = float(OFlabentries[22].get())
ionb['Z'] = float(OFlabentries[23].get())
espectro = spectro(int(float(OFlabentries[21].get())/float(OFlabentries[16].get())), int(OFlabentries[16].get()))
aux = spectro(int(float(OFlabentries[21].get())/float(OFlabentries[16].get())), int(OFlabentries[16].get()))
doseold = float(OFlabentries[24].get())
LSi = int(LSvar.get())
CGi = int(CGvar.get())
......@@ -279,7 +285,7 @@ def init_calc():
calc(param, str(modelvar.get()), ionb, OFlabentries, LSi, CGi, 'layer', espectro, OFlabentries[14].get(), Plot, f2, FT, Plotbuttons, Pcontrol)
elif int(modevar.get()) == 1:
pass #spectroRNA(param, str(modelvar.get()), ionb, OFlabentries, int(LSvar.get()), int(CGvar.get()), temp)
spectrolayer(param, str(modelvar.get()), ionb, OFlabentries, LSi, CGi, 'layer', espectro, OFlabentries[14].get(), Plot, f2, FT, Plotbuttons, Pcontrol,aux)
FT = False
......@@ -292,7 +298,7 @@ CalcButton.pack(side='bottom')
##############################################################################
# Grahical parameters buttons
Adjbut = tk.Button(Gframee, text = 'Adjust', command = init_calc, width=8)
Adjbut = tk.Button(Gframee, text = 'Adjust', command = adjust, width=8)
Databut = tk.Button(Gframel, text = 'Exp Data', command = loadexp, width=6)
Adjbut.pack()
Databut.pack()
......
......@@ -140,4 +140,96 @@ def calc(p, modelo, ion, OFlabentries, LScontrol, CGausscontrol, metodo, espectr
fig.canvas.draw()
fig.show()
####################################################################################################################################################
####################################################################################################################################################
def spectrolayer(p, modelo, ion, OFlabentries, LScontrol, CGausscontrol, metodo, espectro, emin, plote, fig, firsttime, botoes, indice, aux):
EPasso, passox, e, resol, dose, Emin, Emax = variables(OFlabentries)
gshift=0.
curdepht=passox #Avoid zero division
espectro.clear()
Theta_s = PI - (p['Theta_in'] + p['Theta_out'])*PI/180
mi = ion['mass']
first = False
deltaE = 0
for camada in Ldict:
xfinal = curdepht + float(camada.LandE[5].get())
## Calcula o espectro de cada elemento da amostra
for componente in range(len(camada.Elements)):
mt = camada.Elements[componente]['mass']
c = float(camada.Spinboxes[componente].get())
alpha_lineshape = camada.Elements[componente]['LineShape']
dedx = float(camada.LandE[3].get())
dW2dx = float(camada.LandE[4].get())
k = ((sqrt (mt**2-mi**2*(sin(Theta_s)**2)) + mi*cos(Theta_s) ) / (mi+mt) )**2
dedxef=dedx*(k/cos(p['Theta_in']*PI/180.) + 1/cos(p['Theta_out']*PI/180.))
dw2dxef=dW2dx*(k**2./cos(p['Theta_in']*PI/180.)+1./cos(p['Theta_out']*PI/180.))
sinalbessel = e*0
sinalgaussiana = e*0
# Calcula a contribuição de cada passo
for x in arange(curdepht, xfinal, passox):
# Seção de choque - CSRf(Z1, Z2, Ein, M1, M2, Theta):
CS = c*k*CSRf(ion['Z'], camada.Elements[componente]['Z'], k*p['E0']-dedxef*x, mi, mt, Theta_s)*passox
# É multiplicada pelo passo para manter a escala do gráfico independente do mesmo.
# Bessel:
if modelo == 'bessel':
alpha=dedxef*(2./dw2dxef)
m=alpha*dedxef
lbd=m*x*alpha
aux.spectro[int((k*p['E0']-deltaE)/EPasso-1)] = CS*exp(-m*x)+x*m*alpha*exp(-m*x)*i1(0)/sqrt(0.00000000001)*passox*passox
besselcamada = lbd*exp(-m*x-alpha*(k*p['E0']+deltaE-e))*i1(2.*sqrt(lbd*(k*p['E0']+deltaE-e)))/(sqrt(lbd*(k*p['E0']+deltaE-e)+.0000001))
aux.soma( list(nan_to_num(besselcamada*CS)))
if first:
espectro.Convolve(aux)
else:
espectro.soma(aux.spectro)
first = True
aux.clear()
deltaE = deltaE + dedxef*passox
# Gaussiana:
elif modelo == 'gaussiana':
Em=k*p['E0']-x*dedxef
sigma=x*dw2dxef
gaussianacamada = exp((-(e-Em)**2.)/(2.*sigma))/sqrt(2.*PI*sigma)
espectro.soma( list(nan_to_num(gaussianacamada*CS)) )
if modelo == 'bessel':
linecolor='r'
elif modelo == 'gaussiana':
linecolor='b'
curdepht = xfinal
if LScontrol == 1:
espectro.ConvolveF0(1./alpha_lineshape)
if CGausscontrol == 1:
espectro.ConvolveGauss(resol/2.35482)
espectro.multiply(dose)
espectro.eshift = espectro.eshift -(1-k)*p['E0'] - EPasso
print espectro.eshift
plote[indice].set_xdata(espectro.axisenergy())
plote[indice].set_ydata(espectro.spectro)
spect_file(espectro.axisenergy(), espectro.spectro, espectro.eshift, dose)
ylim([0,max(espectro.spectro)*1.1])
#if firsttime == True:
# xlim([Emin,Emax])
labeler(plote,botoes,fig)
fig.canvas.draw()
fig.show()
......@@ -209,7 +209,7 @@ class spectro:
return_val = temp;
"""
self.spectro = list(inline_tools.inline(code,['datasize','stepsize','data','datadois'],type_converters=converters.blitz,compiler = 'gcc'))
self.eshift = float(self.eshift) + spectwo.eshift
self.eshift = float(self.eshift) + float(spectwo.eshift)
self.setnorma(normaantes)
def SetGauss(self, step, size, wg): ### Define o espectro como uma curva normal (gaussiana) ###
......
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