-
Notifications
You must be signed in to change notification settings - Fork 0
/
control.py
64 lines (52 loc) · 2.31 KB
/
control.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
########################
## Code snippets ONLY for the motor control and data collection
# collection of XRF and TXM data
########################
XradiaAxisNameList = ['x','y','z','t','zpx','zpy','zpz',
'cdx','cdy','cdz','cdpitch','cdyaw',
'prx','pry','prz','phx','phy','phz',
'energy', 'detx','dety','detz']
def collectXRF(self, filename):
filename = filename +'.mat'
microscope = xradia_helper.Microscope(motorwait = True, verbose = False, timer=False)
microscope.OpenXrayShutter()
options = getOptions(sys.argv[1:])
print("Starting xrf system...")
init('mercury_1.0.ini')
start_system()
start_run(0)
print("waiting for 30 secs to finish the spectrum")
time.sleep(30)
data = get_spectrum(0)
stop_run(0)
print('DATA maximum: ' + str(max(data)))
print("saving...")
scipy.io.savemat(options.outputfile, dict(data=data))
print("Finished xrf: ", options.outputfile)
# plt.plot(data)
# plt.show()
microscope.Shutdown()
def collectTXM(self, filename):
filename = filename +'.xrm'
Binning = 2 # can be changed
Exptime = 0.5 # can be changed
microscope = xradia_helper.Microscope(motorwait = True, verbose = False, timer=False)
if not microscope.StartGISingleAcquisition(str(os.path.join(self.filepath, filename)),
Binning,
Exptime):
error_message = ( 'ERROR - Could not collect image.')
logging.error(error_message)
print error_message
return
print("Finished TXM: ", str(os.path.join(self.filepath, filename)))
microscope.Shutdown()
def moveMotorAndCapture(self, filename, axisname, position):
savefile = filename
# self.moveBy(axisname,position)
for index in range(len(position)):
self.moveTo(axisname[index], position[index])
# time.sleep(10)
self.collectXRF(savefile)
self.collectTXM(savefile)
Controller.moveMotorAndCapture(filename, axisname, [int(phxi), int(phyi),int(cdxi), int(cdyi)]) #not necessary to be super accurate
print 'Finished the measure, time: '+ str(endtime-starttime)