Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions examples/BESSY2_example/BESSY2Chroma.yaml
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions examples/BESSY2_example/bessy2-chroma.py
Original file line number Diff line number Diff line change
@@ -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)
5 changes: 2 additions & 3 deletions pyaml/diagnostics/chromaticity_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Loading