Squid Curves

The squid_curves module takes data in open loop (only slow integral tracking) and steps through flux values to trace out a SQUID curve. This can be compared against the tracked SQUID curve which might not perfectly replicate this if these curves are poorly approximated by a sine wave (or ~3 harmonics of a fourier expansion).

The user can then plot individual channels and the fit associated via the plot_squid_fit function. The user may also plot summary statistics using the plot_squid_fit_summary function.

Data Taking and Plotting Example

This example steps through 50 bias voltages around 0.3 flux ramp peak-to-peak value and takes one data point of SQUID data at each bias voltage. This is done over all channels on band 1. Then it generates a SQUID fit plot for the 10th channel in the first band, and the last line creates summary plots for all channels in all bands. The output data product from take_squid_curve is written to disk.

Note, the user can instantiate two variables when calling take_squid_curve: rawdat, the rawdata output from calling take_squid_curve, and fit_dict, a dictionary that contains all of the fitting information. Here, we load the SQUID curve data written to disk and plot fits using that. We’re able to load in the raw data because take_squid_curve writes the raw data to disk (location stored in the raw data output).

Plots are displayed but not saved:

from sodetlib.operations import squid_curves
from sodetlib.det_config import DetConfig
import numpy as np

cfg  = DetConfig()
cfg.load_config_files(slot=3)
S = cfg.get_smurf_control(make_logfile=True)

rawdat = squid_curves.take_squid_curve(
  S, cfg, Npts=1, Nsteps=50, bands=[1],
  run_analysis=True, show_pb=True)

fname = rawdat[0]['filepath']
data = np.load(fname, allow_pickle=True).item()

squid_curves.plot_squid_fit(*data, 1, S.which_on(1)[10])
squid_curves.plot_squid_fit_summary(data)

API

sodetlib.operations.squid_curves.autocorr(wave)

Code to calculate the autocorrelation function of signal wave.

Parameters:

wave (float, ndarray) – signal to calculate autocorrelation on

Returns:

  • lags (float, ndarray) – time/x-shift of signal relative to itself

  • corrs (float, ndarray) – correlation coefficient at each lag

sodetlib.operations.squid_curves.dfduPhi0_to_dfdI(dfduphi0, M_in=2.27e-10)

Function to convert averaged squid slope (average squid gain) from units of Hz/micro-Phi0 to H per pA given the mutual inductance between the squid and TES circuit.

Parameters:
  • dfduphi0 (float) – SQUID gain in Hz per micro-Phi0

  • M_in (float) – Mutual inductance between SQUID and TES in units of Henries.

Returns:

dfdI_Hz_per_pA – SQUID gain in Hz per pA

Return type:

float

sodetlib.operations.squid_curves.estimate_fit_parameters(phi, noisy_squid_curve, nharmonics_to_estimate=5, min_acorr_dist_from_zero_frac=0.1)

Estimate rf-SQUID curve fit parameters to pass to fit_squid_curves as an initial guess for fitter.

Parameters:
  • phi (ndarray) – Array of fixed flux ramp bias voltages.

  • noisy_squid_curve (ndarray) – Array of rf-SQUID resonator frequencies, one for each flux ramp bias voltage.

  • nharmonics_to_estimate (int, optional, default 5) – Number of harmonics of fundamental squid curve frequency to estimate.

  • min_acorr_dist_from_zero_frac (float, optional, default 0.1) – Minimum distance to first peak in autocorrelation (used to estimate what how much fr bias current corresponds to 1 phi0) in units fraction of the input phi array (between 0 to 1)

Returns:

est – Estimated fit parameters. Returns None if unable to estimate the phi0 using lag and autocorrelation.

Return type:

ndarray or None

sodetlib.operations.squid_curves.fit_squid_curves(squid_data, fit_args=None, modify_data=True, show_pb=False)

Function for fitting squid curves taken with take_squid_curve.

Parameters:
  • squid_data (dictionary) – Output data product from take_squid_curves

  • fit_args (dictionary) – Dictionary of keyword arguments to be passed to estimate_fit_parameters

Returns:

fit_out – Dictionary of fit parameters.

Return type:

dictionary

sodetlib.operations.squid_curves.get_derived_params_and_text(data, model_params, idx)

Function to calculate some useful parameters derived from the primary squid curve fit parameters and return a text block to add to channel plots.

Parameters:
  • data (ndarray) – Output data dictionary from take_squid_curve.

  • model_params (dict) – Model parameters fitted to squid_curve_model.

  • idx (int) – Index of output data array for channel to get text for.

Returns:

  • plot_txt (str) – String to add to squid fit channel plot.

  • derived_params (dict) – Dictionary of useful parameters derived from the model fit.

sodetlib.operations.squid_curves.plot_squid_fit(data, band, channel, save_plot=False, S=None, plot_dir=None)

Plots data taken with take_squid_curve against fits from fit_squid_curve.

Parameters:
  • data (dict) – Output data product from take_squid_curves

  • band (int) – Band number

  • channel (int) – Channel number

  • save_plot (bool) – Boolean to toggle saving of plot to disk

  • S (PysmurfControl object, optional) – Used to grab plot_dir and publish plots

  • plot_dir (str) – Overrides plot_dir from S, if specified

sodetlib.operations.squid_curves.plot_squid_fit_summary(data, nbins=35, quantile=0.95)

Makes summary plots of squid curve fit parameters. Specifically, Phi_offset, df, dfdI, hhpwr, phi0.

Parameters:
  • data (dict) – Dictionary output created from take_squid_curves. Used to find data[‘bands’].size and data[‘popts’] values.

  • nbins (int) – Number of bins to use for histograms.

  • quantile (float) – Plot data that falls within the quantile given.

sodetlib.operations.squid_curves.squid_curve_model(phi, *p)

Functional form of squid curve, basically a fourier expansion (with n-harmonics).

Parameters:
  • phi (float, ndarray) – depedent variable in function

  • p (ndarray) –

    indices::

    0: period in fraction_full_scale 1: offset phase in fraction_full_scale 2: central value (mean) of squid curve 3 to N: amplitude of the (N-3)th harmonic of the squid curve.

sodetlib.operations.squid_curves.take_squid_curve(S, cfg, wait_time=0.1, Npts=4, Nsteps=500, bands=None, channels=None, lms_gain=None, out_path=None, run_analysis=True, analysis_kwargs=None, show_pb=False, run_serial_ops=True, frac_full_scale_max=0.3)

Takes data in open loop (only slow integral tracking) and steps through flux values to trace out a SQUID curve. This can be compared against the tracked SQUID curve which might not perfectly replicate this if these curves are poorly approximated by a sine wave (or ~3 harmonics of a fourier expansion).

Parameters:
  • S (pysmurf.client.base.smurf_control.SmurfControl) – pysmurf control object

  • cfg (sodetlib.det_config.DeviceConfig) – device config object.

  • wait_time (float) – how long you wait between flux step point in seconds

  • Npts (int) – number of points you take at each flux bias step to average

  • Nsteps (int) – Number of flux points you will take total.

  • bands (int, list) – list of bands to take dc SQUID curves on

  • channels (dict) – default is None and will run on all channels that are on otherwise pass a dictionary with a key for each band with values equal to the list of channels to run in each band.

  • lms_gain (int) – gain used in tracking loop filter and set in tracking_setup defaults to None and pulls from det_config

  • out_path (str, filepath) – directory to output npy file to. defaults to None and uses pysmurf plot directory (S.plot_dir)

  • run_serial_ops (bool) – If true, will run serial grad descent and eta scan

  • frac_full_scale_max (float) – Max value of fraction full scale to use.

Returns:

data – This contains the flux bias array, channel array, and frequency shift at each bias value for each channel in each band. As well as the dictionary of fitted values returned by fit_squid_curves if run_analysis argument is set to True.

Return type:

dict