Math first part ok
This commit is contained in:
parent
dc97dedbfd
commit
ded873ccac
@ -410,9 +410,12 @@ class buildpanel(tk.Frame):
|
|||||||
if (config.pltBaseData16[i] == 0):
|
if (config.pltBaseData16[i] == 0):
|
||||||
config.pltData16[i] = 1
|
config.pltData16[i] = 1
|
||||||
else:
|
else:
|
||||||
config.pltData16[i] = (config.pltData16[i] / config.pltBaseData16[i])
|
if (self.jf.abs_trans.get()==1):
|
||||||
if (self.jf.abs_trans.get()==1):
|
config.pltData16[i] = np.log10(config.pltBaseData16[i] / config.pltData16[i])
|
||||||
config.pltData16 = np.log10(config.pltData16)*-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
|
||||||
try:
|
try:
|
||||||
up = np.max(config.pltData16)
|
up = np.max(config.pltData16)
|
||||||
if (self.jf.get_nm_checked()==1):
|
if (self.jf.get_nm_checked()==1):
|
||||||
|
|||||||
84
JFSphoto.py
84
JFSphoto.py
@ -11,7 +11,7 @@ import config
|
|||||||
|
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
#matplotlib.use("TkAgg")
|
#matplotlib.use("TkAgg")
|
||||||
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
|
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg,NavigationToolbar2Tk
|
||||||
from matplotlib.figure import Figure
|
from matplotlib.figure import Figure
|
||||||
from numpy import arange, sin, pi,cos
|
from numpy import arange, sin, pi,cos
|
||||||
####################################### object
|
####################################### object
|
||||||
@ -274,74 +274,55 @@ class Jfsphoto (object):
|
|||||||
except IOError:
|
except IOError:
|
||||||
print("By the great otter!","No config.ini file")
|
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):
|
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 = tk.Toplevel()
|
||||||
#win.geometry("450x200+100+100")
|
|
||||||
self.center = tk.Frame(win, bg='gray2', width=50, height=40, padx=3, pady=3)
|
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_rowconfigure(0, weight=1)
|
||||||
self.center.grid_columnconfigure(1, weight=1)
|
self.center.grid_columnconfigure(1, weight=1)
|
||||||
self.center.grid(row=1, sticky="nsew")
|
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_mid = tk.Frame(self.center, width=250, height=250, padx=3, pady=3)
|
||||||
self.ctr_right = tk.Frame(self.center, bg='green', width=200, height=190, 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_mid.grid(row=0, column=0, sticky="nsew")
|
||||||
self.ctr_right.grid(row=0, column=1, sticky="ns")
|
self.ctr_right.grid(row=0, column=1, sticky="ns")
|
||||||
|
|
||||||
self.fig = plt.Figure(figsize=(8,4),dpi=100)
|
self.fig = plt.Figure(figsize=(8,4),dpi=100)
|
||||||
|
|
||||||
self.ax1 = self.fig.add_subplot(111)
|
self.ax1 = self.fig.add_subplot(111)
|
||||||
t = arange(0.0, 3.0, 0.01)
|
t = arange(0.0, 3.0, 0.01)
|
||||||
s = sin(2*pi*t)
|
s = sin(2*pi*t)
|
||||||
self.ax1.plot(t, s, linewidth=0.6)
|
self.ax1.plot(t, s, linewidth=0.6)
|
||||||
self.canvas = FigureCanvasTkAgg(self.fig, master = self.ctr_mid)
|
self.canvas = FigureCanvasTkAgg(self.fig, master = self.ctr_mid)
|
||||||
self.canvas._tkcanvas.pack(side = tk.TOP, fill = tk.BOTH, expand = 1)
|
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
|
n = 0
|
||||||
for txt,val in stati:
|
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")
|
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
|
n=n+1
|
||||||
|
|
||||||
|
|
||||||
win.focus_set()
|
win.focus_set()
|
||||||
win.grab_set()
|
win.grab_set()
|
||||||
win.wait_window()
|
win.wait_window()
|
||||||
|
|
||||||
def look(self):
|
def look(self):
|
||||||
#print(self.ok.get())
|
|
||||||
self.ax1.clear()
|
self.ax1.clear()
|
||||||
if self.ok.get()==1:
|
if self.ok.get()==1:
|
||||||
self.df.plot(x = 'nmscale',y = 'p1', color='red',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:
|
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 = '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 = '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:
|
elif self.ok.get()==3:
|
||||||
right = 0
|
right = 0
|
||||||
left = 0
|
left = 0
|
||||||
y = self.df['p1']
|
y = self.df['darkline'] - self.df['p1']
|
||||||
b = self.df['baseline']
|
b = self.df['baseline']
|
||||||
c = np.zeros(3694, np.float32)
|
c = np.zeros(3694, np.float32)
|
||||||
for i in range(0,3694):
|
for i in range(0,3694):
|
||||||
@ -353,19 +334,26 @@ class Jfsphoto (object):
|
|||||||
if (left==0):
|
if (left==0):
|
||||||
left=i
|
left=i
|
||||||
c[i] = y[i]/b[i]
|
c[i] = y[i]/b[i]
|
||||||
print("left ",left," right ",right)
|
self.df['Absorption'] = c
|
||||||
self.df['p2']=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])
|
||||||
#for i in range(0,3694):
|
elif self.ok.get()==4:
|
||||||
# self.df
|
right = 0
|
||||||
# if (self.df(pltBaseData16[i] == 0):
|
left = 0
|
||||||
# config.pltData16[i] = 1
|
y = self.df['darkline'] - self.df['p1']
|
||||||
# else:
|
b = self.df['baseline']
|
||||||
# config.pltData16[i] = (config.pltData16[i] / config.pltBaseData16[i])
|
c = np.zeros(3694, np.float32)
|
||||||
# if (self.jf.abs_trans.get()==1):
|
for i in range(0,3694):
|
||||||
# config.pltData16 = np.log10(config.pltData16)*-1
|
if b[i]==0:
|
||||||
|
c[i] = 1
|
||||||
self.df.plot(x = 'nmscale',y = 'p2', color='red',linewidth=0.6,ax=self.ax1)
|
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])
|
self.ax1.set_xlim([self.nm_left+left*self.nm_step, self.nm_left+right*self.nm_step])
|
||||||
else:
|
else:
|
||||||
t = arange(0.0, 3.0, 0.01)
|
t = arange(0.0, 3.0, 0.01)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user