Skip to content

Commit 2f0fede

Browse files
committed
Correction per plane
1 parent 4010cd1 commit 2f0fede

File tree

2 files changed

+42
-12
lines changed

2 files changed

+42
-12
lines changed

examples/ESRF_ORM_example/correct_orbit.py

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
vcorr = ebs.get_magnets("VCorr")
2525
bpms = ebs.get_bpms("BPM")
2626

27+
x0, y0 = bpms.positions.get().T
28+
reference = np.concat([x0, y0])
29+
2730
# mangle orbit
2831
hcorr.strengths.set(
2932
hcorr.strengths.get() + std_kick * np.random.normal(size=len(hcorr))
@@ -41,14 +44,34 @@
4144

4245
response_matrix = ResponseMatrix.from_json(parent_folder / Path("ideal_orm.json"))
4346
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()))
5275

5376
positions_ac = bpms.positions.get()
5477
std_ac = np.std(positions_ac, axis=0)
@@ -57,16 +80,23 @@
5780
f"{1e6 * std_ac[0]: .1f} µm, V: {1e6 * std_ac[1]: .1f} µm,"
5881
)
5982

60-
6183
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)
6487
ax1.plot(positions_bc[:, 0] * 1e6, label="Orbit before correction")
6588
ax2.plot(positions_bc[:, 1] * 1e6, label="Orbit before correction")
6689
ax1.plot(positions_ac[:, 0] * 1e6, label="Orbit after correction")
6790
ax2.plot(positions_ac[:, 1] * 1e6, label="Orbit after correction")
6891

92+
ax3.plot(hcorr.strengths.get())
93+
ax3.plot(vcorr.strengths.get())
94+
6995
ax1.set_ylabel("Horizontal pos. [μm]")
7096
ax2.set_ylabel("Vertical pos. [μm]")
7197
ax2.set_xlabel("BPM number")
98+
ax3.set_ylabel("Strength (rad)")
99+
ax3.set_xlabel("Steerer number")
100+
fig.tight_layout()
101+
72102
plt.show()

0 commit comments

Comments
 (0)