Math and Kinetik improved
This commit is contained in:
parent
ca316b6650
commit
f1b763309a
@ -276,18 +276,20 @@ class buildpanel(tk.Frame):
|
||||
|
||||
|
||||
def kinetics():
|
||||
if kin_repeats.get() > 0 :
|
||||
if self.device_status.get() == "Device exist":
|
||||
kin_repeats.set(kin_repeats.get()-1)
|
||||
self.after(kin_delta.get()*1000,messure)
|
||||
else:
|
||||
print('Kinetics finisched')
|
||||
kin_time.set(0)
|
||||
self.jf.df['baseline']=self.jf.baseData16
|
||||
self.jf.df['darkline']=self.jf.darkData16
|
||||
self.jf.df['nmscale']=self.jf.nmData16
|
||||
self.jf.save_kinetics("kini.dat")
|
||||
print(self.jf.df.head())
|
||||
|
||||
if kin_repeats.get() > 0 :
|
||||
self.after(kin_delta.get()*1000,messure)
|
||||
else:
|
||||
print('Kinetics finisched')
|
||||
kin_time.set(0)
|
||||
self.jf.df['baseline']=self.jf.baseData16
|
||||
self.jf.df['darkline']=self.jf.darkData16
|
||||
self.jf.df['nmscale']=self.jf.nmData16
|
||||
self.jf.save_kinetics("kini.dat")
|
||||
print(self.jf.df.head())
|
||||
else:
|
||||
messagebox.showerror("By the great otter!"," Sorry No Device")
|
||||
|
||||
|
||||
self.jfstitel = tk.Label(self, text=' Photometer ',fg="#6A9662")
|
||||
|
||||
89
JFSphoto.py
89
JFSphoto.py
@ -14,6 +14,7 @@ import matplotlib.pyplot as plt
|
||||
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg,NavigationToolbar2Tk
|
||||
from matplotlib.figure import Figure
|
||||
from numpy import arange, sin, pi,cos
|
||||
import fnmatch
|
||||
####################################### object
|
||||
|
||||
class Jfsphoto (object):
|
||||
@ -215,7 +216,9 @@ class Jfsphoto (object):
|
||||
|
||||
def load_kinetics(self,name):
|
||||
try:
|
||||
#self.df.drop(self.df.index, inplace=True)
|
||||
self.df = pd.read_csv(name,index_col=0)
|
||||
#print(self.df.head())
|
||||
except IOError:
|
||||
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.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)
|
||||
@ -314,11 +317,9 @@ class Jfsphoto (object):
|
||||
|
||||
self.canvas = FigureCanvasTkAgg(self.fig, master = self.ctr_mid)
|
||||
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.grid(row=1,columnspan=2, sticky="w")
|
||||
toolbar1 = NavigationToolbar2Tk(self.canvas, self.toolbarFrame)
|
||||
self.toolbar1 = NavigationToolbar2Tk(self.canvas, self.toolbarFrame)
|
||||
|
||||
n = 0
|
||||
for txt,val in stati:
|
||||
@ -333,22 +334,28 @@ class Jfsphoto (object):
|
||||
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 = tk.Button(master=self.ctr_right,text="show")
|
||||
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)
|
||||
self.ok.set(0)
|
||||
if 'baseline' in self.df.columns:
|
||||
self.get_kin_list()
|
||||
self.do_get_range()
|
||||
for xx in self.col_list:
|
||||
self.do_absorption(xx)
|
||||
for xx in self.col_list:
|
||||
self.do_transmission(xx)
|
||||
|
||||
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.remove('baseline')
|
||||
self.col_list.remove('darkline')
|
||||
@ -361,18 +368,22 @@ class Jfsphoto (object):
|
||||
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.ok.set(1)
|
||||
self.canvas.draw()
|
||||
|
||||
def do_get_range(self):
|
||||
self.right = 0
|
||||
self.left = 0
|
||||
#### count for random not zero values in the start of the baseline
|
||||
count = 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):
|
||||
count += 1
|
||||
if (self.left==0 and count > 5):
|
||||
self.left=i
|
||||
|
||||
def do_absorption(self,xx):
|
||||
@ -386,61 +397,35 @@ class Jfsphoto (object):
|
||||
c[i] = y[i]/b[i]
|
||||
self.df[xx+'_abs'] = c
|
||||
|
||||
def do_transmission(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] = np.log10(b[i]/y[i])
|
||||
self.df[xx+'_trans'] = 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:
|
||||
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']
|
||||
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])
|
||||
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:
|
||||
t = arange(0.0, 3.0, 0.01)
|
||||
s = sin(2*pi*t)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user