Alles Vorbereitrungen für die Kalibrierung ok

This commit is contained in:
jens 2020-11-23 19:58:56 +01:00
parent b043834892
commit b8dced60d7
3 changed files with 78 additions and 5 deletions

View File

@ -5,6 +5,7 @@ from tkinter import messagebox
import tkinter as tk
import csv
import numpy as np
from configparser import ConfigParser
####################################### object
class Jfsphoto (object):
@ -14,10 +15,17 @@ class Jfsphoto (object):
self.nmi = 0
self.nm2 = 0
self.nm2i = 0
self.nm_left = 0
self.nm_right = 0
self.nm_step = 0
self.tnm_left = tk.StringVar()
self.tnm_right = tk.StringVar()
self.tnm_step = tk.StringVar()
self.nmData16 = np.zeros(3694, np.uint16)
def test1(self):
win = tk.Toplevel()
win.geometry("400x200+30+30")
win.geometry("450x200+100+100")
self.lab1 = tk.Label(win, text='please enter filenames and nm of the peaks').grid(row=0,column=0,columnspan=6)
########## first peak
self.tnm = tk.StringVar()
@ -41,6 +49,20 @@ class Jfsphoto (object):
self.lnm2 = tk.Label(win,textvariable =self.tnm2).grid(row=2,column=3)
self.lnm2 = tk.Label(win,text =" nm by index ").grid(row=2,column=4)
self.lm2i = tk.Label(win,textvariable=self.tnm2i).grid(row=2,column=5)
########### calibration
self.tnm_left.set(str(self.nm_left))
self.tnm_right.set(str(self.nm_right))
self.tnm_step.set(str(self.nm_step))
self.lab4 = tk.Label(win,text="left border [nm]").grid(row=3,column=0)
self.lab5 = tk.Label(win,textvariable=self.tnm_left).grid(row=3,column=1)
self.lab6 = tk.Label(win,text="right border [nm]").grid(row=3,column=2)
self.lab7 = tk.Label(win,textvariable=self.tnm_right).grid(row=3,column=3)
self.lab8 = tk.Label(win,text="[nm]/point").grid(row=3,column=4)
self.lab9 = tk.Label(win,textvariable=self.tnm_step).grid(row=3,column=5)
self.bt3 = tk.Button(win,text="Calibrieren",command=self.calibrate,state=tk.DISABLED)
self.bt3.grid(row=4,column=0)
self.bt4 = tk.Button(win,text="Load Config",command=self.conf_read).grid(row=4,column=1)
self.bt5 = tk.Button(win,text="Save Config",command=self.conf_write).grid(row=4,column=2)
#a=tk.Label(win,text='Hi there')
#a.place(x=10,y=10,width=40,height=25)
#b=tk.Button(win,text='Ok then',command=win.destroy)
@ -51,12 +73,28 @@ class Jfsphoto (object):
win.wait_window()
def checkit(self):
print(self.tnm.get())
self.nm = int(self.tnm.get())
self.nmi = int(self.tnmi.get())
self.nm2 = int(self.tnm2.get())
self.nm2i = int(self.tnm2i.get())
if ((self.nm > 0) & (self.nmi > 0) & (self.nm2 > 0) & (self.nm2i > 0)):
self.bt3.config(state = tk.NORMAL)
def calibrate(self):
self.nm_step = round((self.nm2 - self.nm)/(self.nm2i-self.nmi),5)
self.nm_left = round(self.nm-(self.nm_step*self.nmi),0)
self.nm_right = round(self.nm2 + self.nm_step*(3694-self.nm2i),0)
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 set_nm_scale(self):
if ((self.nm_step > 0) & (self.nm_left > 0)):
for i in range(0,3694):
self.nmData16[i] = self.nm_left + self.nm_step*i
def info(self):
print(f'nm {self.nm} nmi {self.nmi}')
def openfile(self,xx):
rxData16 = np.zeros(3694, np.uint16)
@ -84,3 +122,32 @@ class Jfsphoto (object):
except IOError:
messagebox.showerror("By the great otter!","There's a problem opening the file.")
def conf_write(self):
config = ConfigParser()
config.read('config.ini')
lis = config.sections()
if ('main' not in lis):
config.add_section('main')
config.set('main','nm_left',str(self.nm_left))
config.set('main','nm_right',str(self.nm_right))
config.set('main','nm_step',str(self.nm_step))
with open('config.ini','w') as f:
config.write(f)
def conf_read(self):
config = ConfigParser()
try:
config.read('config.ini')
self.nm_left = float(config.get('main','nm_left',fallback='0'))
self.tnm_left.set(config.get('main','nm_left',fallback='0'))
self.nm_right = float(config.get('main','nm_right',fallback='0'))
self.tnm_right.set(config.get('main','nm_right',fallback='0'))
self.nm_step = float(config.get('main','nm_step',fallback='0'))
self.tnm_step.set(config.get('main','nm_step',fallback='0'))
self.set_nm_scale()
except IOError:
print("By the great otter!","No config.ini file")

5
config.ini Normal file
View File

@ -0,0 +1,5 @@
[main]
nm_left = 320.0
nm_right = 811.0
nm_step = 0.13279

View File

@ -47,6 +47,7 @@ if __name__ == '__main__':
menu = CCDmenusetup.buildmenu(root)
CCDplot = CCDplots.buildplot(root)
jfs =Jfsphoto()
jfs.conf_read()
panel = CCDpanelsetup.buildpanel(root, CCDplot, SerQueue,jfs)
panel.grid(row=0, column=2)