Qudi
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
trace_analysis_logic.TraceAnalysisLogic Class Reference

Perform a gated counting measurement with the hardware. More...

Inheritance diagram for trace_analysis_logic.TraceAnalysisLogic:
Inheritance graph
[legend]
Collaboration diagram for trace_analysis_logic.TraceAnalysisLogic:
Collaboration graph
[legend]

Public Member Functions

def __init__ (self, config, kwargs)
 Create CounterLogic object with connectors. More...
 
def on_activate (self)
 Initialisation performed during activation of the module.
 
def on_deactivate (self)
 Deinitialisation performed during deactivation of the module.
 
def set_num_bins_histogram (self, num_bins, update=True)
 Set the number of bins. More...
 
def do_calculate_histogram (self, mode='normal')
 Passes all the needed parameters to the appropriated methods. More...
 
def calculate_histogram (self, trace, num_bins=None, custom_bin_arr=None)
 Calculate the histogram of a given trace. More...
 
def analyze_flip_prob (self, trace, num_bins=None, threshold=None)
 General method, which analysis how often a value was changed from one data point to another in relation to a certain threshold. More...
 
def analyze_flip_prob2 (self, trace, threshold=1, analyze_mode='full')
 General method, which analysis how often a value was changed from one data point to another in relation to a certain threshold. More...
 
def analyze_flip_prob3 (self, trace, init_threshold=[1, ana_threshold=[1, analyze_mode='full')
 General method, which analysis how often a value was changed from one data point to another in relation to a certain threshold. More...
 
def analyze_flip_prob4 (self, trace, bins=30, init_threshold=[1, ana_threshold=[1, analyze_mode='full')
 
def analyze_flip_prob_postselect (self)
 Post select the data trace so that the flip probability is only calculated from a jump from below a threshold value to an value above threshold. More...
 
def get_fit_functions (self)
 Return all fit functions, which are currently implemented for that module. More...
 
def do_fit (self, fit_function=None)
 Makes the a fit of the current fit function. More...
 
def do_no_fit (self)
 Perform no fit, basically return an empty array. More...
 
def analyze_lifetime (self, trace, dt, method='postselect', distr='gaussian_normalized', state='|-1 >', num_bins=50)
 Perform an lifetime analysis of a 1D time trace. More...
 
def do_gaussian_fit (self, axis, data)
 Perform a gaussian fit. More...
 
def do_doublegaussian_fit (self, axis, data)
 
def do_doublepossonian_fit (self, axis, data)
 
def do_possonian_fit (self, axis, data)
 
def get_poissonian (self, x_val, mu, amplitude)
 Calculate, bases on the passed values a poisson distribution. More...
 
def guess_threshold (self, hist_val=None, trace=None, max_ratio_value=0.1)
 Assume a distribution between two values and try to guess the threshold. More...
 
def calculate_threshold (self, hist_data=None, distr='poissonian')
 Calculate the threshold by minimizing its overlap with the poissonian fits. More...
 
def calculate_binary_trace (self, trace, threshold)
 Calculate for a given threshold all the trace values und output a binary array, where True = Below or equal Threshold False = Above Threshold. More...
 
def extract_filtered_values (self, trace, threshold, below=True)
 Extract only those values, which are below or equal a certain Threshold. More...
 

Public Attributes

 hist_data
 
 spin_flip_prob
 
 fidelity_left
 
 fidelity_right
 
 trace
 
 current_fit_function
 
 debug_lifetime_x
 
 debug_lifetime_y
 

Static Public Attributes

 counterlogic1 = Connector(interface='CounterLogic')
 
 savelogic = Connector(interface='SaveLogic')
 
 fitlogic = Connector(interface='FitLogic')
 
 sigHistogramUpdated = QtCore.Signal()
 
 sigAnalysisResultsUpdated = QtCore.Signal()
 

Detailed Description

Perform a gated counting measurement with the hardware.

Constructor & Destructor Documentation

◆ __init__()

def trace_analysis_logic.TraceAnalysisLogic.__init__ (   self,
  config,
  kwargs 
)

Create CounterLogic object with connectors.

Parameters
dictconfig: module configuration
dictkwargs: optional parameters

Member Function Documentation

◆ analyze_flip_prob()

def trace_analysis_logic.TraceAnalysisLogic.analyze_flip_prob (   self,
  trace,
  num_bins = None,
  threshold = None 
)

General method, which analysis how often a value was changed from one data point to another in relation to a certain threshold.

Parameters
np.arraytrace: 1D trace of data
intnum_bins: optional, if a specific size for the histogram is desired, which is used to calculate the threshold.
floatthreshold: optional, if a specific threshold is going to be used, otherwise the threshold is calculated from the data.
Returns
tuple(flip_prop, param): float the actual flip probability int the total number of flips float the fidelity float the calculated or passed threshold float the lifetime in the dark state in s float lifetime in the bright state in s

◆ analyze_flip_prob2()

def trace_analysis_logic.TraceAnalysisLogic.analyze_flip_prob2 (   self,
  trace,
  threshold = 1,
  analyze_mode = 'full' 
)

General method, which analysis how often a value was changed from one data point to another in relation to a certain threshold.

Parameters
np.arraytrace: 1D trace of data
intnum_bins: optional, if a specific size for the histogram is desired, which is used to calculate the threshold.
floatthreshold: optional, if a specific threshold is going to be used, otherwise the threshold is calculated from the data.
Returns
tuple(flip_prop, param): float the actual flip probability int the total number of flips float the fidelity float the calculated or passed threshold float the lifetime in the dark state in s float lifetime in the bright state in s

◆ analyze_flip_prob3()

def trace_analysis_logic.TraceAnalysisLogic.analyze_flip_prob3 (   self,
  trace,
  init_threshold = [1,
  ana_threshold = [1,
  analyze_mode = 'full' 
)

General method, which analysis how often a value was changed from one data point to another in relation to a certain threshold.

Parameters
np.arraytrace: 1D trace of data
floatthreshold: optional, if a specific threshold is going to be used, otherwise the threshold is calculated from the data.
Returns
tuple(flip_prop, param): float the actual flip probability int the total number of flips float the fidelity float the calculated or passed threshold float the lifetime in the dark state in s float lifetime in the bright state in s

◆ analyze_flip_prob_postselect()

def trace_analysis_logic.TraceAnalysisLogic.analyze_flip_prob_postselect (   self)

Post select the data trace so that the flip probability is only calculated from a jump from below a threshold value to an value above threshold.

Returns
:

◆ analyze_lifetime()

def trace_analysis_logic.TraceAnalysisLogic.analyze_lifetime (   self,
  trace,
  dt,
  method = 'postselect',
  distr = 'gaussian_normalized',
  state = '|-1>',
  num_bins = 50 
)

Perform an lifetime analysis of a 1D time trace.

The analysis is based on the method provided ( for now only post select is implemented ).

Parameters
numpyarray trace: 1 D array
stringmethod: The method used for the lifetime analysis
stringdistr: distribution used for analysis
stringstate: State that the mw was applied to
intnum_bins: number of bins used in the histogram to determine the threshold before digitalisation of data
Returns
: dictionary containing the lifetimes of the different states |0>, |1>, |-1> in the case of the HMM method For the postselect method only lifetime for bright and darkstate is returned, keys are 'bright_state' and 'dark_state'

◆ calculate_binary_trace()

def trace_analysis_logic.TraceAnalysisLogic.calculate_binary_trace (   self,
  trace,
  threshold 
)

Calculate for a given threshold all the trace values und output a binary array, where True = Below or equal Threshold False = Above Threshold.

Parameters
np.arraytrace: a 1D array containing the y data, e.g. ccunts
floatthreshold: value to decide whether a point in the trace is below/equal (True) or above threshold (False).
Returns
np.array: 1D trace of the length(trace) but now with boolean entries

◆ calculate_histogram()

def trace_analysis_logic.TraceAnalysisLogic.calculate_histogram (   self,
  trace,
  num_bins = None,
  custom_bin_arr = None 
)

Calculate the histogram of a given trace.

Parameters
np.arraytrace: a 1D trace
intnum_bins: number of bins between the minimal and maximal value of the trace. That must be an integer greater than or equal to 1.
np.arraycustom_bin_arr: optional, 1D array. If a specific, non-uniform binning array is desired then it can be passed to the numpy routine. Then the parameter num_bins is ignored. Otherwise a uniform binning is applied by default.
Returns
: np.array: a 2D array, where first entry are the x_values and second entry are the count values. The length of the array is normally determined by the num_bins parameter. Usually the bins for the histogram are taken to be equally spaced, ranging from the minimal to the maximal value of the input trace array.

◆ calculate_threshold()

def trace_analysis_logic.TraceAnalysisLogic.calculate_threshold (   self,
  hist_data = None,
  distr = 'poissonian' 
)

Calculate the threshold by minimizing its overlap with the poissonian fits.

Parameters
np.arrayhist_data: 2D array which represent the x and y values of a histogram of a trace. string tells the function on what distribution it should calculate the threshold ( Added because it might happen that one normalizes data between (-1,1) and then a poissonian distribution won't work anymore.
Returns
tuple(float, float): threshold the calculated threshold between two overlapping poissonian distributed peaks. fidelity the measure how good the two peaks are resolved according to the calculated threshold The calculation of the threshold relies on fitting two poissonian distributions to the count histogram and minimize a threshold with respect to the overlap area:

◆ do_calculate_histogram()

def trace_analysis_logic.TraceAnalysisLogic.do_calculate_histogram (   self,
  mode = 'normal' 
)

Passes all the needed parameters to the appropriated methods.

Returns
:

◆ do_fit()

def trace_analysis_logic.TraceAnalysisLogic.do_fit (   self,
  fit_function = None 
)

Makes the a fit of the current fit function.

Parameters
strfit_function: name of the chosen fit function.
Returns
tuple(x_val, y_val, fit_results): x_val a 1D numpy array containing the x values y_val a 1D numpy array containing the y values fit_results a string containing the information of the fit results. You can obtain with get_fit_methods all implemented fit methods.

◆ do_gaussian_fit()

def trace_analysis_logic.TraceAnalysisLogic.do_gaussian_fit (   self,
  axis,
  data 
)

Perform a gaussian fit.

Parameters
axis
data
Returns
:

◆ do_no_fit()

def trace_analysis_logic.TraceAnalysisLogic.do_no_fit (   self)

Perform no fit, basically return an empty array.

Returns
tuple(x_val, y_val, fit_results): x_val a 1D numpy array containing the x values y_val a 1D numpy array containing the y values fit_results a string containing the information of the fit results.

◆ extract_filtered_values()

def trace_analysis_logic.TraceAnalysisLogic.extract_filtered_values (   self,
  trace,
  threshold,
  below = True 
)

Extract only those values, which are below or equal a certain Threshold.

Parameters
np.arraytrace:
floatthreshold:
Returns
tuple(index_array, filtered_array): np.array index_array: 1D integer array containing the indices of the passed trace array which are equal or below the threshold np.array filtered_array: the actual values of the trace, which are equal or below threshold

◆ get_fit_functions()

def trace_analysis_logic.TraceAnalysisLogic.get_fit_functions (   self)

Return all fit functions, which are currently implemented for that module.

Returns
list: with string entries denoting the name of the fit.

◆ get_poissonian()

def trace_analysis_logic.TraceAnalysisLogic.get_poissonian (   self,
  x_val,
  mu,
  amplitude 
)

Calculate, bases on the passed values a poisson distribution.

Parameters
floatmu: expected value of poisson distribution
floatamplitude: Amplitude to which is multiplied on distribution
int,floator np.array x_val: x values for poisson distribution, also works for numbers (int or float)
Returns
np.array: a 1D array with the calculated poisson distribution, corresponding to given parameters/ x values Calculate a Poisson distribution according to: P(k) = mu^k * exp(-mu) / k!

◆ guess_threshold()

def trace_analysis_logic.TraceAnalysisLogic.guess_threshold (   self,
  hist_val = None,
  trace = None,
  max_ratio_value = 0.1 
)

Assume a distribution between two values and try to guess the threshold.

Parameters
np.arrayhist_val: 1D array which represent the y values of a histogram of a trace. Optional, if None is passed here, the passed trace will be used for calculations.
np.arraytrace: optional, 1D array containing the y values of a meausured counter trace. If None is passed to hist_y_val then the threshold will be calculated from the trace.
floatmax_ratio_value: the ratio how strong the lower y values will be cut off. For max_ratio_value=0.1 all the data which are 10% or less in amptitude compared to the maximal value are neglected. The guess procedure tries to find all values, which are max_ratio_value * maximum value of the histogram of the trace and selects those by indices. Then taking the first an the last might and assuming that the threshold is in the middle, gives a first estimate of the threshold value. FIXME That guessing procedure can be improved!
Returns
float: a guessed threshold

◆ set_num_bins_histogram()

def trace_analysis_logic.TraceAnalysisLogic.set_num_bins_histogram (   self,
  num_bins,
  update = True 
)

Set the number of bins.

Parameters
intnum_bins: number of bins for the histogram
boolupdate: if the change of bins should evoke a recalculation of the histogram.

The documentation for this class was generated from the following file: