This repository has been archived by the owner on Aug 31, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
focus2dscan_v2.ipy
151 lines (113 loc) · 5.09 KB
/
focus2dscan_v2.ipy
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
# -*- coding: utf-8 -*-
"""
Created on Wed Aug 5 02:01:58 2015
@author: xf05id1
"""
from epics import PV
import numpy
import time
##standard batch setup
def currenttimestr():
D0=str(time.localtime()[0])
D1=str(time.localtime()[1])
D2=str(time.localtime()[2])
D3=str(time.localtime()[3])
D4=str(time.localtime()[4])
currentTime=D0+'_'+D1+'_'+D2+'_'+D3+'_'+D4
return currentTime
def currenttimehrmin():
D0=time.localtime()[0]
D1=time.localtime()[1]
D2=time.localtime()[2]
D3=time.localtime()[3]
D4=time.localtime()[4]
hrmin=D3*60+D4
return hrmin
batchscantitle='AupatternTest_focus_ssa'
batchscandir='/nfs/xf05id1/data/batchscans/'
recordfile=batchscandir+currenttimestr()+batchscantitle+'.text'
f = open(recordfile, 'w')
f.write(batchscantitle+'\n')
f.write(currenttimestr()+'\n')
f.close()
##relevent PVs and initial positions
#aeroyval=PV('XF:05IDD-ES:1{Stg:Smpl1-Ax:Y}Mtr.VAL')
#aeroyrbv=PV('XF:05IDD-ES:1{Stg:Smpl1-Ax:Y}Mtr.RBV')
posval=PV('XF:05IDD-ES:1{Stg:Smpl1-Ax:Z}Mtr.VAL')
posrbv=PV('XF:05IDD-ES:1{Stg:Smpl1-Ax:Z}Mtr.RBV')
mid=-279.391
rerun=True
setappend = True #append list commands
def preloopblock(title='block scans'):
f = open(recordfile, 'a')
print title
f.write('\n'+title+':\n')
f.close()
def prescanblock (ssahsize=0.05, samzpos=mid):
#initial file output
f = open(recordfile, 'a')
#move motors
ssa.hsize(ssahsize)
posval.put(samzpos)
#wait for motors to settle
time.sleep(5)
#get current motor positions
ssahsize=ssa.hsize()
ycur = posrbv.get()
#print strings of motor positions
ssastr= 'ssa position = '+ str(ssahsize)
samzstr= 'sample z position = '+ str(ycur)
f.write(ssastr+'\n')
f.write(samzstr+'\n')
f.write('fileprefix = \''+currenttimestr()+'_\'\n')
if setappend == True:
f.write('ssahsizeList.append(ycur)\n')
f.write('samzpostList.append(ycur)\n')
f.write('fileprefixList.append(fileprefix)\n')
f.close()
time1=currenttimehrmin()
return time1
def checkcondition(time1):
conditiontime = 10 #if scan takes longer than 10 min, set rerun to false
time2=currenttimehrmin()
if (time2-time1) >= conditiontime:
rerun = False
print 'rerun?', rerun
##################################
##real part:
###testing sample z:
poslist=numpy.array([mid-0.10, mid, mid+0.1, mid+0.25, mid+0.5, mid+1.0, mid+2.0])
print poslist
preloopblock(title='sample z test scans')
for tar in poslist:
prescantime=prescanblock(ssahsize=0.05, samzpos=tar)
rerun = True
print 'rerun?', rerun
while rerun == True:
#%run ./srx-2dscan-sdd.py --detname=XF:05IDA{IM:1} --xstart=-35 --xnumstep=59 --xstepsize=0.5 --ystart=-68 --ynumstep=59 --ystepsize=0.5 --wait=0.1 --acqtime=0.3 --acqnum=1 --checkbeam --checkcryo
%run ./srx-2dscan-sdd-timeout.py --detname=XF:05IDA{IM:1} --xstart=-50 --xnumstep=59 --xstepsize=0.5 --ystart=-67 --ynumstep=59 --ystepsize=0.5 --wait=0.1 --acqtime=0.3 --acqnum=1 --checkbeam --checkcryo
#%run ./srx-2dscan-sdd.py --detname=XF:05IDA{IM:1} --xstart=-35 --xnumstep=1 --xstepsize=0.5 --ystart=-68 --ynumstep=1 --ystepsize=0.5 --wait=0.1 --acqtime=0.1 --acqnum=1 --checkbeam --checkcryo
rerun = checkcondition(prescantime)
### testing ssa
ssalist=numpy.array([0.1, 0.02])
print ssalist
preloopblock(title='ssa testing scans')
for tar in ssalist:
prescantime=prescanblock(ssahsize=tar, samzpos=mid)
rerun = True
print 'rerun?', rerun
while rerun == True:
#%run ./srx-2dscan-sdd.py --detname=XF:05IDA{IM:1} --xstart=-35 --xnumstep=59 --xstepsize=0.5 --ystart=-68 --ynumstep=59 --ystepsize=0.5 --wait=0.1 --acqtime=0.3 --acqnum=1 --checkbeam --checkcryo
%run ./srx-2dscan-sdd-timeout.py --detname=XF:05IDA{IM:1} --xstart=-50 --xnumstep=59 --xstepsize=0.5 --ystart=-67 --ynumstep=59 --ystepsize=0.5 --wait=0.1 --acqtime=0.3 --acqnum=1 --checkbeam --checkcryo
#%run ./srx-2dscan-sdd.py --detname=XF:05IDA{IM:1} --xstart=-35 --xnumstep=1 --xstepsize=0.5 --ystart=-68 --ynumstep=1 --ystepsize=0.5 --wait=0.1 --acqtime=0.1 --acqnum=1 --checkbeam --checkcryo
rerun = checkcondition(prescantime)
####final scan with 0.3 um step size, close ssa back to 0.02
preloopblock(title='0.3 um fine scan')
prescantime=prescanblock(ssahsize=0.05, samzpos=mid)
rerun = True
print 'rerun?', rerun
while rerun == True:
#%run ./srx-2dscan-sdd.py --detname=XF:05IDA{IM:1} --xstart=-35 --xnumstep=59 --xstepsize=0.5 --ystart=-68 --ynumstep=59 --ystepsize=0.5 --wait=0.1 --acqtime=0.3 --acqnum=1 --checkbeam --checkcryo
%run ./srx-2dscan-sdd-timeout.py --detname=XF:05IDA{IM:1} --xstart=-50 --xnumstep=99 --xstepsize=0.3 --ystart=-67 --ynumstep=99 --ystepsize=0.3 --wait=0.1 --acqtime=0.3 --acqnum=1 --checkbeam --checkcryo
#%run ./srx-2dscan-sdd.py --detname=XF:05IDA{IM:1} --xstart=-35 --xnumstep=1 --xstepsize=0.5 --ystart=-68 --ynumstep=1 --ystepsize=0.5 --wait=0.1 --acqtime=0.1 --acqnum=1 --checkbeam --checkcryo
rerun = checkcondition(prescantime)