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.
- 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
- 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
..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.
- 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.
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.
- 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
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.
- 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
- 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
- mcd_name
Label(s) of MCD axis/axes for this component. If None, assume that device is not on an MCD.
- mcd_inds
Indices of entries in
mcdaxisnames
corresponding to the entries of mcd_name. None if mcd_name is None.
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
andmaskstr
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
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.
- 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
- rpc (
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.
- mcd_name
Label(s) of MCD axis/axes for this component. If None, assume that device is not on an MCD.
- mcd_inds
Indices of entries in
mcdaxisnames
corresponding to the entries of mcd_name. None if mcd_name is None.
- 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
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
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
- powerbars
Powerbars object
- Type
powerbar
- sensors
Sensors object.
- Type
- rpc
rpc object for all communications.
- Type
- coronagraph
Coronagraph object
- Type
- source
Source object
- Type
- shutters
Shutters object
- Type
- pnc
PnC object
- Type
- cameras
- Type
gpilib2.mcds module
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
- dar(val: int) None [source]
Toggle DAR for AO PnCs
- Parameters
val (int) – 0 for off, 1 for on
- Returns
None
- fpm_offsets(val: int) None [source]
Toggle FPM offsetsfor AO PnCs
- Parameters
val (int) – 0 for off, 1 for on
- Returns
None
- 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
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.
- 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
- 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
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.
- 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)
- 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
- 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).
- 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
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
- 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
- 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.
- cal_pnc
apodizer object
- Type
- inputfold
lyot object
- Type
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
- rpc
Pointer to
self.sensors.rpc
. rpc object for all communications.- Type
- pbarre
regex that can extract numerical values from powerbar GMB fieldnames
- Type
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
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
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
- 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__.
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
- verb
Verbosity toggle (can be manually set at any time). If object is created with
sim = True
then verbosity is automatically toggled on.- Type
- command_queue
Command queue. List of tuples of the form
(cmdlist, cmd_gmb_field)
wherecmdlist
is a list of command arguments andcmd_gmb_field
is a string of the base of the command GMB field.- Type
- async assemble_pending_commands(cmdstrs: List[str]) List[Tuple[str, Optional[int], bytes, bytes]] [source]
Dump set of pending commands into a gather
- 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
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
- Returns
Contents of fields.
- Return type
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
- 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
- Returns
Contents of fields.
- Return type
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
- Returns
Contents of fields.
- Return type
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
- 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:
- 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
- Returns
- cmd (str):
Original command string
- returncode (int):
proc.returncode
- stdout (bytes):
stdout bytestream
- stderr (bytes):
stderr bytestream
- Return type
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
- sensornames
Array of all sensor names
- Type
- sensorfields
Array of GMB fields corresponding to sensornames
- Type
- 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
- 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
- Returns
Dictionary of field description:sensor value key:value pairs. All values will be floats.
- Return type
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, inputccr
will match sensorsCCR Body temperature, IFS CCR Glycol Output Temp, IFS CCR Glycol Input Temp
while inputccr.*body
will match onlyCCR Body temperature
.
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.
- close(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.
- omss_shutter
OMSS shutter
- Type
gpi_shuter
- cal_entr
cal entrance shutter
- Type
- cal_exit
cal exit shutter
- Type
- cal_ref
cal reference leg shutter
- Type
- cal_sci
cal science leg shutter
- Type
- 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
- 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.
- cal_sphere
sphere object
- Type
- 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.
- 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
- mcd_name
Label(s) of MCD axis/axes for this component. If None, assume that device is not on an MCD.
- mcd_inds
Indices of entries in
mcdaxisnames
corresponding to the entries of mcd_name. None if mcd_name is None.
gpilib2.util module
- gpilib2.util.get_tlc_bindir() str [source]
Return TLC binary directory
- Parameters
None –
- Returns
Full path to binary directory
- Return type
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
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
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
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:
Input (indir)
Environment variable (GPILIB2_DATA_DIR)
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
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.