diff --git a/CCDpanelsetup.py b/CCDpanelsetup.py index b041e54..fcef7f2 100644 --- a/CCDpanelsetup.py +++ b/CCDpanelsetup.py @@ -410,9 +410,12 @@ class buildpanel(tk.Frame): if (config.pltBaseData16[i] == 0): config.pltData16[i] = 1 else: - config.pltData16[i] = (config.pltData16[i] / config.pltBaseData16[i]) - if (self.jf.abs_trans.get()==1): - config.pltData16 = np.log10(config.pltData16)*-1 + if (self.jf.abs_trans.get()==1): + config.pltData16[i] = np.log10(config.pltBaseData16[i] / config.pltData16[i]) + else: + config.pltData16[i] = (config.pltData16[i] / config.pltBaseData16[i]) + #if (self.jf.abs_trans.get()==1): + # config.pltData16 = np.log10(config.pltData16)*-1 try: up = np.max(config.pltData16) if (self.jf.get_nm_checked()==1): diff --git a/JFSphoto.py b/JFSphoto.py index 39a5322..59f169a 100644 --- a/JFSphoto.py +++ b/JFSphoto.py @@ -11,7 +11,7 @@ import config import matplotlib.pyplot as plt #matplotlib.use("TkAgg") -from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg +from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg,NavigationToolbar2Tk from matplotlib.figure import Figure from numpy import arange, sin, pi,cos ####################################### object @@ -274,74 +274,55 @@ class Jfsphoto (object): except IOError: print("By the great otter!","No config.ini file") - #def do_math(self): - # root = tk.Tk() - - # center = tk.Frame(root, bg='gray2', width=50, height=40, padx=3, pady=3) - # root.grid_rowconfigure(1, weight=1) - # root.grid_columnconfigure(0, weight=1) - # center.grid(row=1, sticky="nsew") - # center.grid_rowconfigure(0, weight=1) - # center.grid_columnconfigure(1, weight=1) - # ctr_mid = tk.Frame(center, bg='yellow', width=250, height=190, padx=3, pady=3) - # ctr_right = tk.Frame(center, bg='green', width=100, height=190, padx=3, pady=3) - # ctr_mid.grid(row=0, column=0, sticky="nsew") - # ctr_right.grid(row=0, column=1, sticky="ns") - - # root.title("Mathoptions") - # fig = plt.Figure(figsize=(8,4),dpi=100) - # ax1 = fig.add_subplot(111) - # self.df.plot(x = 'nmscale',y = 'p1', color='red',linewidth=0.6,ax=ax1) - # canvas = FigureCanvasTkAgg(fig, master = ctr_mid) - # canvas._tkcanvas.pack(side = tk.TOP, fill = tk.BOTH, expand = 1) - - # root.mainloop() + def do_math(self): - stati = [("Raw",1),("Raw + Baseline",2),("Transmission",3),("Absorption",4)] + stati = [("Raw",1),("Raw + Baseline",2),("Transmission",4),("Absorption",3)] win = tk.Toplevel() - #win.geometry("450x200+100+100") self.center = tk.Frame(win, bg='gray2', width=50, height=40, padx=3, pady=3) - # self.master.grid_rowconfigure(1, weight=1) - # self.master.grid_columnconfigure(0, weight=1) self.center.grid_rowconfigure(0, weight=1) self.center.grid_columnconfigure(1, weight=1) self.center.grid(row=1, sticky="nsew") - self.ctr_mid = tk.Frame(self.center, bg='yellow', width=250, height=190, padx=3, pady=3) - self.ctr_right = tk.Frame(self.center, bg='green', width=200, height=190, padx=3, pady=3) + self.ctr_mid = tk.Frame(self.center, width=250, height=250, padx=3, pady=3) + self.ctr_right = tk.Frame(self.center, width=200, height=250, padx=3, pady=3) self.ctr_mid.grid(row=0, column=0, sticky="nsew") self.ctr_right.grid(row=0, column=1, sticky="ns") + self.fig = plt.Figure(figsize=(8,4),dpi=100) + self.ax1 = self.fig.add_subplot(111) t = arange(0.0, 3.0, 0.01) s = sin(2*pi*t) self.ax1.plot(t, s, linewidth=0.6) self.canvas = FigureCanvasTkAgg(self.fig, master = self.ctr_mid) self.canvas._tkcanvas.pack(side = tk.TOP, fill = tk.BOTH, expand = 1) - #self.chb = tk.Checkbutton(master=self.ctr_right,text='Raw',variable=self.ok,command=self.look) - #self.chb.grid(row=0,column=0) + + + self.toolbarFrame = tk.Frame(master=self.center,padx=5,pady=5) + self.toolbarFrame.grid(row=1,columnspan=2, sticky="w") + toolbar1 = NavigationToolbar2Tk(self.canvas, self.toolbarFrame) + + n = 0 for txt,val in stati: tk.Radiobutton(master=self.ctr_right,text=txt,variable=self.ok,command=self.look,value=val,padx=5,pady=5).grid(row=n,column=0,sticky="w") n=n+1 - - win.focus_set() win.grab_set() win.wait_window() def look(self): - #print(self.ok.get()) self.ax1.clear() if self.ok.get()==1: self.df.plot(x = 'nmscale',y = 'p1', color='red',linewidth=0.6,ax=self.ax1) elif self.ok.get()==2: self.df.plot(x = 'nmscale',y = 'p1', color='red',linewidth=0.6,ax=self.ax1) self.df.plot(x = 'nmscale',y = 'baseline', color='blue',linewidth=0.6,ax=self.ax1) + self.df.plot(x = 'nmscale',y = 'darkline', color='black',linewidth=0.6,ax=self.ax1) elif self.ok.get()==3: right = 0 left = 0 - y = self.df['p1'] + y = self.df['darkline'] - self.df['p1'] b = self.df['baseline'] c = np.zeros(3694, np.float32) for i in range(0,3694): @@ -353,19 +334,26 @@ class Jfsphoto (object): if (left==0): left=i c[i] = y[i]/b[i] - print("left ",left," right ",right) - self.df['p2']=c - - #for i in range(0,3694): - # self.df - # if (self.df(pltBaseData16[i] == 0): - # config.pltData16[i] = 1 - # else: - # config.pltData16[i] = (config.pltData16[i] / config.pltBaseData16[i]) - # if (self.jf.abs_trans.get()==1): - # config.pltData16 = np.log10(config.pltData16)*-1 - - self.df.plot(x = 'nmscale',y = 'p2', color='red',linewidth=0.6,ax=self.ax1) + self.df['Absorption'] = c + self.df.plot(x = 'nmscale',y = 'Absorption', color='red',linewidth=0.6,ax=self.ax1) + self.ax1.set_xlim([self.nm_left+left*self.nm_step, self.nm_left+right*self.nm_step]) + elif self.ok.get()==4: + right = 0 + left = 0 + y = self.df['darkline'] - self.df['p1'] + b = self.df['baseline'] + c = np.zeros(3694, np.float32) + for i in range(0,3694): + if b[i]==0: + c[i] = 1 + if (left > 0 and right==0): + right=i + else: + if (left==0): + left=i + c[i] = np.log10(b[i]/y[i]) + self.df['Transmission'] = c + self.df.plot(x = 'nmscale',y = 'Transmission', color='red',linewidth=0.6,ax=self.ax1) self.ax1.set_xlim([self.nm_left+left*self.nm_step, self.nm_left+right*self.nm_step]) else: t = arange(0.0, 3.0, 0.01)