Modes
pychilaslasers.modes
PyChilasLasers Modes Module.
Laser modes provide an encapsulation for operations that require common settings and/or cannot be performed together.It includes manual mode for direct control and calibrated modes for steady-state and sweeping operations. The module also defines wavelength change methods and manages the calibration data for different laser models.
Classes:
-
LaserMode
–Enum defining available laser modes
-
Mode
–Abstract base class for all modes
-
ManualMode
–Direct manual control of laser parameters
-
SteadyMode
–Calibrated steady-state wavelength operation
-
SweepMode
–Calibrated sweeping operations
-
_WLChangeMethod
–Abstract base for wavelength change methods
-
_PreLoad
–Preload-based wavelength change method
-
_CyclerIndex
–Cycler index-based wavelength change method
Classes
ManualMode
Bases: Mode
Manual laser control mode for direct heater manipulation.
ManualMode provides unrestricted access to all laser heater channels, allowing users to manually set voltages without calibration constraints. This mode is primarily intended for advanced users, testing, and debugging purposes where precise control over individual components is required at the expense of calibration.
The mode initializes all heater components and provides both individual heater access and a unified interface for driver value setting.
Parameters:
-
laser
(Laser
) –The laser instance to control.
Attributes:
-
heaters
(list[Heater]
) –List of all available heater components.
-
phase_section
(PhaseSection
) –Phase section heater component.
-
large_ring
(LargeRing
) –Large ring heater component.
-
small_ring
(SmallRing
) –Small ring heater component.
-
tunable_coupler
(TunableCoupler
) –Tunable coupler heater component.
Source code in src/pychilaslasers/modes/manual_mode.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 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 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 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 |
|
Attributes
mode: LaserMode
property
Get the laser operation mode.
phase_section: PhaseSection
property
writable
Get the phase section heater.
large_ring: LargeRing
property
writable
Get the large ring heater.
small_ring: SmallRing
property
writable
Get the small ring heater.
tunable_coupler: TunableCoupler
property
writable
Get the tunable coupler.
heaters: list[Heater]
property
Get all heater components as a convenient list.
Alias that provides all individual heater components in a single list.
Returns:
-
list[Heater]
–List containing: 0. phase_section 1. large_ring 2. small_ring 3. tunable_coupler In this order for easy iteration and access.
Functions
__init__(laser: Laser) -> None
Creates all heater component instances. The laser is temporarily turned on during initialization to gather component characteristics.
Parameters:
-
laser
(Laser
) –The laser instance to control.
Source code in src/pychilaslasers/modes/manual_mode.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
|
apply_defaults() -> None
Apply default settings for manual mode operation.
Source code in src/pychilaslasers/modes/manual_mode.py
84 85 86 |
|
set_driver_value(heater_ch: int | HeaterChannel, heater_value: float) -> None
Manually set the voltage value of a specific driver channel.
Provides direct low-level access to set heater voltages without any validation or safety checks. This method bypasses all calibration constraints and allows unrestricted heater control.
Parameters:
-
heater_ch
(int | HeaterChannel
) –The heater channel number or HeaterChannel enum. Valid channels are typically 0-3 for the four main heaters.
-
heater_value
(float
) –The voltage value to set in volts. Range depends on laser specifications and hardware limits.
Warning
This method performs no validation on the input values. Setting inappropriate voltages may result in errors or undefined behavior.
Source code in src/pychilaslasers/modes/manual_mode.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
|
LaserMode
Bases: Enum
Enumeration of laser modes.
Provides an alternative way of referencing modes without using string literals, classes, or instances. This enumeration ensures type safety and consistency throughout the library.
Attributes:
-
MANUAL
–Manual mode for direct component control.
-
SWEEP
–Sweep mode for wavelength scanning (COMET lasers only).
-
STEADY
–Steady mode for precise wavelength control using calibration data.
Source code in src/pychilaslasers/modes/mode.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
|
Mode
Bases: ABC
Abstract base class for laser modes.
This class defines the basic structure and properties that all laser modes should implement. It provides a common interface for interacting with different laser modes, such as manual, sweep, and steady modes.
A laser mode is an abstract operational state of the laser that adds functionality and defines how it behaves, the operations available, and the settings required for its operation.
Source code in src/pychilaslasers/modes/mode.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
|
Attributes
mode: LaserMode
abstractmethod
property
Return the enumeration value identifying this mode type.
Returns:
-
LaserMode
–The enumeration value identifying this mode type.
Functions
__init__(laser: Laser) -> None
Parameters:
-
laser
(Laser
) –The laser instance that owns this mode.
Source code in src/pychilaslasers/modes/mode.py
55 56 57 58 59 60 61 62 63 64 |
|
apply_defaults() -> None
abstractmethod
Apply default settings for the mode.
This method is called when the laser switches to this mode and should configure all mode-specific parameters to their default values.
Source code in src/pychilaslasers/modes/mode.py
68 69 70 71 72 73 74 75 |
|
SteadyMode
Bases: __Calibrated
Steady operation mode of the laser.
SteadyMode allows for tuning to specific wavelengths
The mode supports anti-hysteresis correction to improve wavelength stability and provides convenient methods for wavelength setting and control.
Parameters:
-
laser
(Laser
) –The laser instance to control.
-
calibration
(dict
) –Calibration data dictionary containing steady mode parameters. as returned by the
utils.read_calibration_file
method
Attributes:
-
wavelength
(float
) –Current wavelength setting in nanometers.
-
antihyst
(bool
) –Anti-hysteresis correction enable/disable state.
-
mode
(LaserMode
) –Returns LaserMode.STEADY.
Source code in src/pychilaslasers/modes/steady_mode.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 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 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 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 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
|
Attributes
wavelength: float
property
writable
Get the current wavelength setting.
Returns:
-
float
–Current wavelength in nanometers.
antihyst: bool
property
writable
Get the anti-hysteresis correction state.
Returns:
-
bool
–True if anti-hysteresis correction is enabled, False otherwise.
mode: LaserMode
property
Get the laser operation mode.
Returns:
-
LaserMode
–LaserMode.STEADY indicating steady mode operation.
step_size: float
property
Get the step size between consecutive wavelengths.
Returns:
-
float
–The step size in nanometers between consecutive wavelengths.
Functions
__init__(laser: Laser, calibration: dict) -> None
Parameters:
-
laser
(Laser
) –The laser instance to control.
-
calibration
(dict
) –Calibration data dictionary containing steady mode parameters.
Source code in src/pychilaslasers/modes/steady_mode.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
|
apply_defaults() -> None
Apply default settings for steady mode operation.
Sets the TEC temperature and diode current to their default values as specified in the calibration data.
Source code in src/pychilaslasers/modes/steady_mode.py
94 95 96 97 98 99 100 101 |
|
get_wl() -> float
Get the current wavelength setting.
Alias for the wavelength property getter.
Returns:
-
float
–Current wavelength in nanometers.
Source code in src/pychilaslasers/modes/steady_mode.py
193 194 195 196 197 198 199 200 201 202 |
|
set_wl_relative(delta: float) -> float
Set wavelength relative to current position.
Parameters:
-
delta
(float
) –Wavelength change in nanometers, relative to current wavelength. Positive deltas increase wavelength, negative deltas decrease it.
Returns:
-
float
–The new absolute wavelength that was set.
Raises:
-
ValueError
–If the resulting wavelength is outside the valid range.
Source code in src/pychilaslasers/modes/steady_mode.py
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
|
toggle_antihyst(state: bool | None = None) -> None
Toggle the anti-hysteresis correction state.
Parameters:
-
state
(bool | None
, default:None
) –Optional explicit state to set. If None, toggles current state. True enables anti-hysteresis, False disables it.
Source code in src/pychilaslasers/modes/steady_mode.py
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
|
SweepMode
Bases: __Calibrated
Manages laser wavelength sweep operations.
SweepMode allows the laser to continuously cycle through a range of wavelengths with custom range, intervals, and repetition settings.
Warning
The sweep operates from high wavelengths to low wavelengths. This means the start wavelength should be the maximum (highest) wavelength and the end wavelength should be the minimum (lowest) wavelength in your desired range.
Parameters:
-
laser
(Laser
) –The laser instance to control.
-
calibration
(dict
) –Calibration data dictionary containing sweep mode parameters as returned by the
utils.read_calibration_file
method.
Attributes:
-
wavelength
(float
) –Current wavelength setting.
-
start_wavelength
(float
) –of the sweep range in nanometers.
-
end_wavelength
(float
) –of the sweep range in nanometers.
-
interval
(int
) –Time interval between wavelength steps in microseconds.
-
number_sweeps
(int
) –Number of sweep cycles to perform (0 for infinite).
-
mode
(LaserMode
) –Returns LaserMode.SWEEP.
Raises:
-
ValueError
–If laser model is not compatible with sweep mode.
Source code in src/pychilaslasers/modes/sweep_mode.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 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 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 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 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 |
|
Attributes
mode: LaserMode
property
Get the laser operation mode.
Returns:
-
LaserMode
(LaserMode
) –LaserMode.SWEEP indicating this is a sweep mode instance.
wavelength: float
property
Get the current wavelength from the laser.
Returns:
-
float
–The wavelength corresponding to the current wavelength in nanometers.
Note
Queries the laser hardware for the current position and maps it to the corresponding wavelength in the calibration table.
Warning
Depending on the interval, this value may have changed by the time it is retrieved due to the continuous sweeping operation.
interval: int
property
writable
Get the current interval setting.
Returns:
-
int
–The time interval between wavelength steps in milliseconds.
number_sweeps: int
property
writable
Get the configured number of sweep cycles.
Returns:
-
int
–The number of sweep cycles configured. 0 indicates infinite sweeps.
range: tuple[float, float]
property
writable
Get the current wavelength sweep range.
Returns:
-
tuple[float, float]
–A tuple containing (start_wavelength, end_wavelength) where start_wavelength is the higher value and end_wavelength is the lower value, reflecting the high-to-low sweep direction.
step_size: float
property
Get the step size between consecutive wavelengths in the sweep range.
Returns:
-
float
–The step size in nanometers between consecutive wavelengths in the sweep range.
cycler_running: bool
property
Indicates if the cycler is currently running.
Returns:
-
bool
–if the cycler is running
start_wavelength: float
property
writable
Get the start wavelength of the current sweep range.
Alias for get_range
result extraction for convenience.
Returns:
-
float
–The wavelength at the start of the current sweep range in nanometers.
end_wavelength: float
property
writable
Get the end wavelength of the current sweep range.
Alias for get_range
result extraction for convenience.
Returns:
-
float
–The wavelength at the end of the current sweep range in nanometers.
Functions
__init__(laser: Laser, calibration: dict) -> None
Parameters:
-
laser
(Laser
) –The laser instance to control.
-
calibration
(dict
) –Calibration data dictionary containing sweep mode parameters. This should be the full calibration dictionary as returned by
utils.read_calibration_file
.
Raises:
-
ValueError
–If laser model is not COMET or calibration is invalid.
Source code in src/pychilaslasers/modes/sweep_mode.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
|
apply_defaults() -> None
Apply default settings for sweep mode operation.
Sets the laser to the default TEC temperature, diode current, full wavelength range and interval.
Source code in src/pychilaslasers/modes/sweep_mode.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
|
start(number_sweeps: int | None = None) -> None
Start the wavelength sweep operation.
Initiates the sweep operation with the configured number of cycles. The laser will begin cycling through the wavelength range according to the current range and interval settings.
Source code in src/pychilaslasers/modes/sweep_mode.py
117 118 119 120 121 122 123 124 125 126 127 |
|
stop() -> None
Stop the current wavelength sweep operation.
Immediately halts the sweep operation. The laser will remain at its
current wavelength position. Use resume
to continue the sweep
from where it was stopped.
Source code in src/pychilaslasers/modes/sweep_mode.py
129 130 131 132 133 134 135 136 |
|
resume() -> None
Resume a paused wavelength sweep operation.
Resumes a sweep operation that was previously stopped using the
stop
method. The sweep will continue from its current position
with the same configuration settings.
Source code in src/pychilaslasers/modes/sweep_mode.py
138 139 140 141 142 143 144 145 |
|
get_total_time() -> float
Calculate the total estimated time for the complete sweep operation.
Returns:
-
float
–The estimated total time for the sweep in microseconds, based on the current interval, number of wavelength points, and number of sweep cycles. Returns 0.0 if number of sweeps is 0 (infinite sweeps).
Source code in src/pychilaslasers/modes/sweep_mode.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
|
get_points() -> list[float]
Get all wavelength points within the current sweep range.
Returns:
-
list[float]
–List of wavelengths that will be swept through during operation, including both the lower and upper wavelengths.
Source code in src/pychilaslasers/modes/sweep_mode.py
162 163 164 165 166 167 168 169 170 171 172 173 |
|
set_count(count: int) -> None
Alias for the number_sweeps
property setter.
Parameters:
-
count
(int
) –Number of sweeps to perform. Set to 0 for infinite sweeps.
Raises:
-
ValueError
–If count is negative or not an integer.
Source code in src/pychilaslasers/modes/sweep_mode.py
370 371 372 373 374 375 376 377 378 379 380 |
|
get_wl() -> float
Alias for the wavelength
property getter for convenience.
Returns:
-
float
–Current wavelength in nanometers.
Source code in src/pychilaslasers/modes/sweep_mode.py
382 383 384 385 386 387 388 389 |
|
set_interval(interval: int) -> None
Alias for the interval
property setter.
Parameters:
-
interval
(int
) –Time interval between wavelength steps in microseconds. Must be a positive integer between 20 and 50 000.
Warning
The interval is part of the calibration data. Changing it may cause the laser to behave differently than expected.
Raises:
-
ValueError
–If interval is not a positive integer within the valid range.
Source code in src/pychilaslasers/modes/sweep_mode.py
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 |
|
get_range() -> tuple[float, float]
Alias for range
.
Returns the current sweep range as configured for high-to-low wavelength sweeping.
Returns:
-
tuple[float, float]
–A tuple containing (start_wavelength, end_wavelength) where start_wavelength is the higher value and end_wavelength is the lower value, reflecting the high-to-low sweep direction.
Source code in src/pychilaslasers/modes/sweep_mode.py
466 467 468 469 470 471 472 473 474 475 476 477 478 |
|
set_range(start_wl: float, end_wl: float) -> None
Alias for range
.
Returns the current sweep range as configured for high-to-low wavelength sweeping.
Parameters:
-
start_wl
(float
) –Start wavelength in nanometers (should be the higher value).
-
end_wl
(float
) –End wavelength in nanometers (should be the lower value).
Raises:
-
ValueError
–If wavelength are outside the calibrated range or if start <= end.
Source code in src/pychilaslasers/modes/sweep_mode.py
480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 |
|