-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path00-user_info.py
104 lines (87 loc) · 4 KB
/
00-user_info.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
### For users to run at start of bluesky
from ophyd import EpicsSignal
RE.md['proposal'] = 'xxxx' #'commissioning' #'bdt' #'commissioning'
RE.md['group'] = 'xxxx'
RE.md['project'] = 'xxxx'#'' #'commissioning'
RE.md['orientation'] = ''
RE.md['SAF'] = 'xxxx'
RE.md['sample'] = 'xxxx'
#RE.md.pop('SAF')
RE.md.pop('orientation')
RE.md.pop('project')
#RE.md.pop('group')
### To change polarization ###
# RE(pol_V(0.75))
# RE(pol_H(0.5))
### BASIC SCAN ####
fails = []
def rixs_one_energy_1(split_time, total_exp,cycles,energy, ext_vg,reason='', disable_sclr_plt = True):
'''Basic scan for one RIX spectrum for a single energy
split_time\t :\t float - exposure time of scan [seconds]
total_exp\t :\t integer - total integrated exposure time for a single scan (or cycle) [seconds]
cycles\t :\t integer - number of times to repeat a single total_exp
energy\t :\t float - incident beamline energy [eV] for all cycles
ext_vg\t :\t float - exit slit vertical gap [um] for all cycles (note 11 is realy 10 and 7 is really 5)
reason\t :\t string - extra metadata to describe scan purpose. use db[scan_id].start.reason to recover from database
'''
def rixs_cleanup(sclr_set_time_n):
# this part is the clean up
print('\n\n...............Cleaning up................\n\n')
yield from sleep(1)
yield from pzshutter_disable()
sclr_enable()
yield from mv(sclr.preset_time,sclr_set_time_n)
yield from mv(gvbt1,'Close') # close GV before CCD # this magically closes when the scan finishes or is interupted. Don't understand why.
sclr_set_time=sclr.preset_time.get()
try:
if disable_sclr_plt == True:
sclr_disable()
else:
sclr_enable()
dets=[rixscam, sclr]
#dets=[rixscam, sclr,stemp.temp.B.T]
#dets=[rixscam, sclr, m1.pit, m3.pit, stemp.temp.B.T]
#dets=[rixscam, sclr,stemp.temp.B.T, current_pulse, voltage_pulse_rbk]
yield from mv(extslt.vg,ext_vg, extslt.hg, 150)
#yield from mv(extslt.vg,ext_vg, extslt.hg, 85)
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(0,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(2)
#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 as e:
print('*'*50)
print(f"HAD A TIMEOUT on loop {i+1}")
print(f"Exception: {e}")
print('*'*50)
yield from bps.checkpoint()
yield from bps.sleep(30)
yield from bps.unstage(rixscam)
fails.append((j, time.ctime()))
continue
#except KeyboardInterrupt:
#print('\n\n..........User interuptted rixs_one_energy()...........\n\n')
#yield from rixs_cleanup(sclr_set_time)
#return fails
#raise
except Exception:
print('\n\nOOPS! Possibly you stopped rixs_one_energy()')
yield from rixs_cleanup(1)
#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(sclr_set_time)
return fails