Mode picture module

@author: Sam Schott (ss2151@cam.ac.uk)

(c) Sam Schott; This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 2.0 UK: England & Wales License.

experiment.mode_picture_dataset.lorentz_peak(x, x0, w, a)[source]

Lorentzian with area a, full-width-at-half-maximum w, and center x0.

class experiment.mode_picture_dataset.ModePicture(input_path_or_data, freq=9.385, metadata=None)[source]

Class to store mode pictures. It provides methods to calculate Q-values, and save and load mode picture data from and to .txt files.

If several mode pictures with different zoom factors are given, ModePicture will rescale and combine the data into a single mode picture.

Parameters
  • input_path_or_data (dict) – Dict with zoom factors as keys and respective mode picture data sets as values or path to file with saved mode picture data.

  • freq (float) – Cavity resonance frequency in GHz as float.

  • metadata (dict) – Optional dictionary with metadata to save in the file header.

Variables
  • x_data_mhz – Numpy array with x-axis data of mode picture in MHz.

  • x_data_points – Numpy array with x-axis data of mode picture in pts.

  • y_data – Mode picture y-axis data (absorption of cavity).

  • freq0 – Center frequency of cavity resonance.

  • qvalue – Fitted Q-Value.

  • qvalue_stderr – Standard error of Q-Value from fitting.

combine_data(mode_pic_data)[source]

Rescales mode pictures from different zoom factors and combines them to one.

Parameters

mode_pic_data (dict) – Dict with zoom factors as keys and respective mode picture curves as values.

Returns

(x_axis_mhz_comb, x_axis_points_comb, mode_pic_comb) where x_axis_mhz_comb and x_axis_points_comb are the combined x-axis values of all mode pictures in mhz and points, respectively, and mode_pic_comb is the combines y-axis data in a.u..

fit_qvalue(x_data, y_data, zoom_factor=1)[source]

Least square fit of Lorentzian and polynomial background to mode picture.

Parameters
  • x_data – Iterable containing x-data of mode picture in points.

  • y_data – Iterable containing y-data of mode picture in a.u..

  • zoom_factor – Zoom factor (scaling factor of x-axis).

Returns

(q_value, fit_result) where fit_result is a

get_qvalue_stderr()[source]

Determines 1 sigma confidence bounds for Q-value.

Returns

Standard error of Q-value from fitting.

Return type

float

plot()[source]

Plots mode picture and the least squares fit used to determine the Q-value. Requires matplotlib.

save(filepath)[source]

Saves mode picture data as a text file with headers. If no file path is given, the user is prompted to select a location and name through a user interface.

Parameters

filepath (str) – Absolute file path.

load(path)[source]

Loads mode picture data from text file and determines the resulting Q-factor.

Parameters

path (str) – Path of file.