at.lattice.elements.idtable_element#
ID table Element.
Classes
|
Insertion device kick-map element for a parallel electron beam. |
- class InsertionDeviceKickMap(family_name, nslice=1, fname=None, norm_energy=0.0, *, length=0.0, kickmaps=None, **kwargs)[source]#
Bases:
ElementInsertion device kick-map element for a parallel electron beam.
The element implements tracking through integrated first- and second-order magnetic field maps normalized to a reference energy. It may be created empty, from one kickmap, or from a mapping of named kickmaps.
- Parameters:
- Keyword Arguments:
length – Insertion device length in m. A zero value uses the length read from a supplied kickmap.
kickmaps – Mapping of kickmap names to
(nslice, source, energy)tuples. The first entry is initially active.**kwargs – Additional element attributes. This is also used internally when restoring an element from a lattice file.
If no kickmap arguments are supplied, an empty element with
PassMethod="DriftPass"is created. Adding the first kickmap activates it and changes the pass method toIdTablePass. Supplyingnslice,fnameandnorm_energycreates one kickmap named"default".Native lattice formats store the active map both in the element tracking fields and in its
KickmapStoreentry. This intentional duplication preserves the MATLAB user experience, where tracking fields are available directly on the element.First-order maps are optional. Positive and negative signs are not applied by this implementation, so the input data must already contain the desired signs.
See P. Elleaume, “A New Approach to the Electron Beam Dynamics in Undulators and Wigglers”, EPAC 1992, 0661.
Examples
Create an empty element and add a kickmap later:
>>> elem = InsertionDeviceKickMap("ID") >>> elem.add_kickmap("LH", 25, "lh_kickmap.txt", 2.75)
Create an element with one kickmap:
>>> elem = InsertionDeviceKickMap( ... "ID", 25, "lh_kickmap.txt", 2.75 ... )
The same element may be created with keyword arguments:
>>> elem = InsertionDeviceKickMap( ... "ID", ... nslice=25, ... fname="lh_kickmap.txt", ... norm_energy=2.75, ... )
Create an element with several named kickmaps:
>>> elem = InsertionDeviceKickMap( ... "ID", ... kickmaps={ ... "LH": (25, "lh_kickmap.txt", 2.75), ... "LV": (25, "lv_kickmap.txt", 2.75), ... }, ... )
Initialize an insertion device kick-map element.
- classmethod new_from_dict(**elem_dict)[source]#
Restore kickmap state when loading dictionary-based formats.
- add_kickmap(key, nslice, fname, norm_energy)[source]#
Store a kickmap under a string key without activating it.
Use
use_kickmap()to make a stored kickmap active for tracking.
- read_dict_radia_field_map(id_input)[source]#
Read a dictionary with Radia field map tables.
The required keys are “Length”, “xkick” and “ykick” for the second order maps, “xtable” and “ytable” for the grid, and “xkick1” and “ykick1” for the first order maps.
- Parameters:
id_input (dict) – Radia field map input.
- Returns:
Tuple with Insertion Device parameters.
- read_text_radia_field_map(file_in_name)[source]#
Read a RadiaField map in text format and return.
A File, where : - comments start with #. - the first data line is the length in meters. - the second data line is the number of points in the h. plane. - the third data line is the number of points in the v. plane. - each block is a table with axes. - each data block comes after a START. - first the horizontal data block, and second the vertical data block with the second order kicks. There might be two other blocks with the horizontal and vertical first order kicks.
File example (ignore the !SPACE): ! #comment in line 1 ! #comment in line 2 ! Length_in_m ! #comment in line 4 ! Number of points in horizontal plane :nh ! #comment in line 6 ! Number of points in vertical plane :nv ! #comment in line 8 ! START ! pos_point1h pos_point2h … pos_pointnh ! pos_point1v ! … horizontal kick_map(nv,nh) ! pos_pointnv ! START ! pos_point1h pos_point2h … pos_pointnh ! pos_point1v ! … vertical kick_map(nv,nh) ! pos_pointnv ! (EOL)
- Parameters:
file_in_name (str) – the file name.
- Returns:
Tuple with file tables and axes.
- Raises:
ValueError – if the number of blocks in less than 2 or equal to 3.
- use_kickmap(key)[source]#
Activate a stored kickmap by key for tracking.
Swaps xtable, ytable, xkick, ykick, xkick1, ykick1 and Nslice/Length to the data stored under key.
- Parameters:
key (str) – identifier of a kickmap previously added with
add_kickmap().- Raises:
KeyError – if key is not found in the store.