From d9a8a0e286b8d36fb5afc7d8a401d956eedc4524 Mon Sep 17 00:00:00 2001 From: jens Date: Sat, 28 Nov 2020 00:04:27 +0100 Subject: [PATCH] =?UTF-8?q?baseline=20absorbance=20eingef=C3=BCgt=20output?= =?UTF-8?q?=20bandwidth=20now=20oriented=20on=20Lamp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CCDpanelsetup.py | 114 +++++++++++++++++++++++++++++++---------------- JFSphoto.py | 40 ++++++++++++++++- config.py | 4 +- 3 files changed, 117 insertions(+), 41 deletions(-) diff --git a/CCDpanelsetup.py b/CCDpanelsetup.py index 62a235d..e29cea0 100644 --- a/CCDpanelsetup.py +++ b/CCDpanelsetup.py @@ -231,7 +231,12 @@ 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)) self.jfstitel.grid(row=10,column=4,columnspan=2) @@ -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,44 +325,72 @@ class buildpanel(tk.Frame): def updateplot(self, CCDplot): - #This subtracts the ADC-pixel from ADC-dark - if (config.datainvert==1): - if (self.jf.get_darkline_checked()==1): - config.pltData16 = self.jf.darkData16 - config.rxData16 - else: - config.pltData16 = (config.rxData16[10]+config.rxData16[11])/2 - config.rxData16 - #This subtracts the average difference between even and odd pixels from the even pixels - if (config.balanced==1): - config.offset = (config.pltData16[18]+config.pltData16[20]+config.pltData16[22]+config.pltData16[24]-config.pltData16[19]-config.pltData16[21]-config.pltData16[23]-config.pltData16[24])/4 - #print(config.offset) - for i in range (1847): - config.pltData16[2*i] = config.pltData16[2*i] - config.offset CCDplot.a.clear() - #plot intensities - if (config.datainvert == 1): - ## make max visible - 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_xlabel(" [nm] ") + # 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: - CCDplot.a.plot(config.pltData16) - CCDplot.a.axis([0,3694,-10,4095]) - CCDplot.a.set_xlabel("Pixelnumber") + 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: - if (self.jf.get_nm_checked()==1): - CCDplot.a.plot(self.jf.get_nm_scale(),config.rxData16) - CCDplot.a.axis([self.jf.nm_left,self.jf.nm_right,-10,4095]) - CCDplot.a.set_xlabel(" [nm] ") - else: - CCDplot.a.plot(config.rxData16) - CCDplot.a.axis([0,3694,-10,4095]) - CCDplot.a.set_xlabel("Pixelnumber") - CCDplot.a.set_ylabel("ADCcount") - #plot raw data + else: + #This subtracts the ADC-pixel from ADC-dark + if (config.datainvert==1): + if (self.jf.get_darkline_checked()==1): + config.pltData16 = self.jf.darkData16 - config.rxData16 + else: + config.pltData16 = (config.rxData16[10]+config.rxData16[11])/2 - config.rxData16 + #This subtracts the average difference between even and odd pixels from the even pixels + if (config.balanced==1): + config.offset = (config.pltData16[18]+config.pltData16[20]+config.pltData16[22]+config.pltData16[24]-config.pltData16[19]-config.pltData16[21]-config.pltData16[23]-config.pltData16[24])/4 + #print(config.offset) + for i in range (1847): + config.pltData16[2*i] = config.pltData16[2*i] - config.offset + + #CCDplot.a.clear() + #plot intensities + if (config.datainvert == 1): + ## make max visible + 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_xlabel(" [nm] ") + else: + CCDplot.a.plot(config.pltData16) + CCDplot.a.axis([0,3694,-10,4095]) + CCDplot.a.set_xlabel("Pixelnumber") + CCDplot.a.set_ylabel("Intensity") + + else: + if (self.jf.get_nm_checked()==1): + CCDplot.a.plot(self.jf.get_nm_scale(),config.rxData16) + CCDplot.a.axis([self.jf.nm_left,self.jf.nm_right,-10,4095]) + CCDplot.a.set_xlabel(" [nm] ") + else: + CCDplot.a.plot(config.rxData16) + CCDplot.a.axis([0,3694,-10,4095]) + CCDplot.a.set_xlabel("Pixelnumber") + CCDplot.a.set_ylabel("ADCcount") + #plot raw data CCDplot.canvas.draw() diff --git a/JFSphoto.py b/JFSphoto.py index 6ff92ae..fa17f03 100644 --- a/JFSphoto.py +++ b/JFSphoto.py @@ -29,7 +29,13 @@ 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() win.geometry("450x200+100+100") @@ -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()) diff --git a/config.py b/config.py index fc2e392..d49e4a3 100644 --- a/config.py +++ b/config.py @@ -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])