def RebinSparam(self): self.num = 0 self.top = Toplevel() self.top.title("REBIN PARAMETER") #-------------------------- Prepare group -------------------------------------------------- dif = lambda x: numpy.argmax( numpy.gradient(x.mu) / numpy.gradient(x.energy)) Eo = PPfs_spec[0].energy[dif(PPfs_spec[0])] self.Edgep.set(Eo) self.evaluatepar() #-------------------------- Graphic win -------------------------------------------------- self.graphframe = Frame(self.top) self.graphframe.pack(side=TOP, fill=BOTH, expand=YES) self.grap_win = ut.ParamGraph(self.graphframe, PPfs_spec, "energy", ["mu"], xlabel='energy (eV)', ylabel='mu (abs. unit)') self.grap_win.plot(self.num) self.grap_win.paramplot(self.get_param(), ["b", "g", "k", "r", "b"], ["Min", "XAN", "Eo", "EXAFS", "Max"]) if len(PPfs_spec) > 1: self.grap_win.slider.configure(command=self.panor2) #self.grap_win.onmoving=self.onmoving self.grap_win.canvas.mpl_disconnect(self.grap_win.mov_link) self.grap_win.mov_link = self.grap_win.canvas.mpl_connect( 'motion_notify_event', self.onmoving)
def Compare(self): spectro, name = self.Comn_res() self.num = 0 self.top = Toplevel() self.top.title("COMPARES ") #+ str(self.comp.get())+ " component") #-------------------------- Graphic win -------------------------------------------------- self.graphframe = Frame(self.top) self.graphframe.pack(side=LEFT, fill=BOTH, expand=YES) self.grap_win = ut.ParamGraph(self.graphframe, spectro, "x", ["exp", "sim", "res"] + name) self.grap_win.plot(self.num)
def ranges(self): if not hasattr(self.file_sel, "spectra"): print "\n" * 5 + "#" * 20 + "\nno spectra defined\n" return num = 0 self.top = Toplevel() self.top.title("RANGES PARAMETER") #-------------------------- Graphic win -------------------------------------------------- self.graphframe = Frame(self.top) self.graphframe.pack(side=LEFT, fill=BOTH, expand=YES) self.grap_win = ut.ParamGraph(self.graphframe, self.file_sel.spectra, "x", ["y"]) self.grap_win.plot(num) self.grap_win.paramplot(self.retr_ranges(), ["g"] + ["k"], ["lim1", "lim2"]) if len(self.file_sel.spectra) > 1: self.grap_win.slider.configure(command=self.panor2) self.grap_win.canvas.mpl_disconnect( self.grap_win.mov_link) # new pick release link self.grap_win.mov_link = self.grap_win.canvas.mpl_connect( 'motion_notify_event', self.onmoving) # new pick release link
def __init__(self, genitore): self.genitore = genitore #-------------------------- Declare-------------------------------------------------- self._Eop = StringVar() self._pr_es = StringVar() self._pr_ee = StringVar() self._po_es = StringVar() self._po_ee = StringVar() self._n_poly = StringVar() self.n_poly = 3 self.parN = ["pre1", "pre2", "e0", "norm1", "norm2", "nnorm"] #-------------------------- Define-------------------------------------------------- self.num = 0 if PPset.spectra.call_pe["e0"]: self._Eop.set(PPset.spectra.call_pe["e0"]) else: self._Eop.set("Ifeffit default") if PPset.spectra.call_pe["pre1"]: self._pr_es.set(PPset.spectra.call_pe["pre1"]) else: self._pr_es.set("Ifeffit default") if PPset.spectra.call_pe["pre2"]: self._pr_ee.set(PPset.spectra.call_pe["pre2"]) else: self._pr_ee.set(-50) if PPset.spectra.call_pe["norm1"]: self._po_es.set(PPset.spectra.call_pe["norm1"]) else: self._po_es.set(150) if PPset.spectra.call_pe["norm2"]: self._po_ee.set(PPset.spectra.call_pe["norm2"]) else: self._po_ee.set("Ifeffit default") self._n_poly.set(PPset.spectra.call_pe["nnorm"]) #-------------------------- Params Entries-------------------------------------------------- self.param_win = Frame(genitore) self.param_win.pack(side=LEFT) self.quadro_Eop = LabelFrame(self.param_win, text="Eo") self.quadro_Eop.pack(side=TOP, fill=X) self._entry_Eop = Entry(self.quadro_Eop, width=20, textvariable=self._Eop) self._entry_Eop.pack(side=LEFT, padx=5, ipady=3, fill=X) self.quadro_pr_es = LabelFrame(self.param_win, text="pre1") self.quadro_pr_es.pack(side=TOP, fill=X) self._entry_pr_es = Entry(self.quadro_pr_es, width=20, textvariable=self._pr_es) self._entry_pr_es.pack(side=LEFT, padx=5, ipady=3, fill=X) self.quadro_pr_ee = LabelFrame(self.param_win, text="pre2") self.quadro_pr_ee.pack(side=TOP, fill=X) self._entry_pr_ee = Entry(self.quadro_pr_ee, width=20, textvariable=self._pr_ee) self._entry_pr_ee.pack(side=LEFT, padx=5, ipady=3, fill=X) self.quadro_po_es = LabelFrame(self.param_win, text="Norm1") self.quadro_po_es.pack(side=TOP, fill=X) self._entry_po_es = Entry(self.quadro_po_es, width=20, textvariable=self._po_es) self._entry_po_es.pack(side=LEFT, padx=5, ipady=3, fill=X) self.quadro_po_ee = LabelFrame(self.param_win, text="Norm2") self.quadro_po_ee.pack(side=TOP, fill=X) self._entry_po_ee = Entry(self.quadro_po_ee, width=20, textvariable=self._po_ee) self._entry_po_ee.pack(side=LEFT, padx=5, ipady=3, fill=X) self.quadro_n_poly = LabelFrame(self.param_win, text="n_poly") self.quadro_n_poly.pack(side=TOP, fill=X) self._entry_n_poly = Entry(self.quadro_n_poly, width=20, textvariable=self._n_poly) self._entry_n_poly.pack(side=LEFT, padx=5, ipady=3, fill=X) self.rerefresh = Button( self.param_win, command=self.refresh, #lambda x= self.num: self.refresh(x), text="refresh graph", background="violet", width=20, padx="3m", pady="2m") self.rerefresh.pack(side=TOP, anchor=W, padx=5, pady=5) self.resave = Button(self.param_win, command=self.saveparam, text="Save new paramerter", background="green", width=20, padx="3m", pady="2m") self.resave.pack(side=TOP, anchor=W, padx=5, pady=5) #-------------------------- Graphic win -------------------------------------------------- self.graphframe = Frame(genitore) self.graphframe.pack(side=LEFT, fill=BOTH, expand=YES) self.grap_win = ut.ParamGraph(self.graphframe, PPset.spectra, "energy", ["mu", "pre_edge", "post_edge"], xlabel='energy (eV)', ylabel='mu (abs. unit)') self.refresh() self.grap_win.pick = self.grap_win.canvas.mpl_connect( 'pick_event', self.onpick) # new pick release link self.grap_win.release = self.grap_win.canvas.mpl_connect( 'button_release_event', self.onrelease) self.press = False self.grap_win.slider.configure( command=self.panor2) # new pick release link genitore.wait_window()
def __init__(self, genitore, ini): global x #-------------------------- Declare-------------------------------------------------- self._smoot = StringVar() self._interpolation = StringVar() #-------------------------- Define-------------------------------------------------- self.genitore = genitore self.num_der = 0 self.smoot, self.interpolation, self.lim1, self.lim2 = ini self._smoot.set(self.smoot) if self.interpolation == 0: self._interpolation.set("experimental sampling") else: self._interpolation.set(self.interpolation) #-------------------------- Params Entries-------------------------------------------------- self.param_win_der = Frame(self.genitore) self.param_win_der.pack(side=LEFT) self.quadro_spin_smoot = LabelFrame(self.param_win_der, text="smoot float from 0 to 1%") self.quadro_spin_smoot.pack(side=TOP, fill=X) self.spin_smoot = Entry(self.quadro_spin_smoot, textvariable=self._smoot, width=10) self.spin_smoot.pack(side=LEFT, anchor=W, padx=5, ipadx=2, ipady=3) self.quadro_inter = LabelFrame(self.param_win_der, text="interpolation") self.quadro_inter.pack(side=TOP, fill=X) self._spin_inter = Spinbox( self.quadro_inter, from_=0.0, to=1.0, increment=0.02, command=lambda x=self.num_der: self.panor2_der(x), textvariable=self._interpolation, state="readonly", width=5) self._spin_inter.pack(side=LEFT, padx=5, ipady=3, fill=X, expand=Y) Label(self.quadro_inter, text="eV", justify=LEFT).pack(side=LEFT, anchor=W) self.toprefr = Button(self.param_win_der, command=self.refresh_der, text="refresh", background="violet", width=20, padx="3m", pady="2m") self.toprefr.pack(side=TOP, anchor=W, padx=5, pady=5) self.topsave = Button(self.param_win_der, command=self.saveparam_deriv, text="Save new paramerter", background="green", width=20, padx="3m", pady="2m") self.topsave.pack(side=TOP, anchor=W, padx=5, pady=5) #-------------------------- Graph -------------------------------------------------- self.graphframe_der = Frame(self.genitore) self.graphframe_der.pack(side=LEFT, fill=BOTH) self.grap_win_der = ut.ParamGraph(self.graphframe_der, PPset.spectra, "x_int", ["deriv"]) self.refresh_der() self.grap_win_der.slider.configure(command=self.panor2_der) #-------------------------- Graph -------------------------------------------------- genitore.wait_window()
def __init__(self, genitore): self.genitore=genitore #-------------------------- Declare-------------------------------------------------- self._Eop = StringVar() self._skmin = StringVar() self._skmax = StringVar() self._rbkg = StringVar() self.kweigth = IntVar() self.kweigthp= IntVar() self.parN= ["e0" , "kmin", "kmax", "rbkg", "kweight"] #-------------------------- Define-------------------------------------------------- self.num=0 if PPset.spectra.call_abk["e0"]: self._Eop.set(PPset.spectra.call_abk["e0"]) else: self._Eop.set("default") if PPset.spectra.call_abk["kmin"]: self._skmin.set(PPset.spectra.call_abk["kmin"]) else: self._skmin.set(0) if PPset.spectra.call_abk["kmax"]: self._skmax.set(PPset.spectra.call_abk["kmax"]) else: self._skmax.set("default") if PPset.spectra.call_abk["rbkg"]: self._rbkg.set(PPset.spectra.call_abk["rbkg"]) else: self._rbkg.set(1) if PPset.spectra.call_abk["kweight"]: self.kweigth.set(PPset.spectra.call_abk["kweight"]) else: self.kweigth.set(1) self.kweigthp.set(1) #------------------------------------------------------ self.param_win = Frame(genitore) self.param_win.pack(side=LEFT) self.quadro_Eop = LabelFrame(self.param_win, text = "Eo") self.quadro_Eop.pack(side = TOP, fill = X) self._entry_Eop= Entry(self.quadro_Eop, width = 10, textvariable=self._Eop) self._entry_Eop.pack(side = LEFT, padx = 5, ipady = 3, fill = X) self.quadro_skmin = LabelFrame(self.param_win, text = "skmin") self.quadro_skmin.pack(side = TOP, fill = X) self._entry_skmin= Entry(self.quadro_skmin, width = 10, textvariable=self._skmin) self._entry_skmin.pack(side = LEFT, padx = 5, ipady = 3, fill = X) self.quadro_skmax = LabelFrame(self.param_win, text = "skmax") self.quadro_skmax.pack(side = TOP, fill = X) self._entry_skmax= Entry(self.quadro_skmax, width = 10, textvariable=self._skmax) self._entry_skmax.pack(side = LEFT, padx = 5, ipady = 3, fill = X) self.quadro_rbkg = LabelFrame(self.param_win, text = "rbkg") self.quadro_rbkg.pack(side = TOP, fill = X) self._entry_rbkg= Entry(self.quadro_rbkg, width = 10, textvariable=self._rbkg) self._entry_rbkg.pack(side = LEFT, padx = 5, ipady = 3, fill = X) self.quadro_spin_kweigth = LabelFrame(self.param_win, text = "k_wgt k_plot") self.quadro_spin_kweigth.pack(side = TOP, fill = X, ipady=2, anchor = W, padx=2) self.spin_kweigth = Spinbox(self.quadro_spin_kweigth, from_ = 0, to = 3, textvariable= self.kweigth, width = 2) self.spin_kweigth.pack(side = LEFT ,anchor = W, padx = 5, ipadx = 1, ipady = 3) #, expand = YES, fill = BOTH self.spin_kweigthp = Spinbox(self.quadro_spin_kweigth, from_ = 0, to = 3, textvariable= self.kweigthp, width = 2) self.spin_kweigthp.pack(side = LEFT ,anchor = W, padx = 8, ipadx = 2, ipady = 3) #, expand = YES, fill = BOTH self.rerefresh = Button(self.param_win, command = self.refresh,#lambda x= self.num: self.refresh(x), text = "refresh", background = "violet", width = 8, padx = "3m", pady = "2m") self.rerefresh.pack(side = TOP, anchor = W, padx = 5, pady = 3) self.resave = Button(self.param_win, command = self.saveparam, text = "Save param", background = "green", width = 8, padx = "3m", pady = "2m") self.resave.pack(side = TOP, anchor = W, padx = 5, pady = 3) #-------------------------- Graphic win -------------------------------------------------- self.graphframeM = Frame(genitore) self.graphframeM.pack(side = LEFT, fill=BOTH, expand=YES) self.graphframeE = Frame(genitore) self.graphframeE.pack(side = LEFT, fill=BOTH, expand=YES) self.graphframeF = Frame(genitore) self.graphframeF.pack(side = LEFT, fill=BOTH, expand=YES) self.grap_winM=ut.ParamGraph(self.graphframeM, PPset.spectra, "energy", ["mu", "bkg"], xlabel= '$energy (eV)$', ylabel= '$mu (abs. unit)$' ) self.grap_winE=ut.ParamGraph(self.graphframeE, PPset.spectra, "k", ["chiw"], xlabel= '$k(\AA^{-1})$', ylabel= 'kchi(k)' ) self.grap_winF=ut.ParamGraph(self.graphframeF, PPset.spectra, "r", ["chir_mag"], xlabel= '$R(\AA)$', ylabel= 'FT' ) if (len(PPset.spectra)>1): self.grap_winF.slider.pack_forget() self.grap_winE.slider.pack_forget() self.grap_winM.slider.pack_forget() self.slider = Scale(genitore, from_= 0, to=len(PPset.spectra)-1, command =self.panor2, orient=VERTICAL, label= "Spectra" ) self.slider.pack(side = LEFT,fill = Y, anchor = N,pady = 5, ipady = 0) self.grap_winE.pick=self.grap_winE.canvas.mpl_connect('pick_event', self.onpick) # new pick release link self.grap_winE.release=self.grap_winE.canvas.mpl_connect('button_release_event', self.onrelease) self.grap_winE.canvas.mpl_connect('figure_leave_event', self.onout) self.grap_winF.pick=self.grap_winF.canvas.mpl_connect('pick_event', self.onpick) # new pick release link self.grap_winF.release=self.grap_winF.canvas.mpl_connect('button_release_event', self.onrelease) self.grap_winF.canvas.mpl_connect('figure_leave_event', self.onout) self.grap_winM.pick=self.grap_winM.canvas.mpl_connect('pick_event', self.onpick) # new pick release link self.grap_winM.release=self.grap_winM.canvas.mpl_connect('button_release_event', self.onrelease) self.grap_winM.canvas.mpl_connect('figure_leave_event', self.onout) self.out=False self.press=False #self.preposted() #self.onrelease("pippo") #self.refresh() self.refresh() # new pick release link genitore.wait_window()
def __init__(self, genitore): self.genitore=genitore #-------------------------- Declare-------------------------------------------------- self._kstart = StringVar() self._kend = StringVar() self.FTweigth = IntVar() self._FTWind = StringVar() self._dk = StringVar() self.kweigthp= IntVar() #-------------------------- Define-------------------------------------------------- packLabelFrame = {"side" : TOP, "expand" : YES, "anchor" : W, "pady" : 3} packEntry = {"side" : LEFT, "anchor" : W, "pady" : 6, "padx" : 3, "fill" : X } self.num=0 self.kweigthp.set(1) if PPset.spectra.call_xftf["dk"]: self._dk.set(PPset.spectra.call_xftf["dk"]) else: self._dk.set("default") if PPset.spectra.call_xftf["kmin"]: self._kstart.set(PPset.spectra.call_xftf["kmin"]) else: self._kstart.set(0) if PPset.spectra.call_xftf["kmax"]: self._kend.set(PPset.spectra.call_xftf["kmax"]) else: self._kend.set("default") if PPset.spectra.call_xftf["kweight"]:self.FTweigth.set(PPset.spectra.call_xftf["kweight"]) else: self.FTweigth.set(1) if PPset.spectra.call_xftf["window"]: self._FTWind.set(PPset.spectra.call_xftf["window"]) else: self._FTWind.set('kaiser') #------------------------------------------------------ self.param_win = Frame(genitore) self.param_win.pack(side=LEFT) self.quadro_FT = LabelFrame(self.param_win, text = "Foward FT") #,text = "Correction" self.quadro_FT.pack(side = TOP, fill = X, pady= 3, ipadx = 5, ipady = 3) self.quadro_FT1 = Frame(self.quadro_FT) self.quadro_FT1.pack(side = TOP, fill = X) self.quadro_FTweigth = LabelFrame(self.quadro_FT1, text = "FT_wgt Plot_wgt") self.quadro_FTweigth.pack(**packLabelFrame) self.spin_FTweigth = Spinbox(self.quadro_FTweigth, from_ = 0, to = 3, textvariable= self.FTweigth, width = 3) self.spin_FTweigth.pack(side = LEFT ,anchor = S, pady=5, padx = 5, ipadx = 1) self.spin_kweigthp = Spinbox(self.quadro_FTweigth, from_ = 0, to = 3, textvariable= self.kweigthp, width = 2) self.spin_kweigthp.pack(side = LEFT ,anchor = W, padx = 8, ipadx = 2, ipady = 3) #, expand = YES, fill = BOTH #Label(self.quadro_FT1, text = "FT_weigth", justify = LEFT).pack(side = LEFT, anchor = S, pady=10) self.quadro_FTwin = LabelFrame(self.quadro_FT1, text = "FT_win") self.quadro_FTwin.pack(**packLabelFrame) self.combo_FTw= ttk.Combobox(self.quadro_FTwin , state="readonly", textvariable=self._FTWind, width=5, values=('kaiser', 'hanning', 'welch', 'sine')) self.combo_FTw.pack(side = LEFT ,anchor = S, pady=5, padx = 5, ipadx = 1) self.quadro_FT_lim1 = LabelFrame(self.quadro_FT1, text = "k start") self.quadro_FT_lim1.pack(**packLabelFrame) self._entry_FT_kstart= Entry(self.quadro_FT_lim1, width = 7, textvariable=self._kstart) self._entry_FT_kstart.pack(**packEntry) self.quadro_FT_lim2 = LabelFrame(self.quadro_FT1, text = "k end") self.quadro_FT_lim2.pack(**packLabelFrame) self._entry_FT_kend= Entry(self.quadro_FT_lim2, width = 7, textvariable=self._kend) self._entry_FT_kend.pack(**packEntry) self.quadro_FT_dk = LabelFrame(self.quadro_FT1, text = "dk") self.quadro_FT_dk.pack(**packLabelFrame) self._entry_FT_dk= Entry(self.quadro_FT_dk, width = 7, textvariable=self._dk) self._entry_FT_dk.pack(**packEntry) self.quadro_FT2 = Frame(self.quadro_FT) self.quadro_FT2.pack(side = TOP, fill = BOTH, expand= YES,) self.quadro_FTMg = LabelFrame(self.quadro_FT2, text = "FT Mag.") self.quadro_FTMg.pack(fill= X, **packLabelFrame) self.quadro_FTIm = LabelFrame(self.quadro_FT2, text = "FT Im.") self.quadro_FTIm.pack(fill= X, **packLabelFrame) self.rerefresh = Button(self.param_win, command = self.refresh,#lambda x= self.num: self.refresh(x), text = "refresh", background = "violet", width = 8, padx = "3m", pady = "2m") self.rerefresh.pack(side = TOP, anchor = W, padx = 5, pady = 3) self.resave = Button(self.param_win, command = self.saveparam, text = "Save param", background = "green", width = 8, padx = "3m", pady = "2m") self.resave.pack(side = TOP, anchor = W, padx = 5, pady = 3) #-------------------------- Graphic win -------------------------------------------------- #self.graphframeM = Frame(genitore) #self.graphframeM.pack(side = LEFT, fill=BOTH, expand=YES) self.graphframeE = Frame(genitore) self.graphframeE.pack(side = LEFT, fill=BOTH, expand=YES) self.graphframeF = Frame(genitore) self.graphframeF.pack(side = LEFT, fill=BOTH, expand=YES) self.grap_winE=ut.ParamGraph(self.graphframeE, PPset.spectra, "k", ["chiw","kwin"]) self.grap_winF=ut.ParamGraph(self.graphframeF, PPset.spectra, "r", ["chir_mag"]) if (len(PPset.spectra)>1): self.grap_winF.slider.pack_forget() self.grap_winE.slider.pack_forget() self.slider = Scale(genitore, from_= 0, to=len(PPset.spectra)-1, command =self.panor2, orient=VERTICAL, label= "Spectra" ) self.slider.pack(side = LEFT,fill = Y, anchor = N,pady = 5, ipady = 0) self.grap_winE.pick=self.grap_winE.canvas.mpl_connect('pick_event', self.onpick) # new pick release link self.grap_winE.release=self.grap_winE.canvas.mpl_connect('button_release_event', self.onrelease) self.grap_winE.canvas.mpl_connect('figure_leave_event', self.onout) self.out=False self.refresh() genitore.wait_window()