at.load.file_input#
Generic text parsers for conversion of lattices in different formats to AT
Functions
|
Decorator which adds an "argparser" attribute to a function |
|
Generate a class for skipped elements. |
|
Generate a class for ignored elements. |
|
Add classes for ignored elements in the given namespace. |
|
Add classes for ignored elements in the given namespace. |
Classes
|
Base class for source object descriptors |
|
Simple representation of an element as a |
|
Simple representation of a sequence of elements as a |
|
Generic file parser |
|
Parser allowing definitions in any order |
|
Case independent parser |
|
Case independent parser |
|
- class AnyDescr(*args, **kwargs)[source]#
Bases:
object
Base class for source object descriptors
- bool_attr = ()#
list of names of bool attributes
- pos_args = ()#
list of names of positional arguments
- str_attr = ()#
list of names of str attributes
- class BaseParser(env, *args, strict=True, always_force=True, **kwargs)[source]#
Bases:
DictNoDot
Generic file parser
Analyses files with the following MAD-like format:
variable = value
label : 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}#
- at2mad = {'Length': 'L'}#
- bool_fmt = None#
- class LowerCaseParser(env, *args, strict=True, always_force=True, **kwargs)[source]#
Bases:
BaseParser
Case independent parser
- class SequenceDescr(*args, **kwargs)[source]#
-
Simple representation of a sequence of elements as a
list
- class UnorderedParser(env, *args, **kwargs)[source]#
Bases:
BaseParser
Parser 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)
- Parameters:
env (dict) – global namespace
verbose – If True, print detail on the processing
*args – dict initializer
**kwargs – dict initializer
- class UpperCaseParser(env, *args, strict=True, always_force=True, **kwargs)[source]#
Bases:
BaseParser
Case independent parser
- ignore_class(classname, baseclass, **kwargs)[source]#
Generate a class for ignored elements.
- Parameters:
classname (str) – Name of the generated class
baseclass (type[ElementDescr]) – Base class, must be a subclass of
ElementDescr
**kwargs – dictionary of additional attributes and methods. See
type()
.
- Returns:
cls – Element class, converted to
Marker
orDrift
when generating AT elements
- ignore_names(namespace, baseclass, classnames)[source]#
Add classes for ignored elements in the given namespace.
- Parameters:
namespace (dict)
baseclass (type[ElementDescr]) – Base class, must be a subclass of
ElementDescr
classnames (Iterable[str]) – Class names of the generated classes
- skip_class(classname, baseclass, **kwargs)[source]#
Generate a class for skipped elements.
- Parameters:
classname (str) – Name of the generated class
baseclass (type[ElementDescr]) – Base class, must be a subclass of
ElementDescr
**kwargs – dictionary of additional attributes and methods. See
type()
.
- Returns:
cls – Element class, skipped when generating AT elements
- skip_names(namespace, baseclass, classnames)[source]#
Add classes for ignored elements in the given namespace.
- Parameters:
namespace (dict)
baseclass (type[ElementDescr]) – Base class, must be a subclass of
ElementDescr
classnames (Iterable[str]) – Class names of the generated classes