QCLight: data analysis for THz QCLs

Software & Data Analysis

QCLight_header_rotated_corr.pngRecently, I developed a Python program called QCLight_FF (now at its version v2.0), to provide a fast, reliable and versatile data analysis tool for the optical, electrical and spectral characterization of  Quantum Cascade Lasers operating in the Terahertz frequency region (THz QCLs).

In particular, the program is meant to compare the performance of lasers whose surface is patterned with a two-dimensional photonic structure and differ by their filling factor (FF). The FF is a geometric parameter which controls the scattering properties of the photonic system itself and allows tailoring the emission frequency, output power and far-field intensity pattern of the laser. Of course, the code can be generalized to organize such a comparison according to other structural parameters, so that different type of devices can be studied together.


QCLight_FF is written in Python 3.4 and is mainly based on the Numpy, Scipy and Matplotlib libraries. Currently, the software performs a number of data analysis operations on datafiles related to many lasers at once:

  • simultaneous plotting and analysis of multiple LIV characteristics, i.e. the curves that relate the light intensity output L, the current I and the voltage V across the laser. These are measured with a computer-controlled lock-in system and saved in the LabVIEW Measurement format .lvm
  • automated computation and plotting of the relevant figures of merit (threshold  and maximum current/current density, peak optical output, slope efficiency, wall-plug efficiency)
  • simultaneous analysis and plotting of the lasers’ FTIR emission spectra, expected in the comma-separated values format .csv, with the detection of the spectral lines and their full width at half maximum (FWHM)

Specific algorithms were devised and implemented to face different technical issues, for example for finding the lasing threshold condition, performing an appropriate fitting for the slope efficiency or recognizing the spectral peaks.

Moreover, I devised dedicated filename parsing functions for both the LIV files and the emission spectral files. These routines extract information about the device’s characteristics and the experimental conditions in which they were tested. Particular attention was paid to recognize possible typos in the filename and make the program stable w.r.t. them.

In case the device area is not known, the program reports all results in terms of current (in A) and displays the LIVs. Instead if the area is given, current densities J are computed in A/cm2 and LJV curves are shown. If the collection efficiency (CE) is known, it can be used to effectively evaluate the peak power output L (in mW) and compute the slope efficiency dL/dI and the wall-plug efficiency WP. Otherwise, only the peak lock-in signal in mV can be used and consequently not all the cited figures of merit can be evaluated.

Different diagnostic and control tools were implemented in the program to handle exceptions and examine all the significant execution steps where data analysis may need a closer look.


All the computed data, along with the core information for each laser, are displayed in real time on-screen (in the Python or IPython console) and also stored to a .txt file for future use.

The graphical output of the program execution consists of a series of windows displaying the LIV/LJV curves and related figures of merit, plus the emission spectra, as functions of the parameter FF. All of these figures can be interactively zoomed, moved and also saved as raster or vector images. Some examples are shown below.


Figure 1: Example of LJV curves of a set of QCLs displayed by QCLight_FF v2.0

Figure 2: Corresponding slope efficiencies in a separate window


Figure 3: Example of FTIR emission spectra plotted by QCLight_FF v2.0 labelled with the injected current density at acquisition time

I also have some new ideas to improve and extend the functionalities of this software. Stay tuned for future updates!


Lock-in detection

Technical review


A lock-in amplifier is a widespread detection system, used to extract the amplitude and the phase (R, θ) of a periodic signal even in presence of an intense background noise. Since its invention in the 1930s, the lock-in amplifier has become an indispensable tool in the fields of experimental and applied science and engineering.

A schematic description of a lock-in system is shown below. The operator whishes to detect and measure a noisy input signal Vs(t) with a carrier frequency νs, using a reference signal Vr(t). By processing the input with a system of frequency mixers and low-pass (LP) filters, the amplifier rejects all the noise and retrieves the amplitude and phase of the desired signal.


An example of a real-life Vs(t) is the following. If the light output of a laser, switched on and off by a periodic gate signal, is conveyed to a dedicated sensor, the latter produces a proportional voltage which is sent to a lock-in amplifier as input. In technical jargon, the laser is the DUT (device under test) in such a scenario.

The fundamental idea of the lock-in technique is the orthogonality of sines and cosines oscillating at different frequencies. By exploiting this principle, the noise contributions are effectively removed from the signal’s spectrum. This amplifier performs two core operations:

    • Down-mixing

the input is multiplied by the reference signal which is either provided by an internal oscillator (homodyne detection) or by an external source (heterodyne detection).

    • Demodulation

the resulting signal is filtered in an appropriate frequency bandwidth to exclude all noise and identify the carrier wave’s in-phase and quadrature components (X,Y). These are finally converted in polar coordinates as (R, θ).



The signal Vs(t) coming from the DUT is transmitted to the input channel of the amplifier. Let us assume it is a monochromatic wave with frequency νs and phase θ:


The reference Vr(t) signal can be chosen in different ways. Ideally a pure sine with a modulation frequency νm gives the highest selectivity, since it will discard all input components with ν≠νm. A common choice in real experiments is to exploit a periodic square wave from a function generator. As explained here, a square wave is the superposition of a fundamental sine and all its odd harmonics, therefore a lock-in using such a reference will detect the main frequency plus its odd multiples, introducing a systematic error in the measurement. For simplicity, let us consider a monochromatic reference


The lock-in splits the input signal Vs(t) in two  channels, each connected to a frequency mixer where the reference signal is multiplied by each input copy. After the mixer M1, the resulting complex signal contains information about the in-phase component (X) of the signal:

CodeCogsEqn (15).png

Instead the mixer M2 operates with the signal and a 90°-phase shifted reference, to retrieve information on the quadrature component of the signal (Y):

CodeCogsEqn (13).png

In both cases, the reference signal is tuned properly in order to fulfill the matching condition:

CodeCogsEqn (14).png

so that the high-speed part of W(t) (rotating with frequency νsm) can be neglected. Therefore the down-mixing consists in subtracting the reference frequency from the signal one, resulting in a final ν as close as possible to 0, i.e. a new DC value.



Once the down-mixing is accomplished on both M1 and M2, hopefully with low signal loss and little channel mismatch, LP filters are used to extract the information shifted around 0 Hz.

If the frequency matching condition is not respected, then averaging (or integrating) over a time scale of few periods would give a zero value. This means that all possible noise contribution to the spectrum of the input signal will be discarded, leaving untouched the resonating wave only. This is why lock-in amplification is an example of synchronous detection.

Low-pass filtering of W(t) can be expressed as such average operation:


As discussed above, the oscillation at frequency (νms) gives no contribution, while the rotation with  (νm-νs)  gives a non-zero average only for a perfect matching of the modulation and signal frequency. In this case, the result is


The in-phase and quadrature components are related to this complex value by:


An appropriate conversion from cartesian coordinates to polar ones gives the amplitude R and phase θ of the filtered input signal:


The function atan2 is defined as shown here and returns an angle in [-π, π]. These values are typically visible on the LED displays of the lock-in amplifier and can also be handled to a computer for further processing.

LP filtering acts isolating the down-mixed spectrum in a given bandwidth (BW) [-νBWBW]: a very narrow bandwidth improves the selectivity of the filter and suppresses the noise more efficiently. In the terms of Fourier analysis, this operation is described by the application of the filter’s transfer function H(ν) on the signal coming from the mixer:


The ideal transfer function works as a window, which just lets the spectral components in the bandwidth pass and cancels all the rest:


It is physically unfeasible to implement such a “brick-wall filter”, so different technological solutions have been developed to mimic this H(ν). LP filters based on a resistor and a capacitor (RC) are one of the simplest method, commonly exploited in analog lock-in amplifier. The picture shows a 1st-order (one-pole) RC filter.


The RC low-pass filter has the following transfer function:



The time constant sets the cutoff frequency at which the intensity is reduced by 50% (i.e., -3dB):


For |ν|<ν-3dB, the amplitude and the phase of the input signal undergo a very small change while passing through the filter. Instead, for higher frequencies (|ν|>ν-3dB), the filter provides an attenuation of 20dB/decade and a larger phase shift.

A steeper attenuation is obtained by creating a system of n RC filter in series, so that the attenuation increases as 20 × n dB/decade and the cutoff becomes smaller, improving the selectivity of the filter. The overall transfer function becomes:


which also produces a larger phase delay for higher-order filters. The following Bode plots show the amplitude and the phase shift associated to different low-pass RC filters with fixed 1/τRC= 100 Hz and of order n=1, 2, 3, 4.


The design of the LP module is a result of the tradeoff between stronger attenuation, smaller bandwidth and larger phase alteration, depending on the specific purpose of the instrument. A direct proportionality between the bandwidth νBW and the cutoff frequency ν3dB  exists, as defined by the particular filter architecture. However in our example of a monochromatic input Vs(t), the LP filter returns a demodulated signal extending in the spectral window [-ν-3dB-3dB] :

CodeCogsEqn (28).png

Practical lock-in measurement are also characterized by the settling time τset for the data acquisition, sometimes simply indicated as “time constant” on the front buttons of amplifier. It is defined as the time the lock-in needs to reach a stationary response to a step-like change of the input (for example, switching from 0 to 1) and measure meaningful values of amplitude and phase. One common convention is based on the time at which the filter response reaches 90% of the input. A direct proportionality between τset and the RC time constant τRC∼ 1/(ν-3dB) exists, as defined by the implemented filter. For example:

  • 1st-order LP RC filter: τ90%= 2.3 τRC
  • 4th-order LP RC filter: τ90%= 6.7 τRC

This indicates that the more the effective BW is reduced and the attenuation is increased by adding more cascaded RC filters, the longer it will take for the system to have a reliable measurement.


As exposed above, the lock-in technique is specifically designed to extract periodic signals in a noisy environment. Of course, the use of a narrow BW helps rejecting unwanted noise but it also induces longer acquisition time and therefore poor time resolution.

A variety of physical phenomena introduce noise in a measurement. Intrinsic types of noise are:

  • thermal Johnson-Nyquist noise: it has a flat spectrum and contributes to the so-called “white noise”
  • flicker or “pink” noise: it is dominant at low frequency due to its 1/ν-dependance. It is often introduced by fluctuations in resistance or by vacuum tubes and semiconductors
  • shot noise: it has a quantum origin, since it is due to the discrete nature of the charge carriers and may affect current measurement

Extrinsic noise may be asynchronous or instead be related to the reference signal.

  • In the first case, we can think of electromagnetic interference from computers, WIFI, mobile or radio signals. Even mechanical vibrations (cooling and pumping systems, etc.) produce a temporal variation of the capacitance of the cables and alter the current flow, which is known as “microphone effect”.
  • Synchronous noise may come from crosstalk between the experimental setup, the detector and the lock-in amplifier, when the noise source happens to match the reference frequency νm. In this case, even a highly selective filter cannot help because the noise is resonant with the signal.

The presence of parasitic capacitance may create capacitive coupling between the setup and the lock-in, while an  AC current in the cables may inductively couple via a varying magnetic flux. Finally the presence of ground loops may alter the ground condition for the lock-in, the detector and  the other parts of the setup, which could be an issue for the measurement.

The extrinsic noise  can be minimized by carefully designing the experiment and its electrical connection, while the intrinsic noise is harder to reduce. If possible, the reference frequency should be chosen in order to be in the part of the spectrum where white noise dominates, avoiding the pink noise at low frequency.

Noise can be studied by its power spectral density |VN(ν)|2  in V2/Hz  or its square root |VN(ν)|  in V/√Hz. The overall quality of the measurement is then expressed by the Signal-to-Noise Ratio (SNR), i.e. the ratio between the useful signal power and the total noise power. Another characteristics is the Noise Equivalent Power (NEP) of the system, defined as the input signal power that results in a SNR of 1 in a 1 Hz output bandwidth. Essentially, the NEP gives the minimum detectable power per square root bandwidth for a detector, i.e. it indicates the weakest signal that can be detected.

Especially in noise measurement, the LP filter BW is often not specified in terms of ν-3dB, but using a quantity indicated as νNEP. This is the cut-off frequency of an ideal brick-wall filter that transmits the same amount of flat noise as the filter we are setting. For cascaded RC filters, typically νNEP ≥ ν-3dB .

By knowing the signal amplitude R, the desired SNR value, the noise spectral power density |VN(ν)|2, one can consequently compute the needed NEP cut-off  with the following relation:


The corresponding filter BW and settling time can then be retrieved and set on the lock-in system.

Another important figure of merit of a lock-in is its dynamic reserve, which is  is the ratio of the largest tolerable noise signal to the full-scale signal (expressed in dB), without causing any overload in any part of the instrument. Of course, this is a rather broad definition even because the overload risk can be reduced simply by setting a small gain at the input. Let’s consider a full scale of 3 μV and a dynamic reserve of 100 dB. Then a noise as large as 1e5* 3 μV=300 mV (100 dB larger than full scale) can be tolerated at the input without overload. An alternative definition of tolerable noise is: the noise level that does not affect the output more than a few percent of full scale, in a specific lock-in.

As discussed above, the noise at the reference frequency cannot be uncoupled from the signal, so it undergoes no attenuation and the dynamic reserve at νm is 0 dB. Instead for not resonating frequencies, the dynamic reserve increase since the LP filters suppress the noise components other than the signal. Therefore the dynamic reserve is strongly related to the cut-off of the LP filter and its attenuation at roll-off.

This review of the principles at the core of the lock-in amplifier ends here, even if there will be occasion to further discuss the advent of digital technology in such instrument. Of course, in a future post in this blog…

PNG, Latin modern, 12pt, 120, trasparente

Welcome to Biascophysics


This is my first post on Biascophysics, a website I created to discuss and showcase a variety of topics in science and technology.

I am a young, passionate physicist with an interest in experimental and computational science. Currently, I am pursuing research in photonics and semiconductor lasers, with the objective of controlling and improving the optical and spectral properties of quantum cascade lasers in the Terahertz frequency region.

This site is meant to host both outreach pages for a broad audience and more specific posts. I will focus especially on photonics&optics, electronics, condensed matter physics and lasers, plus some other computational and technical stuff.

I hope you will enjoy your stay here!