utilities¶
-
wavgen.utilities.rp= [1.934454997984215, 2.8421067958595616, 2.677047569335915, 1.1721824508892977, 6.158065366794917, 3.2691669970332335, 2.636275384021578, 1.6254638780707589, 4.919003540925028, 1.6084971058993613, 5.2499387038268575, 2.3688357219496265, 4.713893357925578, 5.223088585470364, 0.3257672775855246, 2.9571038289407126, 2.4258010454280505, 4.084691833872798, 6.1867748426923335, 5.200604534623386, 3.3056812953203925, 4.189137888598024, 1.7650458297661427, 4.080234513102615, 0.6054340441874929, 1.6794564559420377, 2.385531129338364, 5.400612735688388, 4.978163766484847, 5.335873096123345, 0.9273414057111622, 2.4193737371833834, 2.8777346889035185, 6.214778264445415, 3.758998982400149, 3.7838618270241438, 0.60809445869596, 0.1507635470741596, 4.371624180280478, 4.539661740808455, 0.3847626491973457, 6.145153550108536, 1.008385520345513, 5.852133555294753, 0.016620198470431467, 2.0158660597106937, 1.7261705033296812, 5.223710321703292, 2.2220833343473436, 2.9180968688523863, 2.122206092376529, 5.402785161537129, 5.478771156577643, 2.291512850266888, 1.5715835663916051, 2.255249593007268, 1.571931477334538, 1.3993650740616836, 0.6011622182733365, 3.1927489491586014, 4.381746015200942, 1.974081456041723, 1.393542167751563, 5.521906837731298, 5.612290110455913, 2.31118503089683, 4.829965025115874, 0.3421538142269762, 4.555158230853398, 1.6134448025783288, 6.157248240200644, 5.027656526405459, 0.295901526406544, 5.502983369799478, 4.472320872860696, 1.7618458333352276, 4.41379605495804, 4.6652622669145725, 3.379174996566024, 2.9970834472120313, 4.886226685869682, 4.340847582571988, 0.3684494418446467, 3.3447731714626525, 0.3569784383241427, 0.2362652137260263, 4.420022732699935, 6.263528358483921, 6.2277672316776505, 6.0305138883226554, 2.5228306972997183, 0.29710864827838496, 0.5164352609138518, 3.079335706611155, 0.7796787693888715, 2.9068441712875255, 3.3802818513629718, 0.16738916961106443, 1.7466706296839072, 0.7532941316251239]¶ 100 Pre-calculated Random Phases in range [0, 2pi]
-
class
wavgen.utilities.Wave(freq, mag=1.0, phase=0.0)[source]¶ Describes a Sin wave.
-
Frequency¶ The frequency of the tone in Hertz.
- Type
int
-
Magnitude¶ A fraction, in [0,1], indicating the tone’s amplitude as a fraction of the comprising parent Waveform’s.
- Type
float
-
Phase¶ The initial phase, in [0, 2*pi], that the Wave begins with at the comprising parent Waveform’s start.
- Type
float
-
-
class
wavgen.utilities.Step(cur, seg, loops, nxt, tran=None)[source]¶ Describes 1 step in a control sequence.
-
CurrentStep¶ The Sequence index for this step, or step number.
- Type
int
-
SegmentIndex¶ The index into the segmented board memory, to house the associated Waveform.
- Type
int
-
Loops¶ - Number of times the Waveform is looped before checking
the
Transition.
- Type
int
-
NextStep¶ The Sequence index for the next step, or which step this one will transition to.
- Type
int
-
Transition¶ Accepts a keyword which sets the Transition Behavior, options:
NoneTransitions to
NextStepafter looping the WaveformLoopstimes.'trigger'Will Transition after looping set number of times, but only if a trigger event occurs.
'end'Terminates the sequence after the set number of loops have occurred. Stops the card output.
- Type
{None, ‘trigger’, ‘end’}
Hint
All above indices begin at 0.
-
-
wavgen.utilities.from_file(filepath, datapath)[source]¶ Extracts parameters from a HDF5 dataset and constructs the corresponding Waveform object.
- Parameters
filepath (str) – The name of the HDF5 file.
datapath (str) – Path to a specific dataset in the HDF5 database.
- Returns
Marshals extracted parameters into correct Waveform subclass constructor, returning the resulting object.
- Return type
Waveform
-
wavgen.utilities.y_limits(wav)[source]¶ Finds the max & min values of a
Waveformobject.- Parameters
wav (
Waveform) – Waveform object whose max & min values will be returned.- Returns
(Max, Min) values of the Waveform.
- Return type
(int, int)
-
wavgen.utilities.plot_ends(wav)[source]¶ Plots the endpoints of a
Waveform, as well as their concatenation.- Parameters
wav (
Waveform) –TODO (Allow for lists of Waveforms to be passes, resulting in each boundary (between Waveforms) to be plotted.) –
-
wavgen.utilities.gaussian1d(x, x0, w, amp, offset)[source]¶ Parameterized 1-Dimensional Gaussian.
- Parameters
x (ndarray or scalar) – Input value to evaluate the Gaussian at.
x0 (scalar) – Mean value or x-offset
w (scalar) – Standard-Deviation or width.
amp (scalar) – Amplitude or height.
offset (scalar) – Vertical offset of Gaussian.
- Returns
The value of the Gaussian at
x.- Return type
same as
x
-
wavgen.utilities.gaussianarray1d(x, x0_vec, w_vec, amp_vec, offset, ntraps)[source]¶ Superposition of parameterized 1-Dimensional Gaussians.
- Parameters
x (ndarray or scalar) – Domain or input values to evaluate the Gaussians across.
x0_vec (sequence of scalar) – Mean value or x-offset
w_vec (sequence of scalar) – Standard-Deviation or width.
amp_vec (sequence of scalar) – Amplitude or height.
offset (sequence of scalar) – Vertical offset of Gaussian.
ntraps (int) – Number of Gaussians or length of above parameter arrays.
- Returns
The value of the Gaussian superposition for each value in
x.- Return type
same as
x
-
wavgen.utilities.wrapper_fit_func(x, ntraps, *args)[source]¶ Wraps
gaussianarray1d()forscipy.optimize.curve_fit()fitting.
-
wavgen.utilities.extract_peaks(which_cam, image, ntraps)[source]¶ Finds the value & location of each Gaussian Peak.
Given a matrix of pixel values, locates each trap peak and records its position along x-axis and pixel value.
- Parameters
which_cam (bool) – True or False selects Pre- or Post- chamber cameras respectively.
image (2d ndarray) – Pixel matrix obtained from camera driver.
ntraps (int) – Number of peaks (traps) to search for.
- Returns
ndarray – Pixel value at each peak.
list – Compiled parameter list for passing with
wrapper_fit_func().
-
wavgen.utilities.plot_image(which_cam, image, ntraps, step_num=0, fit=None, guess=False)[source]¶ Scans image for peaks, then plots the 1-dimensional gaussian profiles.
- Parameters
which_cam (bool) – True or False selects Pre- or Post- chamber cameras respectively. Returns None is passed.
image (2d ndarray) – Pixel matrix obtained from camera driver.
ntraps (int) – Number of peaks (traps) to search for.
step_num (int, optional) – Indicates current iteration of
stabilize_intensity()fit (list of scalar, optional) – Parameters found as result of fitting. Plots if given.
guess (bool, optional) – Whether to plot initial fitting guess or not.
-
wavgen.utilities.analyze_image(which_cam, cam, ntraps, step_num=0, iterations=20)[source]¶ Fits 1d Gaussians across image x-axis & returns the peak values.
- Parameters
which_cam (bool) – True or False selects Pre- or Post- chamber cameras respectively.
cam (
instrumental.drivers.cameras.uc480) – The camera object opened byinstrumentalmodule.ntraps (int) – Number of peaks (traps) to search for.
step_num (int, optional) – Indicates current iteration of
stabilize_intensity()iterations (int, optional) – How many times the peak values should be averaged.
- Returns
Peak values of each Gaussian in image.
- Return type
ndarray
-
wavgen.utilities.fix_exposure(cam, slider, verbose=False)[source]¶ Automatically adjusts camera exposure.
- Parameters
cam (
instrumental.drivers.cameras.uc480) – The camera object opened byinstrumentalmodule.slider (
matplotlib.widgets.Slider) – Slider which sets camera exposure.verbose (bool, optional) – Verbosity!
-
wavgen.utilities.verboseprint()¶ Print function which works only when global VERBOSE parameter is set.
-
wavgen.utilities.debugprint(*a, **k)¶ Print function which works only when global DEBUG parameter is set.