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

Opção de metodo de interpolaçao na interface

parent d8b41f9b
...@@ -32,7 +32,7 @@ def elem_callback(x, edict , ebutton, Labelmass, LabelZ, Labelname, Labelsymbol, ...@@ -32,7 +32,7 @@ def elem_callback(x, edict , ebutton, Labelmass, LabelZ, Labelname, Labelsymbol,
def elem_select(i, button, Labelmass, LabelZ, Labelname, Labelsymbol, LabelLS, Entrymass, EntryZ, Entryname, Entrysymbol,EntryLS): def elem_select(i, button, Labelmass, LabelZ, Labelname, Labelsymbol, LabelLS, Entrymass, EntryZ, Entryname, Entrysymbol,EntryLS):
global Econtrol, Edict global Econtrol, Edict, methodvar
button[Econtrol]['relief']='raised' button[Econtrol]['relief']='raised'
Econtrol = i Econtrol = i
button[i]['relief']='sunken' button[i]['relief']='sunken'
...@@ -157,6 +157,9 @@ def ewin_build(window, xmax, xstep): ...@@ -157,6 +157,9 @@ def ewin_build(window, xmax, xstep):
Entrysymbol.pack() Entrysymbol.pack()
EntryLS.pack() EntryLS.pack()
methodvar = tk.StringVar()
methodvar.set('reta')
############################################################################## ##############################################################################
# Buttons # Buttons
...@@ -172,11 +175,20 @@ def ewin_build(window, xmax, xstep): ...@@ -172,11 +175,20 @@ def ewin_build(window, xmax, xstep):
BUpdate = tk.Button(EPframel2, text ='Update properties', command=lambda i=int(Econtrol) :update(Econtrol), width=15) BUpdate = tk.Button(EPframel2, text ='Update properties', command=lambda i=int(Econtrol) :update(Econtrol), width=15)
BUpdate.pack()#side='right') BUpdate.pack()#side='right')
BUpdateD = tk.Button(EPframel2, text ='Distribution', command =lambda i=int(Econtrol) : os.system("python profiler.py %s &" %Edict[int(Econtrol)]['symbol']), width=15) BUpdateD = tk.Button(EPframel2, text ='Distribution', command =lambda i=int(Econtrol) : os.system("python profiler.py %s %s &" %( Edict[int(Econtrol)]['symbol'], str(methodvar.get()) ) ), width=15)
BUpdateD.pack()#side='left') BUpdateD.pack()#side='left')
##############################################################################
# Interpolation methods
RS = tk.Radiobutton(Labelprop, text="Step", variable=methodvar, value='step')
RS.pack()
RL = tk.Radiobutton(Labelprop, text="Lines", variable=methodvar, value='reta')
RL.pack()
############################################################################## ##############################################################################
# Init # Init
RS.select()
Ebuttons[0].invoke() Ebuttons[0].invoke()
############################################################################## ##############################################################################
......
...@@ -10,6 +10,7 @@ import sys ...@@ -10,6 +10,7 @@ import sys
param = dict(dedx=192. ,Theta_out=70., dW2dx=20740., E0= 100000., Theta_in=0., FWHM0=180.) param = dict(dedx=192. ,Theta_out=70., dW2dx=20740., E0= 100000., Theta_in=0., FWHM0=180.)
ionb = dict(Z=1, mass=1.0079) ionb = dict(Z=1, mass=1.0079)
init=0 init=0
espessura = 30.
############################################################################## ##############################################################################
# Report file, writes parameters # Report file, writes parameters
...@@ -50,7 +51,7 @@ def init_calc(): ...@@ -50,7 +51,7 @@ def init_calc():
for i in range(len(Edict)): for i in range(len(Edict)):
Edict[i]['dist'] = np.loadtxt(Edict[i]['symbol']+".prof") Edict[i]['dist'] = np.loadtxt(Edict[i]['symbol']+".prof")
spectro(param, str(modelvar.get()), ionb, float(EntryEmin.get()),float(EntryEmax.get()), float(EntryEstep.get()), float(EntryDstep.get()), int(LSvar.get()), float(EntryFWHM0.get()) ) spectro(param, str(modelvar.get()), ionb, float(EntryEmin.get()),float(EntryEmax.get()), float(EntryEstep.get()), float(EntryDstep.get()), int(LSvar.get()), float(EntryFWHM0.get()), espessura )
############################################################################## ##############################################################################
# Main window # Main window
...@@ -204,10 +205,10 @@ ExitButton.pack(side='bottom') ...@@ -204,10 +205,10 @@ ExitButton.pack(side='bottom')
############################################################################## ##############################################################################
# Elements callback # Elements callback
ewin_build(Label1, 15, float(EntryDstep.get())) ewin_build(Label1, espessura, float(EntryDstep.get()))
############################################################################## ##############################################################################
if init == 0: if init == 1:
CalcButton.invoke() CalcButton.invoke()
init = 1 init = 1
......
...@@ -39,7 +39,7 @@ def montaperfil( xy , step, modo): ...@@ -39,7 +39,7 @@ def montaperfil( xy , step, modo):
if modo == 'reta': if modo == 'reta':
for i in xy: for i in xy:
for j in arange (u, round(i[0],2), step): for j in arange (u, round(i[0],3), step):
concent[round(j/step)] = yu + (j-u)*(i[1] - yu)/(i[0] - u) concent[round(j/step)] = yu + (j-u)*(i[1] - yu)/(i[0] - u)
u = round(i[0],2) u = round(i[0],2)
yu = i[1] yu = i[1]
......
...@@ -59,32 +59,31 @@ def convoluiGauss(espectro, Sigma,passoE): ...@@ -59,32 +59,31 @@ def convoluiGauss(espectro, Sigma,passoE):
#################################################################################################################################################### ####################################################################################################################################################
def spectro(p, modelo, ion, Emin, Emax, EPasso, passox, LScontrol, resol): def spectro(p, modelo, ion, Emin, Emax, EPasso, passox, LScontrol, resol, espessura):
e = arange(Emin, Emax, EPasso) e = arange(Emin, Emax, EPasso)
if modelo == 'bessel': if modelo == 'bessel':
Y = e*0. Y = e*0.
try: '''try:
YY YY
except NameError: except NameError:
YY, = plot(e,e*0., 'b') YY, = plot(e,e*0., 'b')
else: else:
YY.set_xdata(e) YY.set_xdata(e)'''
elif modelo == 'gaussiana': elif modelo == 'gaussiana':
X = e*0. X = e*0.
try: '''try:
XX XX
except NameError: except NameError:
XX, = plot(e,e*0., 'r') #XX, = plot(e,e*0., 'r')
else: else:
XX.set_xdata(e) #XX.set_xdata(e)'''
dose = 2e34 dose = 12e34
Theta_s = PI - (p['Theta_in'] + p['Theta_out'])*PI/180 Theta_s = PI - (p['Theta_in'] + p['Theta_out'])*PI/180
mi = ion['mass'] mi = ion['mass']
espessura = 15
## Calcula o espectro de cada elemento da amostra ## Calcula o espectro de cada elemento da amostra
for componente in Edict: for componente in Edict:
...@@ -142,21 +141,23 @@ def spectro(p, modelo, ion, Emin, Emax, EPasso, passox, LScontrol, resol): ...@@ -142,21 +141,23 @@ def spectro(p, modelo, ion, Emin, Emax, EPasso, passox, LScontrol, resol):
X, gshiftX = convoluiGauss(X,resol/2.35482,EPasso) X, gshiftX = convoluiGauss(X,resol/2.35482,EPasso)
if modelo == 'bessel': if modelo == 'bessel':
YY.set_ydata(Y*dose) plt.plot(e-gshiftY,Y*dose, 'b')
#YY.set_ydata(Y-*dose)
ylim([0,max(Y*dose)*1.1]) ylim([0,max(Y*dose)*1.1])
elif modelo == 'gaussiana': elif modelo == 'gaussiana':
XX.set_ydata(X*dose) plt.plot(e-gshiftX,Y*dose, 'r')
#XX.set_ydata((X)*dose)
ylim([0,max(X*dose)*1.1]) ylim([0,max(X*dose)*1.1])
#plt.plot(e,Y*dose) #plt.plot(e,Y*dose)
suptitle('Signal received', fontsize=12) suptitle('Signal received', fontsize=12)
xlabel("Enegy (eV)") xlabel("Enegy (eV)")
ylabel("Yield") ylabel("Yield")
#amostra = np.loadtxt('H2.py') amostra = np.loadtxt('H2.py')
#xxx= amostra[:,0]*1000 xxx= amostra[:,0]*1000
#ccc=amostra[:,1] ccc=amostra[:,1]
#plot (xxx, ccc, 'r.') plot (xxx, ccc, 'r.')
show() show()
......
...@@ -3,7 +3,7 @@ import matplotlib.pyplot as plt ...@@ -3,7 +3,7 @@ import matplotlib.pyplot as plt
from pylab import * from pylab import *
from concentracao import * from concentracao import *
import sys import sys
import os #import os
listay = list() listay = list()
listax = list() listax = list()
...@@ -12,22 +12,21 @@ fig = plt.figure() ...@@ -12,22 +12,21 @@ fig = plt.figure()
ax = fig.add_subplot(111) ax = fig.add_subplot(111)
filename2 = sys.argv[1]+".prof" #raw_input() filename2 = sys.argv[1]+".prof" #raw_input()
filename = sys.argv[1]+".dat" #raw_input() filename = sys.argv[1]+".dat" #raw_input()
modo = sys.argv[2]
print "nome dos arquivos "+filename+" e "+ filename2 print "nome dos arquivos "+filename+" e "+ filename2
fig.canvas.set_window_title(filename) fig.canvas.set_window_title(filename)
dxstep = 0.01 dxstep = 0.01
profundidademax = 20. profundidademax = 30.
xx = arange(0,20, dxstep) # we'll create an x-axis from 0 to 2 pi xx = arange(0,profundidademax, dxstep) # we'll create an x-axis from 0 to 2 pi
temp, = plot(xx,xx*0) # this is our initial plot, and does nothing temp, = plot(xx,xx*0) # this is our initial plot, and does nothing
modo = 'step' #print os.getcwdu()+'/samples/'+filename
#modo = 'reta'
print os.getcwdu()+'/samples/'+filename
####################################################################################################### #######################################################################################################
# Add square # Add square
def add_square(x, y): def add_square(x, y):
global listay, drs, ax global listay, drs, ax
rect = ax.bar(x, 0.02, width=0.3) rect = ax.bar(x, 0.02, width=profundidademax*0.3/20)
for rec in rect: for rec in rect:
dr = DraggableRectangle(rec) dr = DraggableRectangle(rec)
dr.connect() dr.connect()
...@@ -223,7 +222,7 @@ for void in voidrect: ...@@ -223,7 +222,7 @@ for void in voidrect:
vf = voidfunctions(void) vf = voidfunctions(void)
vf.connect() vf.connect()
add_immovable_square(0,0) add_immovable_square(0,0)
add_immovable_square(20,0) add_immovable_square(profundidademax,0)
try: try:
f = np.loadtxt(filename) f = np.loadtxt(filename)
......
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