accelmo.backend.madng.interface¶
The MAD-NG session of accelmo: MadInterface.
Loads the sequence and beam, observes and thins the BPMs, applies the machine state and,
with create_knobs=True, creates the fit knobs selected by the accelerator.
- accelmo.backend.madng.interface.indexed_multipole_attr_info(attr)[source]¶
Return multipole metadata for indexed MAD attrs such as
knl[3]orksl[3].- Return type:
Optional[MultipoleInfo]- Parameters:
attr (str)
- accelmo.backend.madng.interface.read_b2_error_table(path)[source]¶
Read an OMC3-style
.errorstable as an element-name to K1L mapping.- Return type:
dict[str,float]- Parameters:
path (Path | str)
- accelmo.backend.madng.interface.apply_b2_errors_to_sequence(mad, py_name, b2_errors, machine_state)[source]¶
Route a b2 dipole error table into the loaded sequence’s dknl[2] slots.
Works on any MAD interface whose sequence is bound to the
loaded_sequenceglobal (the reconstructionACDipoleMadDriverand the optimisationMadInterfaceboth qualify). The b2 K1L is added to the quadrupole perturbation slot (dknl[2]), leaving the dipole slot dknl[1] untouched. b2 errors shift the machine tunes, so a machine state holding the tune knobs is required to restore them.- Return type:
None- Parameters:
py_name (str)
b2_errors (Path | None)
machine_state (MachineState | None)
- class accelmo.backend.madng.interface.MadInterface(accelerator, *, magnet_range='$start/$end', bpm_range=None, bad_bpms=None, machine_state=None, b2_errors=None, create_knobs=False, initial_model_values=None, py_name='py', debug=False, mad_logfile=None, discard_mad_output=False, tracking_anchor_mode=None, tracking_anchor_markers=None, observe_anchor_markers=True)[source]¶
Bases:
KnobMadInterfaceMAD-NG session: sequence, beam, observed thin BPMs, machine state and (optionally) fit knobs.
create_knobs=Truecreates the knobs selected by the accelerator’serrorsandmisalignments(accelerator hooks inaccelmo.backend.madng.accelerator_hooks) and then appliesinitial_model_values.- Parameters:
accelerator (Accelerator)
magnet_range (str)
bpm_range (str | None)
bad_bpms (list[str] | None)
machine_state (MachineState | None)
b2_errors (Path | None)
create_knobs (bool)
initial_model_values (dict[str, float] | None)
py_name (str)
debug (bool)
mad_logfile (Path | None)
discard_mad_output (bool)
tracking_anchor_mode (str | None)
tracking_anchor_markers (list[str] | None)
observe_anchor_markers (bool)
- accelerator: Accelerator¶
- observe_bpms(bpm_pattern=None, bad_bpms=None, unobserve_first=True)[source]¶
Observe the BPMs matching
bpm_pattern(default: the accelerator’s).- Return type:
None- Parameters:
bpm_pattern (str | None)
bad_bpms (list[str] | None)
unobserve_first (bool)
- get_bpm_list(bpm_range)[source]¶
Observed BPM names in the whole sequence and in
bpm_range.- Return type:
tuple[list[str],list[str]]- Parameters:
bpm_range (str)
- prepare_tracking_anchors(*, mode, marker_names)[source]¶
Prepare marker-anchored tracking modes through one monitor-anchor path.
Returns the observed anchor markers the caller must keep through the BPM observation filter (the ACD before/after monitors; none for kicker mode).
- Return type:
list[str]- Parameters:
mode (str | None)
marker_names (list[str] | None)
- cycle_to_start(start_marker)[source]¶
Cycle the loaded sequence so it begins at
start_marker.Cycling is never done implicitly during construction; callers (e.g. a worker that must track a range as one contiguous segment) request it explicitly. A non-BPM start element is first replaced with a same-name marker so MAD can cycle to it.
- Return type:
None- Parameters:
start_marker (str)
- property nbpms: int¶
Number of observed BPMs in
bpm_range.
- make_all_monitors_thin(monitors, observe_after=True)[source]¶
Replace monitor elements with thin observation markers.
- Return type:
None- Parameters:
monitors (list[str])
observe_after (bool)
- apply_initial_model_values(values)[source]¶
Apply a full initial machine-state map without changing the trainable set.
- Return type:
None- Parameters:
values (dict[str, float] | None)
- get_absolute_knob_values(knob_names)[source]¶
Return underlying absolute strengths for optimisation knob names.
For
*.dk0l/*.dk1l/*.dk2l(and skew equivalents) this returns the base element strength before any perturbation. For direct knobs it returns the current value from the sequence.- Return type:
dict[str,float]- Parameters:
knob_names (list[str])