pml package¶
Submodules¶
pml.cs module¶
Template module to define control systems.
-
class
pml.cs.ControlSystem[source]¶ Bases:
objectDefine a control system to be used with a device.
It uses channel access to comunicate over the network with the hardware.
-
class
pml.cs.NullControlSystem[source]¶ Bases:
pml.cs.ControlSystemDummy control system to set the value of a pv.
pml.device module¶
-
class
pml.device.Device(cs, rb_pv=None, sp_pv=None)[source]¶ Bases:
object-
get_pv_name(handle='*')[source]¶ Get a pv name on a specified handle.
If no handle is specified, then both pvs are returned.
- Args:
- handle(string): The readback or setpoint handle to be returned.
- Returns:
- string: A readback or setpoint pv.
-
get_value(handle)[source]¶ Read the value of a readback or setpoint pv.
If neither readback or setpoint pvs exist then a PvException is raised.
- Args:
- handle(string): Handle used to get the value off a readback or setpoint
- pv.
- Returns:
- Number: The value off the pv.
- Raises:
- PvException: In case the requested pv doesn’t exist.
-
pml.element module¶
-
class
pml.element.Element(name, length, element_type)[source]¶ Bases:
object-
add_device(field, device, uc)[source]¶ Add device and unit conversion objects to a given field.
- Args:
- field (string): The key to store the unit conversion and device
- objects.
device (Device): Represents a device stored on an element. uc (PolyUnitConv/PchipUnitConv): Represents a unit conversion object stored for a
device.
-
add_to_family(family)[source]¶ Add the element to the specified family.
- Args:
- family (string): Represents the name of the family
-
get_device(field)[source]¶ Get the device for the given field.
- Args:
- field (string): The lookup key to find the device on an element.
- Returns:
- Device: The device on the given field.
-
get_fields()[source]¶ Get the fields defined on an element.
- Returns:
- list: A sequence of all the fields defined on an element.
-
get_length()[source]¶ Gets the length of an element.
- Returns:
- float: A floating point number that represents the length of the element.
-
get_pv_name(field, handle='*')[source]¶ Get a pv name on a device.
Can return the readback and setpoint pvs if no handle is specified.
- Args:
field (string): Uniquely identifies a device. handle(string): Can be ‘readback’ or ‘setpoint’ to return each pv.
If neither is specified then both pvs are returned.- Returns:
- string: A readback or setpoint pv associated with the identified device.
- Raises:
- PvException: An exception occured accessing a field with no associated device.
-
get_pv_value(field, handle, unit='engineering', sim=False)[source]¶ Get the value of a pv.
Returns the value of a pv on the element. This value is uniquely identified by a field and a handle. The returned value is either in engineering or physics units. The sim flag returns either real or simulated values.
- Args:
field (string): Choose which device to use. handle (string): Can take as value either ‘setpoint’ or ‘readback’. unit (string): Specify either engineering or physics units to be
returned.sim (boolean): Set whether real or simulated values to be returned.
- Returns:
- Number: A number that corresponds to the pv value of the identified device.
- Raises:
- PvException: When there is no associated device on the given field.
-
is_enabled()[source]¶ Check whether an element is enabled or disabled.
- Returns:
- boolean: Represents whether an element is enabled or disabled.
-
put_pv_value(field, value, unit='engineering', sim=False)[source]¶ Set the pv value on a uniquely identified device.
This value can be set on the machine or the simulation. A field is required to identify a device. Returned value can be engineering or physics.
- Args:
- field (string): The key used to identify a device. value (float): The value set on the device. unit (string): Can be engineering or physics units. sim (boolean): To set whether the simulation is on or off.
- Raises:
- PvException: An exception occured accessing a field with no associated device.
-
pml.exceptions module¶
Template module to represent existant exceptions.
pml.lattice module¶
-
class
pml.lattice.Lattice(name, control_system, energy)[source]¶ Bases:
object-
add_element(element)[source]¶ Add an element to the lattice.
- Args:
- element (Element): The element to be inserted into the lattice.
-
get_all_families()[source]¶ Get all available families of the lattice.
- Returns:
- set(string): Contains all available families in the lattice.
-
get_elements(family=None)[source]¶ Get the elements of a family from the lattice.
If no family is specified it returns the whole lattice.
- Args:
- family (string): A specific family to return the elements of.
- Returns:
- list(Element): A list that contains all elements of the specified family.
-
get_energy()[source]¶ Function to get the total energy of the lattice.
- Returns:
- Number: The total energy of the lattice.
-
get_family_pvs(family, field, handle)[source]¶ Get all pv names for a specific family, field and handle.
- Args:
- family (string): A specific family to requests elements of. field (string): The field to uniquely identify a device. handle (string): It is used to identify a readback or setpoint pv.
- Returns:
- list(string): A list of readback or setpoint pvs from the device.
-
get_family_s(family)[source]¶ Get the positions for a set of elements from the same family.
- Args:
- family(string): The family the positions are being asked for.
- Returns:
- list(float): A list of floating point numbers that represent the positions for each element.
-
get_family_values(family, field, handle='setpoint')[source]¶ Get all pv values for a set of pvs.
- Args:
- family(string): A specific family to requests the values of. field(string): The field to uniquely identify a device. handle(string): It is used to identify a readback or setpoint pv.
- Returns:
- list(float): A list of readback or setpoint pv values from the device.
-
get_s(given_element)[source]¶ Find the position of a given element in the lattice.
Note that the given element must exist in the lattice.
- Args:
- given_element: The element that the position is being asked for.
- Returns:
- float: the position of the given element.
- Raises
- ElementNotFoundException: An exception is raised in case the element doesn’t exist inside the lattice.
-
set_family_values(family, field, values)[source]¶ Set the pv value of a given family of pvs.
The pvs are determined by family and device. Note that only setpoint pvs ca be modified.
- Args:
- family(string): A specific family to set the value of. field(string): The field to uniquely identify a device. values(list(float)): A list of values to assign to the pvs.
- Raises:
- PvException: An exception raised in case the given list of values doesn’t match the number of found pvs.
-
pml.load_csv module¶
-
pml.load_csv.load(mode, control_system, directory=None)[source]¶ Load a lattice object from a directory.
- Parameters:
mode: the mode to be loaded control_system: control system to be used directory: directory where to load the files from. If no directory is given
that the data directory at the root of the repository is used.
pml.physics module¶
List of available physics objects: RF AP DRIFT BPM BEND QUAD SEXT DIPOLE HSTR VSTR HCHICA VTRIM HTRIM MPW12 MPW15 BPM10 source
-
class
pml.physics.Ap(length)¶ Bases:
pml.physics.Physics
-
class
pml.physics.Aperture(limits)¶ Bases:
pml.physics.Physics-
get_limits()¶
-
set_limits(value)¶
-
-
class
pml.physics.Bend(length, poly_a=0, poly_b=0, r1=0, r2=0, t1=0, t2=0)¶ Bases:
pml.physics.Magnet
-
class
pml.physics.Bpm(length, x=None, y=None)¶ Bases:
pml.physics.Physics-
get_x()¶
-
get_y()¶
-
-
class
pml.physics.Bpm10(length, x=0, y=0)¶ Bases:
pml.physics.Physics
-
class
pml.physics.Corrector(length, poly_a=0, poly_b=0, r1=0, r2=0, t1=0, t2=0)¶ Bases:
pml.physics.Magnet-
get_b0()¶
-
put_b0()¶
-
-
class
pml.physics.Dipole(bending_angle, entrance_angle, exit_angle, full_gap, fringe_int1, fringe_int2)¶ Bases:
pml.physics.Magnet-
get_bending_angle()¶
-
get_entrance_angle()¶
-
get_exit_angle()¶
-
get_fringe_int1()¶
-
get_fringe_int2()¶
-
get_full_gap()¶
-
set_bending_angle(value)¶
-
set_entrance_angle(value)¶
-
set_exit_angle(value)¶
-
set_fringe_int1(value)¶
-
set_fringe_int2(value)¶
-
set_full_gap(value)¶
-
-
class
pml.physics.Drift(length)¶ Bases:
pml.physics.Physics
-
class
pml.physics.Hchica(length)¶ Bases:
pml.physics.Physics
-
class
pml.physics.Hstr(length, poly_a=0, poly_b=0, r1=0, r2=0, t1=0, t2=0)¶ Bases:
pml.physics.Corrector
-
class
pml.physics.Htrim(length)¶ Bases:
pml.physics.Physics
-
class
pml.physics.Magnet(length, poly_a=0, poly_b=0, r1=0, r2=0, t1=0, t2=0)¶ Bases:
pml.physics.Physics-
get_poly_a(value)¶
-
get_poly_b()¶
-
get_r1()¶
-
get_r2()¶
-
get_t1()¶
-
get_t2()¶
-
set_poly_a(value)¶
-
set_poly_b(value)¶
-
set_r1(value)¶
-
set_r2(value)¶
-
set_t1(value)¶
-
set_t2(value)¶
-
-
class
pml.physics.Marker¶ Bases:
pml.physics.Physics
-
class
pml.physics.Monitor¶ Bases:
pml.physics.Physics
-
class
pml.physics.Mpw10(length)¶ Bases:
pml.physics.Physics
-
class
pml.physics.Mpw12(length)¶ Bases:
pml.physics.Physics
-
class
pml.physics.Mpw15(length)¶ Bases:
pml.physics.Physics
-
class
pml.physics.Physics(length)¶ Bases:
objectTemplate class to represent an object for the simulation.
-
get_length(field, handle)¶
-
set_length(field, unit)¶
-
-
class
pml.physics.Quad(length)¶ Bases:
pml.physics.Magnet
-
class
pml.physics.RF(voltage, frequency, harmonic_number, time_lag=0)¶ Bases:
pml.physics.Physics-
get_frequency()¶
-
get_harmonic_number()¶
-
get_time_lag()¶
-
get_voltage()¶
-
set_frequency(value)¶
-
set_harmonic_number(value)¶
-
set_time_lag(value)¶
-
set_voltage(value)¶
-
-
class
pml.physics.Rf(length, voltage=0, frequency=0, harmonic_no=0, time_lag=0)¶ Bases:
pml.physics.Physics-
get_frequency()¶
-
get_harmonic_no()¶
-
get_time_lag()¶
-
get_voltage()¶
-
set_frequency(value)¶
-
set_harmonic_no(value)¶
-
set_time_lag(value)¶
-
set_voltage(value)¶
-
-
class
pml.physics.Sext(length, poly_a=0, poly_b=0, r1=0, r2=0, t1=0, t2=0)¶ Bases:
pml.physics.Magnet
-
class
pml.physics.Source(length)¶ Bases:
pml.physics.Physics
-
class
pml.physics.Vstr(length, poly_a=0, poly_b=0, r1=0, r2=0, t1=0, t2=0)¶ Bases:
pml.physics.Corrector
-
class
pml.physics.Vtrim(length)¶ Bases:
pml.physics.Physics
pml.units module¶
-
class
pml.units.PchipUnitConv(x, y, f1=<function unit_function>, f2=<function unit_function>)[source]¶ Bases:
pml.units.UnitConv
-
class
pml.units.PolyUnitConv(coef, f1=<function unit_function>, f2=<function unit_function>)[source]¶ Bases:
pml.units.UnitConv