|
24 | 24 | vcorr = ebs.get_magnets("VCorr") |
25 | 25 | bpms = ebs.get_bpms("BPM") |
26 | 26 |
|
| 27 | +x0, y0 = bpms.positions.get().T |
| 28 | +reference = np.concat([x0, y0]) |
| 29 | + |
27 | 30 | # mangle orbit |
28 | 31 | hcorr.strengths.set( |
29 | 32 | hcorr.strengths.get() + std_kick * np.random.normal(size=len(hcorr)) |
|
41 | 44 |
|
42 | 45 | response_matrix = ResponseMatrix.from_json(parent_folder / Path("ideal_orm.json")) |
43 | 46 | interface = pySCInterface(element_holder=ebs) |
44 | | -trims = orbit_correction( |
45 | | - interface=interface, |
46 | | - response_matrix=response_matrix, |
47 | | - method="svd_cutoff", |
48 | | - parameter=1e-3, |
49 | | - zerosum=True, |
50 | | - apply=True, |
51 | | -) |
| 47 | + |
| 48 | +response_matrix.disable_inputs(["SH3E-C03-V"]) |
| 49 | + |
| 50 | +for _ in range(5): |
| 51 | + trims = orbit_correction( |
| 52 | + interface=interface, |
| 53 | + response_matrix=response_matrix, |
| 54 | + method="svd_values", |
| 55 | + parameter=100, |
| 56 | + zerosum=True, |
| 57 | + apply=True, |
| 58 | + plane="H", |
| 59 | + reference=reference, |
| 60 | + ) |
| 61 | + trims = orbit_correction( |
| 62 | + interface=interface, |
| 63 | + response_matrix=response_matrix, |
| 64 | + method="svd_values", |
| 65 | + parameter=100, |
| 66 | + zerosum=False, |
| 67 | + apply=True, |
| 68 | + plane="V", |
| 69 | + reference=reference, |
| 70 | + ) |
| 71 | + |
| 72 | +print("SH3E-C03-V" in trims.keys()) |
| 73 | +print("H std ", np.std(hcorr.strengths.get())) |
| 74 | +print("V std ", np.std(vcorr.strengths.get())) |
52 | 75 |
|
53 | 76 | positions_ac = bpms.positions.get() |
54 | 77 | std_ac = np.std(positions_ac, axis=0) |
|
57 | 80 | f"{1e6 * std_ac[0]: .1f} µm, V: {1e6 * std_ac[1]: .1f} µm," |
58 | 81 | ) |
59 | 82 |
|
60 | | - |
61 | 83 | fig = plt.figure() |
62 | | -ax1 = fig.add_subplot(211) |
63 | | -ax2 = fig.add_subplot(212) |
| 84 | +ax1 = fig.add_subplot(311) |
| 85 | +ax2 = fig.add_subplot(312) |
| 86 | +ax3 = fig.add_subplot(313) |
64 | 87 | ax1.plot(positions_bc[:, 0] * 1e6, label="Orbit before correction") |
65 | 88 | ax2.plot(positions_bc[:, 1] * 1e6, label="Orbit before correction") |
66 | 89 | ax1.plot(positions_ac[:, 0] * 1e6, label="Orbit after correction") |
67 | 90 | ax2.plot(positions_ac[:, 1] * 1e6, label="Orbit after correction") |
68 | 91 |
|
| 92 | +ax3.plot(hcorr.strengths.get()) |
| 93 | +ax3.plot(vcorr.strengths.get()) |
| 94 | + |
69 | 95 | ax1.set_ylabel("Horizontal pos. [μm]") |
70 | 96 | ax2.set_ylabel("Vertical pos. [μm]") |
71 | 97 | ax2.set_xlabel("BPM number") |
| 98 | +ax3.set_ylabel("Strength (rad)") |
| 99 | +ax3.set_xlabel("Steerer number") |
| 100 | +fig.tight_layout() |
| 101 | + |
72 | 102 | plt.show() |
0 commit comments