-
Notifications
You must be signed in to change notification settings - Fork 0
/
305855_Ward.py
313 lines (225 loc) · 9.04 KB
/
305855_Ward.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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
def RNO_night():
ext_vg = 11
sec_x_pt = 3
total_time = 600
cyc = 4
energy = 853.75
#yield from pol_H(-2.5)
yield from rixs_one_energy_1(sec_x_pt,total_time,cyc,energy,ext_vg, 'RNO')
energy = 855.25
yield from rixs_one_energy_1(sec_x_pt,total_time,cyc,energy,ext_vg, 'RNO')
def RNO_20200830():
sclr_disable()
#####parameters####
ext_vg = 30 # vertical slit opening
sec_x_pt = 3 # exposure time for RIXScam
total_time = 300 # total counting time
cyc = 1 # number of scans
#############################################
# E = list(np.arange(575.6, 581.7, 0.2))
# E = list(np.arange(856.125, 858.1, 0.125))
E = list(np.arange(856.625, 858.1, 0.125))
############################################
# set-up the polarization
#yield from pol_H(-2.5)
#yield from mv(pgm.en,E[0])
#############################################
for i in E:
yield from mvr(cryo.y, 0.003) # move sample a tiny bit after previous scan
yield from sleep(5)
yield from rixs_en_map(sec_x_pt,total_time,cyc,i,ext_vg, 'E_map RNO')
sclr_enable()
def RNO_20200829():
sclr_disable()
#####parameters####
ext_vg = 30 # vertical slit opening
sec_x_pt = 2 # exposure time for RIXScam
total_time = 300 # total counting time
cyc = 1 # number of scans
#############################################
# E = list(np.arange(575.6, 581.7, 0.2))
E = list(np.arange(852.5, 856.1, 0.125))
############################################
# set-up the polarization
#yield from pol_H(-2.5)
#yield from mv(pgm.en,E[0])
#############################################
for i in E:
yield from mvr(cryo.y, 0.003) # move sample a tiny bit after previous scan
yield from sleep(5)
yield from rixs_en_map(sec_x_pt,total_time,cyc,i,ext_vg, 'E_map RNO')
sec_x_pt = 3 # exposure time for RIXScam
total_time = 300 # total counting time
cyc = 1 # number of scans
#############################################
# E = list(np.arange(575.6, 581.7, 0.2))
# E = list(np.arange(856.125, 858.1, 0.125))
E = list(np.arange(856.625, 858.1, 0.125))
############################################
# set-up the polarization
#yield from pol_H(-2.5)
#yield from mv(pgm.en,E[0])
#############################################
for i in E:
yield from mvr(cryo.y, 0.003) # move sample a tiny bit after previous scan
yield from sleep(5)
yield from rixs_en_map(sec_x_pt,total_time,cyc,i,ext_vg, 'E_map RNO')
sclr_enable()
def LCO_20200828():
sclr_disable()
#####parameters####
ext_vg = 40 # vertical slit opening
sec_x_pt = 5 # exposure time for RIXScam
total_time = 900 # total counting time
cyc = 1 # number of scans
#############################################
# E = list(np.arange(575.6, 581.7, 0.2))
E = list(np.arange(576.4, 581.7, 0.2))
############################################
# set-up the polarization
yield from pol_H(-2.5)
yield from mv(pgm.en,E[0])
#############################################
for i in E:
yield from mvr(cryo.y, 0.003) # move sample a tiny bit after previous scan
yield from sleep(5)
yield from rixs_en_map(sec_x_pt,total_time,cyc,i,ext_vg, 'E_map LCO')
sclr_enable()
def LS5BO_20200827():
sclr_disable()
#####parameters####
ext_vg = 40 # vertical slit opening
sec_x_pt = 5 # exposure time for RIXScam
total_time = 900 # total counting time
cyc = 1 # number of scans
#############################################
E = list(np.arange(575.4, 582.1, 0.2))
#############################################
# set-up the polarization
yield from pol_H(-2.5)
yield from mv(pgm.en,E[0])
#############################################
for i in E:
yield from mvr(cryo.y, 0.003) # move sample a tiny bit after previous scan
yield from sleep(5)
yield from rixs_en_map(sec_x_pt,total_time,cyc,i,ext_vg, 'E_map L5BO')
sclr_disable()
#########################################################################################
def L5BO_20200826():
sclr_disable()
#####parameters####
ext_vg = 40 # vertical slit opening
sec_x_pt = 5 # exposure time for RIXScam
total_time = 900 # total counting time
cyc = 1 # number of scans
#############################################
E = list(np.arange(575, 581.1, 0.2))
#############################################
# set-up the polarization
yield from pol_H(-2.5)
yield from mv(pgm.en,E[0])
#############################################
for i in E:
yield from mvr(cryo.y, 0.003) # move sample a tiny bit after previous scan
yield from sleep(5)
yield from rixs_en_map(sec_x_pt,total_time,cyc,i,ext_vg, 'E_map L5BO')
sclr_disable()
#########################################################################################
def LCO_20200826():
sclr_disable()
ext_vg = 25
sec_x_pt = 4
total_time = 900
E = list(np.arange(707.4, 712.1, 0.2))
for i in E:
yield from sleep(5)
yield from rixs_en_map(sec_x_pt,total_time,1,i,ext_vg, 'E_map LCO')
#########################################################################################
def dinner_plan():
ext_vg = 30
sec_x_pt = 5
total_time = 900
cyc = 1
energy = 578.6
yield from pol_H(-2.5)
yield from sleep(30)
yield from rixs_one_energy_1(sec_x_pt,total_time,cyc,energy,ext_vg, 'LCO')
yield from pol_V(-2)
yield from sleep(30)
yield from rixs_one_energy_1(sec_x_pt,total_time,cyc,energy,ext_vg, 'LCO')
def LaCrO3_plan():
ext_vg = 20
sec_x_pt = 5
total_time = 600
cyc = 12
energy = 576.8
#yield from pol_H(-2.5)
yield from rixs_one_energy_1(sec_x_pt,total_time,cyc,energy,ext_vg, 'LCO')
energy = 577.8
yield from rixs_one_energy_1(sec_x_pt,total_time,cyc,energy,ext_vg, 'LCO')
#############################################################################################################################
def rixs_en_map(split_time, total_exp, cycles, energy, ext_vg, reason=''):
"""Basic scan for one RIX spectrum for a single energy
We plan to keep the scalars off!
ensure that sclr_disable() has been run prior to running this macro.
Parameters
-----------
split_time: float
exposure time of scan [seconds]
total_exp: integer
total integrated exposure time for a single scan (or cycle) [seconds]
cycles: integer
number of times to repeat a single total_exp
energy: float
incident beamline energy [eV] for all cycles
ext_vg : float
exit slit vertical gap [um] for all cycles (note 11 is realy 10 and 7 is really 5)
reason: string
extra metadata to describe scan purpose. use db[scan_id].start.reason to recover from database
"""
def rixs_cleanup(sclr_set_time_n=1):
"Set RIXS stuff off and scalar read time."
print('\n\n...............Cleaning up................\n\n')
yield from sleep(1)
yield from pzshutter_disable()
yield from mv(sclr.preset_time, sclr_set_time_n)
try:
dets=[rixscam, sclr, stemp.temp.B.T]
#dets=[rixscam, sclr,stemp.temp.B.T, voltage_dc, current_rbk]
yield from mv(extslt.vg, ext_vg, extslt.hg, 150)
yield from pzshutter_enable()
yield from mv(rixscam.cam.acquire_time, split_time)
yield from mv(sclr.preset_time, split_time)
yield from mv(pgm.en, energy)
yield from mv(gvbt1, 'open')
yield from sleep(5)
pts = int(total_exp/split_time)
import time
fails.clear()
for i in range(cycles):
try:
print('Starting cycle {} of {}' .format((i+1), cycles))
yield from count(dets, num=pts, md = {'reason':'Length = '+str(np.int(pts*split_time))+' s -'+reason} )
#yield from mvr(cryo.y, 0.002) # if you do not want to move comment out this line
#yield from sleep(3)
#yield from mvr(cryo.x,-0.0012) # if you do not want to move comment out this line
#yield from mvr(cryo.z,0.0026) # if you do not want to move comment out this line
print('Ending cycle {} of {}\n' .format((i+1),cycles))
except TimeoutError:
print('*'*50)
print(f"HAD A TIMEOUT on loop {i+1}")
print(f"Exception: {TimeoutError}")
print('*'*50)
yield from bps.checkpoint()
yield from bps.sleep(30)
yield from bps.unstage(rixscam)
fails.append((j, time.ctime()))
continue
except Exception:
print('\n\nOOPS! Possibly you stopped rixs_one_energy()')
yield from rixs_cleanup()
#return fails
raise
print('\n\n..........rixs_one_energy() finished normally...........\n\n')#this prints regardless of quiting during scan or letting it finish
yield from rixs_cleanup()
return fails