tune module

smurf_tune

class pysmurf.client.tune.smurf_tune.SmurfTuneMixin(log=None, epics_root=None, offline=False, pub_root=None, script_id=None, **kwargs)[source]

This contains all the tuning scripts

analyze_eta_phase_check(dat, channel)[source]
assign_channels(freq, band=None, bandcenter=None, channel_per_subband=4, as_offset=True, min_offset=0.1, new_master_assignment=False)[source]

Figures out the subbands and channels to assign to resonators

Parameters
  • freq (float array) – The frequency of the resonators. This is not the same as the frequency output from full_band_resp. This is only where the resonators are.

  • band (int or None, optional, default None) – The band to assign channels.

  • band_center (float array or None, optional, default None) – The frequency center of the band. Must supply band or subband center.

  • channel_per_subband (int, optional, default 4) – The number of channels to assign per subband.

  • min_offset (float, optional, default 0.1) – The minimum offset between two resonators in MHz. If closer, then both are ignored.

Returns

  • subbands (int array) – An array of subbands to assign resonators.

  • channels (int array) – An array of channel numbers to assign resonators.

  • offsets (float array) – The frequency offset from the subband center.

calculate_eta_svd(band, channel, nsamp=32768, filter=True, N=4, Wn=50000, btype='lowpass', method='gust', make_plot=True, show_plot=False, save_plot=True, subtract_median=True, update_eta_phase=True)[source]

Takes I and Q data at attempts to calculate the eta parameters by maximizing the noise in Q. This uses SVD to calculate the rotation.

Parameters
  • band (int) – The 500 Mhz band

  • channel (int) – The channel number in the 500 Mhz band.

  • nsamp (int, optional, default 2**15) – The number of samples to take to estimate the rotation. Warning: nsamp > 2**16 occassionaly crashes the SVD calculation.

  • filter (bool, optional, default True) – Whether to filter the data before eta estimation

  • N (int, optional, default 4) – The filter order

  • Wn (int, optional, default 50000) – The cutoff frequency in Hz of the filter.

  • btype (str, optional, default 'lowpass') – The type of filter to use. See scipy.filter for more info.

  • method (str, optional, default "gust") – The type of filtering to use in the filter application

  • make_plot (bool, optional, default True) – Whether to make the plot

  • show_plot (bool, optional, default False,) – Whether to show the plot.

  • save_plot (bool, optional, default True) – Whether to save the plot.

  • subtract_median (bool, optional, default True) – Whether to subtract the median of the timestream. This mainly matters for plotting.

  • update_eta_phase (bool, optional, default True) – Whether to update the phase in the PV after caluclating the eta rotation

  • Ret

  • ---

  • ang (float) – The angle to rotate the eta parameter

check_freq_scale(f1, f2)[source]

Makes sure that items are the same frequency scale (ie MHz, kHZ, etc.)

Parameters
  • f1 (float) – The first frequency.

  • f2 (float) – The second frequency.

Returns

same_scale – Whether the frequency scales are the same.

Return type

bool

check_lock(band, f_min=0.015, f_max=0.2, df_max=0.03, make_plot=False, flux_ramp=True, fraction_full_scale=None, lms_freq_hz=None, reset_rate_khz=None, feedback_start_frac=None, feedback_end_frac=None, lms_enable1=None, lms_enable2=None, lms_enable3=None, lms_gain=None, **kwargs)[source]

Takes a tracking setup and turns off channels that have bad tracking. The limits are set by the variables f_min, f_max, and df_max. The output is stored to freq_resp[band][‘lock_status’] dict.

Parameters
  • band (int) – The band the check.

  • f_min (float, optional, default 0.015) – The maximum frequency swing.

  • f_max (float, optional, default 0.2) – The minimium frequency swing.

  • df_max (float, optional, default 0.03) – The maximum value of the stddev of df.

  • make_plot (bool, optional, default False) – Whether to make plots.

  • flux_ramp (bool, optional, default True) – Whether to flux ramp or not.

  • fraction_full_scale (float, optional, default None) – Number between 0 and 1. The amplitude of the flux ramp. If None, doesn’t change what’s currently being used.

  • lms_freq_hz (float or None, optional, default None) – The tracking frequency in Hz. If None, doesn’t change what’s currently being used.

  • reset_rate_khz (float or None, optional, default None) – The flux ramp reset rate in kHz. If None, doesn’t change what’s currently being used.

  • feedback_start_frac (float or None, optional, default None) – What fraction of the flux ramp to skip before feedback. Float between 0 and 1. If None, doesn’t change what’s currently being used.

  • feedback_end_frac (float or None, optional, default None) – What fraction of the flux ramp to skip at the end of feedback. Float between 0 and 1. If None, doesn’t change what’s currently being used.

  • lms_enable1 (bool, optional, default None) – Whether to use the first harmonic for tracking. If None, doesn’t change what’s currently being used.

  • lms_enable2 (bool or None, optional, default None) – Whether to use the second harmonic for tracking. If None, doesn’t change what’s currently being used.

  • lms_enable3 (bool or None, optional, default None) – Whether to use the third harmonic for tracking. If None, doesn’t change what’s currently being used.

  • lms_gain (int or None, optional, default None) – Tracking loop gain. If None, doesn’t change what’s currently being used.

  • **kwargs – Arbitrary keyword arguments. Passed to some register sets and gets.

check_lock_flux_ramp_off(band, df_max=0.03, make_plot=False, **kwargs)[source]

Simple wrapper function for check_lock with the flux ramp off

dump_state(output_file=None, return_screen=False)[source]

Dump the current tuning info to config file and write to disk

Parameters
  • output_file (str or None, optional, default None) – Path to output file location. Defaults to the config file status dir and timestamp

  • return_screen (bool, optional, default False) – Whether to also return the contents of the config file in addition to writing to file.

estimate_flux_ramp_amp(band, n_phi0, write_log=True, reset_rate_khz=None, new_epics_root=None, channel=None)[source]

This is like estimate_lms_freq, except it changes the flux ramp amplitude instead of the flux ramp frequency.

Parameters
  • band (int) – The band to measure.

  • n_phi0 (float) – The number of phi0 desired per flux ramp cycle. It is recommended, but not required that this is an integer.

  • write_log (bool, optional, default True) – Whether to write log messages.

  • reset_rate_khz (float or None, optional, default None) – The reset (or flux ramp cycle) frequency in kHz. If None, reads the current value.

  • channel (int array or None, optional, default None) – The channels to use to estimate the amplitude. If None, uses all channels that are on.

estimate_lms_freq(band, reset_rate_khz, fraction_full_scale=None, new_epics_root=None, channel=None, make_plot=False)[source]

Attempts to estimate the carrier (phi0) rate for all channels on in the requested 500 MHz band (0..7) using the flux_mod2 routine.

Parameters
  • band (int) – Will attempt to estimate the carrier rate on the channels which are on in this band.

  • reset_rate_khz (float) – The flux ramp reset rate (in kHz).

  • fraction_full_scale (float or None, optional, default None) – Passed on to the internal tracking_setup call - the fraction of full scale exercised by the flux ramp. Defaults to value in cfg.

  • new_epics_root (str or None, optional, default None) – Passed on to internal tracking_setup call ; If using a different RTM to flux ramp, the epics root of the pyrogue server controlling that RTM.

  • channel (int array or None, optional, default None) – Passed on to the internal flux_mod2 call. Which channels (if any) to plot.

  • make_plot (bool, optional, default False) – Whether or not to make plots.

Returns

The estimated lms frequency in Hz.

Return type

float

eta_estimator(band, subband, freq, resp, delta_freq=0.01, lock_max_derivative=False)[source]

Estimates eta parameters using the slow eta_scan.

Parameters
  • band (int) – The band.

  • subband (int) – The subband.

  • freq (float array) – Frequencies of scan.

  • resp (float array) – Response from scan.

eta_fit(freq, resp, peak_freq, delta_freq, make_plot=False, plot_chans=[], save_plot=True, band=None, timestamp=None, res_num=None, use_slow_eta=False)[source]

Cyndia’s eta finding code.

Parameters
  • freq (float array) – The frequency data.

  • resp (float array) – The response data.

  • peak_freq (float) – The frequency of the resonance peak.

  • delta_freq (float) – The width of frequency to calculate values.

  • make_plot (bool, optional, default False) – Whether to make plots.

  • plot_chans (int array, optional, default []) – The channels to plot. If an empty array, it will make plots for all channels.

  • save_plot (bool, optional, default True) – Whether to save plots.

  • band (int or None, optional, default None) – Only used for plotting - the band number of the resontaor.

  • timestamp (str or None, optional, default None) – The timestamp of the data.

  • res_num (int or None, optional, default None) – The resonator number.

Returns

  • eta (complex) – The eta parameter.

  • eta_scaled (complex) – The eta parameter divided by subband_half_width.

  • eta_phase_deg (float) – The angle to rotate IQ circle.

  • r2 (float) – The R^2 value compared to the resonator fit.

  • eta_mag (float) – The amplitude of eta.

  • latency (float) – The delay.

  • Q (float) – The resonator quality factor.

eta_phase_check(band, rot_step_size=30, rot_max=360, reset_rate_khz=None, fraction_full_scale=None, flux_ramp=True)[source]
eta_scan(band, subband, freq, tone_power, write_log=False, sync_group=True)[source]

Slow eta scan on one subband.

Runs a slow eta scan on one channel. Uses the first channel (ordered by channel number) in the subband. Starts by turning off every channel in the requested band if there are any channels currently on in that band, then runs the eta scan on the first channel in the requested subband. At the end of the scan, sets the channel amplitude to zero. Returns the real and imaginary components of the response.

Warning

This function uses a different convention for the real and imaginary quadratures than e.g. setup_notches(). To convert data returned by this function to the convention used by setup_notches(), you can use the following transformation to scale the returned rr and ii arrays from this function to match the convention used in setup_notches():

ii - 1j*rr

Warning

For historical reasons, you should perform this scaling on the data returned by this function (which returns the results from get_eta_scan_results_real() and get_eta_scan_results_imag() before using it:

rr = np.asarray(rr)
idx = np.where( rr > 2**23 )
rr[idx] = rr[idx] - 2**24
rr /= 2**23

ii = np.asarray(ii)
idx = np.where( ii > 2**23 )
ii[idx] = ii[idx] - 2**24
ii /= 2**23
Parameters
  • band (int) – Which band.

  • subband (int) – Which subband.

  • freq (numpy.ndarray or list) – Frequencies to scan in subband, with respect to subband center, in MHz.

  • tone_power (int) – The drive amplitude to eta scan with. For most SMuRF firmware versions this is an integer in [0,15].

  • write_log (bool, optional, default False) – Whether to write log messages.

  • sync_group (bool, optional, default True) – Whether not to wait for register change using SyncGroup().

Returns

rr, ii – Real (=rr) and imaginary (=ii) response from the sweep. The real part is obtained from get_eta_scan_results_real(), and the imaginary part from get_eta_scan_results_imag(). Note that the convention does not match that used by the setup_notches() routine!

Return type

numpy.ndarray,:py:class:numpy.ndarray

See also

setup_notches()

Faster eta scan on many channels.

fake_resonance_dict(freqs, save_sweeps=False)[source]

Takes a list of resonance frequencies and fakes a resonance dictionary so that we can run setup_notches on a subset without find_freqs

Parameters
  • freqs (list of floats) – Given in MHz, list of frequencies to tune. Need to be within 100kHz to be really effective

  • save_sweeps (bool, optional, default False) – Whether to save each band as an amplitude sweep.

Returns

freq_dict – Resonance dictionary like the one that comes out of find_freqs You probably want to assign it to the right place, as in S.freq_resp = S.fake_resonance_dict(freqs).

Return type

dict

fast_eta_scan(band, subband, freq, n_read, tone_power, make_plot=False)[source]

copy of fastEtaScan.m from Matlab. Sweeps quickly across a range of freq and gets I, Q response

Parameters
  • band (int) – Which 500MHz band to scan.

  • subband (int) – Which subband to scan.

  • freq ((n_freq x 1 array) – Frequencies to scan relative to subband center.

  • n_read (int) – Number of times to scan.

  • tone_power (int) – Tone power.

  • make_plot (bool, optional, default False) – Make eta plots.

Returns

  • resp ((n_freq x 2 array)) – Real, imag response as a function of frequency.

  • freq ((n_freq x n_read array)) – Frequencies scanned, relative to subband center.

fast_relock(band)[source]
find_all_peak(freq, resp, subband=None, rolling_med=False, window=500, grad_cut=0.05, amp_cut=0.25, freq_min=- 250000000.0, flip_phase=False, grad_kernel_width=8, freq_max=250000000.0, make_plot=False, save_plot=True, show_plot=False, plotname_append='', band=None, make_subband_plot=False, subband_plot_with_slow=False, timestamp=None, pad=2, min_gap=2, plot_phase=False)[source]

find the peaks within each subband requested from a fullbandamplsweep

Parameters
  • freq (array) – (n_subbands x n_freq_swept) array of frequencies swept.

  • resp (complex array) – n_subbands x n_freq_swept array of complex response

  • subband (list of int or None, optional, default None) – Subbands that we care to search in.

  • rolling_med (bool, optional, default False) – Whether to use a rolling median for the background.

  • window (int, optional, default 500) – Number of samples to window together for rolling med.

  • grad_cut (float, optional, default 0.05) – The value of the gradient of phase to look for resonances.

  • amp_cut (float, optional, default 0.25) – The fractional distance from the median value to decide whether there is a resonance.

  • flip_phase (bool, optional, default False) – Whether to flip the sign of phase before evaluating the gradient cut.

  • plot_phase (bool, optional, default False) – Whether to generate a plot showing just the phase information

  • freq_min (float, optional, default -2.5e8) – The minimum frequency relative to the center of the band to look for resonances. Units of Hz.

  • freq_max (float, optional, default 2.5e8) – The maximum frequency relative to the center of the band to look for resonances. Units of Hz.

  • make_plot (bool, optional, default False) – Whether to make a plot.

  • save_plot (bool, optional, default True) – Whether to save the plot to self.plot_dir.

  • show_plot (bool, optional, default False) – Whether to show the plot to screen.

  • plotname_append (str, optional, default '') – Appended to the default plot filename.

  • band (int or None, optional, default None) – The band to take find the peaks in. Mainly for saving and plotting.

  • make_subband_plot (bool, optional, default False) – Whether to make a plot per subband. This is very slow.

  • timestamp (str or None, optional, default None) – The timestamp. Mainly for saving and plotting.

  • pad (int, optional, default 2) – Number of samples to pad on either side of a resonance search window.

  • min_gap (int, optional, default 2) – Minimum number of samples between resonances.

Returns

peaks – The frequency of all the peaks found.

Return type

float array

find_flag_blocks(flag, minimum=None, min_gap=None)[source]

Find blocks of adjacent points in a boolean array with the same value.

Parameters
  • flag (array-like of bool) – The array in which to find blocks.

  • minimum (int or None, optional, default None) – The minimum length of block to return. Discards shorter blocks.

  • min_gap (int or None, optional, default None) – The minimum gap between flag blocks. Fills in gaps smaller.

Returns

  • starts (list of int) – The start indices for each block.

  • ends (list of int) – The end indices for each block. NOTE: the end index is the last index in the block. Add 1 for slicing, where the upper limit should be after the block

find_freq(band, start_freq=- 250, stop_freq=250, subband=None, tone_power=None, n_read=2, make_plot=False, save_plot=True, plotname_append='', window=50, rolling_med=True, make_subband_plot=False, show_plot=False, grad_cut=0.05, flip_phase=False, grad_kernel_width=8, amp_cut=0.25, pad=2, min_gap=2)[source]

Finds the resonances in a band (and specified subbands)

Parameters
  • band (int) – The band to search.

  • start_freq (float, optional, default -250) – The scan start frequency in MHz (from band center)

  • stop_freq (float, optional, default 250) – The scan stop frequency in MHz (from band center)

  • subband (deprecated, use start_freq/stop_freq.) – numpy.ndarray of int or None, optional, default None An int array for the subbands. If None, set to all processed subbands =numpy.arange(13,115). Takes precedent over start_freq/stop_freq.

  • tone_power (int or None, optional, default None) – The drive amplitude. If None, takes from cfg.

  • n_read (int, optional, default 2) – The number sweeps to do per subband.

  • make_plot (bool, optional, default False) – Make the plot frequency sweep.

  • save_plot (bool, optional, default True) – Save the plot.

  • plotname_append (str, optional, default '') – Appended to the default plot filename.

  • window (int, optional, default 50) – The width of the rolling median window.

  • rolling_med (bool, optional, default True) – Whether to iterate on a rolling median or just the median of the whole sample.

  • grad_cut (float, optional, default 0.05) – The value of the gradient of phase to look for resonances.

  • flip_phase (bool, optional, default False) – Whether to flip the sign of phase before evaluating the gradient cut.

  • amp_cut (float, optional, default 0.25) – The fractional distance from the median value to decide whether there is a resonance.

  • pad (int, optional, default 2) – Number of samples to pad on either side of a resonance search window

  • min_gap (int, optional, default 2) – Minimum number of samples between resonances.

find_peak(freq, resp, rolling_med=True, window=5000, grad_cut=0.5, amp_cut=0.25, freq_min=- 250000000.0, freq_max=250000000.0, make_plot=False, save_plot=True, plotname_append='', show_plot=False, band=None, subband=None, make_subband_plot=False, subband_plot_with_slow=False, timestamp=None, pad=50, min_gap=100, plot_title=None, grad_kernel_width=8, highlight_phase_slip=True, amp_ylim=None, flip_phase=False, plot_phase=False)[source]

Find the peaks within a given subband.

Parameters
  • freq (float array) – Should be a single row of the broader freq array, in Mhz.

  • resp (complex array) – Complex response for just this subband.

  • rolling_med (bool, optional, default True) – Whether to use a rolling median for the background.

  • window (int, optional, default 5000) – Number of samples to window together for rolling med.

  • grad_cut (float, optional, default 0.5) – The value of the gradient of phase to look for resonances.

  • flip_phase (bool, optional, default False) – Whether to flip the sign of phase before evaluating the gradient cut.

  • plot_phase (bool, optional, default False) – Whether to generate a plot showing just the phase information

  • amp_cut (float, optional, default 0.25) – The fractional distance from the median value to decide whether there is a resonance.

  • freq_min (float, optional, default -2.5e8) – The minimum frequency relative to the center of the band to look for resonances. Units of Hz.

  • freq_max (float, optional, default 2.5e8) – The maximum frequency relative to the center of the band to look for resonances. Units of Hz.

  • make_plot (bool, optional, default False) – Whether to make a plot.

  • save_plot (bool, optional, default True) – Whether to save the plot to self.plot_dir.

  • plotname_append (str, optional, default '') – Appended to the default plot filename.

  • show_plot (bool, optional, default False) – Whether or not to show plots.

  • band (int or None, optional, default None) – The band to take find the peaks in. Mainly for saving and plotting.

  • subband (int or None, optional, default None) – The subband to take find the peaks in. Mainly for saving and plotting.

  • make_subband_plot (bool, optional, default False) – Whether to make a plot per subband. This is very slow.

  • timestamp (str or None, optional, default None) – The timestamp. Mainly for saving and plotting.

  • pad (int, optional, default 50) – Number of samples to pad on either side of a resonance search window.

  • min_gap (int, optional, default 100) – Minimum number of samples between resonances.

  • grad_kernel_width (int, optional, default 8) – The number of samples to take after a point to calculate the gradient of phase.

  • highlight_phase_slip (bool, optional, default True) – Whether to highlight the phase slip.

  • amp_ylim (float or None, optional, default None) – The ylim for the amplitude plot. If None, does nothing.

Returns

resonances – The frequency of the resonances in the band in Hz.

Return type

float array

flux_mod(df, sync, threshold=0.4, minscale=0.02, min_spectrum=0.9, make_plot=False)[source]

Joe made this

flux_mod2(band, df, sync, min_scale=0, make_plot=False, channel=None, threshold=0.5)[source]

Attempts to find the number of phi0s in a tracking_setup. Takes df and sync from a tracking_setup with feedback off.

Parameters
  • band (int) – Which band.

  • df (float array) – The df term from tracking setup with feedback off.

  • sync (float array) – The sync term from tracking setup.

  • min_scale (float, optional, default 0) – The minimum df amplitude used in analysis. This is used to cut channels that are not responding to flux ramp.

  • make_plot (bool, optional, default False) – Whether to make a plot. If True, you must also supply the channels to plot using the channel opt arg.

  • channel (int or int array or None, optional, default None) – The channels to plot.

  • threshold (float, optional, default 0.5) – The minimum convolution amplitude to consider a peak.

Returns

n – The number of phi0 swept out per sync. To get lms_freq_hz, multiply by the flux ramp frequency.

Return type

float

flux_ramp_check(band, reset_rate_khz=None, fraction_full_scale=None, flux_ramp=True, save_plot=True, show_plot=False, setup_flux_ramp=True)[source]

Tries to measure the V-phi curve in feedback disable mode. You can also run this with flux ramp off to see the intrinsic noise on the readout channel.

Parameters
  • band (int) – The band to check.

  • reset_rate_khz (float or None, optional, default None) – The flux ramp rate in kHz.

  • fraction_full_scale (float or None, optional, default None) – The amplitude of the flux ramp from zero to one.

  • flux_ramp (bool, optional, default True) – Whether to flux ramp.

  • save_plot (bool, optional, default True) – Whether to save the plot.

  • show_plot (bool, optional, default False) – Whether to show the plot.

  • setup_flux_ramp (bool, optional, default True) – Whether to setup the flux ramp at the end.

flux_ramp_setup(reset_rate_khz, fraction_full_scale, df_range=0.1, band=2, write_log=False, new_epics_root=None)[source]

Set flux ramp sawtooth rate and amplitude.

Flux ramp reset rate must integer divide 2.4MHz. E.g. you can’t run with a 7kHz flux ramp rate. If you ask for a flux ramp reset rate which doesn’t integer divide 2.4MHz, you’ll get the closest reset rate to your requested rate that integer divides 2.4MHz.

If you are not using the timing system, you can use any flux ramp rate which integer divides 2.4MHz.

If you are using a timing system (i.e. if get_ramp_start_mode() returns 0x1), you may only select from a handful of pre-programmed reset rates. See set_ramp_rate() for more details.

Parameters
  • reset_rate_khz (float) – The flux ramp rate to set in kHz.

  • fraction_full_scale (float) – The amplitude of the flux ramp as a fraction of the maximum possible value.

  • df_range (float, optional, default 0.1) – If the difference between the desired fraction full scale and the closest achievable fraction full scale exceeds this will turn off the flux ramp and raise an exception.

  • band (int, optional, default 2) – The band to setup the flux ramp on.

  • write_log (bool, optional, default False) – Whether to write output to the log.

  • new_epics_root (str or None, optional, default None) – Override the original epics root. If None, does nothing.

Raises

ValueError – Raised if either 1) the requested RTM clock rate is too low (<2MHz) or 2) the difference between the desired fraction full scale and the closest achievable fraction full scale exceeds the df_range argument.

freq_to_band(frequency, band_center_list)[source]

Convert the frequency to which band we’re in. This is almost certainly a duplicate but I can’t find the original…

Parameters
  • frequency (float) – Frequency in MHz.

  • band_center_list (list) – Frequency centers of bands we’re running with. Formatted as [[band_no, band_center],[band_no, band_center],etc.]

Returns

band_no – Which band.

Return type

int

full_band_ampl_sweep(band, subband, tone_power, n_read, n_step=31)[source]

sweep a full band in amplitude, for finding frequencies

Parameters
  • band (int) – bandNo (500MHz band).

  • subband (int) – Which subbands to sweep.

  • tone_power (int) – Drive power.

  • n_read (int) – Numbers of times to sweep.

Returns

  • freq ((list, n_freq x 1)) – Frequencies swept.

  • resp ((array, n_freq x 2)) – Complex response.

full_band_resp(band, n_scan=1, nsamp=524288, make_plot=False, save_plot=True, show_plot=False, save_data=False, timestamp=None, save_raw_data=False, correct_att=True, swap=False, hw_trigger=True, write_log=False, return_plot_path=False, check_if_adc_is_saturated=True)[source]

Injects high amplitude noise with known waveform. The ADC measures it. The cross correlation contains the information about the resonances.

Parameters
  • band (int) – The band to sweep.

  • n_scan (int, optional, default 1) – The number of scans to take and average.

  • nsamp (int, optional, default 2**19) – The number of samples to take.

  • make_plot (bool, optional, default False) – Whether the make plots.

  • save_plot (bool, optional, default True) – If making plots, whether to save them.

  • show_plot (bool, optional, default False) – Whether to show plots.

  • save_data (bool, optional, default False) – Whether to save the data.

  • timestamp (str or None, optional, default None) – The timestamp as a string. If None, loads the current timestamp.

  • save_raw_data (bool, optional, default False) – Whether to save the raw ADC/DAC data.

  • correct_att (bool, optional, default True) – Correct the response for the attenuators.

  • swap (bool, optional, default False) – Whether to reverse the data order of the ADC relative to the DAC. This solved a legacy problem.

  • hw_trigger (bool, optional, default True) – Whether to start the broadband noise file using the hardware trigger.

  • write_log (bool, optional, default False) – Whether to write output to the log.

  • return_plot_path (bool, optional, default False) – Whether to return the full path to the summary plot.

  • check_if_adc_is_saturated (bool, optional, default True) – Right after playing the noise file, checks if ADC for the requested band is saturated. If it is saturated, gives up with an error.

Returns

  • f (float array) – The frequency information. Length nsamp/2.

  • resp (complex array) – The response information. Length nsamp/2.

get_closest_subband(f, band, as_offset=True)[source]

Gives the closest subband number for a given input frequency.

Parameters
  • f (float) – The frequency to search for a subband.

  • band (int) – The band to identify.

Returns

subband – The subband that contains the frequency.

Return type

int

get_eta_scan_result_channel(band)[source]

Convenience function that gets the channel assignments from eta scans.

Parameters

band (int) – The band.

Returns

channels – The channels of the resonators.

Return type

int array

get_eta_scan_result_eta(band)[source]

Convenience function that gets thee eta values from eta scans.

Parameters

band (int) – The band.

Returns

eta – The eta of the resonators.

Return type

complex array

get_eta_scan_result_eta_mag(band)[source]

Convenience function that gets thee eta mags from eta scans.

Parameters

band (int) – The band.

Returns

eta_mag – The eta of the resonators.

Return type

float array

get_eta_scan_result_eta_phase(band)[source]

Convenience function that gets the eta phase values from eta scans.

Parameters

band (int) – The band.

Returns

eta_phase – The eta_phase of the resonators.

Return type

float array

get_eta_scan_result_eta_scaled(band)[source]

Convenience function that gets the eta scaled from eta scans. eta_scaled is eta_mag/digitizer_freq_mhz/n_subbands

Parameters

band (int) – The band.

Returns

eta_scaled – The eta_scaled of the resonators.

Return type

float array

get_eta_scan_result_freq(band)[source]

Convenience function that gets the frequency results from eta scans.

Parameters

band (int) – The band.

Returns

freq – The frequency in MHz of the resonators.

Return type

float array

get_eta_scan_result_offset(band)[source]

Convenience function that gets the offset from center frequency from eta scans.

Parameters

band (int) – The band.

Returns

offset – The offset from the subband centers of the resonators.

Return type

float array

get_eta_scan_result_subband(band)[source]

Convenience function that gets the subband from eta scans.

Parameters

band (int) – The band.

Returns

subband – The subband of the resonators.

Return type

float array

get_fraction_full_scale(new_epics_root=None)[source]

Returns the fraction_full_scale.

Parameters

new_epics_root (str or None, optional, default None) – Overrides the initialized epics root.

Returns

fraction_full_scale – The fraction of the flux ramp amplitude.

Return type

float

get_group_list(band, group)[source]

Returns a list of all the channels in a band and bias group. Note that it is possible to have channels that are on the same bias group but different bands.

Parameters
  • band (int) – The band number.

  • group (int) – The bias group number.

Returns

bias_group_list – The list of channels that are in the band and bias group.

Return type

int array

get_group_number(band, ch)[source]

Gets the bias group number of a band, channel pair. The master_channel_assignment must be filled.

Parameters
  • band (int) – The band number.

  • ch (int) – The channel number.

Returns

bias_group – The bias group number.

Return type

int

get_master_assignment(band)[source]

Returns the master assignment list.

Parameters

band (int) – The band number.

Returns

  • freqs (float array) – The frequency of the resonators.

  • subbands (int array) – The subbands the channels are assigned to.

  • channels (int array) – The channels the resonators are assigned to.

  • groups (int array) – The bias group the channel is in.

last_tune()[source]

Returns the full path to the most recent tuning file.

load_master_assignment(band, filename)[source]

By default, pysmurf loads the most recent master assignment. Use this function to overwrite the default one.

Parameters
  • band (int) – The band for the master assignment file.

  • filename (str) – The full path to the new master assignment file. Should be in self.tune_dir.

load_tune(filename=None, override=True, last_tune=True, band=None)[source]

Loads the tuning information (self.freq_resp) from tuning directory

Parameters
  • filename (str or None, optional, default None) – The name of the tuning.

  • override (bool, optional, default True) – Whether to replace self.freq_resp.

  • last_tune (bool, optional, default True) – Whether to use the most recent tuning file.

  • band ((int, int array), optional, default None) – If None, loads entire tune. If band number is provided, only loads the tune for that band. Not used at all unless override=True.

make_master_assignment_from_file(band, tuning_filename)[source]

Makes a master assignment file

Parameters
  • band (int) – The band number.

  • tuning_filename (str) – The tuning file to use for generating the master_assignment.

make_sync_flag(sync)[source]

Takes the sync from tracking setup and makes a flag for when the sync is True.

Parameters

sync (float array) – The sync term from tracking_setup.

Returns

  • start (int array) – The start index of the sync.

  • end (int array) – The end index of the sync.

optimize_lms_delay(band, lms_delays=None, reset_rate_khz=None, fraction_full_scale=None, nsamp=262144, lms_gain=7, lms_freq_hz=None, meas_lms_freq=False, feedback_start_frac=0.2, feedback_end_frac=0.98, meas_flux_ramp_amp=True, n_phi0=4, make_plot=False, show_plot=False, save_plot=True, df_bins=None)[source]

Loops over multiple LMS delays and measures df. Looks for the minima of the median of the df terms for all the channels that are on. It is recommended that you turn off all bad channels before running this.

Parameters
  • band (int) – The 500 MHz band to optimize

  • lms_delays (int array, optional, default None) – The delays to test. If None, uses default values [12, 16, 20, 22, 23, 24, 25, 26, 28]

  • reset_rate_khz (float or None, optional, default None) – The flux ramp frequency.

  • fraction_full_scale (float or None, optional, default None) – The flux ramp amplitude, as a fraction of the maximum.

  • nsamp (int, optional, default 2**19) – The number of samples to take of the flux ramp

  • lms_gain (int or None, optional, default None) – The tracking gain parameters. Default is the value in the config table.

  • lms_freq_hz (float or None, optional, default None) – The frequency of the tracking algorithm.

  • meas_lms_freq (bool, optional, default False) – Whether or not to try to estimate the carrier rate using the flux_mod2 function. lms_freq_hz must be None.

  • feedback_start_frac (float or None, optional, default None) – The fraction of the full flux ramp at which to stop applying feedback in each flux ramp cycle. Must be in [0,1). Defaults to whatever’s in the cfg file.

  • feedback_end_frac (float or None, optional, default None) – The fraction of the full flux ramp at which to stop applying feedback in each flux ramp cycle. Must be >0. Defaults to whatever’s in the cfg file.

  • make_plot (bool, optional, default False) – Whether to make plots.

  • save_plot (bool, optional, default True) – Whether to save plots.

  • show_plot (bool, optional, default True) – Whether to display the plot.

  • meas_lms_freq – Whether or not to try to estimate the carrier rate using the flux_mod2 function. lms_freq_hz must be None.

  • meas_flux_ramp_amp (bool, optional, default False) – Whether or not to adjust fraction_full_scale to get the number of phi0 defined by n_phi0. lms_freq_hz must be None for this to work.

  • n_phi0 (float, optional, default 4) – The number of phi0 to match using meas_flux_ramp_amp.

  • df_bins (float array or None, optional, default None) – The histogram bins for the plotting. If None, set to np.arange(0,50.1,2.5).

Returns

  • lms_delays (int array) – A list of lms delays swept through

  • f_swing (float array) – The max - min swing for the flux ramp response

  • df_std (float array) – The standard deviation of the flux ramp df term

pad_flags(f, before_pad=0, after_pad=0, min_gap=0, min_length=0)[source]

Adds and combines flagging.

Parameters
  • f (list of bool) – The flag array to pad.

  • before_pad (int, optional, default 0) – The number of samples to pad before a flag.

  • after_pad (int, optional, default 0) – The number of samples to pad after a flag.

  • min_gap (int, optional, default 0) – The smallest allowable gap. If bigger, it combines.

  • min_length (int, optional, default 0) – The smallest length a pad can be.

Returns

pad_flag – The padded boolean array.

Return type

list of bool

plot_eta_fit(freq, resp, eta=None, eta_mag=None, peak_freq=None, eta_phase_deg=None, r2=None, save_plot=True, plotname_append='', show_plot=False, timestamp=None, res_num=None, band=None, sk_fit=None, f_slow=None, resp_slow=None, channel=None)[source]

Plots the eta parameter fits. This is called by self.eta_fit or plot_tune_summary.

Parameters
  • freq (float array) – The frequency data.

  • resp (complex array) – The response data.

  • eta (complex or None, optional, default None) – The eta parameter.

  • eta_mag (complex or None, optional, default None) – The amplitude of the eta parameter.

  • eta_phase_deg (float or None, optional, default None) – The angle of the eta parameter in degrees.

  • r2 (float or None, optional, default None) – The R^2 value.

  • save_plot (bool, optional, default True) – Whether to save the plot.

  • plotname_append (str, optional, default '') – Appended to the default plot filename.

  • timestamp (str or None, optional, default None) – The timestamp to name the file.

  • res_num (int or None, optional, default None) – The resonator number to label the plot.

  • band (int or None, optional, default None) – The band number to label the plot.

  • sk_fit (float array or None, optional, default None) – The fit parameters for the skewed lorentzian.

plot_find_freq(f=None, resp=None, subband=None, filename=None, save_plot=True, save_name='amp_sweep.png', show_plot=False)[source]

Plots the response of the frequency sweep. Must input f and resp, or give a path to a text file containing the data for offline plotting. To do: Add ability to use timestamp and multiple plots.

Parameters
  • f (float array or None, optional, default None) – An array of frequency data.

  • resp (complex array or None, optional, default None) – An array of find_freq response values.

  • subband (int array or None, optional, default None) – A list of subbands that are scanned.

  • filename (str or None, optional, default None) – The full path to the file where the find_freq is stored.

  • save_plot (bool, optional, default True) – Save the plot.

  • save_name (str, optional, default 'amp_sweep.png') – What to name the plot.

  • show_plot (bool, optional, default False) – Whether to show the plot.

plot_find_peak(freq, resp, peak_ind, save_plot=True, save_name=None)[source]

Plots the output of find_freq.

Parameters
  • freq (float array) – The frequency data.

  • resp (float array) – The response to full_band_resp.

  • peak_ind (int array) – The indicies of peaks found.

  • save_plot (bool, optional, default True) – Whether to save the plot.

  • save_name (str or None, optional, default None) – The name of the plot.

plot_tune_summary(band, eta_scan=False, show_plot=False, save_plot=True, eta_width=0.3, channels=None, plot_summary=True, plotname_append='')[source]

Plots summary of tuning. Requires self.freq_resp to be filled. In other words, you must run find_freq and setup_notches before calling this function. Saves the plot to plot_dir. This will also make individual eta plots as well if {eta_scan} is True. The eta scan plots are slow because there are many of them.

Parameters
  • band (int) – The band number to plot.

  • eta_scan (bool, optional, default False) – Whether to also plot individual eta scans. Warning this is slow.

  • show_plot (bool, optional, default False) – Whether to display the plot.

  • save_plot (bool, optional, default True) – Whether to save the plot.

  • eta_width (float, optional, default 0.3) – The width to plot in MHz.

  • channels (list of int or None, optional, default None) – Which channels to plot. If None, plots all available channels.

  • plot_summary (bool, optional, default True) – Plot summary.

  • plotname_append (str, optional, default '') – Appended to the default plot filename.

relock(band, res_num=None, tone_power=None, r2_max=0.08, q_max=100000, q_min=0, check_vals=False, min_gap=None, write_log=False)[source]

Turns on the tones. Also cuts bad resonators.

Parameters
  • band (int) – The band to relock.

  • res_num (int array or None, optional, default None) – The resonators to lock. If None, tries all the resonators.

  • tone_power (int or None, optional, default None) – The tone amplitudes to set.

  • r2_max (float, optional, default 0.08) – The highest allowable R^2 value.

  • q_max (float, optional, default 1e5) – The maximum resonator Q factor.

  • q_min (float, optional, default 0) – The minimum resonator Q factor.

  • check_vals (bool, optional, default False) – Whether to check r2 and Q values.

  • min_gap (float or None, optional, default None) – The minimum distance between resonators.

save_tune(update_last_tune=True)[source]

Saves the tuning information (self.freq_resp) to tuning directory

set_fixed_flux_ramp_bias(fractionFullScale, debug=True, do_config=True)[source]

No description

Parameters

fractionFullScale (float) – Fraction of full flux ramp scale to output from [-1,1].

setup_notches(band, resonance=None, tone_power=None, sweep_width=0.3, df_sweep=0.002, min_offset=0.1, delta_freq=None, new_master_assignment=False, lock_max_derivative=False, scan_unassigned=False)[source]

Does a fine sweep over the resonances found in find_freq. This information is used for placing tones onto resonators. It is recommended that you follow this up with run_serial_gradient_descent() afterwards.

Parameters
  • band (int) – The 500 MHz band to setup.

  • resonance (float array or None, optional, default None) – A 2 dimensional array with resonance frequencies and the subband they are in. If given, this will take precedent over the one in self.freq_resp.

  • tone_power (int or None, optional, default None) – The power to drive the resonators. Default is defined in cfg file.

  • sweep_width (float, optional, default 0.3) – The range to scan around the input resonance in units of MHz.

  • df_sweep (float, optional, default 0.002) – The sweep step size in MHz.

  • min_offset (float, optional, default 0.1) – Minimum distance in MHz between two resonators for assigning channels.

  • delta_freq (float or None, optional, default None) – The frequency offset at which to measure the complex transmission to compute the eta parameters. Passed to eta_estimator. Units are MHz. If None, takes value in config file.

  • new_master_assignment (bool, optional, default False) – Whether to create a new master assignment file. This file defines the mapping between resonator frequency and channel number.

  • scan_unassigned (bool, optional, default False) – Whether or not to scan unassigned channels. Unassigned channels are scanned serially after the much faster assigned channel scans.

track_and_check(band, channel=None, reset_rate_khz=None, make_plot=False, save_plot=True, show_plot=True, lms_freq_hz=None, flux_ramp=True, fraction_full_scale=None, lms_enable1=True, lms_enable2=True, lms_enable3=True, lms_gain=None, f_min=0.015, f_max=0.2, df_max=0.03, toggle_feedback=True, relock=True, tracking_setup=True, feedback_start_frac=None, feedback_end_frac=None, setup_flux_ramp=True)[source]

This runs tracking setup and check_lock to prune bad channels. This has all the same inputs and tracking_setup and check_lock. In particular the cut parameters are f_min, f_max, and df_max.

Parameters
  • band (int) – The band to track and check.

  • channel (int or int array or None, optional, default None) – List of channels to plot.

  • reset_rate_khz (float or None, optional, default None) – The flux ramp frequency.

  • make_plot (bool, optional, default False) – Whether to make plots.

  • save_plot (bool, optional, default True) – Whether to save plots.

  • show_plot (bool, optional, default True) – Whether to display the plot.

  • lms_freq_hz (float or None, optional, default None) – The frequency of the tracking algorithm.

  • flux_ramp (bool, optional, default True) – Whether to turn on flux ramp.

  • fraction_full_scale (float or None, optional, default None) – The flux ramp amplitude, as a fraction of the maximum.

  • lms_enable1 (bool, optional, default True) – Whether to use the first harmonic for tracking.

  • lms_enable2 (bool, optional, default True) – Whether to use the second harmonic for tracking.

  • lms_enable3 (bool, optional, default True) – Whether to use the third harmonic for tracking.

  • lms_gain (int or None, optional, default None) – The tracking gain parameters. Default is the value in the config file

  • f_min (float, optional, default 0.015) – The maximum frequency swing.

  • f_max (float, optional, default 0.20) – The minimium frequency swing.

  • df_max (float, optional, default 0.03) – The maximum value of the stddev of df.

  • toggle_feedback (bool, optional, default True) – Whether or not to reset feedback (both the global band feedbackEnable and the lmsEnables between tracking_setup and check_lock.

  • relock (bool, optional, default True) – Whether or not to relock at the start.

  • tracking_setup (bool, optional, default True) – Whether or not to run tracking_setup.

  • feedback_start_frac (float or None, optional, default None) – The fraction of the full flux ramp at which to stop applying feedback in each flux ramp cycle. Must be in [0,1). Defaults to whatever’s in the cfg file.

  • feedback_end_frac (float or None, optional, default None) – The fraction of the full flux ramp at which to stop applying feedback in each flux ramp cycle. Must be >0. Defaults to whatever’s in the cfg file.

  • setup_flux_ramp (bool, optional, default True) – Whether to setup the flux ramp at the end.

tracking_setup(band, channel=None, reset_rate_khz=None, write_log=False, make_plot=False, save_plot=True, show_plot=True, nsamp=524288, lms_freq_hz=None, meas_lms_freq=False, meas_flux_ramp_amp=False, n_phi0=4, flux_ramp=True, fraction_full_scale=None, lms_enable1=True, lms_enable2=True, lms_enable3=True, feedback_gain=None, lms_gain=None, return_data=True, new_epics_root=None, feedback_start_frac=None, feedback_end_frac=None, setup_flux_ramp=True, plotname_append='')[source]

The function to start tracking. Starts the flux ramp and if requested attempts to measure the lms (demodulation) frequency. Otherwise this just tracks at the input lms frequency. This will also make plots for the channels listed in {channel} input.

Parameters
  • band (int) – The band number.

  • channel (int or int array or None, optional, default None) – The channels to plot.

  • reset_rate_khz (float or None, optional, default None) – The flux ramp frequency.

  • write_log (bool, optional, default False) – Whether to write output to the log.

  • make_plot (bool, optional, default False) – Whether to make plots.

  • save_plot (bool, optional, default True) – Whether to save plots.

  • show_plot (bool, optional, default True) – Whether to display the plot.

  • nsamp (int, optional, default 2**19) – The number of samples to take of the flux ramp.

  • lms_freq_hz (float or None, optional, default None) – The frequency of the tracking algorithm.

  • meas_lms_freq (bool, optional, default False) – Whether or not to try to estimate the carrier rate using the flux_mod2 function. lms_freq_hz must be None.

  • meas_flux_ramp_amp (bool, optional, default False) – Whether or not to adjust fraction_full_scale to get the number of phi0 defined by n_phi0. lms_freq_hz must be None for this to work.

  • n_phi0 (float, optional, default 4) – The number of phi0 to match using meas_flux_ramp_amp.

  • flux_ramp (bool, optional, default True) – Whether to turn on flux ramp.

  • fraction_full_scale (float or None, optional, default None) – The flux ramp amplitude, as a fraction of the maximum.

  • lms_enable1 (bool, optional, default True) – Whether to use the first harmonic for tracking.

  • lms_enable2 (bool, optional, default True) – Whether to use the second harmonic for tracking.

  • lms_enable3 (bool, optional, default True) – Whether to use the third harmonic for tracking.

  • feedback_gain (Int16, optional, default None.) – The tracking feedback gain parameter. This is applied to all channels within a band. 1024 corresponds to approx 2kHz bandwidth. 2048 corresponds to approx 4kHz bandwidth. Tune this parameter to track the demodulated band of interest (0…2kHz for 4kHz flux ramp). High gains may affect noise performance and will eventually cause the tracking loop to go unstable.

  • lms_gain (int or None, optional, default None) –

    ** Internal register dynamic range adjustment ** ** Use with caution - you probably want feedback_gain** Select which bits to slice from accumulation over a flux ramp period. Tracking feedback parameters are integrated over a flux ramp period at 2.4MHz. The internal register allows for up to 9 bits of growth (from full scale). lms_gain = 0 : select upper bits from accumulation register (9 bits growth) lms_gain = 1 : select upper bits from accumulation register (8 bits growth) lms_gain = 2 : select upper bits from accumulation register (7 bits growth) lms_gain = 3 : select upper bits from accumulation register (6 bits growth) lms_gain = 4 : select upper bits from accumulation register (5 bits growth) lms_gain = 5 : select upper bits from accumulation register (4 bits growth) lms_gain = 6 : select upper bits from accumulation register (3 bits growth) lms_gain = 7 : select upper bits from accumulation register (2 bits growth)

    The max bit gain is given by ceil(log2(2.4e6/FR_rate)). For example a 4kHz FR can accumulate ceil(log2(2.4e6/4e3)) = 10 bits if the I/Q tracking parameters are at full scale (+/- 2.4MHz) Typical SQUID frequency throws of 100kHz have a bit growth of ceil(log2( (100e3/2.4e6)*(2.4e6/FR_rate) )) So 100kHz SQUID throw at 4kHz has bit growth ceil(log2(100e3/4e3)) = 5 bits. Try lms_gain = 4.

    This should be approx 9 - ceil(log2(100/reset_rate_khz)) for CMB applications.

    Too low of lms_gain will use only a small dynamic range of the streaming registers and contribute to incrased noise. Too high of lms_gain will overflow the register and greatly incrase noise.

  • return_data (bool, optional, default True) – Whether or not to return f, df, sync.

  • new_epics_root (str or None, optional, default None) – Override the original epics root.

  • feedback_start_frac (float or None, optional, default None) – The fraction of the full flux ramp at which to stop applying feedback in each flux ramp cycle. Must be in [0,1). Defaults to whatever’s in the cfg file.

  • feedback_end_frac (float or None, optional, default None) – The fraction of the full flux ramp at which to stop applying feedback in each flux ramp cycle. Must be >0. Defaults to whatever’s in the cfg file.

  • setup_flux_ramp (bool, optional, default True) – Whether to setup the flux ramp.

  • plotname_append (str, optional, default '') – Optional string to append plots with.

tune(load_tune=True, tune_file=None, last_tune=False, retune=False, f_min=0.02, f_max=0.3, df_max=0.03, fraction_full_scale=None, make_plot=False, save_plot=True, show_plot=False, new_master_assignment=False, track_and_check=True)[source]

This runs a tuning, does tracking setup, and prunes bad channels using check lock. When this is done, we should be ready to take data.

Parameters
  • load_tune (bool, optional, default True) – Whether to load in a tuning file. If False, will do a full tuning. This will be very slow (~ 1 hour)

  • tune_file (str or None, optional, default None) – The tuning file to load in. If tune_file is None and last_tune is False, this will load the default tune file defined in exp.cfg.

  • last_tune (bool, optional, default False) – Whether to load the most recent tuning file.

  • retune (bool, optional, default False) – Whether to re-run tune_band_serial to refind peaks and eta params. This will take about 5 minutes.

  • f_min (float, optional, default 0.02) – The minimum frequency swing allowable for check_lock.

  • f_max (float, optional, default 0.3) – The maximum frequency swing allowable for check_lock.

  • df_max (float, optional, default 0.03) – The maximum df stddev allowable for check_lock.

  • fraction_full_scale (float or None, optional, default None) – The fraction (between 0-1) to set the flux ramp amplitude.

  • make_plot (bool, optional, default False) – Whether to make a plot.

  • save_plot (bool, optional, default True) – If making plots, whether to save them.

  • show_plot (bool, optional, default False) – Whether to display the plots to screen.

  • new_master_assignment (bool, optional, default False) – Whether to make a new master assignment which forces resonators at a given frequency to a given channel.

  • track_and_check (bool, optional, default True) – Whether or not after tuning to run track and check.

tune_band(band, freq=None, resp=None, nsamp=524288, make_plot=False, show_plot=False, plot_chans=[], save_plot=True, save_data=True, make_subband_plot=False, n_scan=5, subband_plot_with_slow=False, tone_power=None, grad_cut=0.05, freq_min=- 250000000.0, freq_max=250000000.0, amp_cut=0.5, use_slow_eta=False)[source]

This does the full_band_resp, which takes the raw resonance data. It then finds the where the resonances are. Using the resonance locations, it calculates the eta parameters.

Parameters
  • band (int) – The band to tune.

  • freq (float array or None, optional, default None) – The frequency information. If both freq and resp are not None, it will skip full_band_resp.

  • resp (float array or None, optional, default None) – The response information. If both freq and resp are not None, it will skip full_band_resp.

  • nsamp (int, optional, default 2**19) – The number of samples to take in full_band_resp.

  • make_plot (bool, optional, default False) – Whether to make plots. This is slow, so if you want to tune quickly, set to False.

  • show_plot (bool, optional, default False) – Whether to display the plots to screen.

  • plot_chans (list, optional, default []) – If making plots, which channels to plot. If empty, will just plot all of them.

  • save_plot (bool, optional, default True) – Whether to save the plot. If True, it will close the plots before they are shown. If False, plots will be brought to the screen.

  • save_data (bool, optional, default True) – If True, saves the data to disk.

  • make_subband_plot (bool, optional, default False) – Whether to make a plot per subband. This is very slow.

  • n_scan (int, optional, default 5) – The number of scans to take and average.

  • grad_cut (float, optional, default 0.05) – The value of the gradient of phase to look for resonances.

  • freq_min (float, optional, default -2.5e8) – The minimum frequency relative to the center of the band to look for resonances. Units of Hz.

  • freq_max (float, optional, default 2.5e8) – The maximum frequency relative to the center of the band to look for resonances. Units of Hz.

  • amp_cut (float, optional, default 0.5) – The distance from the median value to decide whether there is a resonance.

Returns

resonances – A dictionary with resonance frequency, eta, eta_phase, R^2, and amplitude.

Return type

dict

tune_band_serial(band, nsamp=524288, make_plot=False, save_plot=True, save_data=True, show_plot=False, make_subband_plot=False, subband=None, n_scan=5, subband_plot_with_slow=False, window=5000, rolling_med=True, grad_cut=0.03, freq_min=- 250000000.0, freq_max=250000000.0, amp_cut=0.25, del_f=0.005, tone_power=None, new_master_assignment=False, from_old_tune=False, old_tune=None, pad=50, min_gap=50, highlight_phase_slip=True, amp_ylim=None)[source]

Tunes band using serial_gradient_descent and then serial_eta_scan. This requires an initial guess, which this function gets by either loading an old tune or by using the full_band_resp. This takes about 3 minutes per band if there are about 150 resonators. This saves the results to the freq_resp dictionary.

Parameters
  • band (int) – The band the tune.

  • nsamp (int, optional, default 2**19) – The number of samples to take in full_band_resp.

  • make_plot (bool, optional, default False) – Whether to make plots.

  • save_plot (bool, optional, default True) – Whether to save the plot. If True, it will close the plots before they are shown. If False, plots will be brought to the screen.

  • show_plot (bool, optional, default False) – If make_plot is True, whether to display the plots to screen.

  • make_subband_plot (bool, optional, default False) – Whether to make a plot per subband. This is very slow.

  • new_master_assignment (bool, optional, default False) – Whether to overwrite the previous master_assignment list.

  • from_old_tune (bool, optional, default False) – Whether to use an old tuning file. This will load a tuning file and use its peak frequencies as a starting point for serial_gradient_descent.

  • old_tune (str or None, optional, default None) – The full path to the tuning file.

  • highlight_phase_slip (bool, optional, default True) – Whether to highlight the phase slip.

  • amp_ylim (float or None, optional, default None) – The ylim for the amplitude plot. If None, does nothing.

unset_fixed_flux_ramp_bias(acCouple=True)[source]

Alias for setting ModeControl=0

write_group_assignment(bias_group_dict)[source]

Combs master channel assignment and assigns group number to all channels in ch_list. Does not affect other channels in the master file.

Parameters

bias_group_dict (dict) – The output of identify_bias_groups.

write_master_assignment(band, freqs, subbands, channels, bias_groups=None)[source]

Writes a comma-separated list in the form band, freq (MHz), subband, channel, group. Group number defaults to -1. The order of inputs is legacy and weird.

Parameters
  • band (int array) – A list of bands.

  • freqs (float array) – A list of frequencies.

  • subbands (int array) – A list of subbands

  • channels (int array) – A list of channel numbers

  • bias_groups (list of int or None, optional, default None) – A list of bias groups. If None, fills the array with -1.