Startup
This commit is contained in:
@@ -208,7 +208,7 @@
|
||||
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||
<Properties>
|
||||
<Property name="horizontalAlignment" type="int" value="4"/>
|
||||
<Property name="text" type="java.lang.String" value="I1:"/>
|
||||
<Property name="text" type="java.lang.String" value="phi_start"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JSpinner" name="spinnerI1">
|
||||
@@ -221,7 +221,7 @@
|
||||
<Component class="javax.swing.JLabel" name="jLabel2">
|
||||
<Properties>
|
||||
<Property name="horizontalAlignment" type="int" value="4"/>
|
||||
<Property name="text" type="java.lang.String" value="I2:"/>
|
||||
<Property name="text" type="java.lang.String" value="phi_end:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JSpinner" name="spinnerI2">
|
||||
|
||||
@@ -132,12 +132,12 @@ public class LaserGunAlignment extends Panel {
|
||||
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Parameters"));
|
||||
|
||||
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
|
||||
jLabel1.setText("I1:");
|
||||
jLabel1.setText("phi_start");
|
||||
|
||||
spinnerI1.setModel(new javax.swing.SpinnerNumberModel(95.0d, 50.0d, 150.0d, 1.0d));
|
||||
|
||||
jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
|
||||
jLabel2.setText("I2:");
|
||||
jLabel2.setText("phi_end:");
|
||||
|
||||
spinnerI2.setModel(new javax.swing.SpinnerNumberModel(100.0d, 50.0d, 150.0d, 1.0d));
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Tool to align the solenoid on the gun.
|
||||
# S. Bettoni, A. Gobbo, D. Voulot
|
||||
# 06/06/2016
|
||||
|
||||
#Code ok with the GUI
|
||||
|
||||
# Procedure:
|
||||
# switch off all the magnets between the gun solenoid and the screen or BPM used for the measurement
|
||||
|
||||
@@ -13,31 +13,80 @@ if get_context().source == CommandSource.ui:
|
||||
dphi = 1.0
|
||||
settling_time = 0.1
|
||||
|
||||
import org.apache.commons.math3.linear.Array2DRowRealMatrix as Matrix
|
||||
import ch.psi.utils.Convert.toBidimensional as mono_to_bidi
|
||||
import datetime
|
||||
|
||||
print phi1
|
||||
print phi2
|
||||
print dphi
|
||||
print settling_time
|
||||
abort()
|
||||
if get_context().source == CommandSource.ui:
|
||||
phi1 = 95.0
|
||||
phi2 = 100.0
|
||||
dphi = 1.0
|
||||
settling_time = 0.1
|
||||
plot_image = False
|
||||
number_images = 1
|
||||
use_background = True
|
||||
multiple_background = True
|
||||
number_backgrounds = 5
|
||||
zero_solenoids=False
|
||||
do_elog = False
|
||||
centroid_excursion_plot = True
|
||||
else:
|
||||
centroid_excursion_plot = False
|
||||
|
||||
print "Parameters: ", phi1, phi2, dphi, settling_time, plot_image, number_images, use_background, multiple_background, number_backgrounds
|
||||
|
||||
plot_name = datetime.datetime.fromtimestamp(time.time()).strftime('%H%M%S')
|
||||
|
||||
cam_x = Channel("SINEG01-DSCR190:profile.X_stats.com", alias = "cam_x")
|
||||
cam_y = Channel("SINEG01-DSCR190:profile.Y_stats.com", alias = "cam_y")
|
||||
|
||||
bpm_x = Channel("SINEG01-DBPM340:X1", alias = "bpm_x")
|
||||
bpm_y = Channel("SINEG01-DBPM340:Y1", alias = "bpm_y")
|
||||
profile_x = Channel("SINEG01-DSCR190:profile.X", alias = "profile_x")
|
||||
profile_y = Channel("SINEG01-DSCR190:profile.Y", alias = "profile_y")
|
||||
|
||||
cam_raw_data = Channel("SINEG01-DSCR190:data")
|
||||
|
||||
|
||||
class CameraImage(ReadableMatrix):
|
||||
def read(self):
|
||||
raw = cam_raw_data.read()
|
||||
return Matrix(mono_to_bidi(raw, self.getHeight(), self.getWidth())).transpose().getData() #data is transposed
|
||||
#return mono_to_bidi(raw, self.getWidth(), self.getHeight())
|
||||
|
||||
def getWidth(self):
|
||||
return self._width
|
||||
|
||||
def getHeight(self):
|
||||
return self._height
|
||||
|
||||
cam_img = CameraImage()
|
||||
cam_img._width = len(profile_x.read())
|
||||
cam_img._height = len(profile_y.read())
|
||||
|
||||
|
||||
def ccr(mag):
|
||||
n = 1
|
||||
while n > 0:
|
||||
sleep(0.5)
|
||||
n = caget(mag + ":I-COMP")
|
||||
|
||||
def laser_on():
|
||||
caput("SIN-TIMAST-TMA:Beam-Las-Delay-Sel", 0)
|
||||
|
||||
def laser_off():
|
||||
caput("SIN-TIMAST-TMA:Beam-Las-Delay-Sel", 1)
|
||||
|
||||
|
||||
def run_pipeline():
|
||||
caput("camtool...:start")
|
||||
|
||||
while !caget("camtool...:done"):
|
||||
sleep(0.1)
|
||||
|
||||
caget("camtool....:data")
|
||||
#caget("camtool....:X_stats.com")
|
||||
#caget("camtool....:X_stats.com")
|
||||
|
||||
|
||||
|
||||
# Switch off magnets
|
||||
mag = [ "SINEG01-MCRX120","SINEG01-MCRY120",
|
||||
@@ -49,28 +98,40 @@ mag = [ "SINEG01-MCRX120","SINEG01-MCRY120",
|
||||
"SINEG01-MCRX220","SINEG01-MCRY220",
|
||||
"SINEG01-MQUA310",
|
||||
"SINEG01-MQUA320" ]
|
||||
for m in mag:
|
||||
caput(m + ":I-SET", 0.0)
|
||||
for m in mag:
|
||||
ccr(m)
|
||||
if zero_solenoids:
|
||||
for m in mag:
|
||||
caput(m + ":I-SET", 0.0)
|
||||
for m in mag:
|
||||
ccr(m)
|
||||
|
||||
# add here gun phase setting see wiki page
|
||||
|
||||
def br():
|
||||
pass
|
||||
def ar():
|
||||
pass
|
||||
|
||||
pass
|
||||
|
||||
r = None
|
||||
laser_on()
|
||||
try:
|
||||
r = lscan(gun_phase, [bpm_x, bpm_y], phi1, phi2, dphi, settling_time, before_read = br, after_read = ar)
|
||||
sensors = [cam_x, cam_y, cam_img] if plot_image else [cam_x, cam_y]
|
||||
r = lscan(gun_solenoid, sensors , I1, I2, dI, settling_time, before_read = br, after_read = ar)
|
||||
finally:
|
||||
laser_off()
|
||||
|
||||
# take the result of the scan and do the plots
|
||||
plot(r.getReadable(1), xdata=r.getReadable(0), title = "Centroid excursion")
|
||||
#add_convex_hull_plot ("Centroid excursion", r.getReadable(0),r.getReadable(1), "Name")
|
||||
# take the result of the scan and generate convex hull plot
|
||||
if centroid_excursion_plot:
|
||||
(hx,hy)=add_convex_hull_plot ("Centroid excursion", r.getReadable(0),r.getReadable(1), plot_name)
|
||||
else:
|
||||
(hx,hy)= convex_hull(x=r.getReadable(0), y=r.getReadable(1))
|
||||
hx.append(hx[0]); hy.append(hy[0])
|
||||
|
||||
# save the entry in the logbook
|
||||
msg = str(r)
|
||||
msg = msg + "\nFile: " + get_context().path
|
||||
msg = msg + "\n\n" + r.print()
|
||||
elog("Gun laser alignment", msg , get_plot_snapshots())
|
||||
if do_elog:
|
||||
msg = str(r)
|
||||
msg = msg + "\nFile: " + get_context().path
|
||||
msg = msg + "\n\n" + r.print()
|
||||
elog("Gun solenoid current scan", msg , get_plot_snapshots())
|
||||
|
||||
|
||||
set_return([r, hx,hy])
|
||||
|
||||
@@ -18,7 +18,7 @@ r = lscan(phi_set, [phi_get, amp_get, bpm_x], phi1, phi2, dphi, 0.5, before_read
|
||||
|
||||
plot(r.getReadable(2), xdata = r.getReadable(0), title = "Phase scan")
|
||||
|
||||
(amplitude, angular_frequency, phase, ok, maximum) = hfit(r.getReadable(2), xdata = r.getReadable(0))
|
||||
(amplitude, angular_frequency, phase, ok, maximum, fit_x, fit_y) = hfit(r.getReadable(2), xdata = r.getReadable(0))
|
||||
|
||||
caput(rsys + ":SET-ON-CREST-VSUM-PHASE", maximum)
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ try:
|
||||
#plot(r.getReadable(1), xdata = r.getPositions(0), title = "data")
|
||||
phase_fit_max = None
|
||||
try:
|
||||
(amplitude, angular_frequency, phase, phase_fit_max) = hfit(f , xdata = xdata)
|
||||
(amplitude, angular_frequency, phase, phase_fit_max, fit_x, fit_y) = hfit(f , xdata = xdata)
|
||||
except:
|
||||
raise Exception("Fit failure")
|
||||
|
||||
|
||||
@@ -85,11 +85,11 @@ def hfit(ydata, xdata = None):
|
||||
if start <=m <=end:
|
||||
print "fit = ", m
|
||||
p.addMarker(m, None, "Fit="+str(round(m ,2)), Color.MAGENTA.darker())
|
||||
return (amplitude, angular_frequency, phase, True, m)
|
||||
return (amplitude, angular_frequency, phase, True, m, fit_x, fit_y)
|
||||
else:
|
||||
print "max = ",max_x
|
||||
p.addMarker(max_x, None, "Max="+str(round(max_x ,2)), Color.MAGENTA.darker())
|
||||
return (amplitude, angular_frequency, phase, False, max_x)
|
||||
return (amplitude, angular_frequency, phase, False, max_x, fit_x, fit_y)
|
||||
|
||||
|
||||
def elog(title, message, attachments = [], author = None, category = "Info", domain = "", logbook = "SwissFEL commissioning data", encoding=1):
|
||||
|
||||
Reference in New Issue
Block a user