From f06f87d1ed03a2d76a8a7129a9b61c7417cce4f5 Mon Sep 17 00:00:00 2001 From: jens Date: Wed, 25 Nov 2020 21:26:40 +0100 Subject: [PATCH] no change to [nm] scale if there is no calibration or proper config .ini file --- CCDpanelsetup.py | 39 +++++---------------------------------- JFSphoto.py | 21 ++++++++++++++++----- 2 files changed, 21 insertions(+), 39 deletions(-) diff --git a/CCDpanelsetup.py b/CCDpanelsetup.py index 02dd216..9cd3360 100644 --- a/CCDpanelsetup.py +++ b/CCDpanelsetup.py @@ -75,7 +75,7 @@ class buildpanel(tk.Frame): self.updateplotfields(update_row, CCDplot) # self.jf = JFSphoto - self.jfsAddOns(CCDplot,JFSphoto) + self.jfsAddOns(CCDplot) @@ -226,17 +226,15 @@ class buildpanel(tk.Frame): # # - def jfsAddOns(self,CCDplot,JFSphoto): + def jfsAddOns(self,CCDplot): self.jfstitel = tk.Label(self, text=' Photometer ') #self.jfstitel.config(font=("Courier",0)) self.jfstitel.grid(row=10,column=4,columnspan=2) - self.jfs4cal = tk.Button(self,text='Calibration',fg="blue", command=JFSphoto.do_calibrate) + self.jfs4cal = tk.Button(self,text='Calibration',fg="blue", command=self.jf.do_calibrate) self.jfs4cal.grid(row=11,column=4) - #self.jfs4nm = tk.Button(self,text='set nm-axis',fg="blue", command=lambda CCDplot=CCDplot,JFSphoto=JFSphoto: self.updateplot_jfs(CCDplot,JFSphoto)) - #self.jfs4nm.grid(row=12,column=4) - self.jfs4nm_check = tk.Checkbutton(self,text="[nm] scale on/off",variable=JFSphoto.nm_checked,command=lambda CCDplot=CCDplot: self.updateplot(CCDplot)) - self.jfs4nm_check.grid(row=13,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) ### Callbacks for traces, buttons, etc ### def callback(self): @@ -309,33 +307,6 @@ class buildpanel(tk.Frame): status.set("Device doesn't exist") colr.configure(fg="red") - def updateplot_jfs(self, CCDplot,JFSphoto): - # plots data with a nm-scale - # makes the max value visble - #This subtracts the ADC-pixel from ADC-dark - if (config.datainvert==1): - 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 - 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 - CCDplot.a.plot(JFSphoto.get_nm_scale(),config.pltData16) - CCDplot.a.set_ylabel("Intensity") - CCDplot.a.axis([JFSphoto.nm_left,JFSphoto.nm_right,-10,up]) - else: - #plot raw data - CCDplot.a.plot(JFSphoto.get_nm_scale(),config.rxData16) - CCDplot.a.set_ylabel("ADCcount") - CCDplot.a.axis([JFSphoto.nm_left,JFSphoto.nm_right,-10,4095]) - CCDplot.a.set_xlabel("[nm]") - - CCDplot.canvas.draw() def updateplot(self, CCDplot): #This subtracts the ADC-pixel from ADC-dark diff --git a/JFSphoto.py b/JFSphoto.py index 32a9dc1..aaa9603 100644 --- a/JFSphoto.py +++ b/JFSphoto.py @@ -88,16 +88,27 @@ class Jfsphoto (object): self.tnm_left.set(str(self.nm_left)) self.tnm_right.set(str(self.nm_right)) self.tnm_step.set(str(self.nm_step)) - + + + def nm_scale_ok(self): + if ((self.nm_left > 0) & (self.nm_right > 0)): + return 1 + else: + return 0 + def get_nm_checked(self): - return self.nm_checked.get() + if (self.nm_scale_ok()): + return self.nm_checked.get() + else: + return 0 def set_nm_scale(self): - self.nmData16 = np.linspace(self.nm_left,self.nm_right,3694) + if (self.nm_scale_ok): + self.nmData16 = np.linspace(self.nm_left,self.nm_right,3694) def get_nm_scale(self): - self.set_nm_scale() - return self.nmData16 + self.set_nm_scale() + return self.nmData16 def openfile(self,xx): rxData16 = np.zeros(3694, np.uint16)