baseline absorbance eingefügt output bandwidth now oriented on Lamp

This commit is contained in:
jens 2020-11-28 00:04:27 +01:00
parent d8b0e185a1
commit d9a8a0e286
3 changed files with 117 additions and 41 deletions

View File

@ -231,6 +231,11 @@ class buildpanel(tk.Frame):
def darkline():
if (self.jf.do_save_darkline(config.rxData16)==1):
self.jfsdark_check.config(state=tk.NORMAL)
def baseline():
if (self.jf.get_darkline_checked() == 1):
base = self.jf.darkData16-config.rxData16
if (self.jf.do_save_baseline(base)==1):
self.jfsbase_check.config(state=tk.NORMAL)
self.jfstitel = tk.Label(self, text=' Photometer ')
#self.jfstitel.config(font=("Courier",0))
@ -239,11 +244,14 @@ class buildpanel(tk.Frame):
self.jfs4cal.grid(row=11,column=4)
self.jfs4nm_check = tk.Checkbutton(self,text="[nm] scale on/off",variable=self.jf.nm_checked,command=lambda CCDplot=CCDplot: self.updateplot(CCDplot))
self.jfs4nm_check.grid(row=12,column=4)
self.jfs4cal = tk.Button(self,text='save Darkline',fg="blue", command= darkline)
self.jfs4cal.grid(row=13,column=4)
self.jfsdark = tk.Button(self,text='save Darkline',fg="blue", command= darkline)
self.jfsdark.grid(row=13,column=4)
self.jfsdark_check = tk.Checkbutton(self,text="Darkline on/off",variable=self.jf.darkline_checked,state=tk.DISABLED,command=lambda CCDplot=CCDplot: self.updateplot(CCDplot))
self.jfsdark_check.grid(row=14,column=4)
self.jfsbase = tk.Button(self,text='save Baseline',fg="blue", command= baseline)
self.jfsbase.grid(row=15,column=4)
self.jfsbase_check = tk.Checkbutton(self,text="Baseline on/off",variable=self.jf.baseline_checked,state=tk.DISABLED,command=lambda CCDplot=CCDplot: self.updateplot(CCDplot))
self.jfsbase_check.grid(row=16,column=4)
### Callbacks for traces, buttons, etc ###
def callback(self):
self.bopen.config(state=tk.DISABLED)
@ -317,6 +325,33 @@ class buildpanel(tk.Frame):
def updateplot(self, CCDplot):
CCDplot.a.clear()
# Photometer Job Baseline is the Intensity of the Lamp
# baseline start and baseline end depends on the spektral range of the Lamp
# the actuel input is lower due to the absorption of the liquid
if (self.jf.get_baseline_checked()==1):
config.pltBaseData16 = self.jf.baseData16
config.pltData16 = self.jf.darkData16 - config.rxData16
for i in range(0,3694):
if (config.pltBaseData16[i] == 0):
config.pltData16[i] = 1
else:
config.pltData16[i] = (config.pltData16[i] / config.pltBaseData16[i])
config.pltData16 = 100*config.pltData16
up = np.max(config.pltData16) + 50
if (self.jf.get_nm_checked()==1):
CCDplot.a.plot(self.jf.get_nm_scale(),config.pltData16)
CCDplot.a.axis([self.jf.nm_left,self.jf.nm_right,-10,up])
CCDplot.a.set_xlim([self.jf.nm_left+self.jf.baseline_start*self.jf.nm_step, self.jf.nm_left+self.jf.baseline_end*self.jf.nm_step])
CCDplot.a.set_xlabel(" [nm] ")
else:
CCDplot.a.plot(config.pltData16)
CCDplot.a.axis([0,3694,-10,up])
CCDplot.a.set_xlim([self.jf.baseline_start, self.jf.baseline_end])
CCDplot.a.set_xlabel("Pixelnumber")
CCDplot.a.set_ylabel("Intensity")
else:
#This subtracts the ADC-pixel from ADC-dark
if (config.datainvert==1):
if (self.jf.get_darkline_checked()==1):
@ -329,7 +364,8 @@ class buildpanel(tk.Frame):
#print(config.offset)
for i in range (1847):
config.pltData16[2*i] = config.pltData16[2*i] - config.offset
CCDplot.a.clear()
#CCDplot.a.clear()
#plot intensities
if (config.datainvert == 1):
## make max visible

View File

@ -29,6 +29,12 @@ class Jfsphoto (object):
self.darkData16 = np.zeros(3694, np.float32)
self.darkline_checked = tk.IntVar()
self.darkline_checked.set(0)
########## baseline of the lightsource
self.baseData16 = np.zeros(3694, np.float32)
self.baseline_checked = tk.IntVar()
self.baseline_checked.set(0)
self.baseline_start=0
self.baseline_end=0
def do_calibrate(self):
win = tk.Toplevel()
@ -85,6 +91,7 @@ class Jfsphoto (object):
self.button.pack()
self.mroot.mainloop()
############ Darkline
def do_save_darkline(self,dark):
x = np.min(dark)
if (x < 3700):
@ -97,6 +104,37 @@ class Jfsphoto (object):
def get_darkline_checked(self):
return self.darkline_checked.get()
############ Baseline depends on the capacity of the light source block spektralrange if the intensity is to low
def do_save_baseline(self,base):
### no margin at all
doIt = True
#### no left margin
left = True
x = np.max(base)
if (x < 500):
self.do_msg(" This is not a Baseine \n Is the Lightsouce switch on ? ")
return 0
else:
for i in range(0,3694):
if (base[i] < 200) :
if doIt:
if left:
self.baseline_start = i
else:
self.baseline_end = i
doIt = False
self.baseData16[i] = 0
else:
if (base[i] > 300):
left = False
self.baseData16[i] = base[i]*1.0
print(self.baseline_start," ",self.baseline_end)
return 1
def get_baseline_checked(self):
return self.baseline_checked.get()
############ Calibration and Load/Save Configuration Part 2
def checkit(self):
self.nm = int(self.tnm.get())
self.nmi = int(self.tnmi.get())

View File

@ -10,7 +10,7 @@ SHperiod = np.uint32(200)
ICGperiod = np.uint32(100000)
AVGn = np.uint8([0,1])
MCLK = 2000000
SHsent = np.uint32(200)
SHsent = np.uint32(50)
ICGsent = np.uint32(100000)
stopsignal = 0
@ -18,6 +18,8 @@ stopsignal = 0
rxData8 = np.zeros(7388, np.uint8)
rxData16 = np.zeros(3694, np.uint16)
pltData16 = np.zeros(3694, np.float32)
pltBaseData16 = np.zeros(3694, np.float32)
#Arrays for data to transmit
txsh = np.uint8([0,0,0,0])