Welcome to broadbean’s documentation!

The broadbean package is a tool for creating and manipulating pulse sequences.


class broadbean.broadbean.PulseAtoms

A class full of static methods. The basic pulse shapes.

Any pulse shape function should return a list or an np.array and have SR, npoints as its final two arguments.

Rounding errors are a real concern/pain in the business of making waveforms of short duration (few samples). Therefore, the PulseAtoms take the number of points rather than the duration as input argument, so that all ambiguity can be handled in one place (the _subelementBuilder)

static gaussian(ampl, sigma, mu, offset, SR, npts)

Returns a Gaussian of peak height ampl (when offset==0)

Is by default centred in the middle of the interval

static gaussian_smooth_cutoff(ampl, sigma, mu, offset, SR, npts)

Returns a Gaussian of peak height ampl (when offset==0)

Is by default centred in the middle of the interval

smooth cutoff by making offsetting the Gaussian so endpoint = 0 and normalizing the hight to 1

broadbean.broadbean.marked_for_deletion(replaced_by: Optional[str] = None) → Callable

A decorator for functions we want to kill. The function still gets called.

exception broadbean.ripasso.MissingFrequenciesError
broadbean.ripasso.applyCustomTransferFunction(signal, SR, tf_freqs, tf_amp, invert=False)

Apply custom transfer function

Given a signal, its sample rate, and a provided transfer function, apply the transfer function to the signal.

Parameters:
  • signal (np.array) – A numpy array containing the signal
  • SR (int) – The sample rate of the signal (Sa/s)
  • tf_freqs (np.array) – The frequencies of the transfer function. Must be monotonically increasing.
  • tf_amp (np.array) – The amplitude of the transfer function. Must be dimensionless.
  • invert (Optional[bool]) – If True, the inverse transfer function is applied. Default: False.
Returns:

The modified signal.

Return type:

np.array

broadbean.ripasso.applyInverseRCFilter(signal, SR, kind, f_cut, order, DCgain=1)

Apply the inverse of an RC-circuit filter to a signal and return the compensated signal.

Note that a high-pass filter in principle has identically zero DC gain which requires an infinite offset to compensate.

Parameters:
  • signal (np.array) – The input signal. The signal is assumed to start at t=0 and be evenly sampled at sample rate SR.
  • SR (int) – Sample rate (Sa/s) of the input signal
  • kind (str) – The type of filter. Either ‘HP’ or ‘LP’.
  • f_cut (float) – The cutoff frequency of the filter (Hz)
  • order (int) – The order of the filter. The first order filter is applied order times.
  • DCgain (Optional[float]) – The DC gain of the filter. ONLY used by the high-pass filter. Default: 1.
Returns:

The filtered signal along the original time axis. Imaginary parts are discarded prior to return.

Return type:

np.array

Raises:
  • ValueError – If kind is neither ‘HP’ nor ‘LP’
  • ValueError – If DCgain is zero.
broadbean.ripasso.applyRCFilter(signal, SR, kind, f_cut, order, DCgain=0)

Apply a simple RC-circuit filter to signal and return the filtered signal.

Parameters:
  • signal (np.array) – The input signal. The signal is assumed to start at t=0 and be evenly sampled at sample rate SR.
  • SR (int) – Sample rate (Sa/s) of the input signal
  • kind (str) – The type of filter. Either ‘HP’ or ‘LP’.
  • f_cut (float) – The cutoff frequency of the filter (Hz)
  • order (int) – The order of the filter. The first order filter is applied order times.
  • DCgain (Optional[float]) – The DC gain of the filter. ONLY used by the high-pass filter. Default: 0.
Returns:

The filtered signal along the original time axis. Imaginary parts are discarded prior to return.

Return type:

np.array

Raises:

ValueError – If kind is neither ‘HP’ nor ‘LP’

Indices and tables