Skip to main content

pyThorlabsPM100x

pyThorlabsPM100x is a Python library/GUI interface to control the Thorlabs consoles PM100A and PM100D. The package is composed of two parts, a low-level driver to perform basic operations, and high-level GUI, written with PyQt5, which can be easily embedded into other GUIs.

Table of Contents

Installation

Use the package manager pip to install,

pip install pyThorlabsPM100x

This should automatically install all libraries needed by pyThorlabsPM100x. If any error occurs during installation, try installing first the required dependencies separately (one by one), via

pip install "PyQt5>=5.15.6"
pip install "pyqtgraph>=0.12.4"
pip install pyvisa
pip install numpy

and then run again pip install pyThorlabsPM100x

Important: in order to be accessible from this library, the console needs to be set to "NI-VISA driver" modality, and not to "TLPM modality". Typically, if you used recent Thorlabs software to acquire from a console, that will automatically set the console to "TLPM modality". You can use the utility Power Meter Driver Switcher to switch between modalities.

Usage as a stand-alone GUI interface

The installation should set up an entry point for the GUI. Just typing

pyThorlabsPM100x

in the command prompt will start the GUI.

Usage via the low-level driver

pyThorlabsPM100x provides also a low-level driver, based on the library pyvisa, to directly interface with the powermeter console.

from pyThorlabsPM100x.driver import ThorlabsPM100x
powermeter = ThorlabsPM100x()
available_devices = powermeter.list_devices()
print(available_devices)
powermeter.connect_device(device_addr = available_devices[0][0])
print(powermeter.power)
powermeter.disconnect_device()

The method list_devices() returns a list, with each element representing one available device in the format [address,identity,model]. The string address contains the physical address of the device. The line powermeter.connect_device(device_addr = available_devices[0][0]) establishes a connection to the first device found. We then print the power currently read by the console, and finally disconnect from it.

The class ThorlabsPM100x supports several properties and methods to communicate with the console and to read/change its settings. Some of the properties are read-only, while others can be set. A full list of properties and methods is available here below

Properties

Property Type Description
Can be set?
Notes
power (float,str) First element of list is the power currently read by the console, second element is the power units. No
power_units str Power units No
wavelength int Operating wavelength (in nanometers) of the console. Yes Each powermerter head has a different range of acceptable wavelengths. The driver will not return an error when trying to set a wavelength outside of this range.
power_range float Current power range, defined as the maximum power measurable in the current range Yes When setting this property to a particular value X, the console will change the power range to the smallest power range which allows to measure the desired power X.
min_power_range float Minimum power range available. No For the same console/head, this value might vary for different wavelengths.
max_power_range float Maximum power range available. No For the same console/head, this value might vary for different wavelengths.
auto_power_range bool Determines whether the consol is in auto power range or not. Yes
being_zeroed bool It is True if zero of the device is currently being set. No The property power will return (None,'') if read while being_zeroed==True

Methods

Method Returns Description
list_devices() list Returns a list of all available devices. Each element of the list identifies a different device, and it is a three-element list in the form [address,identity,model]. The string address contains the physical address of the device. The string idn contains the 'identity' of the device (which is the answer of the device to the visa query '*IDN?'. The string model contains the device model (either 'PM100A' or 'PM100D').
connect_device(device_addr: str) (str,int) Attempt to connect to the device identified by the address in the string device_addr. It returns a list of two elements. The first element is a string containing either the ID number of the connected device or an error message. The second element is an integer, equal to 1 if connection was succesful or to 0 otherwise.
disconnect_device() (str,int) Attempt to disconnect the currently connected device. If no device is currently connected, it raises a RuntimeError. It returns a list of two elements. The first element is a string containing info on succesful disconnection or an error message. The second element is an integer, equal to 1 if disconnection was succesful or to 0 otherwise.
read_min_max_wavelength() (float,float) Returns the minimum and maximum operating wavelengths for the connected device. If no device is currently connected, it raises a RuntimeError.
set_zero() int Set the zero to the currently connected (if any) console. The returned value is 1 if the operation was successful, or 0 if any error occurred.
move_to_next_power_range(direction: int) None It increases or decreases the power range of the console, depending on whether the input parameter is direction=+1 or direction=-1.

Examples

from pyThorlabsPM100x.driver import ThorlabsPM100x
powermeter = ThorlabsPM100x()
available_devices = powermeter.list_devices() #Check which devices are available
print(available_devices)
powermeter.connect_device(device_addr = available_devices[0][0]) #Connect to the first available device
print(powermeter.power) #print the power currently read
print(powermeter.wavelength) #print the operating wavelength
(minWL,maxWL) = powermeter.read_min_max_wavelength() #read max and min available wavelengths
powermeter.wavelength = maxWL #set wavelength to the max
print(powermeter.power_range) #print current power range
powermeter.move_to_next_power_range(direction=+1) #increaase power range
print(powermeter.power_range) #print new power range
powermeter.disconnect_device() #disconnect the device

Metadata

Release files for pyPhotonLLTFContrast 0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyPhotonLLTFContrast 0.4
File Size Uploaded Provenance
pyPhotonLLTFContrast-0.4.tar.gz 14.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for pyPhotonLLTFContrast 0.4
File Interpreter ABI Platform
pyPhotonLLTFContrast-0.4-py3-none-any.whl Python 3 none any Details

Total release size: 28.6 kB

Release files / pyPhotonLLTFContrast-0.4.tar.gz

Download URL pyPhotonLLTFContrast-0.4.tar.gz
Size 14.0 kB
Tags Source
SHA-256 checksum
How to use checksums
6ceb14d196a23662afb5195f41c3cf63786e272473a8309f2d4723181d0180fe
BLAKE2b-256 checksum
How to use checksums
21ec07c1d177473759b91a53efcfb6cfe38d775503b197913412547ffbfefdd3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

Release files / pyPhotonLLTFContrast-0.4-py3-none-any.whl

Download URL pyPhotonLLTFContrast-0.4-py3-none-any.whl
Size 14.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
502a36f3104324def34a81b5e3baf759d74ea4f55ccabc65cb6e0869d5c9508c
BLAKE2b-256 checksum
How to use checksums
79ea1f08da36b64200856c281119e344d031c9809eabc8bd3cc8e45b7137b030
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

Security for pyPhotonLLTFContrast 0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page