elli.fitting package
Submodules
elli.fitting.decorator module
Abstract base class for Decorator functions for convenient fitting
- class elli.fitting.decorator.FitDecorator[source]
Bases:
abc.ABCThe abstract base class for fitting decorators. Providing features for fit, undo and redo buttons.
- fit_button_clicked()[source]
Fit and update plot after the fit button has been clicked
- Parameters
selected (dict) – Dict containing the current widget information of the selection dropdown.
- abstract get_model_data(params=None, append_exp_data=False)[source]
Gets the data from the provided model with the provided parameters. If no parameters are provided, the fitted parameters are used (which default to the initial parameters if no fit has been triggered).
- Parameters
params (Parameters, optional) – The parameters to calculate the model with. If not provided, the fitted parameters are used. Defaults to None.
append_exp_data (bool, optional) – Appends the experimental data if set to True. Defaults to False.
- Returns
The model results
- Return type
pd.DataFrame
- re_undo_button_clicked(button)[source]
Redo or undo an operation on the paramters history object
- Parameters
button (widgets.Button) – The button instance, which triggered the event.
- to_csv(fname, params=None, append_exp_data=False, *args, **kwargs)[source]
Saves the current model to csv. This is just a wrapper to pandas Dataframe and any argument to pandas to_csv may be passed as function arguments.
- Parameters
elli.fitting.decorator_mmatrix module
Decorator functions for convenient fitting of Mueller matrices
- class elli.fitting.decorator_mmatrix.FitMuellerMatrix(exp_mm, params, model, **kwargs)[source]
Bases:
elli.fitting.decorator.FitDecoratorA class to fit mueller matrices to experimental data
Intialize the mueller matrix fitting class
- Parameters
exp_mm (pd.DataFrame) – The dataframe containing an experimental mueller matrix. It should contain 16 columns with labels Mxy, where xy are the matrix positions.
params (Parameters) – Fitting start parameters
model (Callable[[npt.NDArray, Parameters], Result]) – A function taking wavelengths as first parameter and fitting parameters as second, which returns a pyEllis Result object. This function contains the actual model which should be fitted
**display_single (bool) – Returns a figure containing a single graph, if set to true. Returns a grid of figures otherwise.
**sharex (bool) – Ties the zoom of the x-axes together for grid view.
**full_scale (bool) – Sets the y-axis scale to [-1, 1] if set to True.
- fit_function(params, lbda, mueller_matrix)[source]
The fit function to minimize the fitting problem
- Parameters
params (Parameters) – The lmfit fitting Parameters to construct the simulation
lbda (npt.NDArray) – Wavelengths in nm
mueller_matrix (pd.DataFrame) – The experimental data to compare to the fitted model
- Returns
- Residual between the calculation
with current parameters and experimental data
- Return type
npt.NDArray
- get_model_data(params=None, append_exp_data=False)[source]
Gets the data from the provided model with the provided parameters. If no parameters are provided, the fitted parameters are used (which default to the initial parameters if no fit has been triggered).
- Parameters
params (Parameters, optional) – The parameters to calculate the model with. If not provided, the fitted parameters are used. Defaults to None.
append_exp_data (bool, optional) – Appends the experimental data if set to True. Defaults to False.
- Returns
The model results
- Return type
pd.DataFrame
- plot(**kwargs)[source]
Plot the fit results
- Parameters
- Returns
The figure containing the data
- Return type
go.Figure
- elli.fitting.decorator_mmatrix.fit_mueller_matrix(exp_mm, params, **kwargs)[source]
A parameters decorator for fitting mueller matrices. Displays an ipywidget float box for each fitting parameter and an interactive plot to estimate parameters.
- Parameters
exp_mm (pd.DataFrame) – The dataframe containing an experimental mueller matrix. It should contain 16 columns with labels Mxy, where xy are the matrix positions.
params (Parameters) – Fitting start parameters
**display_single (bool) – Returns a figure containing a single graph, if set to true. Returns a grid of figures otherwise.
**sharex (bool) – Ties the zoom of the x-axes together for grid view.
**full_scale (bool) – Sets the y-axis scale to [-1, 1] if set to True.
- Returns
A function taking wavelengths as first parameter and fitting parameters as second, which returns a pyEllis Result object. This function contains the actual model which should be fitted and is automatically provided when used as a decorator.
- Return type
Callable[[npt.NDArray, Parameters], Result]
- elli.fitting.decorator_mmatrix.mmatrix_to_dataframe(exp_df, mueller_matrix, identifier=None)[source]
Reshape a numpy 4x4 array containing mueller matrix elements to a dataframe with columns Mxy. The index labels for each column are taken from the provided exp_df.
- Parameters
exp_df (pd.DataFrame) – The experimental dataframe providing the index and columns for the newly generated dataframe.
mueller_matrix (npt.NDArray) – Data to be reshaped into a dataframe
identifier (str, optional) – An identifier to append to each column name, in the form Mxy_<identifier>, where Mxy is the old column name. Defaults to None.
- Returns
Contains the data from mueller_matrix in the shape of exp_df
- Return type
pd.DataFrame
elli.fitting.decorator_psi_delta module
Decorator functions for convenient fitting
- class elli.fitting.decorator_psi_delta.FitRho(exp_data, params, model, angle=70)[source]
Bases:
elli.fitting.decorator.FitDecoratorA class to fit psi/delta or rho based ellipsometry data with two degress of freedom
Intialize the psi/delta fitting class
- Parameters
exp_data (pd.DataFrame) – The dataframe containing an experimental mueller matrix. It should contain 2 columns with labels Ψ and Δ.
params (Parameters) – Fitting start parameters
model (Callable[[npt.NDArray, Parameters], Result]) – A function taking wavelengths as first parameter and fitting parameters as second, which returns a pyEllis Result object. This function contains the actual model which should be fitted.
angle (float, optional) – The angle of incident of the measurement. Used to calculate the Pseudo-Dielectric function. Defaults to 70.
- fit_function(params, lbda, rhor, rhoi)[source]
The fit function to minimize the fitting problem
- Parameters
params (Parameters) – The lmfit fitting Parameters to construct the simulation
lbda (npt.NDArray) – Wavelengths in nm
rhor (npt.NDArray) – The real part of the experimental rho
rhoi (npt.NDArray) – The imaginary part of the experimental rho
- Returns
Residual between the calculation with current parameters and experimental data
- Return type
npt.NDArray
- get_model_data(params=None, repr='psi-delta', append_exp_data=False)[source]
Gets the data from the provided modle with the provided parameters. If no parameters are provided, the fitted parameters are used (which default to the initial parameters if no fit has been triggered).
- Parameters
params (Parameters, optional) – The parameters to calculate the model with. If not provided, the fitted parameters are used. Defaults to None.
repr (str, optional) – The representation of the model and experiment data. Valid values are ‘psi-delta’ or ‘rho’. Defaults to ‘psi-delta’.
append_exp_data (bool, optional) – Appends the experimental data if set to True. Defaults to False.
- Raises
ValueError – Raised if the representation is not a valid value.
- Returns
The model results
- Return type
pd.DataFrame
- set_pseudo_diel(update_exp=False, update_names=False)[source]
Sets Plot to Pseudo Dielectric function values
- elli.fitting.decorator_psi_delta.fit(exp_data, params, angle=70)[source]
A parameters decorator for fitting psi/delta valus. Displays an ipywidget float box for each fitting parameter and an interactive plot to estimate parameters.
- Parameters
exp_data (pd.DataFrame) – The dataframe containing an experimental mueller matrix. It should contain 2 columns with labels Ψ and Δ.
params (Parameters) – Fitting start parameters
angle (float, optional) – The angle of incident of the measurement. Used to calculate the Pseudo-Dielectric function. Defaults to 70.
- Returns
fitting parameters as second, which returns a pyEllis Result object. This function contains the actual model which should be fitted and is automatically provided when used as a decorator.
- Return type
Callable[[npt.NDArray, Parameters], Result]
elli.fitting.params_hist module
ParmsHist provides a wrapper around lmfit.Parameters to keep track of the changes made to the parameters.
- class elli.fitting.params_hist.ParamsHist[source]
Bases:
lmfit.parameter.ParametersA wrapper around lmfit.Parameters to keep track of the changes made to the parameters.
- Parameters
usersyms (dict, optional) – Dictionary of symbols to add to the
asteval.Interpreter(default is None).
- property history
Gets the entire history
- Returns
The history
- Return type
List[Parameters]
- property history_len
The current length of the history
- Returns
The length of the history
- Return type
- property max_history_len
The maximum length of the history
- Returns
The maximum length of the history
- Return type
- revert(hist_pos)[source]
Reverts to an older history version and keeps the entire history.
- Parameters
hist_pos (int) – The history position to revert to.