-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMPE_auto.py
175 lines (101 loc) · 5.22 KB
/
MPE_auto.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# -*- coding: utf-8 -*-
"""
Created on Wed Nov 16 13:05:34 2022
@author: ldavidov
"""
import tkinter as tk
import numpy as np
# Dimensions of the GUI window
WIDTH = 600;
HEIGHT = 500;
def I_col(P,D): # Calculates irradiance for power and a diameter
A_colimated = (np.pi*D**2)/4;
I_colimated = P/A_colimated;
return I_colimated;
def message_return(ratio_MPE):
if ratio_MPE > 1.0 and ratio_MPE < 5:
laser_advice = "MPE value exceeded!";
elif ratio_MPE >= 5:
laser_advice = "WARNING: MPE value exceeded \n by more than 5 times!"
elif ratio_MPE <= 1.0:
laser_advice = "SAFE!";
return laser_advice;
def calc(wavel,P,BD): # Determines the irradiance to MPE ratio based on the laser safety table per wavelength
if wavel > 400 and wavel <= 700:
t_eye = 0.25; # Eye response time [s]
MPE = 18*t_eye**(0.75)/t_eye; # MPE value [W/m^2]
I_calc = I_col(P,BD); # Calculated irradiance [W/m^2]
ratio = I_calc/MPE; # Ratio I_calc to MPE
elif wavel < 400:
ratio = "NaN";
elif wavel > 700 and wavel <= 1050:
MPE = 10*10**(0.002*(wavel-700));
I_calc = I_col(P,BD); # Calculated irradiance [W/m^2]
ratio = I_calc/MPE; # Ratio I_calc to MPE
elif wavel > 1050 and wavel <= 1150:
MPE = 10*5*1;
I_calc = I_col(P,BD); # Calculated irradiance [W/m^2]
ratio = I_calc/MPE; # Ratio I_calc to MPE
elif wavel > 1150 and wavel <= 1200:
MPE = 10*5*10**(0.018*(wavel-1150));
I_calc = I_col(P,BD); # Calculated irradiance [W/m^2]
ratio = I_calc/MPE; # Ratio I_calc to MPE
elif wavel > 1200 and wavel <= 1250:
MPE = 10*5*(8+10**(0.04*(wavel-1250)));
I_calc = I_col(P,BD); # Calculated irradiance [W/m^2]
ratio = I_calc/MPE; # Ratio I_calc to MPE
elif wavel > 1250 and wavel <= 1400:
MPE = 2000*5;
I_calc = I_col(P,BD); # Calculated irradiance [W/m^2]
ratio = I_calc/MPE; # Ratio I_calc to MPE
elif wavel > 1400 and wavel <= 10**6:
MPE = 1000;
I_calc = I_col(P,BD); # Calculated irradiance [W/m^2]
ratio = I_calc/MPE; # Ratio I_calc to MPE
ratio = round(ratio, 3);
label_output_MPE.config(text = ratio);
label_output.config(text = message_return(ratio))
return ratio;
# Here starts the root for the GUI
root = tk.Tk()
root.title('MPE Calculation Software for CW laser')
photo = tk.PhotoImage(file = "logo_small1.png")
root.iconphoto(False, photo)
root.geometry("600x500")
root.resizable(0, 0)
canvas = tk.Canvas(root, height = HEIGHT, width = WIDTH)
canvas.pack()
background_image = tk.PhotoImage(file='background.png')
background_label=tk.Label(root, image=background_image)
background_label.place(relwidth=1, relheight=1)
frame1 = tk.Frame(root, bg = '#3c5bb0', bd=5)
frame1.place(relx=0.95, rely=0.5, relwidth=0.30, relheight=0.5, anchor = 'e')
entry1 = tk.Entry(frame1, font=("Calibri 10"))
entry1.place(relwidth=0.5, relheight=0.075)
label1 = tk.Label(frame1, text = " \u03BB [nm]", bg = '#80c1ff')
label1.place(relx=0.55, relheight=0.075, relwidth=0.45)
entry2 = tk.Entry(frame1, font=("Calibri 10"))
entry2.place(rely=0.2, relwidth=0.5, relheight=0.075)
label2 = tk.Label(frame1, text = "Power [W]", bg = '#80c1ff')
label2.place(relx=0.55, rely=0.2, relheight=0.075, relwidth=0.45)
entry3 = tk.Entry(frame1, font=("Calibri 10"))
entry3.place(rely=0.4, relwidth=0.5, relheight=0.075)
label3 = tk.Label(frame1, text = "BD [m]", bg = '#80c1ff')
label3.place(relx=0.55, rely=0.4, relheight=0.075, relwidth=0.45)
button = tk.Button(frame1, text = "CALCULATE", command=lambda: [calc(float(entry1.get()),float(entry2.get()),float(entry3.get()))])
button.place(relx=0.05,rely=0.8, relheight=0.1, relwidth=0.9)
lower_frame = tk.Frame(root, bg='#3c5bb0', bd=5)
lower_frame.place(relx=0.05, rely=0.5, relwidth=0.5, relheight=0.5, anchor = 'w')
label = tk.Label(lower_frame, text = "Calculated values", bg = '#bdecfc')
label.place(relx=0.1, rely=0, relheight=0.1, relwidth=0.8)
label = tk.Label(lower_frame, text = "MPE Ratio", bg = '#80c1ff')
label.place(relx=0.025, rely=0.2, relheight=0.1, relwidth=0.45)
label_output_MPE = tk.Label(lower_frame, text = "", bg = '#80c1ff')
label_output_MPE.place(relx=0.525, rely=0.2, relheight=0.1, relwidth=0.45)
label_output = tk.Label(lower_frame, text = "", bg = '#80c1ff')
label_output.place(relx=0.05, rely=0.4, relheight=0.3, relwidth=0.90)
lowest_frame = tk.Frame(root, bg='#3c5bb0', bd=5)
lowest_frame.place(relx=0.5, rely=0.95, relwidth=0.9, relheight=0.15, anchor = 's')
label = tk.Label(lowest_frame, text = "Please choose a value ABOVE 400 nm \n BD = Bundel Diameter \n 1 inch = 0.0254 m \n For visible light the exposure time is t = 0.25s. For \u03BB > 700nm maximum exposure time is taken ", bg = '#80c1ff')
label.place(relheight=1, relwidth=1)
root.mainloop()