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) diff --git a/pyaml/diagnostics/chromaticity_monitor.py b/pyaml/diagnostics/chromaticity_monitor.py index 195148e9..e9f79d7f 100644 --- a/pyaml/diagnostics/chromaticity_monitor.py +++ b/pyaml/diagnostics/chromaticity_monitor.py @@ -283,18 +283,17 @@ 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: title += " + " - print(title) ax.plot(delta, np.polyval(coefs[::-1], delta)) 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()