OpenFlatus.py 5.95 KB
Newer Older
1
2
3
# -*- coding: iso-8859-15 -*-

import Tkinter as tk
4
from Ewindow import *
Matheus Müller's avatar
Matheus Müller committed
5
from numerical import *
6

Matheus Müller's avatar
Matheus Müller committed
7
##############################################################################
8
# Arbitrary parameters to declare dictionaries
Matheus Müller's avatar
Matheus Müller committed
9
param = dict(dedx=192. ,Theta_out=70., dW2dx=20740., E0= 100000., Theta_in=0., FWHM0=180.)
10
ionb = dict(Z=1, mass=1.0079)
11
OFlabentries = list()
12

Matheus Müller's avatar
Matheus Müller committed
13
##############################################################################
14
# Calculation callback
15
# Get parameters
16
17

def init_calc():
18
    global modelvar
19
20
21
22
23
24
25
26
    param['dedx'] = float(OFlabentries[9].get())
    param['dW2dx'] = float(OFlabentries[10].get())
    param['Theta_out'] = float(OFlabentries[11].get())
    param['Theta_in'] = float(OFlabentries[12].get())
    param['E0'] = float(OFlabentries[21].get())
    param['FWHM0'] = float(OFlabentries[13].get())
    ionb['mass'] = float(OFlabentries[22].get())
    ionb['Z'] = float(OFlabentries[23].get())      
27

28
29
30
31
32
33
34
    if str(modevar.get()) == 'IONS':
        if str(distvar.get()) == 'drawing':
            for i in range(len(Edict)):
                Edict[i]['dist'] = np.loadtxt(Edict[i]['symbol']+".prof")
            spectro(param, str(modelvar.get()), ionb, OFlabentries, int(LSvar.get()), int(CGvar.get()))
        elif str(distvar.get()) == 'layer':
            spectrolayer(param, str(modelvar.get()), ionb, OFlabentries, int(LSvar.get()), int(CGvar.get()))
35

36
37
    elif str(modevar.get()) == 'RRNA':
       return 0
38

Matheus Müller's avatar
Matheus Müller committed
39
##############################################################################
40
41
42
# Main window

root = tk.Tk()
43
root.minsize(670,550)
44
root.title('Open Flatus')
45
root.geometry('670x500+200+400')
46

Matheus Müller's avatar
Matheus Müller committed
47
##############################################################################
48
49
50
# Frames
MasterFrame1 = tk.Frame(root)
MasterFrame1.pack(side='left')
Matheus Müller's avatar
Matheus Müller committed
51
52
MasterFrame2 = tk.Frame(root)
MasterFrame2.pack(side='top')
53

54
55
Label0 = tk.LabelFrame(MasterFrame1, text = 'Experiment', relief='raised', bd=2)
Label0.pack(side='top')
56
57
58
Label2 = tk.LabelFrame(MasterFrame1, text = 'Parameters', relief='raised', bd=2)
Label2.pack(side='top')
Label3 = tk.LabelFrame(MasterFrame1, text = 'Ion parameters', relief='raised', bd=2)
Matheus Müller's avatar
Matheus Müller committed
59
60
61
62
63
64
65
Label3.pack(side='top')
Label4 = tk.LabelFrame(MasterFrame1, text = 'Energy loss model', relief='raised', bd=2)
Label4.pack(side='top')

# Elements frame
Label1 = tk.Frame(MasterFrame2)
Label1.pack(side='top')
66
67
68
69
70
71

Pframel = tk.Frame(Label2)
Pframel.pack(side='left')
Pframee = tk.Frame(Label2)
Pframee.pack(side='right')

Matheus Müller's avatar
Matheus Müller committed
72
Iframel = tk.Frame(Label3, width=9)
73
Iframel.pack(side='left')
Matheus Müller's avatar
Matheus Müller committed
74
Iframee = tk.Frame(Label3, width=11)
75
Iframee.pack(side='right')
76

Matheus Müller's avatar
Matheus Müller committed
77
##############################################################################
78
# Parameters
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# Labels // Entries numbers:
# 0 // 9 = dedx
# 1 // 10 = dW2dx
# 2 // 11 = theta out
# 3 // 12 = theta in
# 4 // 13 = FWHM0
# 5 // 14 = Energy min
# 6 // 15 = Energy max
# 7 // 16 = Energy step
# 8 // 17 = Depht step

OFlabentries.insert(0, tk.Label(Pframel, width=9, text='dƐ/dx', pady=2))
OFlabentries.insert(1, tk.Label(Pframel, width=9, text='dω²/dx', pady=2))
OFlabentries.insert(2, tk.Label(Pframel, width=9, text='θ out', pady=2))
OFlabentries.insert(3, tk.Label(Pframel, width=9, text='θ in', pady=2))
OFlabentries.insert(4, tk.Label(Pframel, width=9, text='FWHM0', pady=2))
OFlabentries.insert(5, tk.Label(Pframel, width=9, text='Emin', pady=2))
OFlabentries.insert(6, tk.Label(Pframel, width=9, text='Emax', pady=2))
OFlabentries.insert(7, tk.Label(Pframel, width=9, text='Estep', pady=2))
OFlabentries.insert(8, tk.Label(Pframel, width=9, text='Depth step', pady=2))
for n in range(9):
    OFlabentries[n].pack()
101
102

# Entries
103
104
105
for n in arange(9,18):
    OFlabentries.insert(n, tk.Entry(Pframee, width=11))
    OFlabentries[n].pack()
106
107

#Ion
108
109
110
111
112
113
114
115
116
117
118
119
120
# Labels // Entries numbers:
# 18 // 21 = Initial Energy
# 19 // 22 = mass
# 20 // 23 = Z (atomic number)
OFlabentries.insert(18, tk.Label(Iframel, width=9, text='Energy'))
OFlabentries.insert(19, tk.Label(Iframel, width=9, text='Mass'))
OFlabentries.insert(20, tk.Label(Iframel, width=9, text='Z'))
for n in arange(18,21):
    OFlabentries[n].pack()

for n in arange(21,24):
    OFlabentries.insert(n, tk.Entry(Iframee, width=11))
    OFlabentries[n].pack()
121

122
##############################################################################
123
#Initial values
124
125
126
127
128
129
130
131
132
133
134
135
136

OFlabentries[9].insert(0,param['dedx'])
OFlabentries[10].insert(0,param['dW2dx'])
OFlabentries[11].insert(0,param['Theta_out'])
OFlabentries[12].insert(0,param['Theta_in'])
OFlabentries[13].insert(0,param['FWHM0'])
OFlabentries[14].insert(0,70000)
OFlabentries[15].insert(0,100000) 
OFlabentries[16].insert(0,20) 
OFlabentries[17].insert(0,0.01) 
OFlabentries[21].insert(0,param['E0'])
OFlabentries[22].insert(0, ionb['mass'])
OFlabentries[23].insert(0, ionb['Z'])
137

Matheus Müller's avatar
Matheus Müller committed
138
##############################################################################
139
140
# Energy loss models

141
142
modevar = tk.StringVar()
modevar.set('IONS')
143
144
145
146
147
modelvar = tk.StringVar()
R1 = tk.Radiobutton(Label4, text="Gaussian", variable=modelvar, value='gaussiana')
R1.pack()
R2 = tk.Radiobutton(Label4, text="Bessel", variable=modelvar, value='bessel')
R2.pack()
148
R2.select()
149

Matheus Müller's avatar
Matheus Müller committed
150
##############################################################################
151
# Line shape/Convolve gaussian checkbox
Matheus Müller's avatar
Matheus Müller committed
152
153

LSvar = tk.IntVar()
154
CGvar = tk.IntVar()
Matheus Müller's avatar
Matheus Müller committed
155
156
C1 = tk.Checkbutton(Label4, text="Use Line Shape", variable=LSvar)
C1.pack()
157
C1.select()
158
159
160
C2 = tk.Checkbutton(Label4, text="Resolution Convolve", variable=CGvar)
C2.pack()
C2.select()
Matheus Müller's avatar
Matheus Müller committed
161
162

##############################################################################
163
# Calculate and Exit buttons
164

Matheus Müller's avatar
Matheus Müller committed
165
CalcButton = tk.Button(Label4, text = 'Calculate', command = init_calc, bd=4, width=17, height=2)
166
167
CalcButton.pack()

Matheus Müller's avatar
Matheus Müller committed
168
##############################################################################
169
170
# Elements callback

171
172
distvar = tk.StringVar()
distvar.set('drawing')
173
ewin_build(Label1, OFlabentries, root, CalcButton, distvar, modevar, Label0)
174

Matheus Müller's avatar
Matheus Müller committed
175
##############################################################################
176
177
178

root.mainloop()

Matheus Müller's avatar
Matheus Müller committed
179
##############################################################################