Laser
pychilaslasers.laser
Define the Laser class for Chilas lasers.
This acts as the main interface for controlling the laser. Some properties and methods of the laser are accessible at all times, while others are only available in specific operation modes.
The modes of the laser are:
- ManualMode: Allows manual control of the heater values.
- SteadyMode: Can be used to tune the laser to specific wavelengths according to the calibration data.
- SweepMode: Sweep mode is used for COMET lasers to enable the sweep functionality.
Changing the diode current or TEC temperature of the laser is available in all modes however this implies that the calibration of the laser is no longer valid and the laser may not achieve the desired wavelength.
Authors: RLK, AVR, SDU
pychilaslasers.Laser(com_port: str, calibration_file: str | Path | None = None)
Laser class for Chilas lasers.
Contains the main methods for communication with the laser, the logic for changing and accessing the laser modes, and the properties of the laser. Multiple overloaded methods are available to interact with the laser. Many of the methods are overloads of other methods that either provide different ways do the same operation for convenience.
Usage
Accessing functionality of a specific mode is done through the mode
property
such as laser.steady.method_name()
or laser.sweep.method_name()
. This will
however only work if the laser is in the correct mode. If the laser is not in
the correct mode, an exception will be raised. The current mode of the laser
can be set using the mode
property as well.
The laser can be turned on and off using the system_state
property. The laser
can also be triggered to pulse using the trigger_pulse()
method. The laser
can be set to prefix mode using the prefix_mode
property. The prefix mode can
be used to speed up communication with the laser by reducing the amount of data
sent over the serial connection however this reduces the amount of information
that is sent back from the laser.
Some laser components such as the TEC and Diode can be accessed in all modes
using the tec
and diode
properties respectively. Other components are only
available in manual mode.
Attributes:
-
tec
(TEC
) –The TEC component of the laser.
-
diode
(Diode
) –The Diode component of the laser.
-
mode
(Mode
) –The current mode of the laser.
-
system_state
(bool
) –The system state of the laser (on/off).
-
prefix_mode
(bool
) –Whether the laser is in prefix mode or not.
Opens the serial connection to the laser, initializes the laser components and variables, and sets the initial mode to manual.
Warning
During the initialization, the laser will turn on and communicate over the serial connection to gather necessary information about the laser and its components such as maximum values for parameters.
Parameters:
-
com_port
(str
) –The COM port to which the laser is connected. This should be a string such as "COM7". To see available COM you may use the
pychilaslasers.utils.list_comports
method from theutils
module. -
calibration_file
(str | Path
, default:None
) –The path to the calibration file that was provided for the laser.
Source code in src/pychilaslasers/laser.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
|
Attributes
comm: Communication
property
Communication object for the laser.
This property provides access to the communication object used to interact with the laser. It can be used to send commands and queries to the laser.
Returns:
-
Communication
–The communication object for the laser.
system_state: bool
property
writable
System state of the laser.
The property of the laser that indicates whether the laser is on or off. This is a boolean property that can be set to True to turn on the laser or False to turn it off.
Returns:
-
bool
–The system state. Whether the laser is on (True) or off (False).
mode: LaserMode
property
writable
Gets the current mode of the laser.
Returns:
-
LaserMode
–The current mode of the laser. This can be one of the following: - LaserMode.MANUAL - LaserMode.STEADY - LaserMode.SWEEP
steady: SteadyMode
property
Getter function for the steady mode instance.
This property allows access to the steady mode instance of the laser in a
convenient way such as laser.steady.method()
. Steady mode uses calibration
data to tune the laser to specific wavelengths with high precision. This mode
is available for both COMET and ATLAS lasers and provides wavelength control
based on the laser's calibration file.
Warning
This method will not change the mode of the laser, it will only return
the steady mode instance if the laser is in that mode. To switch to steady
mode, use laser.mode = LaserMode.STEADY
or laser.set_mode("steady")
first.
Returns:
-
SteadyMode
–The steady mode instance with access to wavelength control methods.
Raises:
-
ModeError
–If the laser is not in steady mode.
Example
>>> laser.mode = LaserMode.STEADY
>>> laser.steady.set_wavelength(1550.0) # Set wavelength to 1550nm
sweep: SweepMode
property
Getter function for the sweep mode instance.
This property allows access to the sweep mode instance of the laser in a convenient way
such as laser.sweep.method()
. Sweep mode is only available for COMET lasers and
enables sweeping functionality for wavelength scanning applications. This mode uses
calibration data to perform controlled wavelength sweeps across specified ranges.
Warning
This method will not change the mode of the laser, it will only return
the sweep mode instance if the laser is in that mode. To switch to sweep mode,
use laser.mode = LaserMode.SWEEP
or laser.set_mode("sweep")
first.
Returns:
-
SweepMode
–The sweep mode instance with access to sweep control methods.
Raises:
-
ModeError
–If the laser is not in sweep mode or sweep mode is not available.
Example
>>> laser.mode = LaserMode.SWEEP # Only works for COMET lasers
>>> laser.sweep.start_wavelength_sweep(1550.0, 1560.0) # Sweep from 1550nm to 1560nm
manual: ManualMode
property
Getter function for the manual mode instance.
This property allows access to the manual mode instance of the laser in a
convenient way such as laser.manual.method()
. Manual mode is always available
and is the default mode. In manual mode, you have direct control over individual
laser components and can manually set heater values and other parameters.
Warning
This method will not change the mode of the laser, it will only return
the manual mode instance if the laser is in that mode. To switch to manual
mode, use laser.mode = LaserMode.MANUAL
or laser.set_mode("manual")
first.
Returns:
-
ManualMode
–The manual mode instance with access to manual control methods.
Raises:
-
ModeError
–If the laser is not in manual mode.
Example
>>> laser.mode = LaserMode.MANUAL
>>> laser.manual.set_heater_value(50.0) # Set heater to 50%
model: str
property
Return the model of the laser.
Returns:
-
str
–The model of the laser. May be "COMET" or "ATLAS"
calibrated: bool
property
Check if the laser is calibrated.
Returns:
-
bool
–True if the laser has calibration data, False otherwise.
Functions
trigger_pulse() -> None
Instructs the laser to send a trigger pulse.
Source code in src/pychilaslasers/laser.py
143 144 145 146 |
|
calibrate(calibration_file: str | Path) -> None
Calibrates the laser with the given calibration file.
Parameters:
-
calibration_file
(str | Path
) –The path to the calibration file to be used for calibrating the laser.
Source code in src/pychilaslasers/laser.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
|
set_mode(mode: LaserMode | Mode | str) -> None
Set the mode of the laser.
This is an alias for the mode
property setter.
Source code in src/pychilaslasers/laser.py
453 454 455 456 457 458 |
|
turn_on() -> None
Turn on the laser.
This is an alias for setting the system state to True.
Source code in src/pychilaslasers/laser.py
460 461 462 463 464 465 |
|
turn_off() -> None
Turn off the laser.
This is an alias for setting the system state to False.
Source code in src/pychilaslasers/laser.py
467 468 469 470 471 472 |
|