Newer
Older
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
import numpy as np
import os
from beamline_29 import beamline_29
IMAGE = False
class surrogateBL():
def __init__(self, beamline):
'''
beamline : Shadow-based beamline
'''
#create necessary inputs/output; initialize to zero/empty
print(80*'#')
print('Initializing pyDevice surrogate beamline object')
self.beamline = beamline
print(80*'#')
self.motorPositions = []
def setupMotorLimits(self, subsFile):
'''
Go through shadow beamline and get DOF limits and set them as the motor
limits
Don't have a good way to do this; will manually update simulated motor
substitutions file with limits
'''
pass
def elementUpdate(self, element, dof, position):
'''
Update element position array but do not trigger detector
'''
self.beamline.pos[element, dof]=position
def detectorUpdate(self):
'''
Update detector(s)
'''
# Update optical element positions
self.beamline.adjust()
# Trigger ray tracing
results = self.beamline.run()
pydev.iointr('new_intensity', int(results))
if IMAGE:
image_data = np.zeros(128,128) # need to add screen to shadow simulation
flattened_data = image_date.flatten() # need to flatten for waveform
pydev.iointr('raw_image', flattened_data)
def updateVerbosity(self, verbosity):
'''
Turn on minor printing
'''
print(f'Verbosity set to {verbosity}')
self.verbose = verbosity