From fe22a21046135dc3f9e48adf2f39c33d9a012fff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matheus=20M=C3=BCller?= Date: Fri, 9 Dec 2011 13:47:32 -0200 Subject: [PATCH] =?UTF-8?q?Op=C3=A7=C3=A3o=20de=20metodo=20de=20interpola?= =?UTF-8?q?=C3=A7ao=20na=20interface?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ewindow.py | 16 ++++++++++++++-- OpenFlatus.py | 7 ++++--- concentracao.py | 2 +- numerical.py | 29 +++++++++++++++-------------- profiler.py | 15 +++++++-------- 5 files changed, 41 insertions(+), 28 deletions(-) diff --git a/Ewindow.py b/Ewindow.py index 3cd3232..1c2335e 100644 --- a/Ewindow.py +++ b/Ewindow.py @@ -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() ############################################################################## diff --git a/OpenFlatus.py b/OpenFlatus.py index dc33f54..83d73d8 100644 --- a/OpenFlatus.py +++ b/OpenFlatus.py @@ -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 diff --git a/concentracao.py b/concentracao.py index 002c1e7..596158d 100644 --- a/concentracao.py +++ b/concentracao.py @@ -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] diff --git a/numerical.py b/numerical.py index eec7716..6c24b8c 100644 --- a/numerical.py +++ b/numerical.py @@ -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() diff --git a/profiler.py b/profiler.py index c211215..9ce2972 100644 --- a/profiler.py +++ b/profiler.py @@ -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) -- 2.22.0