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,
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'
Econtrol = i
button[i]['relief']='sunken'
......@@ -157,6 +157,9 @@ def ewin_build(window, xmax, xstep):
Entrysymbol.pack()
EntryLS.pack()
methodvar = tk.StringVar()
methodvar.set('reta')
##############################################################################
# Buttons
......@@ -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.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')
##############################################################################
# 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
RS.select()
Ebuttons[0].invoke()
##############################################################################
......
......@@ -10,6 +10,7 @@ import sys
param = dict(dedx=192. ,Theta_out=70., dW2dx=20740., E0= 100000., Theta_in=0., FWHM0=180.)
ionb = dict(Z=1, mass=1.0079)
init=0
espessura = 30.
##############################################################################
# Report file, writes parameters
......@@ -50,7 +51,7 @@ def init_calc():
for i in range(len(Edict)):
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
......@@ -204,10 +205,10 @@ ExitButton.pack(side='bottom')
##############################################################################
# Elements callback
ewin_build(Label1, 15, float(EntryDstep.get()))
ewin_build(Label1, espessura, float(EntryDstep.get()))
##############################################################################
if init == 0:
if init == 1:
CalcButton.invoke()
init = 1
......
......@@ -39,7 +39,7 @@ def montaperfil( xy , step, modo):
if modo == 'reta':
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)
u = round(i[0],2)
yu = i[1]
......
......@@ -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)
if modelo == 'bessel':
Y = e*0.
try:
'''try:
YY
except NameError:
YY, = plot(e,e*0., 'b')
else:
YY.set_xdata(e)
YY.set_xdata(e)'''
elif modelo == 'gaussiana':
X = e*0.
try:
'''try:
XX
except NameError:
XX, = plot(e,e*0., 'r')
#XX, = plot(e,e*0., 'r')
else:
XX.set_xdata(e)
#XX.set_xdata(e)'''
dose = 2e34
dose = 12e34
Theta_s = PI - (p['Theta_in'] + p['Theta_out'])*PI/180
mi = ion['mass']
espessura = 15
## Calcula o espectro de cada elemento da amostra
for componente in Edict:
......@@ -142,21 +141,23 @@ def spectro(p, modelo, ion, Emin, Emax, EPasso, passox, LScontrol, resol):
X, gshiftX = convoluiGauss(X,resol/2.35482,EPasso)
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])
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])
#plt.plot(e,Y*dose)
suptitle('Signal received', fontsize=12)
xlabel("Enegy (eV)")
ylabel("Yield")
#amostra = np.loadtxt('H2.py')
#xxx= amostra[:,0]*1000
#ccc=amostra[:,1]
amostra = np.loadtxt('H2.py')
xxx= amostra[:,0]*1000
ccc=amostra[:,1]
#plot (xxx, ccc, 'r.')
plot (xxx, ccc, 'r.')
show()
......
......@@ -3,7 +3,7 @@ import matplotlib.pyplot as plt
from pylab import *
from concentracao import *
import sys
import os
#import os
listay = list()
listax = list()
......@@ -12,22 +12,21 @@ fig = plt.figure()
ax = fig.add_subplot(111)
filename2 = sys.argv[1]+".prof" #raw_input()
filename = sys.argv[1]+".dat" #raw_input()
modo = sys.argv[2]
print "nome dos arquivos "+filename+" e "+ filename2
fig.canvas.set_window_title(filename)
dxstep = 0.01
profundidademax = 20.
xx = arange(0,20, dxstep) # we'll create an x-axis from 0 to 2 pi
profundidademax = 30.
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
modo = 'step'
#modo = 'reta'
print os.getcwdu()+'/samples/'+filename
#print os.getcwdu()+'/samples/'+filename
#######################################################################################################
# Add square
def add_square(x, y):
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:
dr = DraggableRectangle(rec)
dr.connect()
......@@ -223,7 +222,7 @@ for void in voidrect:
vf = voidfunctions(void)
vf.connect()
add_immovable_square(0,0)
add_immovable_square(20,0)
add_immovable_square(profundidademax,0)
try:
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