Math and Kinetik improved
This commit is contained in:
parent
ca316b6650
commit
f1b763309a
@ -276,8 +276,9 @@ class buildpanel(tk.Frame):
|
|||||||
|
|
||||||
|
|
||||||
def kinetics():
|
def kinetics():
|
||||||
if kin_repeats.get() > 0 :
|
if self.device_status.get() == "Device exist":
|
||||||
kin_repeats.set(kin_repeats.get()-1)
|
kin_repeats.set(kin_repeats.get()-1)
|
||||||
|
if kin_repeats.get() > 0 :
|
||||||
self.after(kin_delta.get()*1000,messure)
|
self.after(kin_delta.get()*1000,messure)
|
||||||
else:
|
else:
|
||||||
print('Kinetics finisched')
|
print('Kinetics finisched')
|
||||||
@ -287,7 +288,8 @@ class buildpanel(tk.Frame):
|
|||||||
self.jf.df['nmscale']=self.jf.nmData16
|
self.jf.df['nmscale']=self.jf.nmData16
|
||||||
self.jf.save_kinetics("kini.dat")
|
self.jf.save_kinetics("kini.dat")
|
||||||
print(self.jf.df.head())
|
print(self.jf.df.head())
|
||||||
|
else:
|
||||||
|
messagebox.showerror("By the great otter!"," Sorry No Device")
|
||||||
|
|
||||||
|
|
||||||
self.jfstitel = tk.Label(self, text=' Photometer ',fg="#6A9662")
|
self.jfstitel = tk.Label(self, text=' Photometer ',fg="#6A9662")
|
||||||
|
|||||||
97
JFSphoto.py
97
JFSphoto.py
@ -14,6 +14,7 @@ import matplotlib.pyplot as plt
|
|||||||
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg,NavigationToolbar2Tk
|
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
|
||||||
|
import fnmatch
|
||||||
####################################### object
|
####################################### object
|
||||||
|
|
||||||
class Jfsphoto (object):
|
class Jfsphoto (object):
|
||||||
@ -215,7 +216,9 @@ class Jfsphoto (object):
|
|||||||
|
|
||||||
def load_kinetics(self,name):
|
def load_kinetics(self,name):
|
||||||
try:
|
try:
|
||||||
|
#self.df.drop(self.df.index, inplace=True)
|
||||||
self.df = pd.read_csv(name,index_col=0)
|
self.df = pd.read_csv(name,index_col=0)
|
||||||
|
#print(self.df.head())
|
||||||
except IOError:
|
except IOError:
|
||||||
messagebox.showerror("By the great otter!","There's a problem saving the file.")
|
messagebox.showerror("By the great otter!","There's a problem saving the file.")
|
||||||
|
|
||||||
@ -304,8 +307,8 @@ class Jfsphoto (object):
|
|||||||
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)
|
||||||
@ -314,11 +317,9 @@ class Jfsphoto (object):
|
|||||||
|
|
||||||
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.toolbarFrame = tk.Frame(master=self.center,padx=5,pady=5)
|
self.toolbarFrame = tk.Frame(master=self.center,padx=5,pady=5)
|
||||||
self.toolbarFrame.grid(row=1,columnspan=2, sticky="w")
|
self.toolbarFrame.grid(row=1,columnspan=2, sticky="w")
|
||||||
toolbar1 = NavigationToolbar2Tk(self.canvas, self.toolbarFrame)
|
self.toolbar1 = NavigationToolbar2Tk(self.canvas, self.toolbarFrame)
|
||||||
|
|
||||||
n = 0
|
n = 0
|
||||||
for txt,val in stati:
|
for txt,val in stati:
|
||||||
@ -333,22 +334,28 @@ class Jfsphoto (object):
|
|||||||
self.scrollbar = tk.Scrollbar(master=self.ctr_right)
|
self.scrollbar = tk.Scrollbar(master=self.ctr_right)
|
||||||
self.listbox.config(yscrollcommand =self.scrollbar.set)
|
self.listbox.config(yscrollcommand =self.scrollbar.set)
|
||||||
self.scrollbar.config(command = self.listbox.yview)
|
self.scrollbar.config(command = self.listbox.yview)
|
||||||
self.kbtn1 = tk.Button(master=self.ctr_right,text="show",command=self.kini)
|
self.kbtn1 = tk.Button(master=self.ctr_right,text="show")
|
||||||
self.kbtn1.grid(row=14,column=0,sticky="w")
|
self.kbtn1.grid(row=14,column=0,sticky="w")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
win.focus_set()
|
win.focus_set()
|
||||||
win.grab_set()
|
win.grab_set()
|
||||||
win.wait_window()
|
win.wait_window()
|
||||||
|
|
||||||
def calculate(self):
|
def calculate(self):
|
||||||
|
self.ok.set(0)
|
||||||
|
if 'baseline' in self.df.columns:
|
||||||
self.get_kin_list()
|
self.get_kin_list()
|
||||||
self.do_get_range()
|
self.do_get_range()
|
||||||
for xx in self.col_list:
|
for xx in self.col_list:
|
||||||
self.do_absorption(xx)
|
self.do_absorption(xx)
|
||||||
|
for xx in self.col_list:
|
||||||
|
self.do_transmission(xx)
|
||||||
|
|
||||||
def get_kin_list(self):
|
def get_kin_list(self):
|
||||||
|
self.col_list = list(self.df.columns.values.tolist())
|
||||||
|
##### delete remaining _trans and _abs
|
||||||
|
filtered = fnmatch.filter(self.col_list,'*_*')
|
||||||
|
self.df.drop(filtered,axis=1,inplace=True)
|
||||||
self.col_list = list(self.df.columns.values.tolist())
|
self.col_list = list(self.df.columns.values.tolist())
|
||||||
self.col_list.remove('baseline')
|
self.col_list.remove('baseline')
|
||||||
self.col_list.remove('darkline')
|
self.col_list.remove('darkline')
|
||||||
@ -361,18 +368,22 @@ class Jfsphoto (object):
|
|||||||
for xx in self.col_list:
|
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 = xx, linewidth=0.6,ax=self.ax1)
|
||||||
self.listbox.insert(tk.END, xx)
|
self.listbox.insert(tk.END, xx)
|
||||||
|
self.ok.set(1)
|
||||||
self.canvas.draw()
|
self.canvas.draw()
|
||||||
|
|
||||||
def do_get_range(self):
|
def do_get_range(self):
|
||||||
self.right = 0
|
self.right = 0
|
||||||
self.left = 0
|
self.left = 0
|
||||||
|
#### count for random not zero values in the start of the baseline
|
||||||
|
count = 0
|
||||||
b = self.df['baseline']
|
b = self.df['baseline']
|
||||||
for i in range(0,3694):
|
for i in range(0,3694):
|
||||||
if b[i]==0:
|
if b[i]==0:
|
||||||
if (self.left > 0 and self.right==0):
|
if (self.left > 0 and self.right==0):
|
||||||
self.right=i
|
self.right=i
|
||||||
else:
|
else:
|
||||||
if (self.left==0):
|
count += 1
|
||||||
|
if (self.left==0 and count > 5):
|
||||||
self.left=i
|
self.left=i
|
||||||
|
|
||||||
def do_absorption(self,xx):
|
def do_absorption(self,xx):
|
||||||
@ -386,61 +397,35 @@ class Jfsphoto (object):
|
|||||||
c[i] = y[i]/b[i]
|
c[i] = y[i]/b[i]
|
||||||
self.df[xx+'_abs'] = c
|
self.df[xx+'_abs'] = c
|
||||||
|
|
||||||
def look(self):
|
def do_transmission(self,xx):
|
||||||
# self.get_kin_list()
|
y = self.df['darkline'] - self.df[xx]
|
||||||
# self.do_get_range()
|
|
||||||
# for xx in self.col_list:
|
|
||||||
# self.do_absorption(xx)
|
|
||||||
self.ax1.clear()
|
|
||||||
if self.ok.get()==1:
|
|
||||||
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:
|
|
||||||
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
|
|
||||||
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
|
|
||||||
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):
|
||||||
if b[i]==0:
|
if b[i]==0:
|
||||||
c[i] = 1
|
c[i] = 1
|
||||||
if (left > 0 and right==0):
|
|
||||||
right=i
|
|
||||||
else:
|
else:
|
||||||
if (left==0):
|
|
||||||
left=i
|
|
||||||
c[i] = np.log10(b[i]/y[i])
|
c[i] = np.log10(b[i]/y[i])
|
||||||
self.df['Transmission'] = c
|
self.df[xx+'_trans'] = 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])
|
def look(self):
|
||||||
|
self.ax1.clear()
|
||||||
|
if self.ok.get()==1:
|
||||||
|
for xx in self.col_list:
|
||||||
|
self.df.plot(x = 'nmscale',y = xx, linewidth=0.6,ax=self.ax1)
|
||||||
|
elif self.ok.get()==2:
|
||||||
|
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 = '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:
|
||||||
|
for xx in self.col_list:
|
||||||
|
self.df.plot(x = 'nmscale',y = xx+'_abs', 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:
|
||||||
|
for xx in self.col_list:
|
||||||
|
self.df.plot(x = 'nmscale',y = xx+'_trans',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])
|
||||||
else:
|
else:
|
||||||
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)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user