pml package

Submodules

pml.cs module

Template module to define control systems.

class pml.cs.ControlSystem[source]

Bases: object

Define a control system to be used with a device.

It uses channel access to comunicate over the network with the hardware.

get(pv)[source]

Get the value of the given pv.

Args:
pv(string): The Pv to get the value of.
Returns:
Number: The numeric value of the pv.
put(pv, value)[source]

Put the value of a given pv.

Args:
pv(string): The string to put the value for. value(Number): The value to be set.
class pml.cs.NullControlSystem[source]

Bases: pml.cs.ControlSystem

Dummy control system to set the value of a pv.

get(pv)[source]

Get the value of the given pv.

Args:
pv(string): The Pv to get the value of.
Returns:
Number: The numeric value of the pv.
put(pv, value)[source]

Put the value of a given pv.

Args:
pv(string): The string to put the value for. value(Number): The value to be set.

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.
put_value(value)[source]

Set the value of a pv.

If not setpoint pv exists a PvException is raised.

Args:
value(Number): The value to set on the pv.
Raises:
PvException: An exception occured when no setpoint pv exists.

pml.element module

class pml.element.Element(name, length, element_type, physics=None)[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 (UcPoly/UcPchip): 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.
set_enabled(enabled=True)[source]

Enable or disable an element.

Args:
enabled (boolean): Set whether an element is disabled or enabled.

pml.exceptions module

Template module to represent existant exceptions.

exception pml.exceptions.ElementNotFoundException[source]

Bases: exceptions.Exception

exception pml.exceptions.PvException[source]

Bases: exceptions.Exception

exception pml.exceptions.UniqueSolutionException[source]

Bases: exceptions.Exception

pml.lattice module

class pml.lattice.Lattice(name, control_system)[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_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_length()[source]

Returns the length of the lattice.

Returns:
float: The length of the lattice.
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(directory, mode, control_system)[source]

Load a lattice object from a directory.

Parameters:
directory: directory where to load the files from mode:the mode to be loaded control_system: control system to be 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)[source]

Bases: pml.physics.Physics

class pml.physics.Aperture(limits)[source]

Bases: pml.physics.Physics

get_limits()[source]
set_limits(value)[source]
class pml.physics.Bend(length, poly_a=0, poly_b=0, r1=0, r2=0, t1=0, t2=0)[source]

Bases: pml.physics.Magnet

class pml.physics.Bpm(length, x=None, y=None)[source]

Bases: pml.physics.Physics

get_x()[source]
get_y()[source]
class pml.physics.Bpm10(length, x=0, y=0)[source]

Bases: pml.physics.Physics

class pml.physics.Corrector(length, poly_a=0, poly_b=0, r1=0, r2=0, t1=0, t2=0)[source]

Bases: pml.physics.Magnet

get_b0()[source]
put_b0()[source]
class pml.physics.Dipole(bending_angle, entrance_angle, exit_angle, full_gap, fringe_int1, fringe_int2)[source]

Bases: pml.physics.Magnet

get_bending_angle()[source]
get_entrance_angle()[source]
get_exit_angle()[source]
get_fringe_int1()[source]
get_fringe_int2()[source]
get_full_gap()[source]
set_bending_angle(value)[source]
set_entrance_angle(value)[source]
set_exit_angle(value)[source]
set_fringe_int1(value)[source]
set_fringe_int2(value)[source]
set_full_gap(value)[source]
class pml.physics.Drift(length)[source]

Bases: pml.physics.Physics

class pml.physics.Hchica(length)[source]

Bases: pml.physics.Physics

class pml.physics.Hstr(length, poly_a=0, poly_b=0, r1=0, r2=0, t1=0, t2=0)[source]

Bases: pml.physics.Corrector

class pml.physics.Htrim(length)[source]

Bases: pml.physics.Physics

class pml.physics.Magnet(length, poly_a=0, poly_b=0, r1=0, r2=0, t1=0, t2=0)[source]

Bases: pml.physics.Physics

get_poly_a(value)[source]
get_poly_b()[source]
get_r1()[source]
get_r2()[source]
get_t1()[source]
get_t2()[source]
set_poly_a(value)[source]
set_poly_b(value)[source]
set_r1(value)[source]
set_r2(value)[source]
set_t1(value)[source]
set_t2(value)[source]
class pml.physics.Marker[source]

Bases: pml.physics.Physics

class pml.physics.Monitor[source]

Bases: pml.physics.Physics

class pml.physics.Mpw10(length)[source]

Bases: pml.physics.Physics

class pml.physics.Mpw12(length)[source]

Bases: pml.physics.Physics

class pml.physics.Mpw15(length)[source]

Bases: pml.physics.Physics

class pml.physics.Physics(length)[source]

Bases: object

Template class to represent an object for the simulation.

get_length(field, handle)[source]
set_length(field, unit)[source]
class pml.physics.Quad(length)[source]

Bases: pml.physics.Magnet

class pml.physics.RF(voltage, frequency, harmonic_number, time_lag=0)[source]

Bases: pml.physics.Physics

get_frequency()[source]
get_harmonic_number()[source]
get_time_lag()[source]
get_voltage()[source]
set_frequency(value)[source]
set_harmonic_number(value)[source]
set_time_lag(value)[source]
set_voltage(value)[source]
class pml.physics.Rf(length, voltage=0, frequency=0, harmonic_no=0, time_lag=0)[source]

Bases: pml.physics.Physics

get_frequency()[source]
get_harmonic_no()[source]
get_time_lag()[source]
get_voltage()[source]
set_frequency(value)[source]
set_harmonic_no(value)[source]
set_time_lag(value)[source]
set_voltage(value)[source]
class pml.physics.Sext(length, poly_a=0, poly_b=0, r1=0, r2=0, t1=0, t2=0)[source]

Bases: pml.physics.Magnet

class pml.physics.Source(length)[source]

Bases: pml.physics.Physics

class pml.physics.Vstr(length, poly_a=0, poly_b=0, r1=0, r2=0, t1=0, t2=0)[source]

Bases: pml.physics.Corrector

class pml.physics.Vtrim(length)[source]

Bases: pml.physics.Physics

pml.units module

class pml.units.UcPchip(x, y)[source]

Bases: object

machine_to_physics(machine_value)[source]

Convert between machine and engineering units.

Args:
machine_value(float): The machine value to be converted to the engineering unit.
Returns:
float: The converted engineering value from the given machine value.
physics_to_machine(physics_value)[source]

Convert between engineering and machine units.

Args:
physics_value(float): The engineering value to be converted to the
machine value.
Returns:
float: The converted engineering value from the given physics value.
Raises:
ValueError: An error occured when there exist no or more than one roots.
class pml.units.UcPoly(coef)[source]

Bases: object

machine_to_physics(machine_value)[source]

Convert between machine and engineering units.

Args:
machine_value(float): The machine value to be converted to the engineering unit.
Returns:
float: The engineering value determined using the machine value.
physics_to_machine(physics_value)[source]

Convert between engineering and machine units.

Args:
physics_value(float): The engineering value to be converted to the
machine value.
Returns:
float: The converted machine value from the given engineering value.
Raises:
ValueError: An error occured when there exist no or more than one roots.

Module contents