From 5ba82b7db77e3e8c1d4458b1daa258b6a724e8ab Mon Sep 17 00:00:00 2001 From: sfop Date: Mon, 6 Jun 2016 17:09:38 +0200 Subject: [PATCH] Closedown --- script/Alignment/Gun_solenoid_alignment_dv.py | 35 ++++----- .../Gun_solenoid_alignment_dv_sim.py | 53 ------------- script/Alignment/Laser_gun_alignment_dv.py | 54 +++++++------- script/Alignment/test_Simona.py | 52 ------------- script/test/test_Simona.py | 74 +++++++++---------- 5 files changed, 79 insertions(+), 189 deletions(-) delete mode 100644 script/Alignment/Gun_solenoid_alignment_dv_sim.py delete mode 100755 script/Alignment/test_Simona.py diff --git a/script/Alignment/Gun_solenoid_alignment_dv.py b/script/Alignment/Gun_solenoid_alignment_dv.py index d434448..632b83d 100644 --- a/script/Alignment/Gun_solenoid_alignment_dv.py +++ b/script/Alignment/Gun_solenoid_alignment_dv.py @@ -1,6 +1,6 @@ # Tool to align the solenoid on the gun. # S. Bettoni, A. Gobbo, D. Voulot -# 30/05/2016 +# 06/06/2016 # Procedure: @@ -19,24 +19,23 @@ def ccr(mag): while n > 0: sleep(0.5) n = caget(mag + ":I-COMP") - +def laser_on(): + caput("SIN-CVME-TIMAST-TMA:LaserDelayControl", 0) +def laser_off(): + caput("SIN-CVME-TIMAST-TMA:LaserDelayControl", 1) + I1 = 20.0 I2 = 150.0 dI = 1.0 # Switch off magnets -mag = [ "SINEG01-MCRX120", - "SINEG01-MCRY120", +mag = [ "SINEG01-MCRX120","SINEG01-MCRY120", "SINEG01-MQUA140", "SINEG01-MQUA150", - "SINEG01-MCRX160", - "SINEG01-MCRY160", - "SINEG01-MCRX180", - "SINEG01-MCRY180", - "SINEG01-MCRX200", - "SINEG01-MCRY200", - "SINEG01-MCRX220", - "SINEG01-MCRY220", + "SINEG01-MCRX160","SINEG01-MCRY160", + "SINEG01-MCRX180","SINEG01-MCRY180", + "SINEG01-MCRX200","SINEG01-MCRY200", + "SINEG01-MCRX220","SINEG01-MCRY220", "SINEG01-MQUA310", "SINEG01-MQUA320" ] for m in mag: @@ -44,21 +43,13 @@ for m in mag: for m in mag: ccr(m) -# Disable laser delay -caput("SIN-CVME-TIMAST-TMA:LaserDelayControl", 0) - # Scan using the screen #r = lscan(I_set, [I_read, cam_x, cam_y], I1, I2, dI, 1.0, passes = 2, zigzag = True) # Scan using the BPM -r = lscan(I_set, [I_read, bpm_x, bpm_y], I1, I2, dI, 1.0, passes = 2, zigzag = True) - -# Enable laser delay -caput("SIN-CVME-TIMAST-TMA:LaserDelayControl", 1) +r = lscan(I_set, [I_get, bpm_x, bpm_y], I1, I2, dI, 1.0, before_read = laser_on(), after_read = laser_off()) # take the result of the scan and do the plots -centroid_x = r.getReadable(1) -centroid_y = r.getReadable(2) -plot(centroid_y, xdata=centroid_x, title = "Centroid excursion") +plot(r.getReadable(2), xdata=r.getReadable(1), title = "Centroid excursion") # save the entry in the logbook msg = str(r) diff --git a/script/Alignment/Gun_solenoid_alignment_dv_sim.py b/script/Alignment/Gun_solenoid_alignment_dv_sim.py deleted file mode 100644 index 782529c..0000000 --- a/script/Alignment/Gun_solenoid_alignment_dv_sim.py +++ /dev/null @@ -1,53 +0,0 @@ -# Tool to align the solenoid on the gun. -# S. Bettoni, A. Gobbo, D. Voulot -# 30/05/2016 - - -# Procedure: - # switch off all the magnets between the gun solenoid and the screen or BPM used for the measurement - # change the current of the gun soleoid - # look at the centroid position (BPM or screen) downstream of the gun. - -I_set = Channel("SINEG01-MSOL130:I-SET") -I_read = Channel("SINEG01-MSOL130:I-READ") -# cam_x, cam_y = ... # some camtool command / channel? -bpm_x = ai1 # Channel("SINEG01-DBPM340:X1") -bpm_y = ai2 # Channel("SINEG01-DBPM340:Y1") - -def ccr(mag): - n = 1 - while n > 0: - sleep(0.5) - n = caget(mag + ":I-COMP") - -I1 = 2.0 -I2 = 5.0 -dI = 0.5 - -# Switch off magnets -mag = [ "SINEG01-MCRX120", - "SINEG01-MCRY120"] -for m in mag: - caput(m + ":I-SET", 0.0) -for m in mag: - ccr(m) - -# Disable laser delay -#caput("SIN-CVME-TIMAST-TMA:LaserDelayControl", 0) - -# Scan using the screen -#r = lscan(I_set, [I_read, cam_x, cam_y], I1, I2, dI, passes = 2, zigzag = True) -# Scan using the BPM -r = lscan(I_set, [I_read, bpm_x, bpm_y], I1, I2, dI, 1.0) - -# Enable laser delay -#caput("SIN-CVME-TIMAST-TMA:LaserDelayControl", 1) - -# take the result of the scan and do the plots -plot(r.getReadable(2), xdata=r.getReadable(1), title = "Centroid excursion") - -# save the entry in the logbook -msg = str(r) -msg = msg + "\nFile: " + get_context().path -msg = msg + "\n\n" + r.print() -elog("Gun solenoid current scan", msg , get_plot_snapshots()) diff --git a/script/Alignment/Laser_gun_alignment_dv.py b/script/Alignment/Laser_gun_alignment_dv.py index 9f0c7a3..96dbfb8 100644 --- a/script/Alignment/Laser_gun_alignment_dv.py +++ b/script/Alignment/Laser_gun_alignment_dv.py @@ -1,9 +1,6 @@ # Tool to align the laser on the cathode. # S. Bettoni, A. Gobbo, D. Voulot -# 30/05/2016 - -from operator import sub - +# 06/06/2016 # Procedure: # switch off all the magnets between the gun solenoid and the screen or BPM used for the measurement @@ -11,40 +8,47 @@ from operator import sub # look at the centroid position (BPM or screen) downstream of the gun. phi_set = Channel("SINEG01-RSYS:SET-BEAM-PHASE") -phi = Channel("SINEG01-RSYS:GET-BEAM-PHASE") -cam_x, cam_y = ... # some camtool command / channel? +phi_get = Channel("SINEG01-RSYS:GET-BEAM-PHASE") +# cam_x, cam_y = ... # some camtool command / channel? bpm_x = Channel("SINEG01-DBPM340:X1") bpm_y = Channel("SINEG01-DBPM340:Y1") +def ccr(mag): + n = 1 + while n > 0: + sleep(0.5) + n = caget(mag + ":I-COMP") +def laser_on(): + caput("SIN-CVME-TIMAST-TMA:LaserDelayControl", 0) +def laser_off(): + caput("SIN-CVME-TIMAST-TMA:LaserDelayControl", 1) + phi1 = 20.0 phi2 = 150.0 dphi = 1.0 # Switch off magnets -caput("SINEG01-MCRX120:I-SET", 0.0) -caput("SINEG01-MCRY120:I-SET", 0.0) -caput("SINEG01-MQUA140:I-SET", 0.0) -caput("SINEG01-MQUA150:I-SET", 0.0) -caput("SINEG01-MCRX160:I-SET", 0.0) -caput("SINEG01-MCRY160:I-SET", 0.0) -caput("SINEG01-MCRX180:I-SET", 0.0) -caput("SINEG01-MCRY180:I-SET", 0.0) - -# Disable laser delay -caput("SIN-CVME-TIMAST-TMA:LaserDelayControl", 0) +mag = [ "SINEG01-MCRX120","SINEG01-MCRY120", + "SINEG01-MQUA140", + "SINEG01-MQUA150", + "SINEG01-MCRX160","SINEG01-MCRY160", + "SINEG01-MCRX180","SINEG01-MCRY180", + "SINEG01-MCRX200","SINEG01-MCRY200", + "SINEG01-MCRX220","SINEG01-MCRY220", + "SINEG01-MQUA310", + "SINEG01-MQUA320" ] +for m in mag: + caput(m + ":I-SET", 0.0) +for m in mag: + ccr(m) # Scan using the screen -#r = lscan(phi_set, [phi, cam_x, cam_y], phi1, phi2, dphi, passes = 2, zigzag = True, before_read = CheckCurrent) +#r = lscan(phi_set, [phi_get, cam_x, cam_y], phi1, phi2, dphi, 0.5) # Scan using the BPM -r = lscan(phi_set, [phi, bpm_x, bpm_y], phi1, phi2, dphi, passes = 2, zigzag = True, before_read = CheckCurrent) - -# Enable laser delay -caput("SIN-CVME-TIMAST-TMA:LaserDelayControl", 1) +r = lscan(phi_set, [phi_get, bpm_x, bpm_y], phi1, phi2, dphi, 0.5, before_read = laser_on(), after_read = laser_off()) # take the result of the scan and do the plots -x = r.getReadable(1) -y = r.getReadable(2) -plot(y, xdata=x, title = "CM") +plot(r.getReadable(2), xdata=r.getReadable(1), title = "Centroid excursion") # save the entry in the logbook msg = str(r) diff --git a/script/Alignment/test_Simona.py b/script/Alignment/test_Simona.py deleted file mode 100755 index 780779a..0000000 --- a/script/Alignment/test_Simona.py +++ /dev/null @@ -1,52 +0,0 @@ - - - -import numpy as np -import matplotlib.pyplot as plt - -# example data -x = np.arange(0.5, 5.5, 0.5) -y = np.exp(-x) -xerr = 0.1 -yerr = 0.2 -ls = 'dotted' - -fig = plt.figure() -ax = fig.add_subplot(1, 1, 1) - -# standard error bars -plt.errorbar(x, y, xerr=xerr, yerr=yerr, ls=ls, color='blue') - -# including upper limits -uplims = np.zeros(x.shape) -uplims[[1, 5, 9]] = True -plt.errorbar(x, y + 0.5, xerr=xerr, yerr=yerr, uplims=uplims, ls=ls, - color='green') - -# including lower limits -lolims = np.zeros(x.shape) -lolims[[2, 4, 8]] = True -plt.errorbar(x, y + 1.0, xerr=xerr, yerr=yerr, lolims=lolims, ls=ls, - color='red') - -# including upper and lower limits -plt.errorbar(x, y + 1.5, marker='o', ms=8, xerr=xerr, yerr=yerr, - lolims=lolims, uplims=uplims, ls=ls, color='magenta') - -# including xlower and xupper limits -xerr = 0.2 -yerr = np.zeros(x.shape) + 0.2 -yerr[[3, 6]] = 0.3 -xlolims = lolims -xuplims = uplims -lolims = np.zeros(x.shape) -uplims = np.zeros(x.shape) -lolims[[6]] = True -uplims[[3]] = True -plt.errorbar(x, y + 2.1, marker='o', ms=8, xerr=xerr, yerr=yerr, - xlolims=xlolims, xuplims=xuplims, uplims=uplims, lolims=lolims, - ls='none', mec='blue', capsize=0, color='cyan') - -ax.set_xlim((0, 5.5)) -ax.set_title('Errorbar upper and lower limits') -plt.show() \ No newline at end of file diff --git a/script/test/test_Simona.py b/script/test/test_Simona.py index 1e8adaf..780779a 100755 --- a/script/test/test_Simona.py +++ b/script/test/test_Simona.py @@ -1,52 +1,52 @@ -#Simona test -#!/usr/bin/env python import numpy as np import matplotlib.pyplot as plt # example data -x = np.arange(0.1, 4, 0.5) +x = np.arange(0.5, 5.5, 0.5) y = np.exp(-x) +xerr = 0.1 +yerr = 0.2 +ls = 'dotted' -# example variable error bar values -yerr = 0.1 + 0.2*np.sqrt(x) -xerr = 0.1 + yerr +fig = plt.figure() +ax = fig.add_subplot(1, 1, 1) -# First illustrate basic pyplot interface, using defaults where possible. -plt.figure() -plt.errorbar(x, y, xerr=0.2, yerr=0.4) -plt.title("Simplest errorbars, 0.2 in x, 0.4 in y") +# standard error bars +plt.errorbar(x, y, xerr=xerr, yerr=yerr, ls=ls, color='blue') -# Now switch to a more OO interface to exercise more features. -fig, axs = plt.subplots(nrows=2, ncols=2, sharex=True) -ax = axs[0,0] -ax.errorbar(x, y, yerr=yerr, fmt='o') -ax.set_title('Vert. symmetric') +# including upper limits +uplims = np.zeros(x.shape) +uplims[[1, 5, 9]] = True +plt.errorbar(x, y + 0.5, xerr=xerr, yerr=yerr, uplims=uplims, ls=ls, + color='green') -# With 4 subplots, reduce the number of axis ticks to avoid crowding. -ax.locator_params(nbins=4) +# including lower limits +lolims = np.zeros(x.shape) +lolims[[2, 4, 8]] = True +plt.errorbar(x, y + 1.0, xerr=xerr, yerr=yerr, lolims=lolims, ls=ls, + color='red') -ax = axs[0,1] -ax.errorbar(x, y, xerr=xerr, fmt='o') -ax.set_title('Hor. symmetric') +# including upper and lower limits +plt.errorbar(x, y + 1.5, marker='o', ms=8, xerr=xerr, yerr=yerr, + lolims=lolims, uplims=uplims, ls=ls, color='magenta') -ax = axs[1,0] -ax.errorbar(x, y, yerr=[yerr, 2*yerr], xerr=[xerr, 2*xerr], fmt='--o') -ax.set_title('H, V asymmetric') - -ax = axs[1,1] -ax.set_yscale('log') -# Here we have to be careful to keep all y values positive: -ylower = np.maximum(1e-2, y - yerr) -yerr_lower = y - ylower - -ax.errorbar(x, y, yerr=[yerr_lower, 2*yerr], xerr=xerr, - fmt='o', ecolor='g', capthick=2) -ax.set_title('Mixed sym., log y') - -fig.suptitle('Variable errorbars') - -plt.show() +# including xlower and xupper limits +xerr = 0.2 +yerr = np.zeros(x.shape) + 0.2 +yerr[[3, 6]] = 0.3 +xlolims = lolims +xuplims = uplims +lolims = np.zeros(x.shape) +uplims = np.zeros(x.shape) +lolims[[6]] = True +uplims[[3]] = True +plt.errorbar(x, y + 2.1, marker='o', ms=8, xerr=xerr, yerr=yerr, + xlolims=xlolims, xuplims=xuplims, uplims=uplims, lolims=lolims, + ls='none', mec='blue', capsize=0, color='cyan') +ax.set_xlim((0, 5.5)) +ax.set_title('Errorbar upper and lower limits') +plt.show() \ No newline at end of file