elli.fitting package

Submodules

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: object

A class to fit mueller matrices to experimental data

create_widgets()[source]

Create ipywidgets for parameter estimation

fit(method='leastsq')[source]

Execute lmfit with the current fitting parameters

Parameters

method (str, optional) – The fitting method to use. Any method supported by scipys curve_fit is allowed. Defaults to ‘leastsq’.

Returns

The fitting result

Return type

Result

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_fit_data()[source]

Gets the fit results as dataframe

Returns

The fit results

Return type

pd.DataFrame

plot(**kwargs)[source]

Plot the fit results

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

The figure containing the data

Return type

go.Figure

update_params(change)[source]

Update plot after a change of fitting parameters

Parameters

change (dict) – A dictionary containing the ipywidgets change event

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)[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

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: object

A class to fit psi/delta or rho based ellipsometry data with two degress of freedom

create_widgets()[source]

Create ipywidgets for parameter estimation

fit(method='leastsq')[source]

Execute lmfit with the current fitting parameters

Parameters

method (str, optional) – The fitting method to use. Any method supported by scipys curve_fit is allowed. Defaults to ‘leastsq’.

Returns

The fitting result

Return type

Result

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

plot()[source]

Plot the fit results as Psi/Delta

plot_rho()[source]

Plot the fit results as Rho

set_pseudo_diel(update_exp=False, update_names=False)[source]

Sets Plot to Pseudo Dielectric function values

Parameters
  • update_exp (bool, optional) – Flag to change the experimental data as well. Defaults to False.

  • update_names (bool, optional) – Flag to change the label names. Defaults to False.

set_psi_delta(update_exp=False, update_names=False)[source]

Sets Plot to Psi/Delta values

Parameters
  • update_exp (bool, optional) – Flag to change the experimental data as well. Defaults to False.

  • update_names (bool, optional) – Flag to change the label names. Defaults to False.

set_rho(update_exp=False, update_names=False)[source]

Sets Plot to Rho values

Parameters
  • update_exp (bool, optional) – Flag to change the experimental data as well. Defaults to False.

  • update_names (bool, optional) – Flag to change the label names. Defaults to False.

update_params(change, selected)[source]

Update plot after a change of fitting parameters

Parameters
  • change (dict) – A dictionary containing the ipywidgets change event

  • selected (dict) – The selected value of the data display dropdown widget

update_selection(change)[source]

Update plot after selection of displayed data

Parameters

change (dict) – A dictionary containing the ipywidgets change event

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

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.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(usersyms=None)[source]

Bases: lmfit.parameter.Parameters

A wrapper around lmfit.Parameters to keep track of the changes made to the parameters.

clear_history()[source]

Clears the parameters history

commit()[source]

Saves the current parameter set to history.

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

int

property max_history_len

The maximum length of the history

Returns

The maximum length of the history

Return type

int

revert(hist_pos)[source]

Reverts to an older history version

Parameters

hist_pos (int) – The history position to revert to.

tracked_add(*args, **kwargs)[source]

Adds a parameter and keeps track of the change in history

update_value(key, value)[source]

Updates a parameter and keeps track of the change in history

Parameters
  • key (str) – The key to be updated

  • value (float) – The value the key should be updated to

Module contents