Newer
Older
import numpy as np
import os
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*'#')
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
'''
if self.verbose: print(f'Setting element {element}, DOF {dof} to {position}')
self.beamline.pos[element, dof]=position
if self.verbose: print(f'Setting complete')
'''
Update detector(s)
'''
# Update optical element positions
if self.verbose: print(f'Adjusting OE settings ')
self.beamline.adjust()
if self.verbose: print(f'Adjusting OE settings complete')
# Trigger ray tracing
if self.verbose: print(f'Running Shadow simulation')
if self.verbose:
print(f'Run complete')
print(f'Results: {results}')
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)