at.load.file_input#
Generic text parsers for conversion of lattices in different formats to AT.
Functions
|
Generate a class for ignored elements. |
|
Generate a class for skipped elements. |
Classes
|
Base class for source object descriptors. |
|
Generic file parser. |
|
|
|
Simple representation of an element as a |
|
Case independent parser. |
|
Simple representation of a sequence of elements as a |
|
Parser allowing definitions in any order. |
|
Case independent parser. |
- class BaseParser(env, strict=True, verbose=False, always_force=True, **kwargs)[source]#
-
Generic file parser.
Analyses files with the following MAD-like format:
variable = valuelabel : command [,attribute=value] [,attribute=value]...The parser builds a database of all the defined objects
- Parameters:
- evaluate(expr)[source]#
Evaluate the right side of an expression.
- Parameters:
expr (str) – expression to evaluate
- Returns:
value – evaluated expression
- lattice(use='ring', **kwargs)[source]#
Create a lattice from the selected sequence.
- Parameters:
use – Name of the sequence or line containing the desired lattice. Default:
ring- Keyword Arguments:
name (str) – Name of the lattice. Default: sequence name.
particle (Particle) – Circulating particle. Default: Particle(“relativistic”)
energy (float) – Energy of the lattice [eV]. Default: 1.0 GeV
periodicity (int) – Number of periods. Default: 1
* – All other keywords will be set as Lattice attributes
- parse_files(*filenames, final=True, prolog=None, epilog=None, **kwargs)[source]#
Process files and fill the database.
- property ignored#
Set of ignored commands.
- property missing#
Set of missing definitions
- property sequences#
List of available sequences or lines.
- class ElementDescr(*args, origin=None, **kwargs)[source]#
-
Simple representation of an element as a
dict.- to_at(*args, **params)[source]#
Generate the AT element. Must be overloaded for each specific element.
- array_fmt = {40: 123, 41: 125, 91: 123, 93: 125}#
- class LowerCaseParser(env, strict=True, verbose=False, always_force=True, **kwargs)[source]#
Bases:
BaseParserCase independent parser.
- class SequenceDescr(*args, **kwargs)[source]#
-
Simple representation of a sequence of elements as a
list.
- class UnorderedParser(env, **kwargs)[source]#
Bases:
BaseParserParser allowing definitions in any order.
This is done by storing the failed statements in a queue and iteratively trying to execute them after all input statements have been processed, until the number of failures is constant (hopefully zero)
- class UpperCaseParser(env, strict=True, verbose=False, always_force=True, **kwargs)[source]#
Bases:
BaseParserCase independent parser.
- ignore_class(classname, baseclass, module=None, **kwargs)[source]#
Generate a class for ignored elements.
The element generates an AT Drift or Marker element depending on its length.
- Parameters:
classname (str) – Name of the generated class
baseclass (type[ElementDescr]) – Base class, must be a subclass of
ElementDescrmodule (str | None) – Name of the module where the class is defined. If
None, use the module of the base class.**kwargs – dictionary of additional attributes and methods. See
type().
- Returns:
cls – Element class, converted to
MarkerorDriftwhen generating AT elements
- skip_class(classname, baseclass, module=None, **kwargs)[source]#
Generate a class for skipped elements.
No AT element is generated for these elements.
- Parameters:
classname (str) – Name of the generated class
baseclass (type[ElementDescr]) – Base class, must be a subclass of
ElementDescrmodule (str | None) – Name of the module where the class is defined. If
None, use the module of the base class.**kwargs – dictionary of additional attributes and methods. See
type().
- Returns:
cls – Element class, skipped when generating AT elements