Files
sf-op/script/Diagnostics/Laser_position_scan.py
2017-09-22 10:58:17 +02:00

74 lines
2.3 KiB
Python

import ch.psi.pshell.epics.ControlledVariable as ControlledVariable
#CAMERA = "S10DI01-DSCR020" #"simulation"
CAMERA = "SINDI02-DLAC055" #"simulation"
QUADRUPOLE = "S10CB02-MQUA230" # quadrupole for the scan with S10DI01-DSCR020: S10CB02-MQUA230
CHARGE_BPM = "SINEG01-DBPM340:Q1"
CHARGE_ICT = "SINEG01-DICT215:B1_CHARGE-OP"
RANGE = (-3.0, 0.0)
STEPS = 100
SETTLING_TIME = 1
print cam_server.cameras
cam_server.start(CAMERA)
wait_cam_server_message()
print cam_server.value.identifiers
#plot(cam_server.getValue("y_fit_gauss_function"))
m=cam_server.getDataMatrix()
x = cam_server.stream.getChild("x_fit_mean")
y = cam_server.stream.getChild("y_fit_mean")
"""
ax = create_averager(x, 5, -1, "X Fit")
ay = create_averager(y, 5, -1, "Y Fit")
ay.monitored = True
"""
set_device_alias(m,"image")
#Create quadrupole device
quad = ControlledVariable(QUADRUPOLE, QUADRUPOLE + ":I-SET", QUADRUPOLE + ":I-READ")
quad.config.minValue =-10.0
quad.config.maxValue = 10.0
quad.config.precision = 3
quad.config.resolution = 0.007
quad.config.save()
quad.initialize()
bpm = Channel(CHARGE_BPM, 'd', alias = "Charge BPM")
ict = Channel(CHARGE_ICT, 'd', alias = "Charge ICT")
#Metadata
try:
set_attribute("/", "Camera", CAMERA)
set_attribute("/", "Quadrupole", QUADRUPOLE)
set_attribute("/", "Scan Parameters", RANGE + (STEPS,))
set_attribute("/", "Screen Position", caget(CAMERA + ":GET_SCREEN1_POS", 's'))
set_attribute("/", "Filter Position", caget(CAMERA + ":GET_FILTER", 's'))
except:
pass
try:
laser_off()
#save_dataset("/Background", m.read())
#mscan (cam_server.stream, m, 10) #Saves 10 next frames -> For machine at 10 -> 100Hz
tscan(m, 10, 1.0) # 10 samples every 0.2 s -> For machine at 1Hz
laser_on()
#tscan((m, x, y), 10, 1.0) # 10 samples every 1.0 s
#mscan (cam_server.stream,(m, x, y), -1, 5.0) #Saves all frames received in 5s
#mscan (cam_server.stream,(m, x, y), 50) # Saves firs 50 frames
#lscan(quad, (m, x, y), RANGE[0], RANGE[1], STEPS, latency=SETTLING_TIME)
readables = cam_server.stream.getReadables().clone() + [bpm, ict]
readables.remove(cam_server.stream.getChild("image"))
readables.insert(0,m)
lscan(quad, readables, RANGE[0], RANGE[1], STEPS, latency=SETTLING_TIME)
finally:
quad.close()
cam_server.stop()