Rotating Coild Data Analysis for BO QD Magnets

Import libraries and Load measurement data


In [1]:
import numpy as np
import matplotlib
matplotlib.use('Qt5Agg')

%matplotlib notebook

import matplotlib.pyplot as plt
from lnls.rotcoil import *

In [3]:
# Define serial numbers, one for each magnet

serials = [
    '001', '002', 
#     '003', # does not have measurements for ~32A!
    '004', '005', 
    '006', 
    '007', '008', '009', '010', 
    '011', '012', '013', '014', '015', '016', '017', '018', '019', 
    '020',
    '021', '022', '023', '024', '025', '026', '027',
]

# Load all data
data = MagnetsAnalysis(RotCoilMeas_BOQuadQD, serials)
data.init()

# Print info
data.print_info()


index: 00, serial_number: 001, data sets: ['M2', 'M1', 'M3']
index: 01, serial_number: 002, data sets: ['M2', 'M1', 'M3']
index: 02, serial_number: 004, data sets: ['M2', 'M1', 'M3']
index: 03, serial_number: 005, data sets: ['M2', 'M1', 'M3']
index: 04, serial_number: 006, data sets: ['M2', 'M1', 'M3']
index: 05, serial_number: 007, data sets: ['M2', 'M1', 'M3']
index: 06, serial_number: 008, data sets: ['M2', 'M1', 'M3']
index: 07, serial_number: 009, data sets: ['M2', 'M1', 'M3']
index: 08, serial_number: 010, data sets: ['M2', 'M1', 'M3']
index: 09, serial_number: 011, data sets: ['M2', 'M1', 'M3']
index: 10, serial_number: 012, data sets: ['M2', 'M1', 'M3']
index: 11, serial_number: 013, data sets: ['M2', 'M1', 'M3']
index: 12, serial_number: 014, data sets: ['M2', 'M1', 'M3']
index: 13, serial_number: 015, data sets: ['M2', 'M1', 'M3']
index: 14, serial_number: 016, data sets: ['M2', 'M1', 'M3']
index: 15, serial_number: 017, data sets: ['M2', 'M1', 'M3']
index: 16, serial_number: 018, data sets: ['M2', 'M1', 'M3']
index: 17, serial_number: 019, data sets: ['M2', 'M1', 'M3']
index: 18, serial_number: 020, data sets: ['M2', 'M1', 'M6', 'M4', 'M5', 'M3']
index: 19, serial_number: 021, data sets: ['M2', 'M1', 'M3']
index: 20, serial_number: 022, data sets: ['M2', 'M1', 'M3']
index: 21, serial_number: 023, data sets: ['M2', 'M1', 'M3']
index: 22, serial_number: 024, data sets: ['M2', 'M1', 'M3']
index: 23, serial_number: 025, data sets: ['M2', 'M1', 'M3']
index: 24, serial_number: 026, data sets: ['M2', 'M1', 'M3']
index: 25, serial_number: 027, data sets: ['M2', 'M1', 'M3']

Maximum Integrated Quadrupole


In [4]:
# gets integrated strength at maximum current for all magnets
data.main_intmpole_at_max_current('M1')


index:00, serial:001, idx:07, max_current:   +31.9731 [A], diff_spec: +0.77 [%]
index:01, serial:002, idx:07, max_current:   +31.9846 [A], diff_spec: +0.72 [%]
index:02, serial:004, idx:07, max_current:   +31.9719 [A], diff_spec: +0.70 [%]
index:03, serial:005, idx:07, max_current:   +31.9695 [A], diff_spec: +0.69 [%]
index:04, serial:006, idx:07, max_current:   +31.9788 [A], diff_spec: +1.08 [%]
index:05, serial:007, idx:07, max_current:   +31.9662 [A], diff_spec: +0.86 [%]
index:06, serial:008, idx:07, max_current:   +31.9696 [A], diff_spec: +0.86 [%]
index:07, serial:009, idx:07, max_current:   +31.9691 [A], diff_spec: +0.80 [%]
index:08, serial:010, idx:07, max_current:   +31.9641 [A], diff_spec: +0.83 [%]
index:09, serial:011, idx:07, max_current:   +31.9606 [A], diff_spec: +0.73 [%]
index:10, serial:012, idx:07, max_current:   +31.9734 [A], diff_spec: +0.72 [%]
index:11, serial:013, idx:07, max_current:   +31.9668 [A], diff_spec: +0.80 [%]
index:12, serial:014, idx:07, max_current:   +31.9689 [A], diff_spec: +0.76 [%]
index:13, serial:015, idx:07, max_current:   +31.9633 [A], diff_spec: +0.81 [%]
index:14, serial:016, idx:07, max_current:   +31.9641 [A], diff_spec: +0.77 [%]
index:15, serial:017, idx:07, max_current:   +31.9648 [A], diff_spec: +0.83 [%]
index:16, serial:018, idx:07, max_current:   +31.9602 [A], diff_spec: +0.91 [%]
index:17, serial:019, idx:07, max_current:   +31.9662 [A], diff_spec: +0.87 [%]
index:18, serial:020, idx:07, max_current:   +32.0024 [A], diff_spec: +1.02 [%]
index:19, serial:021, idx:07, max_current:   +31.9651 [A], diff_spec: +0.82 [%]
index:20, serial:022, idx:07, max_current:   +31.9660 [A], diff_spec: +0.83 [%]
index:21, serial:023, idx:07, max_current:   +31.9692 [A], diff_spec: +0.73 [%]
index:22, serial:024, idx:07, max_current:   +31.9677 [A], diff_spec: +0.91 [%]
index:23, serial:025, idx:07, max_current:   +31.9815 [A], diff_spec: +0.74 [%]
index:24, serial:026, idx:07, max_current:   +31.9914 [A], diff_spec: +0.90 [%]
index:25, serial:027, idx:07, max_current:   +31.9899 [A], diff_spec: +0.85 [%]

In [4]:
# plot data comparison with spec
data.main_intmpole_at_max_current_plot(plt)
plt.show()


Magnetic Center


In [5]:
# Horizontal center for all magnets x currents
plt.figure()
data.magnetic_center_direction_plot('M1', 'X', plt)
plt.show()

# each magnet is represented by two curves: one rampup and one rampdown


Horizontal center at maximum current [um]: +13.41 ± 13.03

In [6]:
# Vertical center for all magnets y currents
plt.figure()
data.magnetic_center_direction_plot('M1', 'Y', plt)
plt.show()

# each magnet is represented by two curves: one rampup and one rampdown


Vertical center at maximum current [um]: +41.62 ± 12.14

In [7]:
# Horizontal and vertical positions of all magnets
plt.figure()
data.magnetic_center_plot('M1', plt)
# data.magnetic_center_plot('M3', plt)
plt.show()



In [8]:
# Transverse plane positions
plt.figure()
data.magnetic_center_transverse_plot('M1', plt)
plt.show()


Ramp Up


In [9]:
# Plot rampup integrated strength of main multipole and compare it to nominal values and maximum spec
plt.figure()
data.rampup_excitation_curve_plot('M1', plt)
plt.show()


Nominal Integrated Quadrupole [T]:
BO-Fam:MA-QD    : -0.011206

In [10]:
# Plot rampup dispersion amongst magnets
plt.figure()
data.rampup_excitation_curve_dispersion_plot('M1', plt)
plt.show()



In [5]:
# Print random integrated main strength for various currents
data.rampup_excitation_curve_rms_error_print('M1')


current:   -0.032 [A], rms_error: 19.2906 [%], max_error: 87.9191 [%]
current:   +1.966 [A], rms_error:  1.4974 [%], max_error:  6.6978 [%]
current:   +3.966 [A], rms_error:  0.7045 [%], max_error:  3.0908 [%]
current:   +5.965 [A], rms_error:  0.4255 [%], max_error:  1.7899 [%]
current:   +7.965 [A], rms_error:  0.2845 [%], max_error:  1.1105 [%]
current:   +9.964 [A], rms_error:  0.2059 [%], max_error:  0.7365 [%]
current:  +19.966 [A], rms_error:  0.0918 [%], max_error:  0.3161 [%]
current:  +31.972 [A], rms_error:  0.0920 [%], max_error:  0.2614 [%]

In [6]:
# Plot Integrated Quadrupole Error for maximum current
plt.figure()
data.rampup_excitation_curve_rms_error_plot(plt)
plt.show()


Hysteresis


In [13]:
# Absolute
plt.figure()
data.hysteresis_absolute_plot('M1', plt)
plt.show()



In [14]:
# Relative
plt.figure()
data.hysteresis_relative_plot('M1', plt)
plt.show()


Save Excitation Data Files


In [17]:
# save average excitation data to file

data.save_excdata_average('M1')

In [4]:
# save excitation data of all magnets to separate files
data.save_excdata_individuals('M1')

Multipoles


In [7]:
# Horizontal kick

plt.figure()
data.multipole_errors_kickx_plot('M1', plt)
plt.show()



In [8]:
# Vertical kick

# BD-021: big skew error!
plt.figure()
data.multipole_errors_kicky_plot('M2', plt)
plt.show()


Magnets Sorting


In [5]:
med = 'M1'
print('Rampup')
c, gl = data.tmpl.get_rampup(med)
for i in range(len(c)):
    print('{:02d}: I = {:8.4f} A => GL = {:+.4f} T'.format(i, c[i], gl[i]))


Rampup
00: I =  -0.0284 A => GL = -0.0029 T
01: I =   1.9701 A => GL = -0.0351 T
02: I =   3.9682 A => GL = -0.0676 T
03: I =   5.9670 A => GL = -0.1002 T
04: I =   7.9674 A => GL = -0.1330 T
05: I =   9.9666 A => GL = -0.1659 T
06: I =  19.9674 A => GL = -0.3310 T
07: I =  31.9731 A => GL = -0.5294 T

In [7]:
cidx = 1
print('Booster QD Quadrupoles Magnetic Center and Integrated Quadrupole')
print(80*'='+'\n')
print('As measured with rotcoil for I = {0:3.0f}A (nominal GL @ 3 GeV is ~2A)\n'.format(c[cidx]))
print('{0:7s} |{1:^29s} |{2:^29s} |{3:^29s} |'.format('Magnet', 'M1', 'M2', 'M3'))
print('{0:7s} |'.format(''), end='')
st = '{:>8s} {:>8s} {:>10s} |'.format('x0 [mm]', 'y0 [mm]', 'GL/I [T/mA]')
print(3*st)
for s in data:
    print('BQD-{} |'.format(s), end='')
    for med in ['M1', 'M2', 'M3']:
        x = data[s].get_magnetic_center_x(med)[cidx]
        y = data[s].get_magnetic_center_y(med)[cidx]
        c, gl = data[s].get_rampup(med)
        print('{:+8.1f} {:+8.1f} {:+10.4f}  |'.format(x, y, 1000*gl[cidx]/c[cidx]), end='')
    print()


Booster QD Quadrupoles Magnetic Center and Integrated Quadrupole
================================================================================

As measured with rotcoil for I =   2A (nominal GL @ 3 GeV is ~2A)

Magnet  |             M1               |             M2               |             M3               |
        | x0 [mm]  y0 [mm] GL/I [T/mA] | x0 [mm]  y0 [mm] GL/I [T/mA] | x0 [mm]  y0 [mm] GL/I [T/mA] |
BQD-001 |  +209.9   +117.4   -17.8269  |  +236.8   +122.3   -17.8060  |  +236.9   +125.6   -17.8003  |
BQD-002 |  +240.9   +115.7   -17.7620  |  +238.6   +106.4   -17.7674  |  +237.8   +108.6   -17.7623  |
BQD-004 |  +214.8    +89.8   -17.8347  |  +220.1    +86.3   -17.8148  |  +215.6    +84.1   -17.8029  |
BQD-005 |  +225.4   +141.5   -17.8943  |  +227.3   +161.5   -17.9305  |  +228.1   +148.0   -17.9174  |
BQD-006 |  +172.1   +202.3   -18.3250  |  +180.1   +197.7   -18.2627  |  +177.1   +204.1   -18.2240  |
BQD-007 |  +235.8   +101.6   -17.9279  |  +229.7    +93.1   -17.8620  |  +226.1    +84.5   -17.9033  |
BQD-008 |  +244.2   +135.9   -17.9560  |  +239.9   +136.0   -17.9318  |  +235.9   +132.3   -17.9123  |
BQD-009 |  +223.3   +110.9   -17.8780  |  +232.5   +122.7   -17.8606  |  +245.3   +125.1   -17.8414  |
BQD-010 |  +211.3   +120.4   -17.9354  |  +211.9   +116.3   -17.9320  |  +213.5   +131.5   -17.9319  |
BQD-011 |  +201.6   +102.2   -17.9008  |  +191.6    +95.4   -17.8807  |  +199.2    +81.3   -17.8666  |
BQD-012 |  +243.6   +134.4   -17.9068  |  +241.4   +157.0   -17.9058  |  +246.7   +152.9   -17.8991  |
BQD-013 |  +216.8   +131.2   -17.9383  |  +216.1   +129.9   -17.9557  |  +224.2   +118.1   -17.9467  |
BQD-014 |  +235.7   +166.9   -17.9485  |  +234.7   +176.5   -17.9279  |  +234.2   +172.7   -17.9081  |
BQD-015 |  +233.8   +148.1   -17.9438  |  +223.5   +136.8   -17.9258  |  +221.8   +162.2   -17.9194  |
BQD-016 |  +209.5   +120.0   -17.9595  |  +205.2   +120.7   -17.9549  |  +208.3   +114.9   -17.9391  |
BQD-017 |  +207.1   +120.1   -17.9093  |  +202.8   +125.8   -17.9611  |  +202.8   +146.2   -17.9657  |
BQD-018 |  +227.9   +108.4   -17.9757  |  +226.7   +137.7   -17.9740  |  +221.5   +145.9   -17.9360  |
BQD-019 |  +208.1   +123.6   -17.9058  |  +205.0   +122.8   -17.9163  |  +210.5   +124.9   -17.9097  |
BQD-020 |  +239.1   +149.5   -16.3315  |  +264.2   +138.2   -16.3114  |  +218.7   +102.5   -17.6134  |
BQD-021 |  +218.2   +127.0   -17.8855  |  +218.2   +124.8   -17.8962  |  +225.1   +114.4   -17.8865  |
BQD-022 |  +203.8    +89.4   -17.9396  |  +206.3   +100.1   -17.9208  |  +205.8    +99.8   -17.9128  |
BQD-023 |  +206.8   +132.7   -17.8798  |  +209.6   +115.6   -17.8586  |  +207.0   +109.6   -17.8727  |
BQD-024 |  +205.2   +154.3   -17.9780  |  +204.6   +162.8   -17.9472  |  +208.2   +167.7   -17.9581  |
BQD-025 |  +171.4   +164.8   -17.7785  |  +176.1   +181.7   -17.7996  |  +175.9   +156.7   -17.7730  |
BQD-026 |  +204.6   +111.8   -17.8806  |  +209.2   +132.9   -17.8608  |  +218.8   +119.8   -17.8692  |
BQD-027 |  +244.7   +113.3   -17.8535  |  +223.2   +117.0   -17.8208  |  +221.9   +109.8   -17.8063  |

In [8]:
cidx = 2
print('Booster QD Quadrupoles Magnetic Center and Integrated Quadrupole')
print(80*'='+'\n')
print('As measured with rotcoil for I = {0:3.0f}A (nominal GL @ 3 GeV is ~2A)\n'.format(c[cidx]))
print('{0:7s} |{1:^29s} |{2:^29s} |{3:^29s} |'.format('Magnet', 'M1', 'M2', 'M3'))
print('{0:7s} |'.format(''), end='')
st = '{:>8s} {:>8s} {:>10s} |'.format('x0 [mm]', 'y0 [mm]', 'GL/I [T/mA]')
print(3*st)
for s in data:
    print('BQD-{} |'.format(s), end='')
    for med in ['M1', 'M2', 'M3']:
        x = data[s].get_magnetic_center_x(med)[cidx]
        y = data[s].get_magnetic_center_y(med)[cidx]
        c, gl = data[s].get_rampup(med)
        print('{:+8.1f} {:+8.1f} {:+10.4f}  |'.format(x, y, 1000*gl[cidx]/c[cidx]), end='')
    print()


Booster QD Quadrupoles Magnetic Center and Integrated Quadrupole
================================================================================

As measured with rotcoil for I =   4A (nominal GL @ 3 GeV is ~2A)

Magnet  |             M1               |             M2               |             M3               |
        | x0 [mm]  y0 [mm] GL/I [T/mA] | x0 [mm]  y0 [mm] GL/I [T/mA] | x0 [mm]  y0 [mm] GL/I [T/mA] |
BQD-001 |  +116.7    +70.5   -17.0256  |  +114.8    +73.5   -17.0142  |  +117.3    +72.1   -17.0142  |
BQD-002 |  +121.0    +74.1   -16.9863  |  +119.8    +73.9   -16.9923  |  +117.5    +70.2   -16.9920  |
BQD-004 |  +109.2    +51.4   -17.0189  |  +108.7    +48.1   -17.0086  |  +109.9    +42.3   -17.0072  |
BQD-005 |  +116.0   +106.4   -17.0397  |  +116.9   +104.1   -17.0595  |  +116.0   +101.7   -17.0520  |
BQD-006 |   +86.1   +106.3   -17.2633  |   +88.0   +101.0   -17.2338  |   +87.4    +93.4   -17.2174  |
BQD-007 |  +123.1    +76.8   -17.0735  |  +119.3    +70.6   -17.0509  |  +118.1    +72.5   -17.0625  |
BQD-008 |  +137.7    +94.3   -17.0830  |  +136.7    +82.4   -17.0767  |  +132.5    +78.9   -17.0709  |
BQD-009 |  +110.2    +72.0   -17.0459  |  +113.2    +75.0   -17.0405  |  +120.3    +74.1   -17.0285  |
BQD-010 |   +99.4    +76.4   -17.0735  |  +100.2    +82.7   -17.0723  |  +100.7    +83.6   -17.0713  |
BQD-011 |  +100.4    +73.5   -17.0519  |   +97.1    +72.7   -17.0431  |   +99.6    +79.1   -17.0356  |
BQD-012 |  +136.9   +101.1   -17.0476  |  +133.4   +110.9   -17.0479  |  +137.6   +106.6   -17.0356  |
BQD-013 |  +115.5    +86.0   -17.0679  |  +113.0    +83.3   -17.0770  |  +116.8    +79.9   -17.0667  |
BQD-014 |  +127.1   +107.0   -17.0699  |  +129.2   +117.3   -17.0542  |  +126.5   +117.1   -17.0576  |
BQD-015 |  +127.7    +94.5   -17.0755  |  +123.3    +90.0   -17.0719  |  +122.4   +101.4   -17.0664  |
BQD-016 |  +113.6    +65.5   -17.0809  |  +113.8    +66.6   -17.0718  |  +113.6    +73.8   -17.0674  |
BQD-017 |  +107.2    +84.4   -17.0912  |  +109.9    +84.1   -17.0751  |  +110.1    +76.4   -17.0796  |
BQD-018 |  +125.0    +96.5   -17.1005  |  +123.5    +86.4   -17.0994  |  +118.3    +91.9   -17.0875  |
BQD-019 |  +113.6    +77.9   -17.0634  |  +113.6    +84.9   -17.0685  |  +115.4    +82.9   -17.0669  |
BQD-020 |  +113.0    +84.3   -16.3477  |  +124.8    +89.3   -16.3346  |  +107.0    +68.6   -16.9392  |
BQD-021 |  +114.2    +71.8   -17.0577  |  +110.2    +85.7   -17.0471  |  +115.3    +78.7   -17.0528  |
BQD-022 |  +103.2    +63.7   -17.0697  |  +104.0    +63.6   -17.0639  |  +105.3    +62.0   -17.0632  |
BQD-023 |  +110.6    +89.9   -17.0405  |  +111.4    +89.4   -17.0339  |  +109.6    +84.9   -17.0389  |
BQD-024 |  +104.6    +89.7   -17.0979  |  +107.4    +94.3   -17.0847  |  +108.4    +92.7   -17.0817  |
BQD-025 |   +77.7   +108.8   -16.9887  |   +78.9   +107.1   -17.0216  |   +81.9   +101.7   -16.9664  |
BQD-026 |  +115.1    +81.2   -17.0581  |  +117.4    +81.7   -17.0298  |  +121.9    +84.9   -17.0508  |
BQD-027 |  +138.7    +79.4   -17.0012  |  +125.0    +81.5   -17.0266  |  +125.8    +84.6   -17.0312  |

In [24]:
cidx = 2
med = 'M2'
current_avg = np.zeros(len(data))
current_std = np.zeros(len(data))
gl = np.zeros(len(data))
for i, s in enumerate(data):
    current_avg[i] = data[s].get_currents_avg(med)[cidx]
    current_std[i] = data[s].get_currents_std(med)[cidx]
    gl[i] = data[s].get_intmpole_normal_avg(med, data[s].main_harmonic)[cidx]
    
plt.figure()
plt.plot(current_avg/current_avg.mean()-1, label='I_avg')
plt.plot(gl/gl.mean()-1, label='GL_avg')
plt.plot(current_std, label='I_std')
plt.legend(loc='best')
plt.grid(True)
plt.show()



In [25]:
cidx = 2
med = 'M3'
current_avg = np.zeros(len(data))
current_std = np.zeros(len(data))
gl = np.zeros(len(data))
for i, s in enumerate(data):
    current_avg[i] = data[s].get_currents_avg(med)[cidx]
    current_std[i] = data[s].get_currents_std(med)[cidx]
    gl[i] = data[s].get_intmpole_normal_avg(med, data[s].main_harmonic)[cidx]
    
plt.figure()
plt.plot(current_avg/current_avg.mean()-1, label='I_avg')
plt.plot(gl/gl.mean()-1, label='GL_avg')
plt.plot(current_std, label='I_std')
plt.legend(loc='best')
plt.grid(True)
plt.show()



In [26]:
cidx = 2
med = 'M1'
current_avg = np.zeros(len(data))
current_std = np.zeros(len(data))
gl = np.zeros(len(data))
for i, s in enumerate(data):
    current_avg[i] = data[s].get_currents_avg(med)[cidx]
    current_std[i] = data[s].get_currents_std(med)[cidx]
    gl[i] = data[s].get_intmpole_normal_avg(med, data[s].main_harmonic)[cidx]
    
plt.figure()
plt.plot(current_avg/current_avg.mean()-1, label='I_avg')
plt.plot(gl/gl.mean()-1, label='GL_avg')
plt.plot(current_std, label='I_std')
plt.legend(loc='best')
plt.grid(True)
plt.show()