This commit is contained in:
gobbo_a
2017-05-11 13:02:21 +02:00
parent c3532fc3d1
commit ee6689d661
10 changed files with 302 additions and 30 deletions
+11 -11
View File
@@ -1,16 +1,16 @@
#Tue May 09 14:37:55 CEST 2017
#Thu May 11 11:21:30 CEST 2017
colormap=Flame
colormapAutomatic=false
colormapMax=1000.0
colormapAutomatic=true
colormapMax=0.0
colormapMin=0.0
flipHorizontally=false
flipVertically=false
grayscale=false
imageHeight=2160
imageWidth=2560
imageHeight=-1
imageWidth=-1
invert=false
regionStartX=1
regionStartY=1
regionStartX=0
regionStartY=0
rescaleFactor=1.0
rescaleOffset=0.0
roiHeight=-1
@@ -21,9 +21,9 @@ rotation=0.0
rotationCrop=false
scale=1.0
serverURL=localhost\:10000
spatialCalOffsetX=-561.5040694398416
spatialCalOffsetY=-561.5353189903899
spatialCalScaleX=-8.510638213864555
spatialCalScaleY=-8.23581701380606
spatialCalOffsetX=NaN
spatialCalOffsetY=NaN
spatialCalScaleX=NaN
spatialCalScaleY=NaN
spatialCalUnits=mm
transpose=false
+2 -2
View File
@@ -1,4 +1,4 @@
#Mon May 08 17:19:11 CEST 2017
#Thu May 11 08:37:16 CEST 2017
defaultSpeed=6000.0
estbilizationDelay=0
hasEnable=false
@@ -6,7 +6,7 @@ homingType=None
maxSpeed=8000.0
maxValue=51500.0
minSpeed=50.0
minValue=-57027.0
minValue=-56789.2
offset=0.0
precision=1
resolution=0.1
+3 -3
View File
@@ -1,4 +1,4 @@
#Tue Mar 21 12:18:16 CET 2017
#Thu May 11 13:01:43 CEST 2017
colormap=Temperature
colormapAutomatic=true
colormapMax=30000.0
@@ -6,8 +6,8 @@ colormapMin=0.0
flipHorizontally=false
flipVertically=false
grayscale=false
imageHeight=1628
imageWidth=1280
imageHeight=0
imageWidth=0
invert=false
offsetX=0.0
offsetY=0.0
+3 -3
View File
@@ -1,4 +1,4 @@
#Tue Apr 18 13:47:25 CEST 2017
#Thu May 11 13:01:43 CEST 2017
colormap=Grayscale
colormapAutomatic=true
colormapMax=255.0
@@ -6,8 +6,8 @@ colormapMin=0.0
flipHorizontally=false
flipVertically=false
grayscale=false
imageHeight=1680
imageWidth=1744
imageHeight=0
imageWidth=0
invert=false
offsetX=0.0
offsetY=0.0
+5 -5
View File
@@ -1,4 +1,4 @@
#Mon May 01 09:53:33 CEST 2017
#Thu May 11 11:13:46 CEST 2017
colormap=Flame
colormapAutomatic=true
colormapMax=578.797
@@ -18,9 +18,9 @@ roiY=0
rotation=0.0
rotationCrop=false
scale=1.0
spatialCalOffsetX=-226.5485440792231
spatialCalOffsetY=-401.5108176113712
spatialCalScaleX=-7.61744675127048
spatialCalScaleY=-7.774538465366242
spatialCalOffsetX=-630.5060320164276
spatialCalOffsetY=-612.5104241897614
spatialCalScaleX=-26.761820720381525
spatialCalScaleY=-26.595744663521685
spatialCalUnits=mm
transpose=false
+2 -1
View File
@@ -1,6 +1,7 @@
#Thu Mar 02 17:53:24 CET 2017
#Thu May 11 08:37:38 CEST 2017
alignmentRetries=20
disableCompression=false
dropIncomplete=false
keepListeningOnStop=false
parallelHandlerProcessing=true
sendIncompleteMessages=true
+121
View File
@@ -0,0 +1,121 @@
#import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
import ch.psi.pshell.bs.Scalar as Scalar
import ch.psi.pshell.epics.DiscretePositioner as DiscretePositioner
#Arguments
SAMPLES = 20
GAINS = ["SINDI02-DBLM084:M06-1-CH03-V-MM","SINDI02-DBLM084:M06-1-CH03-V-MM2",]
BLMS = ["SINDI02-DBLM025", "SINDI02-DBLM085", "S10DI01-DBLM045"]
BPMS = ["SINDI01-DBPM060:Q1", "SINDI02-DBPM010:Q1"]
ATTENUATORS = ["SINDI02-DBLM084:M06-1-ATT2-VAL", "SINDI02-DBLM084:M06-2-ATT2-VAL", "S10DI01-DBLM113:M06-1-ATT2-VAL"]
RANGE = [0.5, 1.1]
STEP_SIZE = 0.01
SETTLING_TIME = 0.5
SIMULATION = True
do_elog = True
gain_positioners = []
for i in range(len(GAINS)):
gain_positioners.append( DummyPositioner("gain " + str(i+1)) if SIMULATION else Channel(GAINS[i], alias = "gain " + str(i+1)))
attenuators = []
for i in range(len(ATTENUATORS)):
att = DiscretePositioner("Att"+str(i+1), ATTENUATORS[i])
att.initialize()
attenuators.append(att)
#Channel-based
#blm1 = ChannelDouble("blm1", "SINDI02-DBLM025:B1_LOSS"); blm1.setMonitored(True); blm1.initialize()
#blm2 = ChannelDouble("blm2", "SINDI02-DBLM085:B1_LOSS"); blm2.setMonitored(True); blm2.initialize()
#Stream creation
sensors = []
line_plots = []
st = Stream("pulse_id", dispatcher)
for i in range(len(BLMS)):
blm = Scalar("blm" + str(i+1), st, BLMS[i] + ":B1_LOSS", 10, 0)
av = create_averager(blm, SAMPLES, interval = -1)
av.setMonitored(i>0)
sensors.append(av)
sensors.append(av.stdev)
sensors.append(av.samples)
line_plots.append(av.samples)
#st.initialize()
#st.start()
#st.waitCacheChange(10000) #Wait stream be running before starting scan
for i in range(len(BPMS)):
bpm = Scalar("bpm" + str(i+1), st, BPMS[i], 10, 0)
av1 = create_averager(bpm, SAMPLES, interval = -1)
av1.setMonitored(i>0)
sensors.append(av1)
sensors.append(av1.stdev)
sensors.append(av1.samples)
line_plots.append(av1.samples)
st.initialize()
st.start()
st.waitCacheChange(10000) #Wait stream be running before starting scan
"""
#Averaging
ablm1 = create_averager(blm1, SAMPLES, interval = -1)
ablm2 = create_averager(blm2, SAMPLES, interval = -1)
ablm2.setMonitored(True)
"""
#Plot setup
setup_plotting( line_plots = line_plots)
#Metadata
set_attribute("/", "Samples" , SAMPLES)
set_attribute("/", "StepSize" , STEP_SIZE)
set_attribute("/", "SamplingTime" , SETTLING_TIME)
set_attribute("/", "Range" , RANGE)
set_attribute("/", "BLM" , BLMS)
set_attribute("/", "Gain" , GAINS)
set_attribute("/", "Attenuators" , ATTENUATORS)
set_attribute("/", "BPM" , BPMS)
for att in attenuators:
set_attribute("/", att.setpoint.channelName, att.read())
try:
r=lscan(gain_positioners, sensors, [RANGE[0],] * len(gain_positioners), [RANGE[1],] * len(gain_positioners), [STEP_SIZE,] * len(gain_positioners), latency = SETTLING_TIME)
finally:
st.close()
# save the entry in the logbook
if do_elog:
if get_option("Generated data file:\n" + get_exec_pars().path + "\n\n" + "Save to ELOG?", "YesNo") == "Yes":
gsa_log_msg = "Data file: " + get_exec_pars().path
gsa_log_msg = gsa_log_msg + "\nSamples = " + str(SAMPLES)
gsa_log_msg = gsa_log_msg + "\nStepSize = " + str(STEP_SIZE)
gsa_log_msg = gsa_log_msg + "\nSamplingTime = " + str(SETTLING_TIME)
gsa_log_msg = gsa_log_msg + "\nRange = " + str(RANGE)
gsa_log_msg = gsa_log_msg + "\nBLM = " + str(BLMS)
gsa_log_msg = gsa_log_msg + "\nBPM = " + str(BPMS)
gsa_log_msg = gsa_log_msg + "\nGain = " + str(GAINS)
gsa_log_msg = gsa_log_msg + "\nAttenuators:" # = " + str(ATTENUATORS)
for att in attenuators:
gsa_log_msg = gsa_log_msg + "\n " + att.setpoint.channelName + " = " + str(att.read())
plots = get_plot_snapshots()
save=[]
for i in range(len(BLMS)):
save.append(plots[3*i])
for i in range(len(BPMS)):
save.append(plots[3*i])
elog("Wire Scan", gsa_log_msg, save)
@@ -0,0 +1,87 @@
import ch.psi.pshell.epics.ControlledVariable as ControlledVariable
#Easy script to read the camtool camera data and save it
#
#CAMERA = "S10DI01-DSCR020" #"simulation"
#CAMERA = "SINDI02-DLAC055" #"simulation"
#CAMERA = "S10BD01-DSCR030" #"simulation"
#CAMERA = "SINDI01-DSCR080" #"simulation"
CAMERA = "SINEG01-DSCR190" #"simulation"
#QUADRUPOLE = "S10CB02-MQUA230" # quadrupole for the scan with S10DI01-DSCR020: S10CB02-MQUA230
CHARGE_BPM = "SINDI01-DBPM060:Q1"
CHARGE_ICT = "S10DI01-DICT025:B1_CHARGE-OP"
#RANGE = (-3.0, 0.0)
#STEPS = 100
#SETTLING_TIME = 1
#kill_camtool()
check_camtool()
print camtool.getCameras()
#camtool.start("SINBD01-DSCR010")
camtool.start(CAMERA)
camtool.stream.waitCacheChange(10000)
print camtool.value.identifiers
#plot(camtool.getValue("y_fit_gauss_function"))
m=camtool.getDataMatrix()
x = camtool.stream.getChild("x_fit_mean")
y = camtool.stream.getChild("y_fit_mean")
x_profile = camtool.stream.getChild("x_profile")
y_profile = camtool.stream.getChild("y_profile")
x_axis = camtool.stream.getChild("x_axis")
y_axis = camtool.stream.getChild("y_axis")
"""
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 (camtool.stream, m, 10) #Saves 10 next frames -> For machine at 10 -> 100Hz
#tscan(m, 10, 0.2) # 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 (camtool.stream,(m, x, y), -1, 5.0) #Saves all frames received in 5s
#mscan (camtool.stream,(m, x, y), 50) # Saves firs 50 frames
#lscan(quad, (m, x, y), RANGE[0], RANGE[1], STEPS, latency=SETTLING_TIME)
#readables = camtool.stream.getReadables().clone() + [bpm, ict]
#readables.remove(camtool.stream.getChild("image"))
#readables.insert(0,m)
# lscan(quad, readables, RANGE[0], RANGE[1], STEPS, latency=SETTLING_TIME)
mscan(camtool.stream, (m, x_profile, y_profile, x_axis, y_axis), 1)
finally:
# quad.close()
camtool.stop()
+13 -5
View File
@@ -59,6 +59,10 @@ set_attribute("/", "Cycles", cycles)
set_attribute("/", "Motor Velocity", velocity*math.sqrt(2))
set_attribute("/", "Wire Velocity", velocity)
set_attribute("/", "Background Measures", bkgrd)
set_attribute("/", "BPMs", bpms)
set_attribute("/", "BLMs", blms)
filename = get_exec_pars().path
#Stream creation
print "Starting stream..."
@@ -117,7 +121,7 @@ def do_background():
#Scan
def do_scan(index):
global scan_complete, cur_cycle, wire
wire = "y" if (index==1) or (scan_type in [WireScanner.WireY1, WireScanner.WireY1]) else "x"
wire = "y" if (index==1) or (scan_type in [WireScanner.WireY1, WireScanner.WireY2]) else "x"
set_exec_pars(group=wire+"_{count}", reset=True)
scanner.set_selection(get_scan_selection(scan_type, index))
if wire == "x":
@@ -131,6 +135,7 @@ def do_scan(index):
cur_cycle = 1.0
for s in plt.getAllSeries():
s.clear()
plt.removeMarker(None)
try:
scanner.scan() #scanner.waitState(State.Busy, 60000) Not needed as stream filter will make the wait
st.getChild("scanning").waitValue(1.0, 10000)
@@ -148,7 +153,7 @@ def do_scan(index):
#x,y = [s.x[x] for x in indexes], [s.y[x] for x in indexes]
#plot(y, xdata = x)
calculate()
img_file = os.path.abspath(get_exec_pars().path + "_" + get_exec_pars().group[0:1] + ".png")
img_file = os.path.abspath(filename + "_" + get_exec_pars().group[0:1] + ".png")
time.sleep(0.1) #Give some time to plot finish (async)
plt.saveSnapshot(img_file, "png")
snapshots.append(img_file)
@@ -191,7 +196,7 @@ def calculate():
sample = [v for v in sample if v is not None]
stats[i].append( (mean(sample), stdev(sample)) if len(sample)>0 else (float("nan"), float("nan")) )
plt.addMarker(stats[i][2][0], None, "Gcom=" + "%.2f" % stats[i][2][0], plt.getSeries(i).color)
plt.addMarker(stats[i][1][0], None, "Rcom=" + "%.2f" % stats[i][1][0], plt.getSeries(i).color.brighter())
plt.addMarker(stats[i][0][0], None, "Rcom=" + "%.2f" % stats[i][0][0], plt.getSeries(i).color.brighter())
msg += " RMS COM: " + "%.4f" % stats[i][0][0] + " +- " +"%.4f" % stats[i][0][1] + "\n" #unichr(0x03C3) + "="
msg += " RMS Sigma: " + "%.4f" % stats[i][1][0] + " +- " + "%.4f" % stats[i][1][1] + "\n"
@@ -219,14 +224,17 @@ print msg
# save the entry in the logbook
if do_elog:
if get_option("Generated data file:\n" + get_exec_pars().path +"\n\n" + msg + "\n\n" + "Save to ELOG?", "YesNo") == "Yes":
gsa_log_msg = "Data file: " + get_exec_pars().path
if get_option("Generated data file:\n" + filename +"\n\n" + msg + "\n\n" + "Save to ELOG?", "YesNo") == "Yes":
gsa_log_msg = "Data file: " + filename
gsa_log_msg = gsa_log_msg + "\nWire Scanner: " + prefix
gsa_log_msg = gsa_log_msg + "\nScan Type: " + str(scan_type)
gsa_log_msg = gsa_log_msg + "\nRange: " + str(scan_range)
gsa_log_msg = gsa_log_msg + "\nCycles: " + str(cycles)
gsa_log_msg = gsa_log_msg + "\nWire Velocity: " + str(velocity)
gsa_log_msg = gsa_log_msg + "\nBackground Measures: " + str(bkgrd)
gsa_log_msg = gsa_log_msg + "\nBPMs: " + str(bpms)
gsa_log_msg = gsa_log_msg + "\nBLMs: " + str(blms)
gsa_log_msg = gsa_log_msg + "\n" + msg
elog("Wire Scan", gsa_log_msg, snapshots)
+55
View File
@@ -0,0 +1,55 @@
import traceback
is_panel = get_exec_pars().source != CommandSource.ui #Must be checked before callin "run"
run("Devices/Elements")
run("Devices/WireScanner")
set_exec_pars(persist=False)
BPM_SENSORS = [("x","X1"), ("y","Y1"), ("q","Q1")] #(logic name sufix, channel sufix)
#Paramter parsing
prefix = args[0] if is_panel else "S30CB09-DWSC440" #"SINDI01-DWSC090"
scan_type = args[1] if is_panel else WireScanner.WireX1
scan_range = args[2] if is_panel else [-200, 200, -200, 200]
cycles = args[3] if is_panel else 3
velocity = args[4] if is_panel else 200
bpms = args[5] if is_panel else get_wire_scanners_bpms(prefix)
blms = args[6] if is_panel else get_wire_scanners_blms(prefix)
bkgrd = args[7] if is_panel else 10
do_elog = True if is_panel else True
print "WireScan parameters: ", prefix, scan_type, scan_range, cycles, cycles, bpms
#Creating WireScanner object
print "Creating scanner..."
if prefix not in get_wire_scanners():
raise Exception("Invalid wire scan: " + prefix)
scanner = WireScanner(prefix, scan_range, cycles, velocity, True)
#List of stream channels
channels = [("m_pos", scanner.motor_bs_readback.get_name()),
("cur_cycle", scanner.curr_cycl.get_name()),
("scanning", scanner.status_channels[0].get_name())]
for i in range (len(blms)):
channels.append (("blm" + str(i+1), blms[i] + ":B1_LOSS"))
for i in range (len(bpms)):
for sensor in BPM_SENSORS:
channels.append (("bpm" + str(i+1) + "_" + sensor[0], bpms[i] + ":" + sensor[1]))
#Stream creation
print "Starting stream..."
st = Stream("pulse_id", dispatcher)
for c in channels:
st.addScalar(c[0], c[1], 10, 0)
st.initialize()
st.start()
st.waitCacheChange(10000) #Wait stream be running before starting scan
try:
bscan(st, 1000)
finally:
scanner.close()
st.close()