gpilib2 package

Submodules

gpilib2.cameras module

class gpilib2.cameras.cal_camera(rpc: gpilib2.rpc.rpc, binary: str, move_cmd: int, move_gmb_field: str, curr_state_gmb_field: str, name: str, camera_num: int, server: str = 'cal')[source]

Bases: gpilib2.cameras.gpi_camera

CAL camera object

Parameters
  • rpc (rpc) – rpc object. sim status and verbosity will be set based on its settings.

  • binary (str) – binary name

  • move_cmd (int) – Command number in binary to use

  • move_gmb_field (str) – GMB field prefix corresponding to the move command

  • curr_state_gmb_field (str) – GMB field of current camera state

  • name (str) – Name of this camera

  • server (str) – Server address to send commands to.

rpc

rpc object for communications

Type

rpc

server

Server address to send commands to.

Type

str

binary

binary name

Type

str

move_cmd

Command number in binary to use

Type

int

move_gmb_field

GMB field prefix corresponding to the move command

Type

str

curr_state_gmb_field

GMB field of current camera state

Type

str

name

Name of this camera

Type

str

camera_num

Camera number (0 = LOWFS, 1 = HOWFS)

Type

int

assemble_fname() str[source]

Assemble full name of next exposure

Parameters

None

Returns

Path to next exposure file relative to the data directory

Return type

str

take_exp(return_im: bool = False) Union[str, Tuple[numpy.ndarray[Any, numpy.dtype[numpy.float64]], str]][source]

Take Exposure

Parameters

return_im (bool) – If True, return the image data along with the filename.

Returns

str:

Full path to file on disk

numpy.ndarray:

Image data (only if return_im is True)

Return type

str or tuple

..warning:

The NFS cache may cause file access to fail.  To avoid this, the cal data
volume must be mounted with option ``noac``.
class gpilib2.cameras.cameras(rpc: gpilib2.rpc.rpc)[source]

Bases: object

All GPI cameras

Parameters

rpc (rpc) – rpc object. sim status and verbosity will be set based on its settings.

rpc

rpc object for communications

Type

rpc

class gpilib2.cameras.gpi_camera(rpc: gpilib2.rpc.rpc, binary: str, move_cmd: int, move_gmb_field: str, curr_state_gmb_field: str, name: str, server: str = 'tlc')[source]

Bases: object

Generic camera object

Parameters
  • rpc (rpc) – rpc object. sim status and verbosity will be set based on its settings.

  • binary (str) – binary name

  • move_cmd (int) – Command number in binary to use

  • move_gmb_field (str) – GMB field prefix corresponding to the move command

  • curr_state_gmb_field (str) – GMB field of current camera state

  • name (str) – Name of this camera

  • server (str) – Server address to send commands to.

rpc

rpc object for communications

Type

rpc

server

Server address to send commands to.

Type

str

binary

binary name

Type

str

move_cmd

Command number in binary to use

Type

int

move_gmb_field

GMB field prefix corresponding to the move command

Type

str

curr_state_gmb_field

GMB field of current camera state

Type

str

name

Name of this camera

Type

str

gpilib2.coronagraph module

class gpilib2.coronagraph.apodizer(rpc: gpilib2.rpc.rpc)[source]

Bases: gpilib2.coronagraph.coronagraph_component

Apodizer

move(mask: Optional[str] = None, rot: Optional[float] = None, xoff: Optional[float] = None, force: bool = False, rel: bool = False, queue: bool = False, noqueuewarning: bool = False) None[source]

Send MOVE command

Parameters
  • mask (str or None) – Mask to move to (or none for override).

  • rot (number or None) – Rotation override in degrees

  • xoff (number or None) – x-Offset override in mm

  • force (bool) – Force move command even if current mask string matches requested mask

  • rel (bool) – Treat rotation and x-offset as relative to current values

  • queue (bool) – Queue command rather than immediately executing

  • noqueuewarning (bool) – If the specific MOVE has required cleanup actions (i.e., self.post_move_required is True) then a warning will be generated when queue = True, unless noqueuewarning is also set to True. Default False.

Returns

None

Notes

At least one of mask, rot, or xoff must be set. If the mask string is not None, the offsets will be ignored.

class gpilib2.coronagraph.coronagraph(rpc: gpilib2.rpc.rpc)[source]

Bases: gpilib2.generic_gpi_assembly.generic_gpi_assembly

All GPI coronagraph components (apodizer, focal-plane mask, lyot stop)

Parameters

rpc (rpc) – rpc object. sim status and verbosity will be set based on its settings.

rpc

rpc object for communications

Type

rpc

fpm

fpm object

Type

fpm

apodizer

apodizer object

Type

apodizer

lyot

lyot object

Type

lyot

components

List of apodizer, fpm, lyot (in that order)

Type

list

move(apodizer: Optional[str] = None, fpm: Optional[str] = None, lyot: Optional[str] = None, queue: bool = False) None[source]

Move some or all coronagraph components to specific masks For override positions and other options, use the component-specific move method.

Parameters
  • apodizer (str or None) – Apodizer mask name

  • fpm (str or None) – FPM mask name

  • lyot (str or none) – Lyot mask name

  • queue (bool) – If True, queue commands rather than executing.

Note

End of mask name must match exact mask string and must be a unique match.

class gpilib2.coronagraph.coronagraph_component(rpc: gpilib2.rpc.rpc, binary: str, move_cmd: int, default_cmd_args: List[str], move_gmb_field: str, configfile: str, maskstr: str, curr_state_gmb_field: str, motor_position_gmb_fields: List[str], override_mask_name: str, name: str, post_move_required: bool = False, server: str = 'tlc', mcd_name: Optional[Union[numpy.typing._array_like._SupportsArray[numpy.dtype], numpy.typing._nested_sequence._NestedSequence[numpy.typing._array_like._SupportsArray[numpy.dtype]], bool, int, float, complex, str, bytes, numpy.typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]]] = None)[source]

Bases: gpilib2.generic_gpi_component.generic_gpi_component

Generic GPI coronagraph component

Parameters
  • rpc (gpilib2.rpc) – rpc object. sim status and verbosity will be set based on its settings.

  • binary (str) – binary name

  • move_cmd (int) – Command number in binary to use

  • default_cmd_args (list) – Default argument sets to use for inits and datums and sims

  • move_gmb_field (str) – GMB field prefix corresponding to the move command

  • configfile (str) – Name of relevant assembly configuration where mask names can be found

  • maskstr (str) – How mask names are identified in the assembly config file

  • curr_state_gmb_field (str) – GMB field where current mask value is stored

  • motor_position_gmb_fields (list) – GMB fields with current filterwheel/slide position values. Must be in the same order as these arguments are passed to the move command.

  • override_mask_name (str) – Mask name to use when setting override motor positions.

  • name (str) – Component name

  • post_move_required (bool) – Set to True if there are mandatory actions to be completed after the end of a successful MOVE command. Specific actions are in self.post_move_cleanup()

  • server (str) – Server address to send commands to.

  • mcd_name (ArrayLike, optional) – Label(s) of MCD axis for this component. If None (default), assume that device is not on an MCD.

rpc

rpc object for communications

Type

rpc

masks

List of (str) mask names

Type

list

configfile

Name of relevant assembly configuration where mask names can be found

Type

str

maskstr

How mask names are identified in the assembly config file

Type

str

binary

Which binary to use to move the wheel

Type

str

move_gmb_field

GMB field prefix corresponding to the move command

Type

str

curr_state_gmb_field

GMB field where current mask value is stored

Type

str

server

Server address to send commands to.

Type

str

move_cmd

Command number in binary to use

Type

int

default_cmd_args

Default argument sets to use for inits and datums

Type

list

motor_position_gmb_fields

GMB fields with current filterwheel/slide position values. Must be in the same order as these arguments are passed to the move command.

Type

list

post_move_required

Set to True if there are mandatory actions to be completed after the end of a successful MOVE command. Specific actions are in self.post_move_cleanup()

Type

bool

override_mask_name

Mask name to use when setting override motor positions.

Type

str

name

Component name

Type

str

mcd_name

Label(s) of MCD axis/axes for this component. If None, assume that device is not on an MCD.

Type

ndarray(str), optional

mcd_inds

Indices of entries in mcdaxisnames corresponding to the entries of mcd_name. None if mcd_name is None.

Type

ndarray(int), optional

Warning

Mask names are read from the specified configuration files in the config dir. Component-specific strings that define which config file to use, and how to find the mask name are set by the configfile and maskstr attributes.

Note

The FPM and apodizer (PPM) have their own assemblies, but the Lyot masks are defined in the IFS assembly.

match_mask_name(mask: str) str[source]

Return unique matching mask string

Parameters

mask (str) – Requested mask. This must match the ending of the full mask string exactly. Case insensitive.

Returns

The exact mask string.

Return type

str

Notes

For apodizers, all final characters are unique, so matching is guaranteed. For FPM, there is mild ambiguity between 50umPIN and Open, so multiple characters are required. Lyots are most annoying with 080m12_04, 080_04, and 080m12_04_c. Using full maks names is safest in this case. Mask names can always be checked by printing self.masks.

move(mask: Optional[str] = None, rot: Optional[float] = None, force: bool = False, rel: bool = False, queue: bool = False, noqueuewarning: bool = False) None[source]

Send MOVE command

Parameters
  • mask (str or None) – Mask to move to (or none for override).

  • rot (number or None) – Rotation override in degrees

  • force (bool) – Force move command even if current mask string matches requested mask

  • rel (bool) – Treat rotation and x-offset as relative to current values

  • queue (bool) – Queue command rather than immediately executing

  • noqueuewarning (bool) – If the specific MOVE has required cleanup actions (i.e., self.post_move_required is True) then a warning will be generated when queue = True, unless noqueuewarning is also set to True. Default False.

Returns

None

Warning

At least one of mask or rot must be set. If the mask string is not None, the rotation override will be ignored.

post_move_cleanup(**kwargs: Any) None[source]

Execute anything required post-move

class gpilib2.coronagraph.fpm(rpc: gpilib2.rpc.rpc)[source]

Bases: gpilib2.coronagraph.coronagraph_component

Focal-Plane Mask

class gpilib2.coronagraph.lyot(rpc: gpilib2.rpc.rpc)[source]

Bases: gpilib2.coronagraph.coronagraph_component

Lyot stop

gpilib2.generic_gpi_assembly module

class gpilib2.generic_gpi_assembly.generic_gpi_assembly(rpc: gpilib2.rpc.rpc)[source]

Bases: object

Base class for various collections of components that take generic commands

Attributes
rpc (rpc):

rpc object for communications

comonents (list):

List of component objects

datum_all() None[source]

Datum all components

init_all() None[source]

Init all components

gpilib2.generic_gpi_component module

class gpilib2.generic_gpi_component.generic_gpi_component(rpc: gpilib2.rpc.rpc, binary: str, move_cmd: int, default_cmd_args: List[str], move_gmb_field: str, curr_state_gmb_field: str, name: str, server: str = 'tlc', mcd_name: Optional[Union[numpy.typing._array_like._SupportsArray[numpy.dtype], numpy.typing._nested_sequence._NestedSequence[numpy.typing._array_like._SupportsArray[numpy.dtype]], bool, int, float, complex, str, bytes, numpy.typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]]] = None)[source]

Bases: object

Base class for various components that take generic commands

Parameters
  • rpc (rpc) – rpc object. sim status and verbosity will be set based on its settings.

  • binary (str) – binary name

  • move_cmd (int) – Command number in binary to use

  • default_cmd_args (list) – Default argument sets to use for inits and datums and sims

  • move_gmb_field (str) – GMB field prefix corresponding to the move command

  • curr_state_gmb_field (str) – GMB field of current state of component

  • name (str) – Component name

  • server (str) – Server address to send commands to.

  • mcd_name (ArrayLike, optional) – Label(s) of MCD axis for this component. If None (default), assume that device is not on an MCD.

rpc

rpc object for communications

Type

rpc

server

Server address to send commands to.

Type

str

binary

binary name

Type

str

move_cmd

Command number in binary to use

Type

int

default_cmd_args

Default argument sets to use for inits and datums and sims

Type

list

move_gmb_field

GMB field prefix corresponding to the move command

Type

str

curr_state_gmb_field

GMB field of current state of component

Type

str

name

Component name

Type

str

mcd_name

Label(s) of MCD axis/axes for this component. If None, assume that device is not on an MCD.

Type

ndarray(str), optional

mcd_inds

Indices of entries in mcdaxisnames corresponding to the entries of mcd_name. None if mcd_name is None.

Type

ndarray(int), optional

check_datum(warn: bool = False) None[source]

Check that component is datumed at the MCD level

Parameters

warn (bool) – Issue warning instead of throwing AssertionError. Defaults False.

check_init(warn: bool = False) None[source]

Check that component is inited at the MCD level

Parameters

warn (bool) – Issue warning instead of throwing AssertionError. Defaults False.

check_mcd_status(statarr: numpy.ndarray[Any, numpy.dtype[numpy.str_]], msg_txt: str, warn: bool = False) None[source]

Check component status at the MCD level

Parameters
  • statarr (ndarray(str)) –

    Status array to check. Should be one of:

  • msg_txt (str) – Text to use in warning/assertion message. Should be on of ‘init’, ‘datum’, or ‘sim’, corresponding to choice of statarr.

  • warn (bool) – Issue warning instead of throwing AssertionError. Defaults False.

Note

If self.mcd_name is None, do nothing. Otherwise, by default, throw an AssertionError if check fails.

datum(queue: bool = False) None[source]

Send DATUM command

Parameters

queue (bool) – Queue rather than execute immediately. Defaults False.

Returns

None

generic_command(mode: str, level: Optional[int] = None, activity: str = 'START', queue: bool = False) None[source]

Send a non-move command

Parameters
  • mode (str) – Mode string (typically INIT, DATUM or SIM). Must be in rpc.ass_mode

  • level (int or None) – If None, use rpc.move_level. Otherwise use this level. Only has an effect for SIM and DEBUG.

  • activity (str) – Activity directve. Defaults to “START”

  • queue (bool) – Queue rather than execute immediately. Defaults False.

Returns

None

Notes

All such commands look the same, but each individual binary command will require a different set of default values to tack on to the command string.

init(queue: bool = False) None[source]

Send INIT command

Parameters

queue (bool) – Queue rather than execute immediately. Defaults False.

Returns

None

set_sim(queue: bool = False) None[source]

Send SIM LEVEL=1 command

Parameters

queue (bool) – Queue rather than execute immediately. Defaults False.

Returns

None

set_unsim(queue: bool = False) None[source]

Send SIM LEVEL=0 command

Parameters

queue (bool) – Queue rather than execute immediately. Defaults False.

Returns

None

stop(queue: bool = False) None[source]

Send STOP command

Parameters

queue (bool) – Queue rather than execute immediately. Defaults False.

Returns

None

track(queue: bool = False) None[source]

Send TRACK command

Parameters

queue (bool) – Queue rather than execute immediately. Defaults False.

Returns

None

gpilib2.gpi module

class gpilib2.gpi.gpi(sim: bool = False, verb: bool = False, sim_fill_val: str = '0')[source]

Bases: object

All of GPI

Parameters
  • sim (bool) – Run in sim mode (default False). Setting to true automatically toggles verbose mode

  • verb (bool) – Toggle verbose mode (default False)

  • sim_fill_val (str) – Default value to fill for simulated GMB queries. Defaults to ‘0’.

powerbars

Powerbars object

Type

powerbar

sensors

Sensors object.

Type

gpilib2.sensors

rpc

rpc object for all communications.

Type

gpilib2.rpc

coronagraph

Coronagraph object

Type

gpilib2.coronagraph

source

Source object

Type

gpilib2.source

shutters

Shutters object

Type

gpilib2.shutters

pnc

PnC object

Type

gpilib2.pnc

cameras
Type

gpilib2.cameras

get_zenith() float[source]

Return current zenith value

set_zenith(val: float) None[source]

Set zenith value in GMB

Parameters

val (float) – Zenith angle in degrees

Returns

None

gpilib2.mcds module

class gpilib2.mcds.mcds(rpc: gpilib2.rpc.rpc)[source]

Bases: object

Access and control devices at the MCD level

Parameters

rpc (rpc) – rpc object. sim status and verbosity will be set based on its settings.

rpc

rpc object for communications

Type

rpc

gpilib2.pnc module

class gpilib2.pnc.ao_pnc(rpc: gpilib2.rpc.rpc, binary: str, move_cmd: int, default_cmd_args: List[str], move_gmb_field: str, curr_state_gmb_field: str, name: str, server: str = 'tlc', has_pointing: bool = True, has_focus: bool = True, tol: float = 1e-05)[source]

Bases: gpilib2.pnc.generic_pnc

AO PnCs

cal_correct(val: int) None[source]

Toggle CAL correct for AO PnCs

Parameters

val (int) – 0 for off, 1 for on

Returns

None

cal_correct_off() None[source]

Toggle CAL correct to OFF

cal_correct_on() None[source]

Toggle CAL correct to ON

dar(val: int) None[source]

Toggle DAR for AO PnCs

Parameters

val (int) – 0 for off, 1 for on

Returns

None

dar_off() None[source]

Toggle DAR to OFF

dar_on() None[source]

Toggle DAR to ON

fpm_offsets(val: int) None[source]

Toggle FPM offsetsfor AO PnCs

Parameters

val (int) – 0 for off, 1 for on

Returns

None

fpm_offsets_off() None[source]

Toggle to OFF

fpm_offsets_on() None[source]

Toggle to ON

get_curr_values() Tuple[numpy.ndarray[Any, numpy.dtype[numpy.float64]], ...][source]

Query all of the GMB variables required to determine current positions and offsets

Parameters

None

Returns

numpy.ndarray:

Array of current net target value (of size self.n)

numpy.ndarray:

Array of currently applied offsets (of size self.n)

numpy.ndarray:

Array of offsets that will be applied to next MOVE (of size self.n)

Return type

tuple

Note

Depending on the current instrument state, there may be residual values in some offset fields even though the offset itself is currently toggled off. For example OLM offsets will be non-zero in the event that the OLM has just been toggled off while the PnCs are stopped. Upon the next move (or track start) the OLM fields will all go to zero. Because of this, the current net target is validated based on all of the offset fields, whereas the offset for the next move is determined based on the current state of the offset toggles.

olm(val: int) None[source]

Toggle OLM for AO PnCs

Parameters

val (int) – 0 for off, 1 for on

Returns

None

class gpilib2.pnc.cal_pnc(rpc: gpilib2.rpc.rpc, binary: str, move_cmd: int, default_cmd_args: List[str], move_gmb_field: str, curr_state_gmb_field: str, name: str, server: str = 'tlc', has_pointing: bool = True, has_focus: bool = True, tol: float = 1e-05)[source]

Bases: gpilib2.pnc.generic_pnc

CAL PnCs

fov_offsets(val: int) None[source]

Toggle FOV offsets for CAL PnCs

Parameters

val (int) – 0 for off, 1 for on

Returns

None

fov_offsets_off() None[source]

Toggle to OFF

fov_offsets_on() None[source]

Toggle to ON

get_curr_values() Tuple[numpy.ndarray[Any, numpy.dtype[numpy.float64]], ...][source]

Query all of the GMB variables required to determine current positions and offsets

Parameters

None

Returns

numpy.ndarray:

Array of current net target value (of size self.n)

numpy.ndarray:

Array of currently applied offsets (of size self.n)

numpy.ndarray:

Array of offsets that will be applied to next MOVE (of size self.n)

Return type

tuple

Note

Depending on the current instrument state, there may be residual values in some offset fields even though the offset itself is currently toggled off. For example OLM offsets will be non-zero in the event that the OLM has just been toggled off while the PnCs are stopped. Upon the next move (or track start) the OLM fields will all go to zero. Because of this, the current net target is validated based on all of the offset fields, whereas the offset for the next move is determined based on the current state of the offset toggles.

lyot_offsets(val: int) None[source]

Toggle Lyot offsets for CAL PnCs

Parameters

val (int) – 0 for off, 1 for on

Returns

None

lyot_offsets_off() None[source]

Toggle to OFF

lyot_offsets_on() None[source]

Toggle to ON

olm(val: int) None[source]

Toggle OLM for CAL PnCs

Parameters

val (int) – 0 for off, 1 for on

Returns

None

class gpilib2.pnc.generic_pnc(rpc: gpilib2.rpc.rpc, binary: str, move_cmd: int, default_cmd_args: List[str], move_gmb_field: str, curr_state_gmb_field: str, name: str, server: str = 'tlc', has_pointing: bool = True, has_focus: bool = True, tol: float = 1e-05)[source]

Bases: gpilib2.generic_gpi_component.generic_gpi_component

GPI pointing and/or centering component

Parameters
  • rpc (rpc) – rpc object. sim status and verbosity will be set based on its settings.

  • binary (str) – binary name

  • move_cmd (int) – Command number in binary to use

  • default_cmd_args (list) – Default argument sets to use for inits and datums and sims

  • move_gmb_field (str) – GMB field prefix corresponding to the move command

  • current_state_gmb_field (str) – GMB field of current shutter state

  • name (str) – Name of this shutter

  • server (str) – Server address to send commands to.

  • has_pointing (bool) – Mechanism has pointing capability (default True)

  • has_focus (bool) – Mechanism has focus capability (default True)

rpc

rpc object for communications

Type

rpc

server

Server address to send commands to.

Type

str

binary

binary name

Type

str

move_cmd

Command number in binary to use

Type

int

default_cmd_args

Default argument sets to use for inits and datums and sims

Type

list

move_gmb_field

GMB field prefix corresponding to the move command

Type

str

current_state_gmb_field

GMB field of current shutter state

Type

str

name

Name of this shutter

Type

str

has_pointing

Mechanism has pointing capability

Type

bool

has_focus

Mechanism has focus capability

Type

bool

n_vals

Number of total settable values (2 for pointing + 2 for centering + 1 for focus)

Type

int

tol

Absolute tolerance to accept successful move commands

Type

float

assemble_move_cmd(pos: numpy.ndarray[Any, numpy.dtype[numpy.float64]]) List[str][source]

Utility method to package move AO PnC move commands

Parameters

pos (numpy.ndarray) – 5 element floating point array of [tip, tilt, x cent, ycent, focus]

Returns

Command list to execute

Return type

list

get_curr_values() Tuple[numpy.ndarray[Any, numpy.dtype[numpy.float64]], ...][source]
move(targ: Optional[List[float]] = None, point: Optional[List[float]] = None, cent: Optional[List[float]] = None, focus: Optional[float] = None, rel: bool = False) None[source]

PnC MOVE command

Parameters
  • targ (list or None) – Either 4 or 5 element list of [tip, tilt, x cent, ycent, focus] values. If 4 elements, focus is set to zero. If None, point and/or cent must be set.

  • point (list or None) – 2-element list of pointing values [tip, tilt] in mas. Ignored if targ is set.

  • cent (list or None) – 2-element list of centering values [x,y] in mm. Ignored if targ is set

  • focus (float or None) – Scalar focus value in mm. Ignored if targ is set.

  • rel (bool) – Apply inputs as offsets from current values (taking into account of all other offsets).

Returns

None

Note

Either targ or at least one of point/cent/focus must be set. If targ is set the other three inputs are ignored.

Warning

The default behavior of this method is inherently different from the equivalent functionality of the original gpilib. When rel is False (i.e., absolute inputs) he offsets to be applied (based on current settings) will be subtracted from the inputs, such that the resulting mirror settings should match the inputs exactly (to within a very small margin of error).

olm(val: int) None[source]
olm_off() None[source]

Toggle to OFF

olm_on() None[source]

Toggle to ON

toggle_offset(field: str, val: int) None[source]

Toggle offset field

Parameters
  • field (str) – GMB field of offset

  • val (int) – 0 for off, 1 for on

Returns

None

class gpilib2.pnc.inputfold(rpc: gpilib2.rpc.rpc, binary: str, move_cmd: int, default_cmd_args: List[str], move_gmb_field: str, curr_state_gmb_field: str, name: str, server: str = 'tlc', has_pointing: bool = True, has_focus: bool = True, tol: float = 1e-05)[source]

Bases: gpilib2.pnc.generic_pnc

get_curr_values() Tuple[numpy.ndarray[Any, numpy.dtype[numpy.float64]], ...][source]

Query all of the GMB variables required to determine current positions and offsets

Parameters

None

Returns

numpy.ndarray:

Array of current net target value (of size self.n)

numpy.ndarray:

Array of currently applied offsets (of size self.n)

numpy.ndarray:

Array of offsets that will be applied to next MOVE (of size self.n)

Return type

tuple

Note

Depending on the current instrument state, there may be residual values in some offset fields even though the offset itself is currently toggled off. For example OLM offsets will be non-zero in the event that the OLM has just been toggled off while the PnCs are stopped. Upon the next move (or track start) the OLM fields will all go to zero. Because of this, the current net target is validated based on all of the offset fields, whereas the offset for the next move is determined based on the current state of the offset toggles.

move(cent: List[float], rel: bool = False) None[source]

inputfold MOVE command

Parameters
  • cent (list or None) – 2-element list of centering values [x,y] in mm.

  • rel (bool) – Apply inputs as offsets from current values (taking into account of all other offsets).

Returns

None

Warning

The default behavior of this method is inherently different from the equivalent functionality of the original gpilib. When rel is False (i.e., absolute inputs) he offsets to be applied (based on current settings) will be subtracted from the inputs, such that the resulting mirror settings should match the inputs exactly (to within a very small margin of error).

olm(val: int) None[source]

Toggle OLM for CAL PnCs

Parameters

val (int) – 0 for off, 1 for on

Returns

None

pupil_offsets(val: int) None[source]

Toggle pupil offsets for the inputfold

Parameters

val (int) – 0 for off, 1 for on

Returns

None

pupil_offsets_off() None[source]

Toggle to OFF

pupil_offsets_on() None[source]

Toggle to ON

class gpilib2.pnc.pnc(rpc: gpilib2.rpc.rpc)[source]

Bases: gpilib2.generic_gpi_assembly.generic_gpi_assembly

All GPI pointing and centering components (inputfold, ao pncs, cal-ifs pncs)

Parameters

rpc (rpc) – rpc object. sim status and verbosity will be set based on its settings.

rpc

rpc object for communications

Type

rpc

ao_pnc

fpm object

Type

ao_pnc

cal_pnc

apodizer object

Type

generic_pnc

inputfold

lyot object

Type

generic_pnc

components

List of inputfold, ao_pnc, cal_pnc (in that order)

Type

list

gpilib2.powerbars module

class gpilib2.powerbars.powerbars(sensors: gpilib2.sensors.sensors)[source]

Bases: object

All GPI powerbars and outlets

Parameters

sensors (gpilib2.sensors) – sensors object. sim status and verbosity will be set based on the sensors.rpc settings.

sensors

Sensors object used for safety checks.

Type

gpilib2.sensors

rpc

Pointer to self.sensors.rpc. rpc object for all communications.

Type

gpilib2.rpc

npowbar

Number of powerbars (4).

Type

int

noutlet

Number of outlets per powerbar (8).

Type

int

pbarre

regex that can extract numerical values from powerbar GMB fieldnames

Type

re.Pattern

outletfields

32-element array of all outlet GMB field names

Type

ndarray

outletnums

32x2 array of all powerbar/outlet command numbers

Type

ndarray

Note

There are 4 powerbars with 8 outlets each. The GMB numbers these with 0-based indexing (so that Powerbar 3 Outlet 6 is ‘tlc.powBarAss.bar[2].outlet[5]’ but the commands and GUIs use 1-based indexing (so you would command 3,6 for the same outlet). Annoying. Because of the danger of using stale powerbar name info, current outlet names are queried at every instantiation of this class.

get_outlet_state(fields: Union[numpy.typing._array_like._SupportsArray[numpy.dtype], numpy.typing._nested_sequence._NestedSequence[numpy.typing._array_like._SupportsArray[numpy.dtype]], bool, int, float, complex, str, bytes, numpy.typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]]) numpy.ndarray[Any, numpy.dtype[numpy.int64]][source]

Query the current outlet state

Parameters

fields (ArrayLike) – Outlet fields to query

Returns

Current states of outlets. 1 = OFF, 0 = ON, 2 = REBOOT

Return type

ndarray

Notes:

identify_outlet_by_name(names: Union[numpy.typing._array_like._SupportsArray[numpy.dtype], numpy.typing._nested_sequence._NestedSequence[numpy.typing._array_like._SupportsArray[numpy.dtype]], bool, int, float, complex, str, bytes, numpy.typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]]) Tuple[List[str], List[str], numpy.ndarray[Any, numpy.dtype[numpy.int64]]][source]

Identify outlet/powerbar locations by name

Parameters

names (ArrayLike) – Name strings (see note)

Returns

list:

Exact names of outlets requested.

list:

Sub-array of self.outletfields corresponding to queried names

~numpy.ndarray:

Sub-array of self.outletnums corresponding to queried names

Return type

tuple

Note

Name matching must be unique to prevent accidentally toggling unintended outlets. Names can be partial, but must uniquely identify the outlet (i.e., ‘CAL’ is not acceptable as it matches 5 different devices).

off(names: Union[numpy.typing._array_like._SupportsArray[numpy.dtype], numpy.typing._nested_sequence._NestedSequence[numpy.typing._array_like._SupportsArray[numpy.dtype]], bool, int, float, complex, str, bytes, numpy.typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]]) None[source]

Toggle off outlets by name

Parameters

names (ArrayLike) – Name strings (see notes in identify_outlet_by_name)

Returns

None

on(names: Union[numpy.typing._array_like._SupportsArray[numpy.dtype], numpy.typing._nested_sequence._NestedSequence[numpy.typing._array_like._SupportsArray[numpy.dtype]], bool, int, float, complex, str, bytes, numpy.typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]]) None[source]

Toggle on outlets by name

Parameters

names (ArrayLike) – Name strings (see notes in identify_outlet_by_name)

Returns

None

reboot(names: Union[numpy.typing._array_like._SupportsArray[numpy.dtype], numpy.typing._nested_sequence._NestedSequence[numpy.typing._array_like._SupportsArray[numpy.dtype]], bool, int, float, complex, str, bytes, numpy.typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]]) None[source]

Reboot outlets by name

Parameters

names (ArrayLike) – Name strings (see notes in identify_outlet_by_name)

Returns

None

send_powerbar_command(nums: numpy.ndarray[Any, numpy.dtype[numpy.int64]], state: int) None[source]

Wrapper to gpPowBarAssClientTester and helper method for on/off/reboot

Parameters
  • nums (ndarray) – n x 2 array of powerbar/outlet numbers

  • state (int) – 0: On 1: Off 2: Reboot

Returns

None

Notes

Remember, the commands and GUIs use 1-based, so the numbers here must be 1-based. So powerbar 3, outlet 6 is [3,6], etc. See also notes in __init__.

update_outlet_names() None[source]

Query and save the names of all outlets

gpilib2.rpc module

class gpilib2.rpc.rpc(sim: bool = False, verb: bool = False, sim_fill_val: str = '0')[source]

Bases: object

Class for io methods via rpc utilities

Parameters
  • sim (bool) – Run in sim mode (default False). Setting to true automatically toggles verbose mode

  • verb (bool) – Toggle verbose mode (default False)

  • sim_fill_val (str) – Default value to fill for simulated GMB queries. Defaults to ‘0’.

sim

Simulated mode toggle (can be manually set at any time)

Type

bool

verb

Verbosity toggle (can be manually set at any time). If object is created with sim = True then verbosity is automatically toggled on.

Type

bool

binaries

Dictionary of binary names (keys) and full paths (values)

Type

dict

command_queue

Command queue. List of tuples of the form (cmdlist, cmd_gmb_field) where cmdlist is a list of command arguments and cmd_gmb_field is a string of the base of the command GMB field.

Type

list

ass_mode

Dictionary of assembly modes. Must match enum in gpUtGeneral.h

Type

dict

activity

Dictionary of activity directives. Must match enum in gpUtGeneral.h

Type

dict

activityId

Default activity id (set to -1 to match GUI activities)

Type

int

move_level

Default level value for MOVE commands

Type

int

nmcd

Number of MCD

Type

int

nax

Number of axes per MCD

Type

int

mcdaxes

Base of GMB fields for all MCD axes

Type

ndarray(str)

mcdaxisnames

Descriptions of all MCD axes

Type

ndarray(str)

mcdaxisinited

GMB fields for MCD Axis init status

Type

ndarray(str)

mcdaxisdatumed

GMB fields for MCD Axis datum status

Type

ndarray(str)

mcdaxissimed

GMB fields for MCD Axis sim status

Type

ndarray(str)

async assemble_pending_commands(cmdstrs: List[str]) List[Tuple[str, Optional[int], bytes, bytes]][source]

Dump set of pending commands into a gather

Parameters

cmdstrs (list) – List of full command strings

Returns

list of tuples as returned by run

Return type

list

clear_queue() None[source]

Remove all pending commands from queue without executing

execute(cmdlist: List[str], cmd_gmb_field: str, queue: bool = False, nowait: bool = False) None[source]

Queue or execute a command, and optionally wait for completion

Parameters
  • cmdlist (list) – Command and arguments

  • cmd_gmb_field (str) – Base of GMB field to check for ack and status

  • queue (bool) – If True, queue the command for later execution. Defaults False.

  • nowait (bool) – If True, return immediately upon confirming an ack. Default False - wait for command state to register complete.

Return type

None

Notes:

execute_queue(nowait: bool = False) None[source]

Execute all pending commands in queue

Parameters

nowait (bool) – If True, return immediately upon confirming an ack. Default False - wait for command state to register complete.

Returns

None

list_gmb_fields(server: str = 'tlc') List[str][source]

Wrapper of gpUtReadWriteClient read command

Parameters

server (str) – Server name or address (defaults to ‘tlc’)

Returns

List of field names

Return type

list

Notes

Expected return from gpUtGmbReadVal is multiple lines of debug messages with all requested field names, followed by a single blank newline.

parse_ReadWriteClient_output(input: str) Optional[str][source]

Parse output of gpUtReadWriteClient command

Parameters

input (str) – gpUtReadWriteClient query output

Returns

Contents of query output. None returned if ‘error’ in input or regular expression matching fails.

Return type

str or None

Notes

gpUtReadWriteClient returns multiple lines of information, with queried value typically at end of the last line as = <#####>.

Numeric output will have format of: [+/-]X or [+/-]X.X or [+/-]X.X[e/E][+/-]X

read_gmb_arrays(fields: Union[numpy.typing._array_like._SupportsArray[numpy.dtype], numpy.typing._nested_sequence._NestedSequence[numpy.typing._array_like._SupportsArray[numpy.dtype]], bool, int, float, complex, str, bytes, numpy.typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]], maxlen: int = 1, server: str = 'tlc') numpy.ndarray[Any, numpy.dtype[Any]][source]

Wrapper of gpUtReadGmbArrs

Parameters
  • field (ArrayLike) – Fields to read.

  • maxlen (int) – Maximum field length. Defaults to 1.

  • server (str) – Server name or address (defaults to ‘tlc’)

Returns

Contents of fields.

Return type

ndarray

Notes

gpUtReadGmbArrs returns one line of info per query, followed by a blank newline. The data lines will either be the value of the field, or an error message (including the word ‘ERROR’). In cases where an initial connection cannot be established (server name is wrong or server cannot be reached), only a single line of error message is returned.

Numeric outputs will have format of: [+/-]X or [+/-]X.X or [+/-]X.X[e/E][+/-]X

read_gmb_value(field: str, server: str = 'tlc') Optional[str][source]

Wrapper of gpUtReadWriteClient read command

Parameters
  • field (str) – Field to read.

  • server (str) – Server name or address (defaults to ‘tlc’)

Returns

Contents of query output. None returned if querying or pattern matching fails.

Return type

str or None

Notes

gpUtReadWriteClient returns multiple lines of information, with queried value typically at end of the last line as = <#####>.

Numeric output will have format of: [+/-]X or [+/-]X.X or [+/-]X.X[e/E][+/-]X

read_gmb_values(fields: Union[numpy.typing._array_like._SupportsArray[numpy.dtype], numpy.typing._nested_sequence._NestedSequence[numpy.typing._array_like._SupportsArray[numpy.dtype]], bool, int, float, complex, str, bytes, numpy.typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]], server: str = 'tlc') numpy.ndarray[Any, numpy.dtype[Any]][source]

Wrapper of gpUtReadGmbValues

Parameters
  • field (ArrayLike) – Fields to read.

  • server (str) – Server name or address (defaults to ‘tlc’)

Returns

Contents of fields.

Return type

ndarray

Notes

gpUtReadGmbValues returns one line of info per query, followed by a blank newline. The data lines will either be the value of the field, or an error message (including the word ‘ERROR’). In cases where an initial connection cannot be established (server name is wrong or server cannot be reached), only a single line of error message is returned.

Numeric outputs will have format of: [+/-]X or [+/-]X.X or [+/-]X.X[e/E][+/-]X

read_gmb_values_legacy(fields: Union[numpy.typing._array_like._SupportsArray[numpy.dtype], numpy.typing._nested_sequence._NestedSequence[numpy.typing._array_like._SupportsArray[numpy.dtype]], bool, int, float, complex, str, bytes, numpy.typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]], server: str = 'tlc') numpy.ndarray[Any, numpy.dtype[Any]][source]

Wrapper of read_gmb_value for array-like inputs. Matches read_gmb_values syntax.

Parameters
  • field (ArrayLike) – Fields to read.

  • server (str) – Server name or address (defaults to ‘tlc’)

Returns

Contents of fields.

Return type

ndarray

Notes

See read_gmb_value()

wait_for_command_completion(fields: Union[numpy.typing._array_like._SupportsArray[numpy.dtype], numpy.typing._nested_sequence._NestedSequence[numpy.typing._array_like._SupportsArray[numpy.dtype]], bool, int, float, complex, str, bytes, numpy.typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]], polling_interval: float = 0.5) Optional[numpy.ndarray[Any, numpy.dtype[Any]]][source]

Wait for completion of one or more commands

Parameters
  • fields (ArrayLike) – Base of GMB fields for commands

  • polling_interval (float) – Time (seconds) to wait between state checks (defaults to 0.5)

Returns

If all commands were successful, return None, otherwise an array of state error messages equivalent in size to the input list of GMB fields.

Return type

None or ndarray

Notes:

write_gmb_value(field: str, value: Any, server: str = 'tlc') None[source]

Wrapper of gpUtReadWriteClient write command

Parameters
  • field (str) – Field to read.

  • server (str) – Server name or address (defaults to ‘tlc’)

Returns

None

async gpilib2.rpc.run(cmd: str, env: Optional[os._Environ[str]] = None, cwd: Optional[str] = None) Tuple[str, Optional[int], bytes, bytes][source]

Wrapper for asynchronous command execution

Parameters
  • cmd (str) – Full command string to execute

  • env (os._Environ) – Environment dictionary. Defaults to None.

  • cwd (str) – Working directory. Defaults to None

Returns

cmd (str):

Original command string

returncode (int):

proc.returncode

stdout (bytes):

stdout bytestream

stderr (bytes):

stderr bytestream

Return type

tuple

gpilib2.sensors module

class gpilib2.sensors.sensors(rpc: gpilib2.rpc.rpc)[source]

Bases: object

All GPI sensors (onewire + IFS)

Parameters

rpc (gpilib2.rpc) – rpc object. sim status and verbosity will be set based on its settings.

rpc

rpc object for communications

Type

gpilib2.rpc

sensorfile

Full path to sensors list on disk

Type

str

sensornames

Array of all sensor names

Type

numpy.ndarray

sensorfields

Array of GMB fields corresponding to sensornames

Type

numpy.ndarray

onewire_data

oneWire log data (only available after get_onewire_logs() is run)

Type

pandas.DataFrame

onewire_keys

Dictionary or sensor names/log ids. (only available after get_onewire_logs() is run)

Type

dict

get_onewire_logs() None[source]

Reads oneWire logs from TLC cross-mount and updates internal dataframe

get_values(sensors: Union[numpy.typing._array_like._SupportsArray[numpy.dtype], numpy.typing._nested_sequence._NestedSequence[numpy.typing._array_like._SupportsArray[numpy.dtype]], bool, int, float, complex, str, bytes, numpy.typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]], fieldname: bool = False, exact: bool = False) Dict[str, float][source]

Get sensor values

Parameters
  • sensors (ArrayLike) – Sensors to query

  • fieldname (bool) – Treat the inputs as exact GMB field names rather than descriptions. Defaults False. If True, matching is exact on the full field name.

  • exact (bool) – Only match exact descriptions rather than searching for all matches. Defaults False

Returns

Dictionary of field description:sensor value key:value pairs. All values will be floats.

Return type

dict

Notes:

query_onewire_logs(names: Union[numpy.typing._array_like._SupportsArray[numpy.dtype], numpy.typing._nested_sequence._NestedSequence[numpy.typing._array_like._SupportsArray[numpy.dtype]], bool, int, float, complex, str, bytes, numpy.typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]], before: Optional[str] = None, after: Optional[str] = None, last_hours: Optional[float] = None, force_update: bool = False) Dict[str, numpy.ndarray[Any, numpy.dtype[numpy.float64]]][source]

Retrieve data from oneWire logs

Parameters
  • names (str or list or numpy.array) – Names or search patterns of sensors to retrieve. For full list of names see sensors.onewire_keys.keys()

  • before (str or None) – Return data before this date/time. Can be: “YYYY-MM-DD” or “YYYY-MM-DD hh:mm:ss”

  • after (str or None) – Return data after this date time. Can be: “YYYY-MM-DD” or “YYYY-MM-DD hh:mm:ss”

  • last_hours (float or None) – Query data from the last last_hours. If set, before and after are ignored.

  • force_update (bool) – If True, re-read log data, even if it has already been loaded. Defaults False

Note

The names input can be an exact sensor name as found in sensors.onewire_keys.keys() or a case insensitive part of the name, or any valid regular expression. For example, input ccr will match sensors CCR Body temperature, IFS CCR Glycol Output Temp, IFS CCR Glycol Input Temp while input ccr.*body will match only CCR Body temperature.

update_sensor_list() None[source]

Query TLC for all oneWire fields with values and descriptions and update sensor list on disk.

Warning

Write permissions required to the gpilib2 install directory. This is intended for use only in developer installations and only during integration.

gpilib2.shutters module

class gpilib2.shutters.gpi_shutter(rpc: gpilib2.rpc.rpc, binary: str, move_cmd: int, default_cmd_args: List[str], cmd_args_index: int, move_gmb_field: str, curr_state_gmb_field: str, name: str, server: str = 'tlc')[source]

Bases: gpilib2.generic_gpi_component.generic_gpi_component

GPI shutter

Parameters
  • rpc (rpc) – rpc object. sim status and verbosity will be set based on its settings.

  • binary (str) – binary name

  • move_cmd (int) – Command number in binary to use

  • default_cmd_args (list) – Default argument sets to use for inits and datums and sims

  • cmd_args_index (int) – Index in default command list where actual shutter comand goes

  • move_gmb_field (str) – GMB field prefix corresponding to the move command

  • curr_state_gmb_field (str) – GMB field of current shutter state

  • name (str) – Name of this shutter

  • server (str) – Server address to send commands to.

rpc

rpc object for communications

Type

rpc

server

Server address to send commands to.

Type

str

binary

binary name

Type

str

move_cmd

Command number in binary to use

Type

int

default_cmd_args

Default argument sets to use for inits and datums and sims

Type

list

cmd_args_index

Index in default command list where actual shutter comand goes

Type

int

move_gmb_field

GMB field prefix corresponding to the move command

Type

str

curr_state_gmb_field

GMB field of current shutter state

Type

str

name

Name of this shutter

Type

str

close(queue: bool = False) None[source]

Open a shutter

Parameters

queue (bool) – If True, queue command rather than executing.

move(state: Union[List[int], int], queue: bool = False) None[source]

Shutter move command

Parameters
  • state (int or [int, int]) – 0 for close, 1 for open. The list input is for toggling both E/E or ref/sci shutters at the same time.

  • queue (bool) – If True, queue command rather than executing.

open(queue: bool = False) None[source]

Open a shutter

Parameters

queue (bool) – If True, queue command rather than executing.

class gpilib2.shutters.shutters(rpc: gpilib2.rpc.rpc)[source]

Bases: gpilib2.generic_gpi_assembly.generic_gpi_assembly

All GPI shutters

Parameters

rpc (rpc) – rpc object. sim status and verbosity will be set based on its settings.

rpc

rpc object for communications

Type

rpc

omss_shutter

OMSS shutter

Type

gpi_shuter

cal_entr

cal entrance shutter

Type

gpi_shutter

cal_exit

cal exit shutter

Type

gpi_shutter

cal_ref

cal reference leg shutter

Type

gpi_shutter

cal_sci

cal science leg shutter

Type

gpi_shutter

components

List of all shutter objects. Because the CAL Entrance/Exit and Ref/Sci shutters are paired for all inits, sims and datums, only one of each is included.

Type

list

move(omss: Optional[str] = None, entrance: Optional[str] = None, exit: Optional[str] = None, ref: Optional[str] = None, sci: Optional[str] = None, queue: bool = False) None[source]

MOVE command for all shutters

Parameters
  • omss (str or None) – OMSS setting (‘open’ or ‘close’) or None to leave as is.

  • entrance (str or None) – CAL entrance setting (‘open’ or ‘close’) or None to leave as is.

  • exit (str or None) – CAL exit setting (‘open’ or ‘close’) or None to leave as is.

  • ref (str or None) – CAL reference setting (‘open’ or ‘close’) or None to leave as is.

  • sci (str or None) – CAL science setting (‘open’ or ‘close’) or None to leave as is.

  • queue (bool) – If True, queue command rather than executing.

Note

All string inputs are case insensitive.

gpilib2.source module

class gpilib2.source.asu(rpc: gpilib2.rpc.rpc, server: str = 'tlc')[source]

Bases: gpilib2.source.source_component

Artificial Source Unit

deploy(sc_att: Optional[float] = None, queue: bool = False) None[source]

Utility wrapper around MOVE command

Parameters
  • sc_att (number or None) – Supercontinuum source attenutation (2.2 to 60). Retain current value if None. If not None, set power to 100.

  • queue (bool) – If True, queue command rather than executing.

Warning

Setting an attenuation automatically sets sc power to 100%. If you want finer control over what is happening, use the move method instead.

extract(queue: bool = False) None[source]

Utility wrapper around MOVE command

Parameters

queue (bool) – If True, queue command rather than executing.

Warning

This will extract the asu and set the supercontinuum power to 0 and attenuation to 60 dB. If you want finer control over what is happening, use the move method instead.

move(asu_pos: Optional[Union[str, List[float]]] = None, sc_pow: Optional[float] = None, sc_att: Optional[float] = None, rel: bool = False, ir_on: Optional[bool] = None, vis_on: Optional[bool] = None, queue: bool = False) None[source]

ASU MOVE command

Parameters
  • asu_pos (str or list or None) – ‘in’, ‘out’, ‘cal_bore’, ‘omss_bore’ or 2-element list of [Y,X] motor positions. Current position retained if None. If string, case insensitive

  • sc_pow (number or None) – Supercontinuum source power (0 to 100). Retain current value if None.

  • sc_att (number or None) – Supercontinuum source attenutation (2.2 to 60). Retain current value if None.

  • rel (bool) – Treat pos inputs as relative to current position (ignored if pos is str or None). Default False.

  • ir_on (bool or None) – Turn on ir laser is True, turn off if False, and retain current state if None.

  • vis_on (bool or None) – Turn on ir laser is True, turn off if False, and retain current state if None.

  • queue (bool) – If True, queue command rather than executing.

Returns

None

Warning

Careful! The override position order is Y, X. Y in this case is the long (deploy/extract) axis, while X is the orthogonal direction.

class gpilib2.source.cal_sphere(rpc: gpilib2.rpc.rpc, server: str = 'tlc')[source]

Bases: gpilib2.source.source_component

CAL Sphere

deploy(sphere_att: Optional[float] = None, queue: bool = False) None[source]

Utility wrapper around MOVE command

Parameters
  • sphere_att (number or None) – CAL sphere attenutation (2.2 to 60). Retain current value if None.

  • queue (bool) – If True, queue command rather than executing.

extract(queue: bool = False) None[source]

Utility wrapper around MOVE command

Parameters

queue (bool) – If True, queue command rather than executing.

Warning

This will extract the cal sphere and set the attenuation to 60 dB. If you want finer control over what is happening, use the move method instead.

move(sphere_pos: Optional[Union[str, float]] = None, sphere_att: Optional[float] = None, rel: bool = False, queue: bool = False) None[source]

CAL Spere MOVE command

Parameters
  • sphere_pos (str or number or None) – ‘in’, ‘out’ or override position value (number). Current position retained if None. If string, case insensitive

  • sphere_att (number or None) – Sphere attenutation (2.2 to 60). Retain current value if None.

  • rel (bool) – Treat pos input as relative to current position (ignored if pos is str or None). Default False.

  • queue (bool) – If True, queue command rather than executing.

Returns

None

class gpilib2.source.source(rpc: gpilib2.rpc.rpc)[source]

Bases: gpilib2.generic_gpi_assembly.generic_gpi_assembly

All GPI sources (everything in source assembly other than OMSS shutter)

Parameters

rpc (rpc) – rpc object. sim status and verbosity will be set based on its settings.

rpc

rpc object for communications

Type

rpc

asu

asu object

Type

asu

cal_sphere

sphere object

Type

cal_sphere

components

List of ASU and CAL_SPHERE (in that order)

Type

list

move(asu_pos: Optional[Union[str, List[float]]] = None, sc_pow: Optional[float] = None, sc_att: Optional[float] = None, rel: bool = False, ir_on: Optional[bool] = None, vis_on: Optional[bool] = None, sphere_pos: Optional[Union[str, float]] = None, sphere_att: Optional[float] = None, queue: bool = False) None[source]

Source MOVE command

Parameters
  • asu_pos (str or list or None) – ‘in’, ‘out’, ‘cal_bore’, ‘omss_bore’ or 2-element list of [Y,X] motor positions. Current position retained if None. If string, case insensitive

  • sc_pow (number or None) – Supercontinuum source power (0 to 100). Retain current value if None.

  • sc_att (number or None) – Supercontinuum source attenutation (2.2 to 60). Retain current value if None.

  • rel (bool) – Treat pos inputs as relative to current position (ignored if pos is str or None). Default False.

  • ir_on (bool or None) – Turn on ir laser is True, turn off if False, and retain current state if None.

  • vis_on (bool or None) – Turn on ir laser is True, turn off if False, and retain current state

  • sphere_pos (str or number or None) – ‘in’, ‘out’ or override position value (number). Current position retained if None. If string, case insensitive

  • sphere_att (number or None) – Sphere attenutation (2.2 to 60). Retain current value if None. if None.

  • queue (bool) – If True, queue commands rather than executing.

Returns

None

Warning

The rel input will be applied to both ASU and CAL SPHERE moves. If you wish to have more granular control, use the move methods on the two sub-classes individualls.

class gpilib2.source.source_component(rpc: gpilib2.rpc.rpc, binary: str, move_cmd: int, default_cmd_args: List[str], move_gmb_field: str, curr_state_gmb_field: str, name: str, motor_position_gmb_fields: List[str], server: str = 'tlc', mcd_name: Optional[Union[numpy.typing._array_like._SupportsArray[numpy.dtype], numpy.typing._nested_sequence._NestedSequence[numpy.typing._array_like._SupportsArray[numpy.dtype]], bool, int, float, complex, str, bytes, numpy.typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]]] = None)[source]

Bases: gpilib2.generic_gpi_component.generic_gpi_component

Base class for ASU and CAL_SPHERE

Parameters
  • rpc (rpc) – rpc object. sim status and verbosity will be set based on its settings.

  • binary (str) – binary name

  • move_cmd (int) – Command number in binary to use

  • default_cmd_args (list) – Default argument sets to use for inits and datums and sims

  • move_gmb_field (str) – GMB field prefix corresponding to the move command

  • curr_state_gmb_field (str) – GMB field of current state of component

  • name (str) – Component name

  • motor_position_gmb_fields (list) – GMB fields with current filterwheel/slide position values. Must be in the same order as these arguments are passed to the move command.

  • server (str) – Server address to send commands to.

  • mcd_name (ArrayLike, optional) – Label(s) of MCD axis for this component. If None (default), assume that device is not on an MCD.

rpc

rpc object for communications

Type

rpc

server

Server address to send commands to.

Type

str

binary

binary name

Type

str

move_cmd

Command number in binary to use

Type

int

default_cmd_args

Default argument sets to use for inits and datums and sims

Type

list

move_gmb_field

GMB field prefix corresponding to the move command

Type

str

curr_state_gmb_field

GMB field of current state of component

Type

str

name

Component name

Type

str

motor_position_gmb_fields

GMB fields with current filterwheel/slide position values. Must be in the same order as these arguments are passed to the move command.

Type

list

mcd_name

Label(s) of MCD axis/axes for this component. If None, assume that device is not on an MCD.

Type

ndarray(str), optional

mcd_inds

Indices of entries in mcdaxisnames corresponding to the entries of mcd_name. None if mcd_name is None.

Type

ndarray(int), optional

gpilib2.util module

gpilib2.util.get_tlc_bindir() str[source]

Return TLC binary directory

Parameters

None

Returns

Full path to binary directory

Return type

str

Note

If environment variable $TLC_BIN_DIR is set, then that will be used. Otherwise the default is $TLC_ROOT/bin/linux64

gpilib2.util.get_tlc_configdir() str[source]

Return TLC config directory

Parameters

None

Returns

Full path to config directory

Return type

str

Note

If environment variable $TLC_CONFIG_DIR is set, then that will be used. Otherwise the default is $TLC_ROOT/config

gpilib2.util.get_tlc_logdir() str[source]

Return TLC log directory

Parameters

None

Returns

Full path to config directory

Return type

str

Note

If environment variable $TLC_LOG_DIR is set, then that will be used. Otherwise the default is $TLC_ROOT/log

gpilib2.util.get_tlc_root() str[source]

Return the TLC_ROOT directory

Parameters

None

Returns

Full path to TLC_ROOT directory

Return type

str

Note

Environment variable $TLC_ROOT must be set.

gpilib2.util.gpilib2_data_dir(indir: Optional[str] = None) str[source]

Returns the full path to the gpilib2 data directory

Order of selection priority is:

  1. Input (indir)

  2. Environment variable (GPILIB2_DATA_DIR)

  3. Default ($HOME/gpilib2_data)

Parameters

indir (str or None) – Full path to data directory. Environment variables allowed.

Returns

Full absolute path to data directory

Return type

str

Note

If path does not exist, it will be created. Path must have read/write/access permissions.

gpilib2.util.validate_directory(outdir: str, perms: Optional[str] = None, mkdir: bool = True, mode: Optional[int] = None) None[source]

Ensure that a directory exists and has proper permissions. Attempt to create if it doesn’t.

Parameters
  • outdir (str) – Full path to directory

  • perms (str or None) – Required permissions. Any combination of ‘r’, ‘w’, ‘x’.

  • mkdir (bool) – Attempt to create direcotry if it exists. Defaults True.

  • mode (int or None) – Apply this mode setting to any newly created directories. Ignored if mkdir is False and when None.

Returns

None

Note

The reason why we use os.chmod rather than sending the mode directly to os.mkdir is that the latter will ignore mode settings in the presence of a conflicting umask. Doing it this way ensures that permissions are actually properly set. Remember that the mode is octal. For 777 you want input 0o777.

Module contents