This commit is contained in:
root
2018-06-04 11:02:16 +02:00
parent 9bafa1e18d
commit 7da4e32097
15 changed files with 150 additions and 65 deletions

View File

@@ -1,16 +1,16 @@
#Thu May 17 10:31:20 CEST 2018
#Mon Jun 04 11:01:59 CEST 2018
colormap=Flame
colormapAutomatic=true
colormapMax=1000.0
colormapMax=255.0
colormapMin=0.0
flipHorizontally=false
flipVertically=false
grayscale=false
imageHeight=2160
imageWidth=2560
imageHeight=494
imageWidth=659
invert=false
regionStartX=1
regionStartY=1
regionStartX=0
regionStartY=0
rescaleFactor=1.0
rescaleOffset=0.0
roiHeight=-1
@@ -21,9 +21,10 @@ rotation=0.0
rotationCrop=false
scale=1.0
serverURL=null
spatialCalOffsetX=-606.4867444313851
spatialCalOffsetY=-602.502078032311
spatialCalScaleX=-26.714158979668674
spatialCalScaleY=-27.100271547904505
spatialCalOffsetX=-1279.4997788627065
spatialCalOffsetY=-1079.4997788915095
spatialCalScaleX=-53.02070816236811
spatialCalScaleY=-53.02454840203798
spatialCalUnits=null
t=
transpose=false

View File

@@ -1,9 +1,9 @@
#Thu May 03 15:36:18 CEST 2018
#Mon May 28 16:52:27 CEST 2018
maxValue=360.0
minValue=-90.0
offset=0.0
precision=4
resolution=0.1
resolution=0.5
rotation=true
scale=1.0
unit=deg

View File

@@ -1,5 +1,5 @@
#Mon May 14 14:06:13 CEST 2018
defaultSpeed=565.685424949238
#Sat Jun 02 09:39:17 CEST 2018
defaultSpeed=6000.0
estbilizationDelay=0
hasEnable=false
homingType=None

View File

@@ -1,4 +1,4 @@
#Mon May 14 18:41:08 CEST 2018
#Fri Jun 01 12:45:57 CEST 2018
colormap=Flame
colormapAutomatic=true
colormapMax=NaN
@@ -16,9 +16,9 @@ roiY=0
rotation=0.0
rotationCrop=false
scale=1.0
spatialCalOffsetX=-797.0771270584523
spatialCalOffsetY=-195.9069772960574
spatialCalScaleX=-18.903591543153755
spatialCalScaleY=-19.379845197810685
spatialCalOffsetX=-674.4869939208238
spatialCalOffsetY=-358.5976650464412
spatialCalScaleX=-18.903591266257227
spatialCalScaleY=-19.37984449994783
spatialCalUnits=mm
transpose=false

View File

@@ -21,8 +21,8 @@ bkgrd = args[7] if has_args else 10
plt = args[8] if has_args else plot(None, title = "Wire Scan")[0]
save_raw = args[9] if has_args else False
bunch = args[10] if has_args else 1
do_elog = True if (is_panel and (not is_script) and (plt is not None)) else False
print is_panel, do_elog
do_elog = True if (has_args and (not is_script) and (plt is not None)) else False
print has_args, do_elog
print "WireScan parameters: ", prefix, scan_type, scan_range, cycles, velocity, bpms, blms, bkgrd, bunch
@@ -71,7 +71,9 @@ for i in range (len(bpms)):
channels.append (("bpm" + str(i+1) + "_" + sensor[0], bpms[i] + ":" + sensor[1]))
if SET_BLM_WS_MODE and (len(blms)>0):
channels.append(("blm1_ws_mode", blms[0] + ":WS_RUNNING"))
channels.append(("blm1_ws_mode", blms[0] + ":WS_RUNNING"))
channels.append(("beam_ok", "SIN-CVME-TIFGUN-EVR0:BEAMOK"))
#Metadata
set_attribute("/", "Wire Scanner", prefix)
@@ -313,7 +315,7 @@ try:
st.getChild("blm1_ws_mode").waitValue(1, SET_BLM_WS_BS_READBACK_TIMEOUT)
print "Reading background..."
do_background()
st.setFilter(scanner.curr_cycl.get_name() + ">0") #scanner.status_channels[0].get_name() + ">0" not used because we must the transition to know when the finished
st.setFilter(scanner.curr_cycl.get_name() + ">0 AND SIN-CVME-TIFGUN-EVR0:BEAMOK == 1") #scanner.status_channels[0].get_name() + ">0" not used because we must the transition to know when the finished
print "Executing scan 1..."
do_scan(0)
if scan_type in [WireScanner.Set1, WireScanner.Set2]:

View File

@@ -11,12 +11,14 @@ plt = args[1] if is_panel else plot(None, title = "Wire Scan Calibrati
ws_blm = get_wire_scanners_blms(ws_prefix )[0]
#S10DI01-DBLM113:AL1-WS-PMT-GAIN
SATURATION = 1000
SATURATION = 19950 / 10
MIN_GAIN, MAX_GAIN = 0.5, 1.1
OPT_STEP = 0.01
SCAN_RANGE_FACTOR = 6.0
#2) Set the number of RF shots (N_shot) to be acquired during a single cycle WSC measurement (e.g.,N_shot=50)
n_shot = 50
n_shot = 200
#3) Set a test scanning range (e.g.,Xmin=-1000,Xmax=+1000um)
x_min, x_max = -1000.0, 1000.0
@@ -29,14 +31,15 @@ ws_speed = (x_max- x_min)*rr/n_shot
#5) Proceed with a test scan (1 cycle) according to the above defined motor settings
args = [ ws_prefix , WireScanner.WireX1, [x_min, x_max, x_min, x_max], 1, ws_speed, [], [ws_blm], 10, plt, False,1]
ret = run("Diagnostics/WireScan", args)
[rms_com, rms_sigma, com, sigma, pos_path, path] = ret
#1) Select a BLM to be used in the WSC measurement and enable the WS_START so that it can be extracted out of the MPS and PMT-Gain and attenuation can be adjusted
#start_blm_ws(ws_blm, 600.0)
start_blm_ws(ws_blm, 600.0)
#6) Apply a gauss fit to the obtained WSC profile in order to determine X_CoM and standard deviation (sigma_Gauss)
[rms_com, rms_sigma, com, sigma, pos_path, path] = ret
#7) Move the wire to the X_CoM position and optimize the PMT-Gain so that the time-integral of the BLM voltage reaches a value equal to 90% of the Σsat level
offset = caget(ws_prefix + ":W1X_U0_SP")
@@ -44,49 +47,68 @@ motor_pos=offset - com * math.sqrt(2)
caput(ws_prefix+":MOTOR_1.VAL", motor_pos) #DVAL?
#LOPR:0.5 HOPR:1.1
def get_gain():
return caget(ws_blm + ":WS_PMT_GAIN_VOLTS")
def set_gain(val):
caput(ws_blm + ":WS_PMT_GAIN_VOLTS", float(val))
print "Starting stream..."
st = Stream("blm_stream", dispatcher)
ch = ws_blm + ":B1_LOSS"
st.addScalar(ch, ch, int(100.0 / get_repetition_rate()), 0)
st.addScalar("blm1_ws_mode", ws_blm + ":WS_RUNNING", int(100.0 / get_repetition_rate()), 0)
st.initialize()
st.start()
st.waitCacheChange(10000) #Wait stream be running before starting scan
def get_loss():
return st.getValue(ch)
def get_gain():
return caget(ws_blm + ":WS_PMT_GAIN_VOLTS")
def set_gain(val):
caput(ws_blm + ":WS_PMT_GAIN_VOLTS", float(val))
def get_loss():
global ch
samples = []
for i in range(10):
st.waitCacheChange(-1)
val = st.getValue(ch)
samples.append(val)
return max(samples)
start_gain = get_gain()
pos = start_val = get_loss()
loss = get_loss()
target = SATURATION * 0.9
target = SATURATION * 0.8
print "Start Gain = ", start_gain
print "Start Loss = ", start_val
print "Target = ", target
def set_bml_ws_gain(gain):
set_gain(gain)
stop_blm_ws(ws_blm)
start_blm_ws(ws_blm, 600.0)
st.getChild("blm1_ws_mode").waitValue(1, SET_BLM_WS_BS_READBACK_TIMEOUT)
if start_val>target:
for pos in range(start_val, target, -OPT_STEP):
set_gain(pos)
for pos in frange(start_gain, MIN_GAIN, -OPT_STEP, True):
set_bml_ws_gain(pos)
loss = get_loss()
print "Pos = ", pos, " Loss = ", loss
if loss<=target:
break
elif start_val<target:
for pos in range(start_val, target, OPT_STEP):
set_gain(pos)
loss = get_loss()
if loss()>=target:
break
stop_blm_ws(ws_blm)
elif start_val<target:
for pos in frange(start_gain, MAX_GAIN, OPT_STEP, True):
set_bml_ws_gain(pos)
loss = get_loss()
print "Pos = ", pos, " Loss = ", loss
if loss>=target:
break
stop_blm_ws(ws_blm)
print "Final Gain = ", pos
print "Final Loss = ", loss
print get_gain()
@@ -94,9 +116,34 @@ print get_loss()
#set_gain(0.6)
#set_gain(0.5)
st.close()
#UPDATE X1 range
#WIRE = 1X, 2X, 1Y, 2Y
def set_wire_scan_range(wire, start, end):
start = min (max(start, -2000), 2000.0)
end = min (max(end, -2000), 2000.0)
caput((ws_prefix + ":W" + wire +"_START_SP"), x_range_min)
caput((ws_prefix + ":W" + wire +"_END_SP"), x_range_max)
#caget(ws_blm+":SAT_RAW_SUM")
args = [ ws_prefix , WireScanner.WireX1, [x_min, x_max, x_min, x_max], 1, ws_speed, [], [ws_blm], 10, plt, False,1]
ret = run("Diagnostics/WireScan", args)
[rms_com, rms_sigma, com, sigma, pos_path, path] = ret
x_range_min, x_range_max = com - SCAN_RANGE_FACTOR * sigma, com + SCAN_RANGE_FACTOR * sigma
set_wire_scan_range("1X", x_range_min, x_range_max)
#Att: caget(ws_blm + ":WS_PMT_ATT_VOLTS")
#8) Optimization of the scan interval: compare (Xmin, Xmax) with (X_CoM-N*sigma_Gauss , X_CoM+N*sigma_Gauss) where N is an integer value: N=5,6.

View File

@@ -52,7 +52,7 @@ else:
phase.config.minValue = -90.0
phase.config.maxValue = 360.0
phase.config.precision = 4
phase.config.resolution = 0.1
phase.config.resolution = 0.5
phase.config.rotation = True
phase.config.save()
phase.initialize()
@@ -103,9 +103,9 @@ dp = [abs(A) * val.mean for val in r.getReadable(1)]
try:
i_max = p.index(max(p))
i_min = dp.index(min(dp))
min_i, max_i = max(i_max-8, 0), min(i_max+8, len(p))
min_i, max_i = max(i_max-6, 0), min(i_max+6, len(p))
(ph_p_max, p_max, ph_p_fit, p_fit, p_R2) = extremum(ph[min_i:max_i], p[min_i:max_i])
min_i, max_i = max(i_min-8, 0), min(i_min+8, len(dp))
min_i, max_i = max(i_min-6, 0), min(i_min+6, len(dp))
(ph_dp_min, dp_min, ph_dp_fit, dp_fit, dp_R2) = extremum(ph[min_i:max_i], dp[min_i:max_i])
plt.addSeries(LinePlotErrorSeries("Momentum Fit", plt.getSeries(0).color))
plt.addSeries(LinePlotErrorSeries("Momentum Spread Fit", plt.getSeries(1).color, 2))

View File

@@ -1,13 +1,13 @@
import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
A1 = ChannelDouble("Current", "S20SY02-MKDC050:I-SET")
S1 = ChannelDouble("x1", "S20SY02-DBPM080:X1")
S2 = ChannelDouble("y1", "S20SY02-DBPM080:Y1")
S1 = ChannelDouble("x1", "S20SY02-DBPM150:X1")
S2 = ChannelDouble("y1", "S20SY02-DBPM150:Y1")
A1.initialize()
S1.initialize()
S2.initialize()
A1_init = A1.read()
A1i = -2.0
A1f = 2.0
A1i = -1.0
A1f = 1.0
nstep = 21
lat = 0.21
nav = 10
@@ -21,8 +21,8 @@ try:
S1_averager = create_averager(S1, nav, lat)
S2_averager = create_averager(S2, nav, lat)
S2_averager.monitored=True
time.sleep(10.0)
r = lscan(A1, (S1_averager, S2_averager), A1i, A1f, nstep, latency=5.0, after_read = after_sample)
time.sleep(1.0)
r = lscan(A1, (S1_averager, S2_averager), A1i, A1f, nstep, latency=1.0, after_read = after_sample)
Act1 = r.getPositions(0)
S1mean = [val.mean for val in r.getReadable(0)]
S1rms = [val.stdev for val in r.getReadable(0)]

35
script/Scan3.py Normal file
View File

@@ -0,0 +1,35 @@
import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
A1 = ChannelDouble("Delay", "S20SY02-MKAC040:TCS-Pul2-TDELAY-K")
S1 = ChannelDouble("Phase", "S20SY02-MKAC040:FRM-PHASE")
S2 = ChannelDouble("y1", "S20SY02-DBPM080:Y1")
A1.initialize()
S1.initialize()
S2.initialize()
A1_init = A1.read()
A1i = 433.8437
A1f = 433.8487
nstep = 21
lat = 0.130
nav = 30
plt = plot(None, title="Output")[0]
plt.clear()
plt.setStyle(plt.Style.ErrorY)
plt.addSeries(LinePlotErrorSeries("Sensor1", Color.red))
def after_sample(record, scan):
plt.getSeries(0).appendData(record.positions[0], record.values[0].mean, record.values[0].stdev)
try:
S1_averager = create_averager(S1, nav, lat)
S2_averager = create_averager(S2, nav, lat)
S2_averager.monitored=True
time.sleep(5.0)
r = lscan(A1, (S1_averager, S2_averager), A1i, A1f, nstep, latency=5.0, after_read = after_sample)
Act1 = r.getPositions(0)
S1mean = [val.mean for val in r.getReadable(0)]
S1rms = [val.stdev for val in r.getReadable(0)]
S2mean = [val.mean for val in r.getReadable(1)]
S2rmsn = [val.stdev for val in r.getReadable(1)]
finally:
A1.write(A1_init)
A1.close()
S1.close()
S2.close()

View File

@@ -1,18 +1,18 @@
import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
A1 = ChannelDouble("Gap", "SARUN03-UPHS060:GAP")
A1 = ChannelDouble("Gap", "SARUN03-UPHS060:GAP")
S1 = ChannelDouble("energy per pulse", "SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-US")
A1 = ChannelDouble("Phase (deg.)", "SARUN11-UIND030:PHI_SET")
A1 = ChannelDouble("Phase (deg.)", "SARUN11-UIND030:PHI_SET")
S1 = ChannelDouble("energy per pulse (uJ)", "SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-US")
S2 = ChannelDouble("HAMP", "SARFE10-PBPG050:HAMP-INTENSITY-CAL")
A1.initialize()
S1.initialize()
S2.initialize()
A1_init = A1.read()
A1i = -0.5
A1f = 1.5
nstep = 20
A1i = -180
A1f = 180
nstep = 72
lat = 0.11
nav = 50
nav = 100
plt = plot(None, title="Output")[0]
plt.clear()
plt.setStyle(plt.Style.ErrorY)

View File

@@ -4,7 +4,7 @@ import ch.psi.pshell.bs.Waveform as Waveform
#dispatcher.config.disableCompression = False
set_exec_pars(persist = False)
set_exec_pars(save = False)
#Arguments
SAMPLES = 5

View File

@@ -38,7 +38,7 @@ st.start()
st.waitCacheChange(10000) #Wait stream be running before starting scan
#Metadata
#set_exec_pars(persist = False)
#set_exec_pars(save = False)
try:
r=lscan(pos, sensors, RANGE[0], RANGE[1],STEP_SIZE, latency = SETTLING_TIME) #PC timestamp
r=bscan(st, 10) #BS Timestamp

View File

@@ -5,7 +5,7 @@ import ch.psi.pshell.epics.DiscretePositioner as DiscretePositioner
dispatcher.config.disableCompression = True
#set_exec_pars(persist = False)
#set_exec_pars(save = False)
#Arguments
SAMPLES = 2

View File

@@ -13,7 +13,7 @@ def create_device(url, parent=None):
devices = create_device(["ca://SINDI02-DBLM025:LOSS_SIGNAL_RAW?monitored=true&op=sum" ]) #SINDI02-DBLM025:LOSS_SIGNAL_RAW
try:
mscan([], devices , 10, -1, persist=False) #ar is ony updated on read
mscan([], devices , 10, -1, save=False) #ar is ony updated on read
#tscan( devices , 5, 0.1)
finally:
devices[0].parent.close()

View File

@@ -4,7 +4,7 @@ is_panel = get_exec_pars().source != CommandSource.ui #Must be checked before c
run("Devices/Elements")
run("Devices/WireScanner")
set_exec_pars(persist=False)
set_exec_pars(save=False)
BPM_SENSORS = [("x","X1"), ("y","Y1"), ("q","Q1")] #(logic name sufix, channel sufix)