Class for working with planar LIF measurements of fluorescence vs. laser power.
func: default is \(\alpha E_L/(1 + \beta E_L)\). The fit() method assumes only this form and works with linearized version for inverted values of laser power. Changing this attribute is currently pointless, but might become useful in future versions.
Calculate and return the 2D map of values beta(y,x) * max(laser_power(y,x)). Served for checking the condition of weak saturation.
Calculate and retun the estimate of standard deviation of the beta parameter from the fit at pixel given by y,x coordinate.
Runs delta_beta for each pixel and returns a 2D map of standard deviations.
Fitting the measured fluorescence vs. laser power data pixelwise. Assumes the dependence fluorescence = alpha * pwr / (1 + beta*pwr). No additive offset is allowed. The results of the fit are stored in the dictionary self.result with keys ‘alpha’, ‘beta’, ‘delta_alpha’. The values of delta_beta (estimate of standard deviation of beta) can be obtained by the method delta_beta(y, x) (single value) or delta_beta_map() (a 2D array for all pixels)
Returns a formatted string with the values of alpha +/- delta_alpha and beta +/- delta_beta at pixel given by coordinates y,x
Advised to run after Alpha.fit(). Re-runs the fit with the limitation that the laser_power * median(self.result[‘beta’]) < M, (i.e., restricts the used values of laser power and ignores the large ones) to force obeying the condition of weak saturation.
M: (float) the upper limit of fitting range, i.e. only values with beta*pwr < M are permitted
betamedx: (bool) determines the method to extract beta. If True (default), median of all valid betas is used. If False, the beta on the particular pixel is used.
Similar to show fit in the parent Crossfit class, but highlights the values really used in refit() method.
y, x: pixel coordinates
betax: (bool) if False, the x-axis of the plot is in the units of laser power. If True (default), the x-axis is multiplied by beta.
save_to_file: If a string is given, it represents the name of the file the figure will be saved to. If None (default), no file is written.
xlabel, ylabel: (strings) passed directly to matplotlib
draw: if True, matplotlib.draw() and clear() are called. May be used in a loop to create an animation.
show: if True (default), matplotlib.show() is called.
Parent class for fitting planar LIF data. Expects series of 2D images (triDData) and some x-axis (x) that enables fitting of function (func) to the measured data for each pixel.
Find the best estimate of parameters of self.default_func for data at (y, x) with scipy.optimize.curve_fit().
y, x: (int) pixel coordinates
keys: (list) of keywords describing the argument to be optimized or simply ‘all’. The keywords should be provided by inherited classes in their definition.
Automatically determine the x-axis for eventual fitting at position (y, x).
return matrix of correlation coefficients. See result[‘cov_order’] for assignign to the right variables.
calculates and returns the real variance-covariance matrix from the scipu.optimize.curve_fit’s output by multiplying it with (len(data)-len(parameters)) / sum_of_squares
Method for plotting the the cross-section of triDData at position y, x vs. the independent_variable for that particular position, together with fitted funcion.
y, x: pixel coordinates
save_to_file: If a string is given, it represents the name of the file the figure will be saved to. If None (dafault), no file will be written.
xlabel, ylabel: (strings) passed directly to matplotlib
draw: defaults to False. if True, matplotlib.draw() will be called to show the figure. May be used in loop to create an animation, as ax.clear() is also called.
show: defaults to True - the figure will be shown by matplotlib.show()
Returns: matplotlib.figure object.
Replacement of ALpha with more rigorous function. Is not very practical for real-world fitting.
Class for working with planar LIF measurements of lfuorescence vs. delay after the laser pulse.
Attributes:
func: a function used to fit the measured dependent. Defaults to \(A {\rm e}^{(-t/ \tau)} + C\).
dfunc_dict: dictionary of derivatives of func with respect to its parameters. The keys should be ‘amplitude’, ‘tau’ and ‘offset’ and the values should be the respective functions taking the arguments (time_axis, amplitude, tau) and returning an array with the same shape as the time_axis.
params: initial guess of the respective values. If left to None, the default values of amplitude = 1e3, tau = 10 and offset = 1e3 are filled from start to the self.result arrays
result: dictionary with keys ‘amplitude’, ‘tau’, ‘offset’ (fit results), ‘damplitude’, ‘dtau’, ‘doffset’ (standard error estimates), (‘cov’, (y, x)) storing “covariance matrices” returned by scipy.optimize.curve_fit and ‘cov_order’ storing the order of the parameters used to calculate the “covariance matrices”.
Calculate correction for the fact that the detection begins after the laser pulse. The fluorescence temporal shape is calculated as a convolution of single-exponential and a*t**b * exp(-c*t).
Read database file exported from LIFBASE.
Example of use:
coefs = read_lifbase_table('abs_00.txt')
print coefs['R1'][coefs['N']==4]