Qudi
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
fit_logic.FitContainer Class Reference

A class for managing a single flexible fit setting in a logic module. More...

Inheritance diagram for fit_logic.FitContainer:
Inheritance graph
[legend]
Collaboration diagram for fit_logic.FitContainer:
Collaboration graph
[legend]

Public Member Functions

def __init__ (self, fit_logic, name, dimension)
 Create a fit container. More...
 
def set_units (self, units)
 Set units for this fit. More...
 
def load_from_dict (self, fit_dict)
 Take a list of fits from a storable dictionary, load to self.fit_list and check. More...
 
def save_to_dict (self)
 Convert self.fit_list to a storable dictionary. More...
 
def clear_result (self)
 Reset fit result and fit parameters from result for this container.
 
def set_fit_functions (self, fit_functions)
 Set the configured fit functions for this container. More...
 
def set_current_fit (self, current_fit)
 Check and set the current fit for this container by name. More...
 
def do_fit (self, x_data, y_data)
 Performs the chosen fit on the measured data. More...
 

Public Attributes

 fit_logic
 
 name
 
 dim
 
 dimension
 
 fit_list
 
 fit_granularity_fact
 
 current_fit
 
 current_fit_param
 
 current_fit_result
 
 units
 

Static Public Attributes

 sigFitUpdated = QtCore.Signal()
 
 sigCurrentFit = QtCore.Signal(str)
 
 sigNewFitResult = QtCore.Signal(str, lmfit.model.ModelResult)
 
 sigNewFitParameters = QtCore.Signal(str, lmfit.parameter.Parameters)
 

Detailed Description

A class for managing a single flexible fit setting in a logic module.

Constructor & Destructor Documentation

◆ __init__()

def fit_logic.FitContainer.__init__ (   self,
  fit_logic,
  name,
  dimension 
)

Create a fit container.

Parameters
fit_logicFitLogic: reference to a FitLogic instance
namestr: user-friendly name for this container
dimensionstr: dimension for fit input in this container, '1d', '2d' or '3d'

Member Function Documentation

◆ do_fit()

def fit_logic.FitContainer.do_fit (   self,
  x_data,
  y_data 
)

Performs the chosen fit on the measured data.

Parameters
arrayx_data: optional, 1D np.array or 1D list with the x values. If None is passed then the module x values are taken.
arrayy_data: optional, 1D np.array or 1D list with the y values. If None is passed then the module y values are taken. If passed, then it should have the same size as x_data.
Returns
: tuple (fit_x, fit_y, str_dict, fit_result) np.array fit_x: 1D array containing the x values of the fit np.array fit_y: 1D array containing the y values of the fit OrderedDict a dictionary with the relevant fit parameters, i.e. the result of the fit. Each entry is again a dict with three entries, {'value': ... , 'error': ...., 'unit': '...'} The values and the errors are always saved in SI units!

lmfit.model.ModelResult fit_result: the result object of lmfit. If additional information is needed from the fit, then they can be obtained from this object. If no fit is performed then result is set to None.

◆ load_from_dict()

def fit_logic.FitContainer.load_from_dict (   self,
  fit_dict 
)

Take a list of fits from a storable dictionary, load to self.fit_list and check.

Parameters
fit_dictdict: fit dictionary with function references etc

◆ save_to_dict()

def fit_logic.FitContainer.save_to_dict (   self)

Convert self.fit_list to a storable dictionary.

Returns
dict: storable configured fits dictionary

◆ set_current_fit()

def fit_logic.FitContainer.set_current_fit (   self,
  current_fit 
)

Check and set the current fit for this container by name.

Parameters
current_fitstr: name of configured fit to be used as current fit

If the name given is not in the list of fits, the current fit will be 'No Fit'. This is a reserved name that will do nothing and should not display a fit line if set.

◆ set_fit_functions()

def fit_logic.FitContainer.set_fit_functions (   self,
  fit_functions 
)

Set the configured fit functions for this container.

Parameters
fit_functionsdict: configured fit functions dictionary

◆ set_units()

def fit_logic.FitContainer.set_units (   self,
  units 
)

Set units for this fit.

Parameters
unitslist(str): list of units (for x axes and y axis)

Number of units must be = dimensions + 1


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