Utilities (utils package)

Module contents

This package contains various utilities.

The utils scripts were used or rather created while building the new measurement software Jagan. Their main purpose was to learn about features which were required for certain functionalities of the measurement software.

Some scripts are not written by us (i.e. pyqt scripts) but are modified in ways to suit our purpose.

We decided to include them in case, that someone would need them.

Note

Most of the scripts are not well documented and programmed in a crude way just to learn things. Technically most of the stuff which is in utils, can be found in some way within the actual main software.

Submodules

utils.backup_data module

Simple backup script which just creates the root structure in an other folder and syncs everything which recursevely lies within one of the source folders. For files bigger than a threshold they are first gziped.

https://codereview.stackexchange.com/questions/101616/simple-backup-script-in-python

parse_input()[source]
size_if_newer(source, target)[source]

If newer it returns size, otherwise it returns False

sync_file(source, target, compress)[source]
sync_root(root, arg)[source]
threaded_sync_file(source, target, compress)[source]
transfer_file(source, target, compress)[source]

Either copy or compress and copies the file

utils.covariance_noise_surpression_python module

This script contains the method magic_function which is used by Y Feng et al. in their paper General noise suppression scheme with reference detection in heterodyne nonlinear spectroscopy. It would be interesting to implement this algorithm into the measurement software to see if it can improve the signal to noise ratio etc.

The original matlab scripts from Feng as well as their paper were used to translate the algorithm into Python.

magic_function(signal, reference)[source]

utils.evaluate_raw_data module

This script is used for averaging raw data with several different methods which are described in https://doi.org/10.1063/1.4921479 and the document we provided regarding the averaging of raw data (or master thesis).

The experiment which was used:

  • Broadband Pump-Probe

  • 1 x Chopper

  • No Wobbler

  • 1 pump interferometer arm blocked

digitize_chopper(chopper_voltage: numpy.ndarray) → numpy.ndarray[source]
evaluate_data_m1(data: numpy.ndarray) → tuple[source]

Absorption averaged data: First calculate shot to shot difference spectrum and then take average and variance of this.

Calculate average of raw data as described in equation 21 of https://doi.org/10.1063/1.4921479. This currently corresponds to method described in section 3.1 of our document.

Parameters

data (ndarray) – raw linearised adc data. shape: (144, samples)

Returns

mean of shot to shot difference spectra. shape: (64) ndarray: 1/variance of shot to shot difference spectra. shape: (64)

Return type

ndarray

evaluate_data_m2(data: numpy.ndarray) → tuple[source]

Transmission averaged data: First calculate shot to shot transmission and then take variance and average of this. Afterwards calculate the difference spectrum from this mean transmission.

Calculate average of raw data as described in equation 22 of https://doi.org/10.1063/1.4921479. This currently corresponds to method described in section 3.2 of our document.

Parameters

data (ndarray) – raw linearised adc data. shape: (144, samples)

Returns

mean of shot to shot transmission. shape: (64, 2)

2 because of two different chopper states

ndarray: 1/variance of shot to shot difference spectra. shape: (64, 2)

2 because of two different chopper states

ndarray: difference spectrum calculated from mean transmission for

each chopper state. shape: (64)

Return type

ndarray

evaluate_data_m3(data: numpy.ndarray) → tuple[source]

Intensity averaged data: Calculate average and variance directly of intensities. Afterwards calculate the difference spectrum from this mean intensity for each each pixel and chopper state.

Calculate average of raw data as described in equation 23 of https://doi.org/10.1063/1.4921479. This currently corresponds to method described in section 3.3 of our document.

Parameters

data (ndarray) – raw linearised adc data. shape: (144, samples)

Returns

mean of intensity. shape: (128, 2)

2 because of two different chopper states

ndarray: 1/variance of intensity. shape: (128, 2)

2 because of two different chopper states

ndarray: difference spectrum calculated from mean intensity for

each chopper state and pixel. shape: (64)

Return type

ndarray

process_data(name, path)[source]

utils.ft2dir module

This script is a standalone version of the Fourier Tranform 2D IR experiment. It can be executed from this script given that the hardware is properly setup, connected and that the ports are chosen accordingly.

utils.quadrant_diode module

This script is intended to be used with a quadrant diode. It averages a certain amount of samples and displays a dot with its standard deviation on a grid. The position of the dot can be resetted via a reset button.

The outputs of the quadrant diodes were connected to an National Instruments ADC which can communicate with the nidaqmx library of python.

class MainWindow(*args, **kwargs)[source]

Bases: PyQt5.QtWidgets.QMainWindow

class Signals[source]

Bases: PyQt5.QtCore.QObject

acquisition_done
reset_position()[source]
run()[source]
main()[source]

utils.testing_r2r_measure_voltages module

This script can be used to test if the R-2R network properly counts. Plug the finished box to the PSU and connect it to your device which is going to run this script. Check if the COM port is correct for your device in the device manager. Plug a BNC into the first R-2R output and connect it to the multimeter to measure the output voltage. The script sets the counter to count 0x0 to 0xF and then from 0x0 to 0xFF in steps of 0xF. Therefore the whole functionality of the R-2R network can be checked. The voltage should increase in 16 equidistant steps. Replug the BNC to the next R-2R output once the 16th step was reached. If you are brave you can write the voltages down and plot them to see four perfectly linear curves!

utils.testing_r2r_with_adc module

This script can be used to test how the R-2R output is read at the ADC. The script sets the counter to count 0x0 to 0xF and then from 0x0 to 0xFF in steps of 0xF. Therefore the whole functionality of the R-2R network can be checked. The ADC should display 4 linear graphs. If this is not the case there might be problems with your R-2R. We also encountered some sort of float overflow when we thought that the R-2R should work for sure (by testing with the testing_r2r_measure_voltages.py). Then a look how the ADC collects the data is necessary. This will probably not be the case.