Skip to content

fit.svd_ga

gadorlhiac edited this page Jan 16, 2017 · 2 revisions

__init__(data)

Loads the correct parameters from the data object using updateData.

updateData(data)

Retrieves the working time and wavelength parameters, singular value decomposition and IRF parameters from the given data object.

display()

Plots a two subplot graph with the singular values on the left, and the weighted left singular vectors on the right. The weighted left singular vectors can be scrolled through with a slider bar.

_genD(taus, T)

Generates the matrix of the exponential decays based on the input lifetimes (taus) and time points (T). If the IRF parameters are set to 0, the decays are generated without IRF convolution. If the IRF parameters are non-zero then they are used with the explicit formula (not using a convolution function) to calculate the decays.

_getDAS(D, Y, alpha=0)

Solves for the decay associated spectra based on a given matrix of decays D (which is a function of lifetime tau), and Y which is the data (or a selection of weighted left singular vectors). The solution is found using QR decomposition of the decay matrix D, and back-substitution. An alpha value can be set greater than zero to use Tikhonov regularization.

_min(taus, Y, T, alpha)

This is the objective function for the global analysis minimization. It calculates D using _genD(taus, T), and the DAS with _getDAS(D, Y, alpha). The residual res = sum((Y - D.dot(DAS)**2) is then returned.

_GA(x0, Y, T, alpha, B)

This runs the minimization routine (minimize) from scipy, using x0 as the initial guesses, _min as the objective function, and B as the bounds (list of tuples). Y, T, and alpha are passed as additional arguments to the _min routine.

Global(wLSVs, x0, B, alpha)

Runs the global analysis using _GA. wLSVs is a string containing indices for which wLSVs to use in the fitting. It is parsed by _get_wLSVs_for_fit(). The results of the fitting are then plotted using _plot_res(), and the calculated lifetimes are returned.

_get_wLSVs_for_fit(wLSV_indices)

wLSVs can be None or a string of integers. If None, all the wLSVs will be used in the global analysis. If the string contains 1 integer n, the first n wLSVs corresponding to the largest singular values will be used. If the list contains multiple integers, those specific wLSVs will be used. The list of indices and the wLSVs for fitting are both returned.

_plot_res(wLSV_fit, wLSVs, taus, DAS, SpecFit, T)

Plots a two subplot graph with matplotlib. The left subplot contains the calculated DAS, and the right subplot contains a comparison of the wLSVs and their fits.