diff --git a/JFSphoto.py b/JFSphoto.py index 889458e..94b6184 100644 --- a/JFSphoto.py +++ b/JFSphoto.py @@ -309,6 +309,9 @@ class Jfsphoto (object): t = arange(0.0, 3.0, 0.01) s = sin(2*pi*t) self.ax1.plot(t, s, linewidth=0.6) + + self.calculate() + self.canvas = FigureCanvasTkAgg(self.fig, master = self.ctr_mid) self.canvas._tkcanvas.pack(side = tk.TOP, fill = tk.BOTH, expand = 1) @@ -322,47 +325,104 @@ class Jfsphoto (object): 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 - self.kbtn = tk.Button(master=self.ctr_right,text="Load Kini",padx=5,pady=5,command=self.kini) + self.kbtn = tk.Button(master=self.ctr_right,text="Load Kini",command=self.kini) self.kbtn.grid(row=7,column=0,sticky="w") + + self.listbox = tk.Listbox(master=self.ctr_right,selectmode = "multiple") + self.listbox.grid(row=8,column=0,sticky='w') + self.scrollbar = tk.Scrollbar(master=self.ctr_right) + self.listbox.config(yscrollcommand =self.scrollbar.set) + self.scrollbar.config(command = self.listbox.yview) + self.kbtn1 = tk.Button(master=self.ctr_right,text="show",command=self.kini) + self.kbtn1.grid(row=14,column=0,sticky="w") + + + win.focus_set() win.grab_set() win.wait_window() + def calculate(self): + self.get_kin_list() + self.do_get_range() + for xx in self.col_list: + self.do_absorption(xx) + + def get_kin_list(self): + self.col_list = list(self.df.columns.values.tolist()) + self.col_list.remove('baseline') + self.col_list.remove('darkline') + self.col_list.remove('nmscale') + def kini(self): self.load_kinetics("kini.dat") + self.calculate() self.ax1.clear() - self.df.plot(x = 'nmscale',y = 'darkline', 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 = '2', color='green',linewidth=0.6,ax=self.ax1) + for xx in self.col_list: + self.df.plot(x = 'nmscale',y = xx, linewidth=0.6,ax=self.ax1) + self.listbox.insert(tk.END, xx) self.canvas.draw() - print(self.df.head()) + + def do_get_range(self): + self.right = 0 + self.left = 0 + b = self.df['baseline'] + for i in range(0,3694): + if b[i]==0: + if (self.left > 0 and self.right==0): + self.right=i + else: + if (self.left==0): + self.left=i + + def do_absorption(self,xx): + y = self.df['darkline'] - self.df[xx] + b = self.df['baseline'] + c = np.zeros(3694, np.float32) + for i in range(0,3694): + if b[i]==0: + c[i] = 1 + else: + c[i] = y[i]/b[i] + self.df[xx+'_abs'] = c def look(self): + # self.get_kin_list() + # self.do_get_range() + # for xx in self.col_list: + # self.do_absorption(xx) self.ax1.clear() if self.ok.get()==1: - self.df.plot(x = 'nmscale',y = 'p1', color='red',linewidth=0.6,ax=self.ax1) + for xx in self.col_list: + self.df.plot(x = 'nmscale',y = xx, linewidth=0.6,ax=self.ax1) + #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) + for xx in self.col_list: + self.df.plot(x = 'nmscale',y = xx, linewidth=0.6,ax=self.ax1) + #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['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] = y[i]/b[i] - 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]) + # 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] = y[i]/b[i] + #self.df['Absorption'] = c + for xx in self.col_list: + self.df.plot(x = 'nmscale',y = xx+'_abs', linewidth=0.6,ax=self.ax1) + #self.df.plot(x = 'nmscale',y = 'Absorption', color='red',linewidth=0.6,ax=self.ax1) + self.ax1.set_xlim([self.nm_left+self.left*self.nm_step, self.nm_left+self.right*self.nm_step]) elif self.ok.get()==4: right = 0 left = 0