laura.models package

Submodules

laura.models.RF module

laura.models._functions module

_rotation_matrix()[source]
merge_two_dicts()[source]

Combine to dictionaries: first dictionary overwrites keys in the second dictionary

read_yaml(fname)[source]
Parameters:

fname (str)

Return type:

BaseModel

laura.models.baseModels module

class Aliases(*args, **kwargs)[source]

Bases: objectList

Parameters:
  • args (Any)

  • kwargs (Any)

aliases: list = []
class DeviceList(*args, **kwargs)[source]

Bases: objectList

Parameters:
  • args (Any)

  • kwargs (Any)

devices: list = []
class IgnoreExtra(*args, **kwargs)[source]

Bases: ModelBase

Base Model that ignores extra fields.

Parameters:
  • args (Any)

  • kwargs (Any)

_create_field(fields, fieldname, fieldinputs)[source]
Parameters:
  • fields (dict)

  • fieldname (str)

  • fieldinputs (List[str])

Return type:

None

_create_field_class(fields, fieldname, fieldclass)[source]
Parameters:
  • fields (dict)

  • fieldname (str)

  • fieldclass (List[str])

Return type:

None

update()[source]
class ModelBase(*args, **kwargs)[source]

Bases: BaseModel

Base Model that ignores extra fields.

Parameters:
  • args (Any)

  • kwargs (Any)

base_model_dump(exclude_defaults=False)[source]
Parameters:

exclude_defaults (bool)

Return type:

dict

class NumpyModel(*args, **kwargs)[source]

Bases: ModelBase

Model using numpy arrays.

Parameters:
  • args (Any)

  • kwargs (Any)

property array: ndarray
classmethod from_list(vec)[source]
Parameters:

vec (List[Union[float, int]])

Return type:

TypeVar(T, bound= BaseModel)

classmethod from_values(*values)[source]
Parameters:

values (Union[float, int])

Return type:

TypeVar(T, bound= BaseModel)

ser_model(handler, info)
Parameters:

info (SerializationInfo)

update()[source]
class NumpyVectorModel(*args, **kwargs)[source]

Bases: NumpyModel

vector model using numpy arrays.

Parameters:
  • args (Any)

  • kwargs (Any)

convert_numpy_types(v)[source]

Recursively convert numpy types in a data structure to native Python types.

Parameters:

v (Any) – The input data structure which may contain numpy types.

Returns:

The data structure with numpy types converted to native Python types.

Return type:

Any

class flow_list[source]

Bases: list

flow_list_rep()[source]
class objectList(*args, **kwargs)[source]

Bases: IgnoreExtra

Parameters:
  • args (Any)

  • kwargs (Any)

quoted_presenter()[source]
class string_with_quotes[source]

Bases: str

laura.models.control module

class ControlVariable[source]

Bases: BaseModel

Model representing a control variable in a system.

Example on updating element attributes based on control variables: ```python from laura.models.element import Element from laura.models.control import ControlVariable, ControlsInformation # Define control variables cv1 = ControlVariable(

identifier=”k1l_control”, dtype=float, protocol=”some_protocol”, units=”1/m”, description=”Control for k1l”, read_only=False, value=0.1, target=”magnetic.k1l”, expression={“op”: “mul”, “args”: [“k1l_control”, “magnetic.length”]},

) controls_info = ControlsInformation(variables={“k1l_control”: cv1}) # Create an element with magnetic attributes element = Element(

name=”Quad1”, magnetic={“k1l”: 0.0, “k2l”: 0.0}, controls=controls_info,

) # Apply control variables to the element controls_info.apply(element) print(element.magnetic.k1l) # Should reflect the updated value based on the control variable ```

_SERIALIZE_DEFAULTS: dict = {'description': 'Default Description', 'read_only': True, 'type': 'statistical', 'units': 'Arb. Units'}
apply()[source]
description: str = 'Default Description'

Description of the control variable.

dtype

Data type of the control variable (e.g., int, float, str).

alias of float

expression: dict | None = None

Expression defining how to compute the value to set at the target.

identifier: str

Unique identifier for the control variable.

protocol: str

Protocol or method used to interact with the control variable.

read_only: bool = True

Indicates if the variable is read-only.

serialize()
states: Optional[Dict] = None

Possible state mapping enums.

target: str | None = None

Target attribute path in the system to apply the control variable.

type: Literal['scalar', 'binary', 'state', 'string', 'waveform', 'statistical'] = 'statistical'

Type of control variable.

units: str = 'Arb. Units'

Units of measurement for the control variable.

validate_dtype(v)

Convert from string to type if necessary.

Return type:

Type

value: float | int | str | list | None = None

Current value of the control variable.

class ControlsInformation(*args, **kwargs)[source]

Bases: BaseModel

Model representing a collection of control variables.

Parameters:
  • args (Any)

  • kwargs (Any)

apply()[source]
static build_context()[source]
validate_variables(v)

Ensure all values are ControlVariable instances.

Return type:

Dict[str, ControlVariable]

variables: Dict[str, ControlVariable]

Dictionary mapping variable names to ~laura.models.control.ControlVariable instances.

class MirrorControlsInformation(*args, **kwargs)[source]

Bases: ControlsInformation

Model representing a collection of control variables pertaining to mirrors.

Parameters:
  • args (Any)

  • kwargs (Any)

default_step: float = 0.005

Default step size for mirror movement

down_sense: int = 1

Down sense for mirror movement

left_sense: int = 1

Left sense for mirror movement

right_sense: int = -1

Right sense for mirror movement

step_max: float = 0.05

Maximum step size for mirror movement

up_sense: int = -1

Up sense for mirror movement

class ScreenControlsInformation(*args, **kwargs)[source]

Bases: ControlsInformation

Model representing a collection of control variables pertaining to screens.

Parameters:
  • args (Any)

  • kwargs (Any)

devices: dict

List of screen device enums

horizontal_devices: dict | None = None

List of horizontal screen device enums

movement_type: str

Screen motion type

vertical_devices: dict | None = None

List of vertical screen device enums

class ShutterControlsInformation(*args, **kwargs)[source]

Bases: ControlsInformation

Model representing a collection of control variables pertaining to shutters.

Parameters:
  • args (Any)

  • kwargs (Any)

shutter_type: str

Type of shutter, i.e. ‘LASER’, ‘BEAM’

eval_expr()[source]
resolve_path(context, path)[source]
Parameters:

path (str)

set_attr_by_path(obj, path, value)[source]
Parameters:

path (str)

laura.models.degauss module

laura.models.diagnostic module

laura.models.electrical module

laura.models.element module

laura.models.elementList module

laura.models.exceptions module

exception LatticeError[source]

Bases: Exception

laura.models.laser module

laura.models.lighting module

laura.models.magnetic module

laura.models.manufacturer module

laura.models.physical module

laura.models.shutter module

laura.models.simulation module

Module contents