accelmo.tracking.config.tracking¶
Tracking-mode planning for arc-by-arc, kicker- and AC-dipole-excited runs.
This module owns everything mode-specific about a training run: one
TrackingPlan per mode fixes the simulation-config entries and start points
that are not free choices for the mode, and expands BPM points into worker ranges.
- accelmo.tracking.config.tracking.extract_bpm_range_names(all_bpms, start_bpm, end_bpm, sdir)[source]¶
Extract BPM names between start and end BPMs, handling circular wrapping.
- Parameters:
all_bpms (
list[str]) – List of all BPM namesstart_bpm (
str) – Starting BPM nameend_bpm (
str) – Ending BPM namesdir (
int) – Direction (1 for forward, -1 for reverse)
- Return type:
list[str]- Returns:
List of BPM names in the range
- Parameters:
all_bpms (list[str])
start_bpm (str)
end_bpm (str)
sdir (int)
- accelmo.tracking.config.tracking.create_bpm_range_specs(bpm_start_points, bpm_end_points, use_fixed_bpm, fixed_start=None, fixed_end=None)[source]¶
Create BPM range specifications for optimisation workers.
- Parameters:
bpm_start_points (
list[str]) – List of starting BPM namesbpm_end_points (
list[str]) – List of ending BPM namesuse_fixed_bpm (
bool) – If True, use fixed BPM pairs; if False, create cartesian productfixed_start (
str|None) – Fixed start BPM for backward tracking (only used if use_fixed_bpm=True)fixed_end (
str|None) – Fixed end BPM for forward tracking (only used if use_fixed_bpm=True)
- Return type:
list[tuple[str,str,int]]- Returns:
List of (start_bpm, end_bpm, sdir) tuples where sdir is 1 for forward, -1 for reverse
- Parameters:
bpm_start_points (list[str])
bpm_end_points (list[str])
use_fixed_bpm (bool)
fixed_start (str | None)
fixed_end (str | None)
- class accelmo.tracking.config.tracking.WorkerRangeSpec(start_bpm, end_bpm, sdir)[source]¶
Bases:
objectLogical BPM range assigned to a worker.
- Parameters:
start_bpm (str)
end_bpm (str)
sdir (int)
- start_bpm: str¶
- end_bpm: str¶
- sdir: int¶
- property init_bpm: str¶
Return the BPM used to initialise tracking for this direction.
- class accelmo.tracking.config.tracking.TrackingPlan[source]¶
Bases:
objectMode-specific tracking policy; the base class is arc-by-arc BPM tracking.
Subclasses override the class-level flags and the range-planning hooks below.
- enable_validation: ClassVar[bool] = True¶
- turns_per_track: ClassVar[int] = 1¶
Turns tracked from each start; an arc range is one turn.
- one_start_per_worker: ClassVar[bool] = False¶
- tracking_anchor_mode: ClassVar[str | None] = None¶
- property init_marker: str | None¶
Element supplying tracking initial conditions instead of a range BPM.
- property cycle_marker: str | None¶
Optional unobserved element used only for sequence cycling.
- property extra_markers: tuple[str, ...]¶
Non-BPM markers that must be kept in measurement data.
- property start_points: tuple[str, ...]¶
Fixed tracking start points of marker-anchored modes; empty means the caller’s BPMs.
- property first_bpm_fallback: str | None¶
Per-file fallback for the BPM the measurement turns are recorded from.
- configure(tracking_data)[source]¶
tracking_datawith the entries this mode fixes; arc ranges fix none.- Return type:
- Parameters:
tracking_data (TrackingDataConfig)
- property tracking_anchor_sources: tuple[str, ...]¶
Elements the model prepares for marker-anchored tracking.
- initial_condition_marker(range_spec)[source]¶
Return the measured marker used for a worker’s initial coordinates.
- Return type:
str|None- Parameters:
range_spec (WorkerRangeSpec)
- observed_bpms(bpms_in_range, all_bpms)[source]¶
Return the BPMs compared against measurements.
- Return type:
list[str]- Parameters:
bpms_in_range (list[str])
all_bpms (list[str])
- select_available_turns(*, bunch_turns_by_file, available_turns)[source]¶
Return boundary turns and the filtered list of usable start turns.
A start turn is unusable when the multi-turn track it seeds would cross a bunch boundary. Each bunch’s first/last turns are therefore removed, using the per-file
bunch_numbergrouping read from the measurement data.- Return type:
tuple[dict[int,set[int]],list[int]]- Parameters:
bunch_turns_by_file (dict[int, dict[int, list[int]]])
available_turns (list[int])
- build_range_specs(ctx)[source]¶
Return the worker range specs for this plan.
- Return type:
list[WorkerRangeSpec]- Parameters:
ctx (BpmRanges)
- class accelmo.tracking.config.tracking.KickerTrackingPlan(kicker_name, turns_per_track=1)[source]¶
Bases:
TrackingPlanForward-only tracking starting from a kicker initial-condition marker.
The measured kicker marker supplies the initial coordinates, while the MAD sequence is cycled to an unobserved centre marker so the observed BPM order begins just after the kicker; only real BPMs are compared.
- Parameters:
kicker_name (str)
turns_per_track (int)
- kicker_name: str¶
- enable_validation: ClassVar[bool] = False¶
- tracking_anchor_mode: ClassVar[str | None] = 'kicker'¶
- configure(tracking_data)[source]¶
One batch: each bunch gives a single track, so batches cannot split the turns.
- Return type:
- Parameters:
tracking_data (TrackingDataConfig)
- property start_points: tuple[str, ...]¶
The kicker marker.
- property first_bpm_fallback: str¶
Kicker files are recorded from the kicker marker.
- property init_marker: str¶
The kicker marker.
- property extra_markers: tuple[str, ...]¶
The kicker marker.
- property tracking_anchor_sources: tuple[str, ...]¶
The kicker marker.
- property cycle_marker: str¶
Marker at the kicker centre.
- observed_bpms(bpms_in_range, all_bpms)[source]¶
Every BPM.
- Return type:
list[str]- Parameters:
bpms_in_range (list[str])
all_bpms (list[str])
- select_available_turns(*, bunch_turns_by_file, available_turns)[source]¶
Each bunch contributes exactly one track, seeded from its first turn.
- Return type:
tuple[dict[int,set[int]],list[int]]- Parameters:
bunch_turns_by_file (dict[int, dict[int, list[int]]])
available_turns (list[int])
- build_range_specs(ctx)[source]¶
One forward range from the first BPM round the ring.
- Return type:
list[WorkerRangeSpec]- Parameters:
ctx (BpmRanges)
- class accelmo.tracking.config.tracking.ACDTrackingPlan(acd_name)[source]¶
Bases:
_AcdPlanBidirectional tracking initialised at AC-dipole markers.
- Parameters:
acd_name (str)
- property start_points: tuple[str, ...]¶
The
afterandbeforemarkers.
- property extra_markers: tuple[str, ...]¶
The
beforeandaftermarkers.
- observed_bpms(bpms_in_range, all_bpms)[source]¶
Every BPM.
- Return type:
list[str]- Parameters:
bpms_in_range (list[str])
all_bpms (list[str])
- build_range_specs(ctx)[source]¶
Forward from
afterand backward frombefore.- Return type:
list[WorkerRangeSpec]- Parameters:
ctx (BpmRanges)
- initial_condition_marker(range_spec)[source]¶
Initialise each direction from the marker at its tracking start.
- Return type:
str- Parameters:
range_spec (WorkerRangeSpec)
- class accelmo.tracking.config.tracking.ACDSinusoidTrackingPlan(acd_name, turns_per_track=1)[source]¶
Bases:
_AcdPlanForward multi-turn tracking from the AC-dipole before-marker through the AC kickers.
Each file is cut into back-to-back tracks of
turns_per_trackturns: one starts at the file’s first turn and a new one everyturns_per_trackturns, each seeded from the measured before-marker at its start turn. The kick comes from the model AC kickersAC_KICKERS(PSBacd_drive_tunes).- Parameters:
acd_name (str)
turns_per_track (int)
- enable_validation: ClassVar[bool] = False¶
- one_start_per_worker: ClassVar[bool] = True¶
- configure(tracking_data)[source]¶
One batch: each worker holds one track (its own AC-kicker phase).
- Return type:
- Parameters:
tracking_data (TrackingDataConfig)
- property start_points: tuple[str, ...]¶
The
beforemarker.
- property init_marker: str¶
The
beforemarker.
- property extra_markers: tuple[str, ...]¶
The
beforeandaftermarkers.
- observed_bpms(bpms_in_range, all_bpms)[source]¶
BPMs in the range.
- Return type:
list[str]- Parameters:
bpms_in_range (list[str])
all_bpms (list[str])
- select_available_turns(*, bunch_turns_by_file, available_turns)[source]¶
Start turns every
turns_per_trackturns of each file.- Return type:
tuple[dict[int,set[int]],list[int]]- Parameters:
bunch_turns_by_file (dict[int, dict[int, list[int]]])
available_turns (list[int])
- build_range_specs(ctx)[source]¶
One forward range from
beforeround the ring.- Return type:
list[WorkerRangeSpec]- Parameters:
ctx (BpmRanges)
- class accelmo.tracking.config.tracking.ACDArcByArcTrackingPlan(acd_name)[source]¶
Bases:
_AcdPlanArc-by-arc tracking of AC-dipole data over ordinary BPM ranges.
Unlike
ACDTrackingPlan(which tracks bidirectionally from the AC-dipolebefore/aftermarkers), this plan tracks the caller’s cartesian product ofbpm_start_pointsxbpm_end_points. The exciter is a driven, turn-varying element, so a range that crosses it would compare BPMs on opposite sides of a kick the free-oscillation model cannot reproduce.Rather than drop such a range, this plan reroutes it: two BPMs are joined by two arcs around the ring, and only one contains the AC dipole, so a crossing pair keeps
startandendconnected via the complementary long-way-round arc (in both tracking directions).The
before/aftermonitors are installed (tracking_anchor_mode=="acd") only so they appear inall_bpmsand mark the exciter’s ring position for the crossing test; they are not observed against the measurement.- Parameters:
acd_name (str)
- observed_bpms(bpms_in_range, all_bpms)[source]¶
BPMs in the range, without the AC-dipole markers.
- Return type:
list[str]- Parameters:
bpms_in_range (list[str])
all_bpms (list[str])
- build_range_specs(ctx)[source]¶
Arc ranges, rerouted round the ring when they contain the AC dipole.
- Return type:
list[WorkerRangeSpec]- Parameters:
ctx (BpmRanges)