Welcome to pyUSRP’s documentation!

This API has been developed with frequency multiplexed cryogenics detector in mind. Hard coded internal parameters may be different for different applications.

Quickstart guide

In order to use this library an instance of the GPU server (link) has to be already running and connected to a USRP device (see link). First of all import the pyUSRP module:

import pyUSRP as u

Than connect to the server:

u.connect()

Note

By default the library will connect to a GPU server that is running on the local machine. If the server is running on an other machine provide the address as a sting argument.

Once the client app is connected to the server launch any measure function provided with the distribution. Let’s take a VNA scan between port TX/RX and RX2 on frontend A:

vna_filename = u.Single_VNA(<your arguments>)

The function will block until the measurement is performed by the server and will create a local HDF5 file. The filename is than returned. In order to visualize the result of the VNA launch then the function:

u.VNA_analysis(vna_filename)

That will read the raw data in the file and create the group VNA containing the frequency and S21 datasets. Finally for plotting launch:

u.plot_VNA(vna_filename)

and optionally use the backend argument to choose between plotly and matplotlib. The matplotlib backend will save to disk a PNG file with the plot.

Examples

This section explain the use and purpose of the examples contained in the script folder of this distribution. For more information about the programs arguments launch each of the scripts with the -h argument. The scope of each of this examples is to wrap library functions and complete a measurement or a simple analysis task.

Note

All the programs that gather data have to interact with the GPU server via network.

Note

These programs are intended as demonstration of the features of the system. They do NOT provide every option for functionality implemented.

get_VNA.py

Save the S21 function raw data to disk. If multiple gain arguments or LO frequency arguments are given, produces multiple scans. By default saves the data to the scripts/data/ folder.

analyze_VNA.py

Analyze all the USRP_VNA* files present in the scripts/data/ folder. Overlay all the analyzed VNA files in a single plot.

fit_VNA.py

Fit the pre-analyzed VNA file with kinetic inductance resonator function and saves the fits results in the resonator group inside the same file. Two ways of initializing the peaks have been implemented: one that estimates the number and position of the peaks using a threshold on the derivative of S21; the other that given a number of peaks scan the S21 function for the best candidates.

After fitting the program plot the resonators fits and the S21 with the resonator tags.

get_noise.py

Multitone noise acquisition. This program acquires multitone data. The tones can be initialized from a previously fitted VNA scan (using just the filename) or manually. Two different acquisition modes have been implemented: the direct demodulation mode and the PFB mode.

analyze_noise.py

Calculates and save in the file the dBc/dBm spectrum of a multitone noise acquisition.

freqts_plot.py

Translate tones power fluctuations into quality factor and resonant frequency fluctuation using VNA fit data.

get_line_delay.py

Estimate the loop line delay between two ports using a short chirped signal.

get_noise_full.py

Use the USRP as spectrum analyzer and saves data to disk

Note

The client/server data rate can easily exceed the network buffer causing the client or the server to freeze if the connection between the does not have enough bandwidth for certain parameters.

plot_spectrogram.py

Plot the full spectrum noise acquisition.

swipe_parameters.py

This code example is the most similar to our acquisition routine. Acquire a VNA scan, analyze and fit it. Use the fit result to take a multitone noise acquisition and change some parameter (in this case the TX gain)

Useful functions

Connections

USRP_connections.Connect([timeout]) Connect both, the Syncronous and Asynchronous communication service.
USRP_connections.Disconnect([blocking]) Disconnect both, the Syncronous and Asynchronous communication service.

Launching measures

USRP_VNA.Single_VNA(start_f, last_f, …[, …]) Perform a VNA scan using a single frontend of a single USRP device.
USRP_noise.Get_noise(tones, measure_t, rate) Perform a noise acquisition using fixed tone technique.
USRP_delay.measure_line_delay(rate, LO_freq, …) Measure the line delay around a given frequency.
USRP_full_spec.get_NODSP_tones(tones, …[, …]) Perform a noise acquisition using fixed tone technique without demodulating the output result.
USRP_noise.Get_full_spec

Getting data from files

USRP_files.openH5file(filename[, ch_list, …]) Retrive Raw data from an hdf5 file generated with pyUSRP.
USRP_files.get_rx_info(filename[, ant]) Retrive RX information from file.
USRP_files.get_tx_info(filename[, ant]) Retrive TX information from file.
USRP_files.get_noise(filename[, …]) Get the noise spectra from a a pre-analyzed H5 file.
USRP_files.get_trigger_info(filename[, ant]) Get the trigger information from a triggered measure.
USRP_files.get_readout_power(filename, channel) Get the readout power for a given single tone channel.
USRP_files.global_parameter.retrive_prop_from_file(…)
USRP_files.get_VNA_data(filename[, …]) Get the frequency and S21 data in a preanalyzed vna file.
USRP_files.get_dynamic_VNA_data(filename[, …]) Get the dynamic frequency and S21 data in a preanalyzed vna file.
USRP_files.get_init_peaks(filename[, verbose]) Get initialized peaks froma a VNA file.
USRP_fitting.get_tones(filename[, …]) Get the central frequency and the list with relative tones.
USRP_fitting.get_best_readout(filename[, …]) Get the best readout frequency from a fitted resonator keeping in account the nonlinear firt model.
USRP_fitting.get_fit_param(filename[, verbose]) Retrive fit parameters from a file.
USRP_fitting.get_fit_data(filename[, verbose]) Retrive fit data from a file.
USRP_delay.load_delay_from_file(filename) Recover delay information from a delay file.
USRP_delay.load_delay_from_folder(foldername) Load line delay structure from folder matching the the acquisition rate with the right delay in the LINE_DELAY variable.
USRP_full_spec.Get_full_spec(tones, …[, …]) Full spectrum version of the Get_noise() function.
USRP_noise.get_frequency_timestreams(…[, …]) Returns the frequency and quality factor timestreams from a noise file in which a resonator group has been already copied.

Move data between files

USRP_fitting.initialize_from_VNA(…[, verbose]) Initialize the peaks in a new VNA file using fitted parameters from an other VNA file that has already been fitted.
USRP_delay.write_delay_to_file(filename, delay) Wrapper around h5py functions to write the delay on file.
USRP_noise.copy_resonator_group(…) Copy the resonator groups from a VNA file to a mnoise file.

Analyze data

USRP_fitting.vna_fit(filename[, p0, …]) Open a pre analyzed, pre plotted (with tagged resonator inside) .h5 VNA file and fit the resonances in it.
USRP_fitting.initialize_peaks(filename[, …]) This function uses a filter on quality factor estimated using the nonlinear resonator model.
USRP_fitting.extimate_peak_number(filename) This function uses peakutils module to initialize the peaks i the file.
USRP_delay.analyze_line_delay(filename[, …]) Analyze the file delay from a tagged file.
USRP_noise.calculate_noise(filename[, …]) Generates the FFT of each channel stored in the .h5 file and stores the results in the same file.
USRP_VNA.VNA_timestream_analysis(filename[, …]) Open a H5 file containing data collected with the function single_VNA() and analyze them as multiple VNA scans, one per iteration.
USRP_VNA.VNA_analysis(filename[, usrp_number]) Open a H5 file containing data collected with the function single_VNA() and analyze them as a VNA scan.

Plotting data

USRP_fitting.plot_resonators(filenames[, …]) Plot the resonators and the resonator fits.
USRP_full_spec.plot_pfb(filename[, …]) Plot the output of a PFB acquisition as an heatmap.
USRP_noise.plot_noise_spec(filenames[, …]) Plot the noise spectra of given, pre-analized, H5 files.
USRP_noise.plot_frequency_timestreams(filenames) Plot frequency timestreams from given H5 noise files.
USRP_noise.diagnostic_VNA_noise(noise_filename) Plot the VNA traces and the noise (averaged or in N points) on the same plot to check for acquisition consistency.
USRP_plotting.plot_raw_data(filenames[, …]) Plot raw data group from given H5 files.
USRP_VNA.VNA_timestream_plot(filename[, …]) Plot the VNA timestream analysis result.
USRP_VNA.plot_VNA(filenames[, backend, …]) Plot the VNA data from various files.

Indices and tables

The “Connections” module

This module consist groups the functions and classes that make the data exchange with the GPU USRP server.

USRP_connections.Async_send(payload)[source]

Send a JSON string to the GPU server. Typically the JSON string represent a command or a status request.

Arguments:
-payload: JSON formatted string.
Returns:
-Boolean value representing the success of the operation.
Note:
In order to use this function the Async_thread has to be up and running. See Start_Async_RX().
USRP_connections.Async_thread()[source]

Receiver thread for async messages from the GPU server. This function is ment to be run as a thread

USRP_connections.Connect(timeout=None)[source]

Connect both, the Syncronous and Asynchronous communication service.

Returns:
  • True if both services are connected, False otherwise.
Arguments:
  • the timeout in seconds. Default is retry forever.
USRP_connections.Decode_Async_header(header)[source]

Extract the length of an async message from the header of an async package incoming from the GPU server

USRP_connections.Decode_Async_payload(message)[source]

Decode asynchronous payloads coming from the GPU server

USRP_connections.Decode_Sync_Header(raw_header, CLIENT_STATUS=<DictProxy object, typeid 'dict'>)[source]

Decode an async header containing the metadata of the packet.

Return:
  • The metadata in dictionary form.
Arguments:
  • The raww header as a string (as returned by the recv() method of socket).
USRP_connections.Disconnect(blocking=True)[source]

Disconnect both, the Syncronous and Asynchronous communication service.

Returns:
  • True if both services are connected, False otherwise.
Arguments:
  • define if the call is blocking or not. Default is blocking.
USRP_connections.Encode_async_message(payload)[source]

Format a JSON string so that the GPU server can read it.

Arguments:
  • payload: A JSON string.
Returns:
  • A formatted string ready to be sent via socket method
Note:
This function performs no check on the validity of the JSON string.
USRP_connections.Packets_to_file(parameters, timeout=None, filename=None, dpc_expected=None, push_queue=None, trigger=None, **kwargs)[source]

Consume the USRP_data_queue and writes an H5 file on disk.

Parameters:
  • parameters – global_parameter object containing the informations used to drive the GPU server.
  • timeout – time after which the function stops and tries to stop the server.
  • filename – eventual filename. Default is datetime.
  • dpc_expected – number of sample per channel expected. if given display a percentage progressbar.
  • push_queue – external queue where to push data and metadata
  • trigger – trigger class (see section on trigger function for deteails)

:return filename or empty string if something went wrong

Note:
  • if the “End of measurement” async signal is received from the GPU server the timeout mode becomes active.
USRP_connections.Start_Async_RX()[source]

Start the Aswync thread. See Async_thread() function for a more detailed explanation.

USRP_connections.Stop_Async_RX()[source]

Stop the Async thread. See Async_thread() function for a more detailed explanation.

USRP_connections.Sync_RX(CLIENT_STATUS, Sync_RX_condition, USRP_data_queue)[source]

Thread that recive data from the TCP data streamer of the GPU server and loads each packet in the data queue USRP_data_queue. The format of the data is specified in a subfunction fill_queue() and consist in a tuple containing (metadata,data).

Note:
This funtion is ment to be a standalone thread handled via the functions Start_Sync_RX() and Stop_Sync_RX().
USRP_connections.USRP_socket_bind(USRP_socket, server_address, timeout)[source]

Binds a soket object with a server address. Trys untill timeout seconds elaplsed.

Args:
  • USRP_socket: socket object to bind with the address tuple.
  • server_address: a tuple containing a string with the ip address and a int representing the port.
  • timeout: timeout in seconds to wait for connection.
Known bugs:
  • On some linux distribution once on two attempts the connection is denied by software. On third attempt however it connects.
Returns:
  • True: if connection was succesfull.
  • False if no connection was established.
Examples:
>>> if(USRP_socket_bind(USRP_data_socket, USRP_server_address_data, 5)):
#   do stuff with function in this library
>>> else:
>>>     print "No connection, check hardware and configs."
Notes:
  • This method will only connect one soket to the USRP/GPU server, not data and async messages. This function is intended to be used in higher level functions contained in this library. The correct methot for connecting to USRP/GPU server is the use of USERP_Connect(timeout) function.
USRP_connections.Wait_for_async_connection(timeout=None)[source]

Block until async thead has established a connection with the server or the thread is expired. In case a timeout value is given, returns after timeout if no connection is established before.

Arguments:
  • timeout: Second to wait for connection. Default is infinite timeout
Return:
  • boolean representing the sucess of the operation.
USRP_connections.Wait_for_sync_connection(timeout=None)[source]

Block until async thead has established a connection with the server or the thread is expired. In case a timeout value is given, returns after timeout if no connection is established before.

Arguments:
  • timeout: Second to wait for connection. Default is infinite timeout
Return:
  • boolean representing the sucess of the operation.
USRP_connections.clean_data_queue(USRP_data_queue=<multiprocessing.queues.Queue object>)[source]

Clean the USRP_data_queue from residual elements. returns the number of element found in the queue.

Returns:
  • Integer number of packets removed from the queue.
USRP_connections.reinit_async_socket()[source]

Reinitialize the command network socket. :return: None

USRP_connections.reinit_data_socket()[source]

Reinitialize the data network socket. :return: None

The “Data analysis” module

This module contains all the functions used to analyze the data take with this software. This module is very application specific: all the functions needed for general purpose analysis (like ffts) are in their respective submodule (i.e. noise)

USRP_data_analysis.linear_phase(phase)[source]

Unwrap the pgase and subtract linear and constrant offset.

The “Delay” module

MAny applications, like the VNA here implemented, requires the knowledge of the line delay. With line delay it is intended the delay introduced by the loop connecting a TX port of the USRP to an active RX port of the USRP.

USRP_delay.LINE_DELAY = {}

This variable contains total line delay at given frequencies.

USRP_delay.analyze_line_delay(filename, diagnostic_plots=False)[source]

Analyze the file delay from a tagged file.

Parameters:
  • filename – the name of the file containing the delay data.
  • diagnostic_plots – saves two diagnostic plots in png.
Returns:

the delay in seconds.

USRP_delay.load_delay_from_file(filename)[source]

Recover delay information from a delay file. Write this information in the internal dictionary LINE_DELAY.

Parameters:filename – Filename of the delay measure already analyzed.
Returns:rate in Msps, delay in ns
Example:
>>> # Once connected to the GPU server:
>>> filename = measure_line_delay(...)
>>> delay = analyze_line_delay(filename)
>>> write_delay_to_file(filename, delay)
>>> # Read back the result:
>>> delay, rate = load_delay_from_file(filename)
USRP_delay.load_delay_from_folder(foldername)[source]

Load line delay structure from folder matching the the acquisition rate with the right delay in the LINE_DELAY variable.

Note: * The line delay is NOT matched with frequency but only with the sps rate of the USRP.

Parameters:foldername – folder containing the delay files. Delay files are detected using the filename string “USRP_Delay*.h5”.
USRP_delay.measure_line_delay(rate, LO_freq, RF_frontend, USRP_num=0, tx_gain=0, rx_gain=0, output_filename=None, compensate=False, duration=0.01, **kwargs)[source]

Measure the line delay around a given frequency. Save the data to file. :param rate: USRP sampling rate in Sps: changing the sampling rate affect how the stock firmware process data. :param LO_freq: the LO frequency used during the delay measurement in Hz. :param RF_frontend: character ‘A’ or ‘B’ to define which front end to use for line delay calculation. :param USRP_num: Server USRP number to use for the measure. Default is 0. :param tx_gain: Transmission gain in dB to use for the measure. Default is 0. :param rx_gain: Receiver gain in dB to use for the measure. Default is 0. :param output_filename: optional parameter to set the output filename. :param kwargs: keyword arguments will be used to store additional attributes in the HDF5 file in the raw data group. :param compensate: if True the initial delay is sourced from the internal variable LINE_DELAY. :parm duration: duration of the measurement. :return A string containing the filename where the data have been saved.

USRP_delay.set_line_delay(rate, delay_ns)[source]

Manually set the LINE_DELAY internal variable.

Parameters:
  • rate – reference rate for the delay in Msps.
  • delay_ns – delay to set in ns.
USRP_delay.write_delay_to_file(filename, delay)[source]

Wrapper around h5py functions to write the delay on file.

Parameters:
  • filename – Name of the file containing the delay data.
  • delay – Delay from analysis function is seconds.

The “Files” module

This module containd the classes and the functions used to interact and create the HDF5 files containing the data coming from the USRP GPU system

USRP_files.Device_chk(device)[source]

Check if the device is recognised by the server or assign to 0 by default.

Arguments:
  • device number or None.
Returns:
  • boolean representing the result of the check or true is assigned by default.
USRP_files.Front_end_chk(Front_end)[source]

Check if the front end code is recognised by the server or assign to A by default.

Arguments:
  • front end code (A or B).
Returns:
  • boolean representing the result of the check or true is assigned by default.
USRP_files.Param_to_H5(H5fp, parameters_class, trigger=None, **kwargs)[source]

Generate the internal structure of a H5 file correstonding to the parameters given.

Parameters:
  • H5fp – already opened H5 file with write permissions
  • parameters_class – an initialized global_parameter object containing the informations used to drive the GPU server.
  • kwargs – each additional parameter will be interpreted as a tag to add in the raw data group of the file.
  • trigger – trigger class (see section on trigger function for deteails)
Returns:
  • A list of names of H5 groups where to write incoming data.
Note:
This function is ment to be used inside the Packets_to_file() function for data collection.
USRP_files.bound_open(filename)[source]

Return pointer to file. It’s user responsability to call the close() method.

USRP_files.get_VNA_data(filename, calibrated=True, usrp_number=0)[source]

Get the frequency and S21 data in a preanalyzed vna file. :param filename: the name of the HDF5 file containing the data. :param calibrated: if True returns the S21 data in linear ratio units (Vrms(in)/Vrms(out)). if False returns S21 in ADC units. :param usrp_number: usrp server number. :return: frequency and S21 axis.

TO DO:
  • Calibrarion for frontend A could be different from frontend B. This could lead to a wrong calibration.
USRP_files.get_dynamic_VNA_data(filename, calibrated=True, usrp_number=0)[source]

Get the dynamic frequency and S21 data in a preanalyzed vna file. :param filename: the name of the HDF5 file containing the data. :param calibrated: if True returns the S21 data in linear ratio units (Vrms(in)/Vrms(out)). if False returns S21 in ADC units. :param usrp_number: usrp server number. :return: frequency and S21 axis.

TO DO:
  • Calibrarion for frontend A could be different from frontend B. This could lead to a wrong calibration.
USRP_files.get_init_peaks(filename, verbose=False)[source]

Get initialized peaks froma a VNA file.

Arguments:
  • filename: the name of the file containing the peaks.
  • verbose: print some debug line.
Return:
  • Numpy array containing the frequency of each ninitialized peak in MHz.
USRP_files.get_noise(filename, usrp_number=0, front_end=None, channel_list=None)[source]

Get the noise spectra from a a pre-analyzed H5 file.

Argumers:
  • filename: [string] the name of the file.
  • usrp_number: the server number of the usrp device. default is 0.
  • front_end: [string] name of the front end. default is extracted from data.
  • channel_list: [listo of int] specifies the channels from which to get samples
Returns:
  • Noise info, Frequency axis, real axis, imaginary axis
Note:
Noise info is a dictionary containing the following parameters [whelch, dbc, rotate, rate, tone]. The first four give information about the fft done to extract the noise; the last one is a list coherent with channel list containing the acquisition frequency of each tone in Hz.
USRP_files.get_readout_power(filename, channel, front_end=None, usrp_number=0)[source]

Get the readout power for a given single tone channel.

USRP_files.get_rx_info(filename, ant=None)[source]

Retrive RX information from file.

:param ant (optional) string to specify receiver. Default is the first found. :return Parameter dictionary

USRP_files.get_trigger_info(filename, ant=None)[source]

Get the trigger information from a triggered measure.

Parameters:
  • filename – the name of the measure file.
  • ant – the name of the antenna. Default is automatically discovered.

:returns trigger dataset as a numpy array.

USRP_files.get_tx_info(filename, ant=None)[source]

Retrive TX information from file.

:param ant (optional) string to specify transmitter. Default is the first found. :return Parameter dictionary

class USRP_files.global_parameter[source]

Global paramenter object representing a measure.

from_dict(ant, dictionary)[source]

Initialize the global parameter object from a dictionary.

Arguments:
  • ant: a string containing one of the following ‘A_TXRX’, ‘B_TXRX’, ‘A_RX2’, ‘B_RX2’. Where the first letter ferers to the front end and the rest to the connector.
  • dictionary: a dictionary containing the parameters.
Note:
if the object is already initialize it overwrites only the parameters in the dictionary otherwise it initializes the object to flat zero before applying the dictionary.
Returns:
  • boolean representing the success of the operation
get_active_rx_param()[source]

Discover which is(are) the active receiver designed by the global parameter object.

Returns:
list of active rx antenna names : this names correspond to the parameter group in the h5 file and to the dictionary name in the (this) parameter object.
get_active_tx_param()[source]

Discover which is(are) the active emitters designed by the global parameter object.

Returns:
list of active tx antenna names : this names correspond to the parameter group in the h5 file and to the dictionary name in the (this) parameter object.
initialize()[source]

Initialize the parameter object to a zero configuration.

pprint()[source]

Output on terminal a diagnosti string representing the parameters.

self_check()[source]

Check if the parameters are coherent.

Returns:
booleare representing the result of the check
Note:
To know what’s wrong, check the warnings.
set(ant, param_name, val)[source]

Initialize the global parameters object and set a parameter value.

Arguments:
  • ant: a string containing one of the following ‘A_TXRX’, ‘B_TXRX’, ‘A_RX2’, ‘B_RX2’. Where the first letter ferers to the front end and the rest to the connector.
  • param_name: a string containing the paramenter name one wants to change. For a complete list of accepeted parameters see section ? in the documentation.
  • val: value to assign.
Returns:
Boolean value representing the success of the operation.
Note:
if the parameter object is already initialized it does not overwrite the other paramenters. This function DOES NOT perform any check on the input parameter; for that check the self_check() method.
to_json()[source]

Convert the global parameter object to JSON string.

Returns:
  • the string to be filled with the JSON
USRP_files.is_VNA_analyzed(filename, usrp_number=0)[source]

Check if the VNA file has been preanalyzed. Basically checks the presence of the VNA group inside the file. :param filename: The file to check. :param usrp_number: usrp server number. :return: boolean results of the check.

USRP_files.is_VNA_dynamic_analyzed(filename, usrp_number=0)[source]

Check if the VNA file has been preanalyzed as a dynamic VNA. Basically checks the presence of the VNA_dynamic group inside the file. :param filename: The file to check. :param usrp_number: usrp server number. :return: boolean results of the check.

USRP_files.openH5file(filename, ch_list=None, start_sample=None, last_sample=None, usrp_number=None, front_end=None, verbose=False, error_coord=False, big_file=False)[source]

Retrive Raw data from an hdf5 file generated with pyUSRP.

Parameters:
  • filename – Name of the file to open
  • ch_list – a list containing the channel number tp open.
  • start_sample – first sample returned.
  • last_sample – last sample returned.
  • usrp_number – if the file contains more than one USRP data, select the usrp server number.
  • front_end – select the front end for data sourcing. Default is automatically detected or A.
  • verbose – print more information about the opening process.
  • error_coord – If True returns (samples, err_coord) where err_coord is a list of tuples containing start and end sample of each faulty packet.
  • big_file – default is False. if True last_sample and start_sample are ignored and the hdf5 object containing the raw data is returned. This is usefull when dealing with very large files. IMPORTANT: is user responsability to close the file if big_file is True, see return sepcs.
Returns:

array-like object containing the data in the form data[channel][samples].

Returns:

In case big_file is True returns the file object (so the user is able to close it) and the raw dataset. (file_pointer, dataset)

Returns:

in case of error_coord True returns also the erorrs coordinate ((file_pointer,) dataset, errors)

The “Fitting” module

This is a homebrew module to find, fit, store and plot the cryogenic resonators S21 profiles

USRP_fitting.S21_func(f, f0, A, phi, D, dQr, dQe_re, dQe_im, a)[source]

Given a frequency range (f) and the resonator paramters return the S21 complex function. d<param name> is intended as 1./<param name>

USRP_fitting.complex_of_real(r)[source]

Does the inverse of real_of_complex() function. :param r: real + imaginary data :return: array of complex numbers

USRP_fitting.do_fit(freq, re, im, p0=None)[source]

Function internally used to fit the resonators. This is not the function to call to fit a VNA scan, to do that, try vna_fit(). Notes: * f0 in p0 is in MHz

USRP_fitting.extimate_peak_number(filename, threshold=0.2, smoothing=None, peak_width=200000.0, verbose=False, exclude_center=True, diagnostic_plots=False)[source]

This function uses peakutils module to initialize the peaks i the file. Stores in the H5 file the result. This does not count as a fit as only the initialization is stored.

Arguments:
  • Filename: filename of the h5 vna file.
  • threshold: a number between 0 an 1 determaning the peak finding. The threshold is applied to the absolute value of the derivative of s21.
  • smoothing: if the vna is too noise one may consider decimation and fir filtering. dmoothing is the decimation factor.
  • peak_width: minimum distance between each peak.
  • verbose: output some diagnostic information.
  • exclude_center: exclude the center (DC) from the fitting.
  • diagnostic_plots: creates a folder with diagnostic png plots.
Returns:the number of extimated peaks.
USRP_fitting.get_best_readout(filename, verbose=False)[source]

Get the best readout frequency from a fitted resonator keeping in account the nonlinear firt model.

Argumets:
  • filename: the h5 file containing the fit data.
  • verbose: print some debug line.
Return:
  • A list of frequencies (one per each fitted resonator).
USRP_fitting.get_fit_data(filename, verbose=False)[source]

Retrive fit data from a file. For fit data is intended the fitted S21.

Arguments:
  • filename the name of the h5 file containing the data.
  • verbose: print some debug information.
Return:
  • List of dictionaries with keys “frequency”, “fitted”, “original”
Note:
  • This function does not returns the fit parameters. to do that use get_fit_param().
USRP_fitting.get_fit_param(filename, verbose=False)[source]

Retrive fit parameters from a file.

Arguments:
  • filename the name of the h5 file containing the data.
  • verbose: print some debug information.
Return:
  • List of dictionaries with keys named after parameters. Specifically: f0, A, phi, D, Qi, Qr, Qe, a
USRP_fitting.get_tones(filename, frontends=None, verbose=False)[source]

Get the central frequency and the list with relative tones.

Parameters:
  • filename – the filename containing the fits (i.e. a VNA file).
  • frontends – can be an antenna name [‘A_RX2’,’B_RX2’], ‘all’ or None.
  • verbose – print some debug line.

:return if the argument ‘all’ is False return a tuple containing the central frequency and a list of relative tones; if None return the first frontend found in RX mode; if frontend name return the tones found in that frontend.

USRP_fitting.initialize_from_VNA(original_VNA, new_VNA, verbose=False)[source]

Initialize the peaks in a new VNA file using fitted parameters from an other VNA file that has already been fitted. This function overwrites the Resonato group of the new_VNA file. :param original_VNA: name of the VNA file containing the fits. :param new_VNA: name of the VNA file to initialize. :param verbose: print debug strings.

USRP_fitting.initialize_peaks(filename, N_peaks=1, smoothing=None, peak_width=90000.0, Qr_cutoff=5000.0, a_cutoff=10, Mag_depth_cutoff=0.15, verbose=False, exclude_center=True, diagnostic_plots=False)[source]

This function uses a filter on quality factor estimated using the nonlinear resonator model. This function considers the resonator around the maximum of the unwraped phase trace, tries to fit the resonator and make a decision if it’s a resonator or not by parsing the quality factor of the fit with the Qt_vutoff argument. Before iterating excludes a zone of peak_width Hz around the previously considered point. Stores in the H5 file the result. This does not count as a fit as only the initialization is stored.

Arguments:
  • Filename: filename of the h5 vna file.
  • smoothing: if the vna is too noise one may consider decimation and fir filtering. dmoothing is the decimation factor.
  • peak_width: minimum distance between each peak.
  • Qr_cutoff: thrashold above wich a fit will result in a resonaton being stored.
  • a_cutoff: cutoff on asymmetry (if the fit returns a>a_cutoff is discarded)
  • Mag_depth_cutoff: cutoff on magnitude depth of the resonance in dB.
  • N_peaks: how may peaks to expect. If this number is bigger than the actual number of resonator, the search process will end after all the frequency chunks are masked.
  • verbose: output some diagnostic information.
  • exclude_center: exclude the center (DC) from the fitting.
  • diagnostic_plots: creates a folder with diagnostic png plots.
Returns:
  • boolean: False if the number of requested peaks does not corresond to the number of peaks found.
USRP_fitting.min_readout_spacing(filename, verbose=False)[source]

Calculate the minimum spacing between f0s of a fitted VNA file.

USRP_fitting.nonlinear_model(f, f0, A, phi, D, dQr, dQe_re, dQe_im, a)[source]

Non-linear model for fitting resonators developed by Albert and Bryan.

Parameters:
  • f – Array containing frequency in MHz.
  • f0 – Resonant frequency in MHz.
  • A – Amplitude of the resonator circle
  • phi – phase of the resonator center
  • D – Line delay of the line in ns?
  • dQr – Inverse of Qr.
  • dQe_re – Inverse of the real part of coupling quality factor.
  • dQe_im – Inverse of the imaginary part of the coupling quality factor.
  • a – Non-linear parameter.
Returns:

USRP_fitting.plot_reso_stat(filenames, reso_freq=None, backend='matplotlib', title_info=None, additional_info=None, verbose=False, output_filename=None, auto_open=True, attr=None)[source]

Plot the resonators parameters in function of the readout power or a custom attribute.

Arguments:
  • filenames: the funcion accept a list of filenames where to source data. A single filename is fine also.
  • attr: if instead of plotting in function of power you want to plot in function of a custom attribute contained in the raw_data0 group, provvide here the name of the attribute as a string.
  • reso_freq: list of resonator frequency in MHz. This arguments is useful to plot only selected resonator from file. The resonator will be selected with the closest approximation of the f0.
  • backend: the backend used to plot. ‘matplotlib’ and ‘plotly’ are currently supported. Both will save a file to disk. Default is matplotlib.
  • verbose: print some debug line.
  • output_filename: set hte name of the output file without the extension (that depends on the backend).
  • auto_open: in case of plotly backend this enable or disable the opening of the plot in the browser.
  • keyword arguments:
    • figsize: fihure size for matplotlib backend.
    • add_info: listo of strings. Must be the same length of the file list. Add information to the legend ion the plot.
    • title: add information to the title of the plot.
Return:
  • None
USRP_fitting.plot_resonators(filenames, reso_freq=None, backend='matplotlib', title_info=None, verbose=False, output_filename=None, auto_open=True, attenuation=None, **kwargs)[source]

Plot the resonators and the resonator fits.

Arguments:
  • filenames: the funcion accept a list of filenames where to source data. A single filename is fine also.
  • reso_freq: list of resonator frequency in MHz. This arguments is useful to plot only selected resonator from file. The resonator will be selected with the closest approximation of the f0.
  • backend: the backend used to plot. ‘matplotlib’ and ‘plotly’ are currently supported. Both will save a file to disk. Default is matplotlib.
  • verbose: print some debug line.
  • output_filename: set hte name of the output file without the extension (that depends on the backend).
  • auto_open: in case of plotly backend this enable or disable the opening of the plot in the browser.
  • attenuation: readout powe will be displayed in the legend, this value helps matching the SDR output power with the on-chip power. The value is in dB.
  • keyword args:
    • figsize: figure size for matplotlib backend.
    • add_info: listo of strings. Must be the same lresonreso_grp[resonator]atorength of the file list. Add information to the legend ion the plot.
    • title: Change the title of the plot.
    • single_plots: if this option is True a folder named resonators_<vna_filename> will be created/accessed and one plot per each resonator created. This option only works with the matplotlib backend.
Return:
  • The filename of the saved plot.
USRP_fitting.real_of_complex(z)[source]

Flatten n-dim complex vector to 2n-dim real vector for fitting. :param z: array of complex numbers. :return: an array composed by real and imaginary part of the number.

USRP_fitting.vna_fit(filename, p0=None, fit_range=100000.0, verbose=False)[source]

Open a pre analyzed, pre plotted (with tagged resonator inside) .h5 VNA file and fit the resonances in it. Creates a new group in the “.h5” file called “resonators” and save fitted curve and attributes in it.

Arguments:
  • filename: string representing the name of the target .h5 file without the “.h5” extension
  • p0 : initial parameters for the fit. if None (default: None: the function tries to generate initial parameters)
  • fit_range: half size in Hz of a the interval around the resonator to consider for the fit
  • verbose: print some diagnostic information
Returns:
Returns boolean: True if the number of succesfull fit corresponds to the number of initialized fit, False otherwise.
Known bugs:
  • initialization of the parameters is not complete, the quality factor is just guessed as a constant
Notes:
  • ported from Bryan’s code: subfunctions for effective fit.

The “Noise” module

Contains the functions needed to acquire, analyze and plot single tones noise data from the resonators.

USRP_noise.Get_noise(tones, measure_t, rate, decimation=None, amplitudes=None, RF=None, tx_gain=0, output_filename=None, Front_end=None, Device=None, delay=None, pf_average=4, mode='DIRECT', trigger=None, **kwargs)[source]

Perform a noise acquisition using fixed tone technique.

Arguments:
  • tones: list of tones frequencies in Hz (absolute if RF is not given, relative to RF otherwise).
  • measure_t: duration of the measure in seconds.
  • decimation: the decimation factor to use for the acquisition. Default for PFB mode is minimum. Note that with the PFB the decimation factor can only be >= N_tones. This parameter represent actual decimation for the DIRECT mode.
  • amplitudes: a list of linear power to use with each tone. Must be the same length of tones arg; will be normalized. Default is equally splitted power.
  • RF: central up/down mixing frequency. Default is deducted by other arguments.
  • tx_gain: gain to use in the transmission side.
  • output_filename: eventual filename. default is datetime.
  • Front_end: the front end to be used on the USRP. default is A.
  • Device: the on-server device number to use. default is 0.
  • delay: delay between TX and RX processes. Default is taken from the INTERNAL_DELAY variable.
  • pf_average: pfb averaging factor. Default is 4 for PFB mode and 1 for DIRECT mode.
  • mode: noise acquisition kernels. DIRECT uses direct demodulation PFB use the polyphase filter bank technique. Note that PF average will refer to something slightly different in DIRECT mode (moving average ratio: 1 has no overlap).
  • trigger: class used for triggering. (See trigger section for more info). Default is no trigger.
  • kwargs:
    • verbose: additional prints. Default is False.
    • push_queue: queue for post writing samples.
Note:
  • In the PFB acquisition scheme the decimation factor and bin width are directly correlated. This function execute a check on the input parameters to determine the number of FFT bins to use.
Returns:
  • filename of the measure file.
USRP_noise.calculate_frequency_timestream(noise_frequency, noise_data, fit_param)[source]

Convert IQ timestreams into frequency and quality factor timestreams. Derived from Albert’s function to convert noise data in f0 stream data. The original function has been stripped of the matplotlib capabilities and adapted to the scope of this library.

Arguments:
  • noise_frequency: float, Noise acquisition tone in Hz.
  • noise_data: list of complex, Noise data already scaled as S21 (see diagnosic() function).
  • fit_param: if fit parameters are given in the form (f0, A, phi, D, Qi, Qr, Qe_re, Qe_im,a, _, _, pcov), the fit won’t be executed again.
Returns:
  • X noise
  • Qr noise
USRP_noise.calculate_noise(filename, welch=None, dbc=False, rotate=True, usrp_number=0, ant=None, verbose=False, clip=0.1)[source]

Generates the FFT of each channel stored in the .h5 file and stores the results in the same file.

Parameters:
  • welch – in how many segment to divide the samples given for applying the Welch method.
  • dbc – scales samples to calculate dBc spectra.
  • rotate – if True rotate the IQ plane.

TODO: * Default behaviour should be getting all the available RX antenna.

USRP_noise.copy_resonator_group(VNA_filename, NOISE_filename)[source]

Copy the resonator groups from a VNA file to a mnoise file.

Arguments:
  • VNA_filename: name of the file containing the resonator group (can also be an other noise file).
  • NOISE_filename: name of the file in which to copy the resonator group. If an other resonator group is in place, it will be rewrited.
Returns:
  • None
USRP_noise.diagnostic_VNA_noise(noise_filename, points=None, VNA_file=None, ant='A_RX2', backend='matplotlib', **kwargs)[source]

Plot the VNA traces and the noise (averaged or in N points) on the same plot to check for acquisition consistency. The noise file has to contain the Resonators group in order to use this function; to copy that from a VNA file use the function #copy_resonator_group().

Parameters:
  • noise_filename – noise acquisition filename.
  • points – the default behaviour is to average every channel in a single point; if this argument is >1 the noise will be decimated in that number of points.
  • VNA_file – if the fit information has to be taken from an external VNA file fill this argument with the filename.
  • backend – Choose the plotting backend. Currently implemented: plotly and matplotlib
  • ant – specify the antenna used to take noise data. Default is A_RX2
  • kwargs
    • auto_open: plotly backend specific, determines if after saving the plot the browser is called.
    • figsize: matplotlib specific argument: figure size of the plot or each plot.

TODO: allow this function to interpret multiple VNA sources and multiple noise files.

USRP_noise.dual_get_noise(tones_A, tones_B, measure_t, rate, decimation=None, amplitudes_A=None, amplitudes_B=None, RF_A=None, RF_B=None, tx_gain_A=0, tx_gain_B=0, output_filename=None, Device=None, delay=None, pf_average=None, mode='DIRECT', **kwargs)[source]

Perform a noise acquisition using fixed tone technique on both frontend with a symmetrical PFB setup

Arguments:
  • tones_A/B: list of ABSOLUTE tones frequencies in Hz for frontend A/B.
  • measure_t: duration of the measure in seconds.
  • decimation: the decimation factor to use for the acquisition. Default is minimum. Note that with the PFB the decimation factor can only be >= N_tones.
  • amplitudes_A/B: a list of linear power to use with each tone. Must be the same length of tones arg; will be normalized. Default is equally splitted power.
  • RF_A/B: central up/down mixing frequency. Default is deducted by other arguments.
  • tx_gain_A/B: gain to use in the transmission side.
  • output_filename: eventual filename. default is datetime.
  • Device: the on-server device number to use. default is 0.
  • delay: delay between TX and RX processes. Default is taken from the INTERNAL_DELAY variable.
  • pf_average: pfb averaging factor. Default is 4 for PFB mode and 1 for DIRECT mode.
  • mode: noise acquisition kernels. DIRECT uses direct demodulation PFB use the polyphase filter bank technique. Note that PF average will refer to something slightly different in DIRECT mode (moving average ratio: 1 has no overlap).
  • kwargs:
    • verbose: additional prints. Default is False.
    • push_queue: queue for post writing samples.
Note:
  • In the PFB acquisition scheme the decimation factor and bin width are directly correlated. This function execute a check on the input parameters to determine the number of FFT bins to use.
Returns:
  • filename of the measure file.
USRP_noise.get_frequency_timestreams(NOISE_filename, start=None, end=None, channel_freq=None, frontend=None)[source]

Returns the frequency and quality factor timestreams from a noise file in which a resonator group has been already copied. To copy the resonator group refer to copy_resonator_group() function.

Arguments:
  • NOISE_filename: Name of the noise file.
  • start: start time in seconds. Default is from the beginning of the file.
  • end: end of the data in seconds. Default is up to file’s end.
  • channel_freq: list of frequency of the channels to return. Default is all of them.
  • frontend: from which frontend to take the noise data. Default is A.
Returns:
  • tuple containing frequency timestreams and quality factor timestreams. Each element of the tuple is a list of timestreams.
Example:
>>> frequencies, Q_factors = get_frequency_timestreams("noisefile.h5", start = 1, end = 1.5, channel_freq = 325.5):
>>> # This will retrive frequency and quality factor timestreams of the 325.5 MHz channel (or closest) from the file "noisefile.h5" between 1 and 1.5 seconds of acquisition.
USRP_noise.plot_frequency_timestreams(filenames, decimation=None, displayed_samples=None, low_pass=None, backend='matplotlib', output_filename=None, channel_list=None, start_time=None, end_time=None, auto_open=True, **kwargs)[source]

Plot frequency timestreams from given H5 noise files.

Arguments:
  • a list of strings containing the files to plot.
  • decimation: eventually deciamte the signal before plotting.
  • displayed_samples: calculate decimation to display a certain number of samples.
  • low pass: floating point number controlling the cut-off frequency of a low pass filter that is eventually applied to the data.
  • backend: [string] choose the return type of the plot. Allowed backends for now are:
    • matplotlib: creates a matplotlib figure, plots in non-blocking mode and return the matplotlib figure object. kwargs in this case accept:
      • size: size of the plot in the form of a tuple (inches,inches). Default is matplotlib default.
    • plotly: plot using plotly and webgl interface, returns the html code descibing the plot. kwargs in this case accept:
      • size: size of the plot. Default is plotly default.
    • bokeh: use bokeh to generate an interactive html file containing the IQ plane and the magnitude/phase timestream.
  • output_filename: string: name of the file saved. Default is a timestamp.
  • channel_list: select only al list of channels to plot.
  • start_time: time where to start plotting. Default is 0.
  • end_time: time where to stop plotting. Default is end of the measure.
  • auto_open: open the plot in default system browser if plotly backend is selected (non-blocking). Default is True.
  • kwargs:
    • usrp_number and front_end can be passed to the openH5file() function.
    • fig_size: the size of matplotlib figure.
    • add_info: list of strings as long as the file list to add info to the legend.
Returns:
  • the complete name of the saved file or None in case no file is saved.
Note:
  • Possible errors are signaled on the plot.
USRP_noise.plot_noise_spec(filenames, channel_list=None, max_frequency=None, title_info=None, backend='matplotlib', cryostat_attenuation=0, auto_open=True, output_filename=None, **kwargs)[source]

Plot the noise spectra of given, pre-analized, H5 files.

Arguments:
  • filenames: list of strings containing the filenames.
  • channel_list:
  • max_frequency: maximum frequency to plot.
  • title_info: add a custom line to the plot title
  • backend: see plotting backend section for informations.
  • auto_open: open the plot in default system browser if plotly backend is selected (non-blocking) or open the matplotlib figure (blocking). Default is True.
  • output_filename: output filename without any system extension. Default is Noise_timestamp().xx
  • kwargs:
    • usrp_number and front_end can be passed to the openH5file() function.
    • tx_front_end can be passed to manually determine the tx frontend to calculate the readout power.
    • add_info could be a list of the same length oF filenames containing additional legend information.
    • html will make the function retrn html code instead of saving a html file in case of plotly backend.
    • fig_size: matplotlib fig size in inches (xx,yy).

:return the name of the file saved

USRP_noise.spec_from_samples(samples, sampling_rate=1, welch=None, dbc=False, rotate=True, verbose=True, clip_samples=False)[source]

Calculate real and imaginary part of the spectra of a complex array using the Welch method.

Arguments:
  • Samples: complex array representing samples.
  • sampling_rate: sampling_rate
  • welch: in how many segment to divide the samples given for applying the Welch method
  • dbc: scales samples to calculate dBc spectra.
  • rotate: if True rotate the IQ plane
Returns:
  • Frequency array,
  • Imaginary spectrum array
  • Real spectrum array

The “Low level” module

Has all the boring functions needed to the other modules to work correctly

USRP_low_level.dbm2vrms(dbm)[source]

Converts a scalar or a numpy array from dbm to volts RMS assuming there is an impedence of 50 Ohm

Arguments:
  • vp: scalar or numpy array containig values in volt RMS to be converted in dmb
Returns:
  • scalar or numpy array containing the result
USRP_low_level.find_nearest(array, value)[source]

Utility function to find the nearest value in an array. :param array: array of numbers. :param value: value to find. :return: closest index.

USRP_low_level.get_timestamp()[source]

Returns the timestamp formatted in a stirng.

Returns:
string containing the timestamp.
USRP_low_level.mgr_init()[source]

Initialization for the thread synchronization manager. This is basically propagaring the Ctrl+C command to kill the threads (processes). This is ment to be used in: >>> manager.start(mgr_init)

Returns:None
USRP_low_level.nostdout(*args, **kwds)[source]

Silence stdoutput of function within a context.

Example: >>> with nostdout(): >>> f0,Qi,Qr,zfit,modelwise = do_fit(…)

USRP_low_level.print_debug(message)[source]

Print the message in italic grey. :param message: the debug message. :return: None

USRP_low_level.print_error(message)[source]

Print a red error label before message. :param message: the error message. :return: None

USRP_low_level.print_line(msg)[source]

Print without new line. :param message: string to print. :return: None

USRP_low_level.print_warning(message)[source]

Print a yellow warning label before message. :param message: the warning message. :return: None

USRP_low_level.to_list_of_str(user_input)[source]

Determines if the input is a string or a list of string. In case is not a list of string, returns a single element list; returns the list otherwise.

Arguments:
  • string or list of strings.
Returns:
  • list of strings.
Note:
  • I’m assuming the strings contain filenames that can’t be long 1.
USRP_low_level.vrms2dbm(vp)[source]

Converts a scalar or a numpy array from volts RMS to dbm assuming there is an impedence of 50 Ohm

Arguments:
  • vp: scalar or numpy array containig values in volt RMS to be converted in dmb
Returns:
  • scalar or numpy array containing the result

The “Plotting” module

Contains a few settings to modify the general look of the plotting plus some raw data plotting function.

USRP_plotting.get_color(N)[source]

Get a color for the list above without exceeding bounds. Usefull to change the overall color scheme.

Arguments:
N: index identifying stuff that has to have the same color.
Return:
string containing the color name.
USRP_plotting.plot_raw_data(filenames, decimation=None, displayed_samples=None, low_pass=None, backend='matplotlib', output_filename=None, channel_list=None, mode='IQ', start_time=None, end_time=None, auto_open=True, **kwargs)[source]

Plot raw data group from given H5 files.

Arguments:
  • a list of strings containing the files to plot.
  • decimation: eventually deciamte the signal before plotting.
  • displayed_samples: calculate decimation to display a certain number of samples.
  • low pass: floating point number controlling the order of a low pass filter (cut-off frequency 0.2F_Ny) that is eventually applied to the data.
  • backend: [string] choose the return type of the plot. Allowed backends for now are:
    • matplotlib: creates a matplotlib figure, plots in non-blocking mode and return the matplotlib figure object. kwargs in this case accept:
      • size: size of the plot in the form of a tuple (inches,inches). Default is matplotlib default.
    • plotly: plot using plotly and webgl interface, returns the html code descibing the plot. kwargs in this case accept:
      • size: size of the plot. Default is plotly default.
  • output_filename: string: name of the file saved. Default is a timestamp.
  • channel_list: select only al list of channels to plot.
  • mode: [string] how to print the IQ signals. Allowed modes are:
    • IQ: default. Just plot the IQ signal with no processing.
    • PM: phase and magnitude. The fase will be unwrapped and the offset will be removed.
  • start_time: time where to start plotting. Default is 0.
  • end_time: time where to stop plotting. Default is end of the measure.
  • auto_open: open the plot in default system browser if plotly backend is selected (non-blocking). Default is True.
  • kwargs:
    • usrp_number and front_end can be passed to the openH5file() function.
    • fig_size: the size of matplotlib figure.
    • add_info: list of strings as long as the file list to add info to the legend.
Returns:
  • the complete name of the saved file or None in case no file is saved.
Note:
  • Possible errors are signaled on the plot.

The “VNA” module

Has the functions needed to acquire, analyze and plot VNAs acquisitions

USRP_VNA.Dual_VNA(start_f_A, last_f_A, start_f_B, last_f_B, measure_t, n_points, tx_gain_A, tx_gain_B, Rate=None, decimation=True, RF_A=None, RF_B=None, Device=None, output_filename=None, Multitone_compensation_A=None, Multitone_compensation_B=None, Iterations=1, verbose=False, **kwargs)[source]

Perform a VNA scan using a two different frontens of a single USRP device.

Arguments:
  • start_f_A: frequency in Hz where to start scanning for frontend A (absolute if RF is not given, relative to RF otherwise).
  • last_f_A: frequency in Hz where to stop scanning for frontend A (absolute if RF is not given, relative to RF otherwise).
  • start_f_B: frequency in Hz where to start scanning for frontend B (absolute if RF is not given, relative to RF otherwise).
  • last_f_B: frequency in Hz where to stop scanning for frontend B (absolute if RF is not given, relative to RF otherwise).
  • measure_t: duration of the measure in seconds.
  • n_points: number of points to use in the VNA scan.
  • tx_gain_A: transmission amplifier gain for frontend A.
  • tx_gain_B: transmission amplifier gain for frontend B.
  • Rate: Optional parameter to control the scan rate. Default is calculate from start_f an last_f args.
  • decimation: if True the decimation of the signal will occur on-server. Default is True.
  • RF_A: central up/down mixing frequency for frontend A. Default is deducted by other arguments.
  • RF_B: central up/down mixing frequency for frontend B. Default is deducted by other arguments.
  • output_filename: eventual filename. default is datetime.
  • Device: the on-server device number to use. default is 0.
  • Multitone_compensation_A: integer representing the number of tones: compensate the amplitude of the signal to match a future multitones accuisition for frontend A.
  • Multitone_compensation_B: integer representing the number of tones: compensate the amplitude of the signal to match a future multitones accuisition for frontend B.
  • Iterations: by default a single VNA scan pass is performed.
  • verbose: if True outputs on terminal some diagnostic info. deafult is False.
  • keyword arguments: Each keyword argument will be interpreted as an attribute to add to the raw_data group of the h5 file.
Returns:
  • filename where the measure is or empty string if something went wrong.
USRP_VNA.Single_VNA(start_f, last_f, measure_t, n_points, tx_gain, Rate=None, decimation=True, RF=None, Front_end=None, Device=None, output_filename=None, Multitone_compensation=None, Iterations=1, verbose=False, **kwargs)[source]

Perform a VNA scan using a single frontend of a single USRP device.

Arguments:
  • start_f: frequency in Hz where to start scanning (absolute if RF is not given, relative to RF otherwise).
  • last_f: frequency in Hz where to stop scanning (absolute if RF is not given, relative to RF otherwise).
  • measure_t: duration of the measure in seconds.
  • n_points: number of points to use in the VNA scan.
  • tx_gain: transmission amplifier gain.
  • Rate: Optional parameter to control the scan rate. Default is calculate from start_f an last_f args.
  • decimation: if True the decimation of the signal will occur on-server. Default is True.
  • RF: central up/down mixing frequency. Default is deducted by other arguments.
  • output_filename: eventual filename. default is datetime.
  • Front_end: the front end to be used on the USRP. default is A.
  • Device: the on-server device number to use. default is 0.
  • Multitone_compensation: integer representing the number of tones: compensate the amplitude of the signal to match a future multitones accuisition.
  • Iterations: by default a single VNA scan pass is performed.
  • verbose: if True outputs on terminal some diagnostic info. deafult is False.
  • keyword arguments: Each keyword argument will be interpreted as an attribute to add to the raw_data group of the h5 file.
Returns:
  • filename where the measure is or empty string if something went wrong.
USRP_VNA.VNA_analysis(filename, usrp_number=0)[source]

Open a H5 file containing data collected with the function single_VNA() and analyze them as a VNA scan. Write the results in a corresponding VNA# group in the root of the H5 file.

Parameters:
  • filename – string containing the name of the H5 file.
  • usrp_number – usrp server number.
USRP_VNA.VNA_timestream_analysis(filename, usrp_number=0)[source]

Open a H5 file containing data collected with the function single_VNA() and analyze them as multiple VNA scans, one per iteration.

Parameters:
  • filename – string containing the name of the H5 file.
  • usrp_number – usrp server number.
USRP_VNA.VNA_timestream_plot(filename, backend='matplotlib', mode='magnitude', unwrap_phase=False, verbose=False, output_filename=None, **kwargs)[source]

Plot the VNA timestream analysis result.

Parameters:
  • filename – string containing the name of the H5 file.
  • backend – the backend used to plot the data.
  • mode – the mode used to plot the data: * magnitude: magnitude of the data. * phase: S21 phase. * df: magnitude of the derivarive of S21 in the frequency direction. * dt : magnitude of the derivarive of S21 in the time direction.
USRP_VNA.plot_VNA(filenames, backend='matplotlib', output_filename=None, unwrap_phase=True, verbose=False, **kwargs)[source]

Plot the VNA data from various files.

param filenames:
 

list of strings containing the filenames to be plotted.

param backend:

“matplotlib”, “plotly” are supported.

param output_filename:
 

filename of the output figure without extension. Default is VNA(_compare)_timestamp.xxx.

param unwrap_phase:
 

if False the angle of S21 is not unwrapped.

param verbose:

print some debug line.

param kwargs:
  • figsize=(xx,yy) inches for matplotlib backends.
  • add_info = [“..”,”..”,”..”] fore commenting each file in the legend.
  • html only to return a html text instead of nothing in case of plotly backend.
  • title is a string containing the title.
  • att: external attenuation: changes the label in the plot from readout power to on-chip power if given.
  • auto_open: for plotly backend. If True opens the plot in a browser. Default is True.

:return The filename of the file just created. if kwargs[‘html’] is True returns the html of the file instead.