hardware_interfaces.triax module¶
Name:
triax - various functions for TRIAX spectrometer control
Description:
This module provides the class Triax to control TRIAX spectrometers over RS232 to the extent that was used in the original mess.frm Visual Basic Script.
This is therefore NOT (yet) a complete implementation of the entire interface as given in the doc, since the other command were apparently not needed.
Warning
When the spectrometer looses power unexpectedly during operation, normal init may fail. It seems that the communications buffer must be cleared first, and the new init procedure does just that. It has not yet been tested though.
Classes:
Triax
-
main()¶ For testing purposes: establish communication and read current state
Versions:
200322 - initial commit, Georg Wille
References
Spectrometer_control_interfacing_programming_manual.pdf
-
class
Triax(hwconfig=None, port: str = 'COM1', turret: str = 'default', gamma: float = - 9.984, d: float = 30.0, f: float = 190.0, w: float = 2.0, step_slit: float = 2.0, pixel_pitch=0.25, pixel_number=64, pixel_center=32, tgratings: Optional[list] = None, init=False, baudrate: int = 19200, bytesize=8, parity='N', stopbits=1, timeout=1.0, xonxoff=True)[source]¶ Bases:
objectRepresents a Triax spectrometer connected via serial port.
By default, object instantiation only tries to set up communication and, if successful, read out the current state. Hardware initialization has to be requested by parameter or performed separately afterwards.
The following attributes have a method for setting them via a set_xxx method, all others are derived from there:
grating
slit
wavelength
wavenumber
- Parameters
hwconfig (hwconfig object) – object provided by hardware properties module, containing all hardware information. IF SPECIFIED, THIS SUPERSEDES ALL EXPLICITLY GIVEN SPECTROMETER AND MCT PARAMETERS.
port (str, optional) – serial port name. Defaults to ‘COM1’
turret (str, optional) – turret name. Defaults to “default”. Purely decorative.
gamma (float, optional) – angle (degrees) between normal of center wavelength beam and focal plane. Defaults to -9.984
d (float, optional) – angle (degrees) between entrance and exit arm, fixed for given spectrometer geometry. Defaults to 30.0
f (float, optional) – focal length (mm). Defaults to 190.0
w (float, optional) – entrance slit width (mm) solely for calculating the wavelength axis. Defaults to 2
step_slit (float, optional) – factor for conversion of slit motor position to true slit width. slit width = step_slit * slit position. Defaults to 2.0
pixel_pitch (float, optional) – center-to-center distance of MCT pixels (mm). Defaults to 0.25
pixel_number (int, optional) – number of pixels per line. Defaults to 64.
pixel_center (int, optional) – index of pixel that gets the central wavelength. Defaults to 32.
tgratings (list, optional) – lines/mm for gratings in positions 0,1,2 of current turret. Defaults to [300., 150., 100.]
init (bool, optional) – immediate hardware init. Defaults to False
baudrate (int, optional) – baud rate. Defaults to 19200
bytesize (optional) – data bits. Defaults to serial.EIGHTBITS
parity (optional) – parity bit. Defaults to serial.PARITY_NONE
stopbits (optional) – number of stop bits. Defaults to serial.STOPBITS_ONE
timeout (float, optional) – timeout in seconds. Defaults to 1.0
xonxoff (bool, optional) – enable software flow control. Defaults to True
-
ser¶ serial port connection object
-
is_connected¶ spectrometer is properly communicating
- Type
bool
-
grating¶ current grating (one of 0, 1, 2)
- Type
int
-
gr_line_density¶ current grating line density in lines/mm
- Type
float
-
slit¶ current slit width in µm
- Type
float
-
slit_pos¶ current slit position in motor steps
- Type
int
-
wavelength¶ current true central wavelength in nm
- Type
float
-
wavelength_base¶ current central wavelength in nm w.r.t to base grating of 1200 l/mm
- Type
float
-
wavenumber¶ current central wavenumber in cm-1
- Type
float
-
wn_axis¶ list of wavenumbers in cm-1 on each detector pixels, length of list depending on pixel number from hardware setting
- Type
ndarray
-
wl_axis¶ list of wavelengths in nm on each detector pixels, length of list depending on pixel number from hardware setting
- Type
ndarray
-
turret¶ current turret
- Type
str
-
tgratings¶ lines/mm for gratings in positions 0,1,2 of current turret.
- Type
list
-
step_slit¶ factor for conversion of slit motor position to true slit width. slit width = step_slit * slit position
- Type
float
-
gamma¶ angle (degrees) between normal of center wavelength beam and focal plane
- Type
float
-
d¶ angle (degrees) between entrance and exit arm, fixed for given spectrometer geometry
- Type
float
-
f¶ focal length (mm)
- Type
float
-
w¶ entrance slit width (mm) for wavelength axis calculation
- Type
float
-
pixel_pitch¶ center-to-center distance of MCT pixels (mm)
- Type
float
-
pixel_number¶ number of pixels per line
- Type
int
-
pixel_center¶ index of pixel that gets the central wavelength
- Type
int
-
MAX_WAVELENGTH= 20000.0¶
-
MIN_WAVELENGTH= 2500.0¶
-
__init__(hwconfig=None, port: str = 'COM1', turret: str = 'default', gamma: float = - 9.984, d: float = 30.0, f: float = 190.0, w: float = 2.0, step_slit: float = 2.0, pixel_pitch=0.25, pixel_number=64, pixel_center=32, tgratings: Optional[list] = None, init=False, baudrate: int = 19200, bytesize=8, parity='N', stopbits=1, timeout=1.0, xonxoff=True)[source]¶ Initializes new spectrometer object instance and establish communication.
-
cli(init=False)[source]¶ Implements a tiny command line interface for TRIAX access
- Parameters
init (Boolean, optional) – call init procedure first? Defaults to False.
-
exit_click()[source]¶ If no collection is running: closes COM port and moves motors 1 and 2 to position 0.
-
set_grating(new_grating: int)[source]¶ Changes to the given grating position.
Sets the current turret to one of its three positions. Instance attributes grating and gr_line_density will be changed accordingly. If an error occurs, these will be set to None.
- Parameters
new_grating (int) – 0, 1 or 2
-
set_slit(new_slit: float)[source]¶ Changes slit width.
Sets the slit to the new width. Instance attributes slit and slit_pos will be changed accordingly. If an error occurs, these will be set to None.
- Parameters
new_slit (float) – new slit width in micrometers
-
set_wavelength(new_wavelength)[source]¶ Changes central wavelength.
Sets the central wavelength to the new value. Instance attributes wavelength, wavelength_base, wavenumber, wn_axis and wl_axis will be set accordingly. If an error occurs, these will be set to None.
See also
set_wavenumber
- Parameters
new_wavelength (float) – new central wavelength in nm