accelmo.tracking.data_manager¶
Measurement data loading and turn batching for the tracking optimisation.
A measurement file becomes a FileTracks: a dense (turn, marker) grid
of coordinate arrays plus the index maps needed to address it. Everything
downstream – worker payloads, initial conditions, momentum refreshes – reads
that grid directly, so there is exactly one place where measurement rows are put
into their tracking order.
- accelmo.tracking.data_manager.TURN_SHUFFLE_SEED = 42¶
Seed of the default turn shuffle.
- accelmo.tracking.data_manager.COORDINATES: tuple[str, ...] = ('x', 'px', 'y', 'py')¶
The observables stored per marker, paired with their variance columns.
- class accelmo.tracking.data_manager.FileTracks(turns, markers, values, kick_plane)[source]¶
Bases:
objectOne measurement file as a dense
(turn, marker)grid.values[name][i, j]is observablenameatturns[i]andmarkers[j]. Markers are in ring order cycled to the BPM the file’s turns were recorded from, so a contiguous tracking range maps to a monotonic column sequence that crosses the ring boundary exactly once – which is how the payload builder infers per-turn wraps.- Parameters:
turns (numpy.ndarray)
markers (list[str])
values (dict[str, numpy.ndarray])
kick_plane (str)
- turns: ndarray¶
- markers: list[str]¶
- values: dict[str, ndarray]¶
- kick_plane: str¶
- turn_row: dict[int, int]¶
- marker_col: dict[str, int]¶
- property first_turn: int¶
Return the lowest global turn number in this file.
- rows(turns)[source]¶
Return the grid rows for the given global turn numbers.
- Return type:
ndarray- Parameters:
turns (list[int])
- cols(markers)[source]¶
Return the grid columns for the given marker names.
- Return type:
ndarray- Parameters:
markers (list[str])
- with_updated_momenta(reconstructed)[source]¶
Return a copy with
px/py(and their variances) patched.reconstructedis a long-form frame ofturn, name, px, py, var_px, var_pyin file-local turn numbering, as produced by the momentum reconstruction. Names are matched case-insensitively; rows naming a marker or turn this file does not hold are ignored, and markers the reconstruction does not cover keep their existing momenta.- Return type:
- Parameters:
reconstructed (pandas.DataFrame)
- accelmo.tracking.data_manager.infer_kick_plane(frame)[source]¶
Infer whether a measurement file is excited in x, y, or both planes.
A plane counts as excited when its coordinate or momentum spans a measurable range; when both do, the larger has to dominate by an order of magnitude for the file to be treated as single-plane.
- Return type:
str- Parameters:
frame (pandas.DataFrame)
- class accelmo.tracking.data_manager.DataManager(bpms_in_range, all_bpms, tracking_data, num_workers, measurement_files, tracking_plan, first_bpms=None, extra_markers=None, shuffle_turns=None)[source]¶
Bases:
objectLoads measurement files and plans the turn batches workers receive.
- Parameters:
bpms_in_range (list[str])
all_bpms (list[str])
tracking_data (TrackingDataConfig)
num_workers (int)
measurement_files (list[Path])
tracking_plan (TrackingPlan)
first_bpms (list[str | None] | None)
extra_markers (list[str] | None)
shuffle_turns (ShuffleTurns | None)
- tracks: dict[int, FileTracks]¶
- available_turns: list[int]¶
- turn_batches: list[list[int]]¶
- validation_turn_batches: list[list[int]]¶
- bunch_turns_by_file: dict[int, dict[int, list[int]]]¶
- boundary_turns_by_file: dict[int, set[int]]¶
- file_map: dict[int, int]¶
- load_track_data()[source]¶
Read every measurement file into a
FileTracksgrid.Each file keeps its own turn numbering on disk; here it is shifted into a disjoint global block so a turn number identifies a file as well as a turn. Bunch structure comes from the
bunch_numbercolumn.- Return type:
None
- with_updated_momenta(reconstructions)[source]¶
Return the track grids with reconstructed momenta patched in.
Files absent from
reconstructionsare passed through unchanged, so a reconstruction that failed for one file this epoch keeps its last momenta.- Return type:
dict[int,FileTracks]- Parameters:
reconstructions (dict[int, pandas.DataFrame])