-
Notifications
You must be signed in to change notification settings - Fork 0
/
det_lib.py
executable file
·196 lines (148 loc) · 5.74 KB
/
det_lib.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
import sys
import os
import time
from string import *
import epics_det
#detector routines
#pixel array specific start
def detector_set_username(username):
epics_det.det_set_username(username)
def detector_save_files():
epics_det.det_save_files()
def detector_set_groupname(groupname):
epics_det.det_set_groupname(groupname)
def detector_set_fileperms(fileperms):
epics_det.det_set_fileperms(fileperms)
def detector_set_period(period):
print("set detector period " + str(period))
epics_det.det_set_image_period(period)
def detector_set_exposure_time(exptime):
print("set detector exposure time " + str(exptime))
epics_det.det_set_exptime(exptime)
def detector_get_seqnum():
return epics_det.det_getSeqNum()
def detector_get_deadtime():
return epics_det.det_get_deadtime()
def detector_setImagesPerFile(numimages):
epics_det.det_setImagesPerFile(numimages)
def detector_set_numimages(numimages):
print("set detector number of images " + str(numimages))
epics_det.det_set_numimages(numimages)
def detector_set_filepath(filepath):
print("set detector file path " + filepath)
epics_det.det_set_filepath(filepath)
def detector_set_fileprefix(fileprefix):
print("set detector file prefix " + fileprefix)
epics_det.det_set_fileprefix(fileprefix)
#def detector_set_fileNamePattern(fileNamePattern):
# print "set detector file name pattern " + fileNamePattern
# epics_det.det_set_fileprefix(fileprefix)
def detector_set_filenumber(filenumber): #I think this does nothing with the eiger
print("set detector file number " + str(filenumber))
epics_det.det_set_filenum(filenumber)
def detector_wait():
epics_det.det_wait()
def detector_waitArmed():
epics_det.det_waitArmed()
#pixel array specific end
def init_detector():
print("init detector")
epics_det.det_channels_init()
epics_det.det_set_numexposures(1)
def detector_start():
print("start detector")
epics_det.det_start()
def detector_trigger():
print("trigger detector")
epics_det.det_trigger()
def get_trigger_mode():
return epics_det.det_get_trigger_mode()
def detector_stop_acquire():
epics_det.det_stop_acquire()
def detector_set_trigger_mode(mode):
epics_det.det_set_trigger_mode(mode)
def detector_set_trigger_exposure(expTime):
epics_det.det_set_trigger_exposure(expTime)
def detector_set_num_triggers(numTrigs):
epics_det.det_set_num_triggers(numTrigs)
def detector_is_manual_trigger():
return epics_det.det_is_manual_trigger()
def detector_stop():
print("stop detector")
epics_det.det_stop()
def detector_write(flag):
# adsc_write(int(flag))
pass
def detector_bin():
epics_det.det_set_bin(2)
def detector_unbin():
epics_det.det_set_bin(1)
def detector_collect_darks(exptime):
pass
def detector_set_filename(filename):
print("detector filename")
print(filename)
last_slash = rfind(filename,"/")
last_underscore = rfind(filename,"_")
last_dot = rfind(filename,".")
img_path = filename[0:last_slash]
epics_det.det_set_filepath(img_path)
img_prefix = filename[last_slash+1:last_underscore]
epics_det.det_set_fileprefix(img_prefix)
img_number = filename[last_underscore+1:last_dot]
epics_det.det_set_filenum(int(img_number))
def detector_set_fileheader(phist,phiinc,dist,wave,theta,exptime,xbeam,ybeam,rot_ax,o,k,p):
#bogus rot axis,
print("detector filehead")
epics_det.det_setheader(float(phist),float(phiinc),float(dist),float(wave),
float(theta),float(exptime),float(xbeam),float(ybeam),
0,float(o),float(k),float(p))
def detector_set_filekind(flag):
pass
# if (flag == 1):
# adsc_setfilekind(4)
# else:
# adsc_setfilekind(5)
def detectorArmEigerObsolete(number_of_images,exposure_period,fileprefix,data_directory_name,wave,xbeam,ybeam,detDist): #will need some environ info to diff eiger/pilatus
global image_started,allow_overwrite,abort_flag
print("data directory = " + data_directory_name)
# test_filename = "%s_%05d.cbf" % (fileprefix,int(file_number))
# if (os.path.exists(test_filename) and allow_overwrite == 0):
# gui_message("You are about to overwrite " + test_filename + " If this is OK, push Continue, else Abort.&")
# pause_data_collection()
# check_pause()
# time.sleep(1.0)
# destroy_gui_message()
# if (abort_flag):
# print "collect sequence aborted"
# return 0
# else:
# allow_overwrite = 1
# detector_dead_time = .0024 #pilatus
detector_dead_time = .00001 #put this in config.
exposure_time = exposure_period - detector_dead_time
file_prefix_minus_directory = str(fileprefix)
try:
file_prefix_minus_directory = file_prefix_minus_directory[file_prefix_minus_directory.rindex("/")+1:len(file_prefix_minus_directory)]
except ValueError:
pass
detector_set_period(exposure_period)
detector_set_exposure_time(exposure_time)
detector_set_numimages(number_of_images)
detector_set_filepath(data_directory_name)
detector_set_fileprefix(file_prefix_minus_directory)
# detector_set_filenumber(file_number)
detector_set_fileheader(0.0,0.0,detDist,wave,0.0,0.0,xbeam,ybeam,"omega",0.0,0.0,0.0) #only a few for eiger
# print "collect eiger %f degrees for %f seconds %d images exposure_period = %f exposure_time = %f" % (range_degrees,range_seconds,number_of_images,exposure_period,exposure_time)
detector_start() #but you need wired or manual trigger
# image_started = range_seconds
# time.sleep(1.0) #4/15 - why so long?
# time.sleep(0.3)
# set_field("state","Expose")
# gon_osc(get_field("scan_axis"),0.0,range_degrees,range_seconds) #0.0 is the angle start that's not used
# image_started = 0
# detector_wait()
# set_field("state","Idle")
### daq_macros.fakeDC(data_directory_name,file_prefix_minus_directory,int(file_number),int(number_of_images))
# return number_of_images
return