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.
- TuneMode: 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.tune.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:
-
system(System) –Container for system-wide non-functional attributes of the laser.
-
tec(TEC) –The TEC component of the laser.
-
cpu(CPU) –The temperature sensor in the CPU of the laser module.
-
pd1(PhotoDiode) –PhotoDiode 1 of laser. (Channel 0)
-
pd2(PhotoDiode) –PhotoDiode 2 of laser. (Channel 1)
-
enclosure(EnclosureTemp) –Temperature sensor of laser module enclosure.
-
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.comm.list_comportsmethod from thecommmodule. -
calibration_file(str | Path, default:None) –The path to the calibration file that was provided for the laser.
-
Package Reference
Documentation Of PyChilasLasers Library
pychilaslasers - PyChilasLasers Quickstart Guide
Source code in src/pychilaslasers/laser.py
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 140 141 142 143 144 145 146 147 148 149 150 | |
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.TUNE - LaserMode.SWEEP
tune: TuneMode
property
Getter function for the tune mode instance.
This property allows access to the tune mode instance of the laser in a
convenient way such as laser.tune.method(). Tune 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 tune mode instance if the laser is in that mode. To switch to tune
mode, use laser.mode = LaserMode.TUNE or laser.set_mode("tune")
first.
Returns:
-
TuneMode–The tune mode instance with access to wavelength control methods.
Raises:
-
ModeError–If the laser is not in tune mode.
Example
>>> laser.mode = LaserMode.TUNE
>>> laser.tune.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.
calibration: Calibration | None
property
writable
Get the current calibration object.
Returns:
-
Calibration | None–Calibration | None: The current calibration object if available, None otherwise.
system: System
property
Container for some informational attributes of the laser.
Functions
trigger_pulse() -> None
Instructs the laser to send a trigger pulse.
Source code in src/pychilaslasers/laser.py
154 155 156 157 | |
calibrate(calibration_file: str | Path | None = None, calibration_object: Calibration | None = None) -> None
Calibrates the laser with the given calibration file or calibration object.
This method configures the laser with calibration data, enabling tune mode and sweep mode (for COMET lasers). Exactly one of calibration_file or calibration_object must be provided.
Parameters:
-
calibration_file(str | Path | None, default:None) –The path to the calibration file to be used for calibrating the laser. Defaults to None.
-
calibration_object(Calibration | None, default:None) –A preloaded calibration object to be used for calibrating the laser. Defaults to None.
Raises:
-
KeyError–If both calibration_file and calibration_object are provided, or if neither is provided.
Source code in src/pychilaslasers/laser.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | |
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
539 540 541 542 543 544 | |
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
546 547 548 549 550 551 | |
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
553 554 555 556 557 558 | |