Thorlabs CCS Spectrometers

This module is for controlling Thorlabs CCS spectrometers.

Installation

The Thorlabs OSA software provided on Thorlabs website must be installed. This driver is currently windows only.

Module Reference

Driver Module for Thorlabs CCSXXX series spectrometers. Currently Windows only.

exception instrumental.drivers.spectrometers.thorlabs_ccs.ThorlabsCCSError
class instrumental.drivers.spectrometers.thorlabs_ccs.CCS(inst=None, **kwds)

Thorlabs CCS-series spectrometer.

If this construcor is called, it will connect to the first available spectrometer (if there is at least one). It can also be accessed by calling get_spectrometer using any one of the parameters ‘address’, ‘serial’, or ‘model’. Calling the function instrument(), using any one of the parameters ‘ccs_usb_address’, ‘ccs_serial_number’, or ‘ccs_model’ will also return a CCS instance (if successful).

calibrate_wavelength(calibration_type=Calibration.User, wavelength_array=None, pixel_array=None)

Sets a custom pixel-wavelength calibration.

The wavelength and pixel points are used to interpolate the correlation between pixel and wavelength.

Note that the given values must be strictly increasing as a function of wavelength, and that the lenght of the arrays must be equal and be between 4 and 10 (inclusive). Note that there are also some other requirements, that seem to have something with the calibration data points being somewhat’smooth’ that are not specified in the documentation and may result in the not very descriptive ‘Invalid user wavelength adjustment data’ error.

If calibration_type is Calibration.User, then the last 3 arguments must be given, and are used to set the wavelength calibration.

If calibration_type is Calibration.Factory, then the last three arguments are ignored, and the default factory wavelength calibration is used.

Parameters
  • pixel_data (array of int) – The pixel indices for the interpolation.

  • wavelength_data (array of float) – The wavelengths (in nm) to be used in the interpolation.

  • calibration_type (Calibration) –

close()

Close the spectrometer

cont_scan_in_progress()

Indicates if a continuous scan is in progress

get_amplitude_data(mode=CorrectionType.Store)

Gets the amplitude correction factors.

Parameters

mode (str) – This parameter can be either ‘stored’ or ‘one_time’. If set to ‘one_time’, the correction factors for the current data are returned. If set to ‘stored’, the correction factors stored in the spectrometers non-volatile memory will be returned.

Returns

correction_factors – Array of pixel correction factors, of length NUM_RAW_PIXELS.

Return type

array of float

get_device_info()

Returns and instance of ID_Infor, containing various device information.

get_integration_time()

Returns the integration time.

get_scan_data()

Returns the processed scan data.

Contains the pixel values from the last completed scan.

Returns

data

Return type

numpy array of type float with of length NUM_RAW_PIXELS = 3648,

get_status(status=None)

Returns a list instance containing strings indicating the status of the device. :param status: :type status: int, optional :param An int representing the state of the byte register. If ‘None’: :param (default): :param the method gets the current status directly from the: :param spectrometer.:

is_data_ready()

Indicates if the spectrometer has data ready to transmit.

is_idle()

Supposedly returns ‘True’ if the spectrometer is idle.

The status bit on the spectrometer this driver was tested with did not seem to work properly. This may or may not be a genereal issue.

reset()

Resets the device.

set_amplitude_data(correction_factors, start_index=0, mode=CorrectionType.Store)

Sets the amplitude correction factors.

These factors multiply the pixels intensities to correct for variations between pixels.

On start-up, these are all set to unity. The factors are set by the values in correction_factors, starting with pixel start_index.

Parameters
  • correction_factors (array of float) – Correction factors for the pixels.

  • num_points (int) – The number of pixels to apply the correction factors (typically the length of correction_factors).

  • start_index (int) – The index of the first pixel to which the correction factors will be applied.

  • mode (CorrectionType) – Can be either ‘store’ or ‘one_time’. If set to OneTime, the correction factors are only applied to the current data. If set to Store, the correction factors will be applied to the current data and all future data.

set_background(integration_time=None, num_avg=1)

Collects a background spectrum using the given settings.

Both the integration time and the number of spectra to average over can be specified as paramters. The background spectra itself is returned.

Parameters
  • integration_time (float) – The integration time, in second. If None,the current integration is used.

  • num_avg (int) – The number of spectra to average over. The default is 1 (no averaging).

set_integration_time(integration_time, stop_scan=True)

Sets the integration time.

start_cont_scan_trg()

Arms spectrometer for continuous external triggering.

The spectrometer will wait for a signal from the external trigger before executing a scan, will rearm immediatley after that scan has completed, and so on.

Note that the function returns immediately, and does not wait for the trigger or for the scan to finish.

Note also that this cancels other scans in progress.

start_continuous_scan()
start_scan_trg()

Arms spectrometer to wait for a signal from the external trigger before executing scan.

Note that the function returns immediately, and does not wait for the trigger or for the scan to finish.

Note also that this cancels other scans in progress.

start_single_scan()
stop_and_clear(max_attempts=10)

Stops any scans in progress, and clears any data waiting to transmit. :param max_attempts: Maximum number of attempts to attempt to clear the spectrometer :type max_attempts: int, Default=MAX_ATTEMPTS=10

stop_scan()
take_data(integration_time=None, num_avg=1, use_background=False, max_attempts=10)

Returns scan data.

The data can be averaged over a number of trials ‘num_Avg’ if desired. The stored backgorund spectra can also be subtracted from the data.

Parameters
  • integration_time (Quantity([time]), optional) – The integration time. If not specified, the current integration time is used. Note that in practice, times greater than 50 seconds do not seem to work properly.

  • num_avg (int, Default=1) – The number of spectra to average over.

  • use_background (bool, Default=False) – If true, the spectrometer subtracts the current background spectra (stored in self._background) from the data.

  • max_attempts (int, Default=MAX_ATTEMPTS=10) – Maximum number of attempts to attempt to clear the spectrometer

Returns

  • data (numpy array of float of size (self.num_pixels, 1)) – The amplitude data from the spectrometer, given in arbitrary units.

  • wavelength_data (numpy array of float of size (self.numpixel, 1)) – The wavelength (in nm) corresponding to each pixel.

waiting_for_trig()

Indicates if the spectrometer is waiting for an external trigger signal.

class instrumental.drivers.spectrometers.thorlabs_ccs.Calibration(value)

An enumeration.

Factory = 0
User = 1
class instrumental.drivers.spectrometers.thorlabs_ccs.CorrectionType(value)

An enumeration.

OneTime = 1
Store = 2
class instrumental.drivers.spectrometers.thorlabs_ccs.ID_Info(manufacturer, device_name, serial_number, firmware_version, driver_version)
__init__(manufacturer, device_name, serial_number, firmware_version, driver_version)
class instrumental.drivers.spectrometers.thorlabs_ccs.SpecTypes(value)

An enumeration.

CCS100
CCS125
CCS150
CCS175
CCS200
class instrumental.drivers.spectrometers.thorlabs_ccs.Status(status)
__init__(status)
instrumental.drivers.spectrometers.thorlabs_ccs.list_instruments()

Get a list of all spectrometers currently attached