qetpy.utils package¶
-
qetpy.utils._utils.
calc_offset
(x, fs=1.0, sgfreq=100.0, is_didv=False)¶ Calculates the DC offset of time series trace.
Parameters: - x : ndarray
Array to calculate offsets of.
- fs : float, optional
Sample rate of the data being taken, assumed to be in units of Hz.
- sgfreq : float, optional
The frequency of signal generator (if is_didv is True. If False, then this is ignored).
- is_didv : bool, optional
If False, average of full trace is returned. If True, then the average of n Periods is returned (where n is the max number of full periods present in a trace).
Returns: - offset : ndarray
Array of offsets with same shape as input x minus the last dimension
- std : ndarray
Array of std with same shape as offset
-
qetpy.utils._utils.
lowpassfilter
(traces, cut_off_freq=100000, fs=625000.0, order=1)¶ Applies a low pass filter to the inputted time series traces
Parameters: - traces : ndarray
An array of shape (# traces, # bins per trace).
- cut_off_freq : float, int, optional
The cut off 3dB frequency for the low pass filter, defaults to 100kHz.
- fs : float, int, optional
Digitization rate of data, defaults to 625e3 Hz.
- order : int, optional
The order of the low pass filter, defaults to 1.
Returns: - filt_traces : ndarray
Array of low pass filtered traces with the same shape as inputted traces.
-
qetpy.utils._utils.
align_traces
(traces, lgcjustshifts=False, n_cut=5000, cut_off_freq=5000.0, fs=625000.0)¶ Function to align dIdV traces if each trace does not trigger at the same point. Uses a convolution of the traces to find the time offset.
Parameters: - traces : ndarray
Array of shape (# traces, # bins per trace).
- lgcjustshifts : boolean, optional
If False, the aligned traces and the phase shifts are returned. If True, just the phase shifts are returned. Default is False.
- n_cut : int, optional
The number of bins to use to do the convolution. Just need enough information to see the periodic signal. Default is 5000.
- cut_off_freq : float or int, optional
3dB cut off frequency for filter. Default is 5000 Hz.
- fs : float or int, optional
Sample rate of data in Hz. Default is 625e3 Hz.
Returns: - shifts : ndarray
Array of phase shifts for each trace in units of bins.
- masked_aligned : masked ndarray, optional
Array of time shift corrected traces, same shape as input traces. The masked array masks the np.NaN values in the time shifted traces so that normal numpy functions will ignore the nan’s in computations.
-
qetpy.utils._utils.
get_offset_from_muon
(avemuon, qetbias, rn, rload, rsh=0.005, nbaseline=6000, lgcfullrtn=True)¶ Function to calculate the offset in the measured TES current using an average muon.
Parameters: - avemuon : array
An average of ‘good’ muons in time domain, referenced to TES current
- qetbias : float
Applied QET bias current
- rn : float
Normal resistance of the TES
- rload : float
Load resistance of TES circuit (rp + rsh)
- rsh : float, optional
Value of the shunt resistor for the TES circuit
- nbaseline : int, optional
The number of bins to use to calculate the baseline, i.e. [0:nbaseline]
- lgcfullrtn : bool, optional
If True, the offset, r0, i0, and bias power is returned, If False, just the offset is returned
Returns: - ioffset : float
The offset in the measured TES current
- r0 : float
The resistance of the TES
- i0 : float
The quiescent current through the TES
- p0 : float
The quiescent bias power of the TES
-
qetpy.utils._utils.
powertrace_simple
(trace, ioffset, qetbias, rload, rsh)¶ Function to convert time series trace from units of TES current to units of power.
The function takes into account the second order depenace on current, but assumes the infinite irwin loop gain approximation.
Parameters: - trace : array
Time series trace, referenced to TES current
- ioffset : float
The offset in the measured TES current
- qetbias : float
Applied QET bias current
- rload : float
Load resistance of TES circuit (rp + rsh)
- rsh : float, optional
Value of the shunt resistor for the TES circuit
Returns: - trace_p : array
Time series trace, in units of power referenced to the TES
-
qetpy.utils._utils.
integrate_powertrace_simple
(trace, time, nbasepre, nbasepost, ioffset, qetbias, rload, rsh)¶ Function to calculate the energy collected by the TESs by integrating the power in the TES as a function of time.
Parameters: - trace : array
Time series trace, referenced to TES current
- time : array
Array of time values corresponding to the trace array
- nbasepre : int
The bin number corresponding to the pre-pulse baseline, i.e. [0:nbasepre]
- nbasepost : int
The bin number corresponding to the post-pulse baseline, i.e. [nbasepost:-1]
- ioffset : float
The offset in the measured TES current
- qetbias : float
Applied QET bias current
- rload : float
Load resistance of TES circuit (rp + rsh)
- rsh : float, optional
Value of the shunt resistor for the TES circuit
Returns: - integrated_energy : float
The energy absorbed by the TES in units of eV
-
qetpy.utils._utils.
stdcomplex
(x, axis=0)¶ Function to return complex standard deviation (individually computed for real and imaginary components) for an array of complex values.
Parameters: - x : ndarray
An array of complex values from which we want the complex standard deviation.
- axis : int, optional
Which axis to take the standard deviation of (should be used if the dimension of the array is greater than 1)
Returns: - std_complex : ndarray
The complex standard deviation of the inputted array, along the specified axis.
-
qetpy.utils._utils.
slope
(x, y, removemeans=True)¶ Computes the maximum likelihood slope of a set of x and y points.
Parameters: - x : array_like
Array of real-valued independent variables.
- y : array_like
Array of real-valued dependent variables.
- removemeans : boolean
Boolean flag for if the mean of x should be subtracted. This should be set to True if x has not already had its mean subtracted. Set to False if the mean has been subtracted. Default is True.
Returns: - slope : float
Maximum likelihood slope estimate, calculated as sum((x-<x>)(y-<y>))/sum((x-<x>)**2)
-
qetpy.utils._utils.
fill_negatives
(arr)¶ Simple helper function to remove negative and zero values from PSD’s and replace them with interpolated values.
Parameters: - arr: ndarray
Array of values to replace neagive values on
Returns: - arr: ndarray
Modified input array with the negative and zero values replace by interpelate values