accelmo.fitting.setup

The model a fit runs on: backend model, BPM ranges and starting knobs.

accelmo.fitting.setup.normalise_true_strengths(true_strengths)[source]

Normalise true strengths to a dictionary format.

Parameters:

true_strengths (Path | dict[str, float] | None) – Can be None, a Path to a file, or a dict

Return type:

dict[str, float]

Returns:

Dictionary of true strengths (empty if None was provided)

Parameters:

true_strengths (Path | dict[str, float] | None)

class accelmo.fitting.setup.MachineSetup(accelerator, sequence_config, *, output_config=None, cycle_marker=None, anchor_mode=None, anchor_markers=(), initial_knob_strengths=None, true_strengths=None, debug=False, machine_state=None, b2_errors=None)[source]

Bases: object

Everything a fitter knows about the machine before any worker starts.

Builds the fitter-side backend model, reads its BPMs (all_bpms and the observed bpms_in_range), and resolves the starting knobs. Every value is in optimisation space: a deltap in the user’s knobs becomes pt.

Attributes set here and read by the fitters:

knob_names

The optimised knobs, in model order.

initial_knobs

The starting value of every knob in knob_names.

initial_model_values

Fixed values (strengths and pt) from initial_knob_strengths that are not optimised here but still have to be set in every model.

true_strengths

The known answer, restricted to knob_names; the initial knobs when none is given.

Parameters:
  • accelerator (Accelerator)

  • sequence_config (SequenceConfig)

  • output_config (OutputConfig | None)

  • cycle_marker (str | None)

  • anchor_mode (str | None)

  • anchor_markers (Sequence[str])

  • initial_knob_strengths (dict[str, float] | None)

  • true_strengths (Path | dict[str, float] | None)

  • debug (bool)

  • machine_state (Path | Mapping[str, float] | None)

  • b2_errors (Path | None)

property worker_start_knobs: dict[str, float]

the fixed values, then the initial knobs.

Type:

Every value a worker model starts from

make_run_log(name, *, resume=False)[source]

A run log under output_config.run_log_root, or None when disabled.

With resume, the newest unfinished run of this name that has recorded some history is continued; a new one is made when there is none.

Return type:

RunLog | None

Parameters:
  • name (str)

  • resume (bool)

close()[source]

Shut down the fitter-side model.

Return type:

None