From 68eac9486e22fa8f75d551fa96c12fd9fbe231a7 Mon Sep 17 00:00:00 2001 From: PONS Date: Thu, 22 Jan 2026 12:22:42 +0100 Subject: [PATCH 1/3] Added chroma measurement --- examples/BESSY2_example/BESSY2Chroma.yaml | 41 +++++++++++++++++++++++ examples/BESSY2_example/bessy2-chroma.py | 11 ++++++ 2 files changed, 52 insertions(+) create mode 100644 examples/BESSY2_example/BESSY2Chroma.yaml create mode 100644 examples/BESSY2_example/bessy2-chroma.py diff --git a/examples/BESSY2_example/BESSY2Chroma.yaml b/examples/BESSY2_example/BESSY2Chroma.yaml new file mode 100644 index 00000000..b635d5d8 --- /dev/null +++ b/examples/BESSY2_example/BESSY2Chroma.yaml @@ -0,0 +1,41 @@ +type: pyaml.accelerator +facility: BESSY2 +machine: sr +energy: 1.7e9 +simulators: +- type: pyaml.lattice.simulator + lattice: bessy2.mat + name: design +controls: +- type: pyaml_cs_oa.controlsystem + prefix: 'pons:' + name: live +data_folder: /data/store +devices: +- type: pyaml.diagnostics.tune_monitor + name: BETATRON_TUNE + tune_h: + type: pyaml_cs_oa.epicsR + read_pvname: beam:twiss:x:tune + unit: '' + tune_v: + type: pyaml_cs_oa.epicsR + read_pvname: beam:twiss:y:tune + unit: '' +- type: pyaml.diagnostics.chromaticity_monitor + name: KSI + betatron_tune: BETATRON_TUNE + RFfreq: RF + fit_order: 1 + N_tune_meas: 1 + N_step: 5 + Sleep_between_meas: 0 + Sleep_between_RFvar: 2 + E_delta: 1e-3 + Max_E_delta: 1e-3 +- type: pyaml.rf.rf_plant + name: RF + masterclock: + type: pyaml_cs_oa.epicsW + write_pvname: MCLKHX251C:freq + unit: KHz diff --git a/examples/BESSY2_example/bessy2-chroma.py b/examples/BESSY2_example/bessy2-chroma.py new file mode 100644 index 00000000..5def2e7b --- /dev/null +++ b/examples/BESSY2_example/bessy2-chroma.py @@ -0,0 +1,11 @@ +from pyaml.accelerator import Accelerator + +sr = Accelerator.load("BESSY2Chroma.yaml") +sr.design.get_lattice().disable_6d() +# Retreive MCF from the model +alphac = sr.design.get_lattice().get_mcf() +print(f"Moment compaction factor: {alphac}") +chromaticity_monitor = sr.live.get_chromaticity_monitor("KSI") +chromaticity_monitor.chromaticity_measurement(do_plot=True, alphac=alphac) +ksi = chromaticity_monitor.chromaticity.get() +print(ksi) From 6310c81453f091c2b339fca387b4f6dc94e9a854 Mon Sep 17 00:00:00 2001 From: PONS Date: Thu, 22 Jan 2026 16:19:44 +0100 Subject: [PATCH 2/3] Fix typo in plot --- pyaml/diagnostics/chromaticity_monitor.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyaml/diagnostics/chromaticity_monitor.py b/pyaml/diagnostics/chromaticity_monitor.py index 195148e9..fd6269bf 100644 --- a/pyaml/diagnostics/chromaticity_monitor.py +++ b/pyaml/diagnostics/chromaticity_monitor.py @@ -283,7 +283,7 @@ def fit_chromaticity(self, delta, NuX, NuY, order, do_plot): if o == 1: dp = "dp/p" elif o >= 1: - dp = "(dp/p)$^2$" + dp = f"(dp/p)$^{o}$" title += f"{coefs[o]:.4f} {dp}" if o != 0: @@ -294,7 +294,7 @@ def fit_chromaticity(self, delta, NuX, NuY, order, do_plot): ax.set_title(title) ax.set_xlabel("Momentum Shift, dp/p [%]") ax.set_ylabel("%s Tune" % ["Horizontal", "Vertical"][i]) - ax.legend() + # ax.legend() if do_plot: fig.tight_layout() From 841f7804d2641afd7442bcca1708d06947a1dc47 Mon Sep 17 00:00:00 2001 From: PONS Date: Thu, 22 Jan 2026 16:22:27 +0100 Subject: [PATCH 3/3] Fix typo in plot --- pyaml/diagnostics/chromaticity_monitor.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pyaml/diagnostics/chromaticity_monitor.py b/pyaml/diagnostics/chromaticity_monitor.py index fd6269bf..e9f79d7f 100644 --- a/pyaml/diagnostics/chromaticity_monitor.py +++ b/pyaml/diagnostics/chromaticity_monitor.py @@ -289,7 +289,6 @@ def fit_chromaticity(self, delta, NuX, NuY, order, do_plot): if o != 0: title += " + " - print(title) ax.plot(delta, np.polyval(coefs[::-1], delta)) ax.set_title(title) ax.set_xlabel("Momentum Shift, dp/p [%]")