ultrapyfit.old package
Submodules
ultrapyfit.old.Calibration_Final_QT_2 module
Created on Thu Dec 5 12:45:11 2019
@author: 79344
- class ultrapyfit.old.Calibration_Final_QT_2.Calibration(ref_data=None, experimental_data=None)
Bases:
object
allow to calculate the correlation polynom (calibration curve) of order N between two data sets
- ref_data
contain the datareference normally X-axis is in wavelength
- Type
pandas Data Frame (defautlt: None)
- experimental_data
contain the experimental data to be calibrated normally X-axis is in pixel
- Type
pandas Data Frame (defautlt: None)
- autoCalibrationWithSpectra(plot=True, fit_order=1)
Try to auto calibrate the data given the attributes ref_data and experimental_data
- Parameters
plot (bool (default True)) – plot experimental_data and ref_data with the automatic founded peaks and a third subplot with the calibration curve found
fit_order (int or float the order for the fitting curve that correlates the experimental_data and ref_data) – normally should be either 1 or 2
- autoFindPeaks(X, y, height, width, prominence=None, plot=True)
- calibrationFromGrapth(fit_order=1)
- cutData(rango)
- cutRef(rango)
- doCalibrationFit(X1, X2, fit_order)
do a polynomial fit of order=fit_order between X1 and X2
- Parameters
X1 (array_like) – cordinate points of the experimental_data to be correlated with X2 (ref_data)
X2 (array_like,) – cordinate points of the of the ref_data
retunr – the polynom of order=fit_order and the R2 of the fit
- importExperimentalData(path, plot=False, header=None, sep=',')
- importReferenceData(path, rango=None, plot=False, header=None, sep=',')
- manualCalibration(lists_pixels, lists_wavelengths, fit_order)
- plotDataRef(find_peaks=True)
make a subplot of the experimental_data and the reference_data
- Parameters
find_peaks (bool (default True)) – if True find and plot the peaks of the experimental_data and reference_data, using the data_find and ref_find attribute parameters
ultrapyfit.old.ChirpCorrection module
Created on Fri Nov 13 17:47:20 2020
@author: 79344
- class ultrapyfit.old.ChirpCorrection.ChripCorrection(data, wavelenght, time)
Bases:
object
- GVD(CaF2=0, SiO2=0, BK7=0, offset=0)
- GVDFromGrapth(qt=None)
- GVDFromPolynom(qt=None)
- buttonVerifiedGVD(label)
- correctGVD(verified=False)
- dispersion(landa, element, excitation)
- finalGVD(event)
- find_nearest(array, value)
- fitPolGVD(event)
- fprime(x, b1, b2, b3, c1, c2, c3)
- getCorrectData()
- indexDifraction(x, b1, b2, b3, c1, c2, c3)
- polynomi(params, x, order)
- radioVerifiedGVD(label)
- updateGVD(val)
- verifiedGVD()
- class ultrapyfit.old.ChirpCorrection.EstimationGVD(data, wavelenght, time)
Bases:
object
- estimateGVD()
- class ultrapyfit.old.ChirpCorrection.EstimationGVDSellmeier(data, wavelenght, time)
Bases:
EstimationGVD
- GVDFromGrapth(qt=None)
- dispersion(landa, element, excitation)
- estimateGVD(CaF2=0, SiO2=0, BK7=0, offset=0)
- finalGVD(event)
- fprime(x, b1, b2, b3, c1, c2, c3)
- indexDifraction(x, b1, b2, b3, c1, c2, c3)
- updateGVD(val)
- ultrapyfit.old.ChirpCorrection.correctGVDSellmeier(data, wavelenght, time)
ultrapyfit.old.ExponentialFit module
Created on Thu Nov 12 21:00:23 2020
@author: lucas
- class ultrapyfit.old.ExponentialFit.GlobalFitExponential(x, data, exp_no, params, deconv=True, tau_inf=1000000000000.0, GVD_corrected=True, **kwargs)
Bases:
Minimizer
,ModelCreator
Class that does a global fit using exponential models. This class is uses by the function, globalfit_gauss_exponential and globalfit_exponential functions. A global fit evaluate the times from all the traces (taus are globally fitted), while the pre_exponential values (pre_exp) are estimated independently from each trace. The pre_exp values give later the decay associated spectra (DAS). The Class do not generates the parameters automatically.
- x
x-vector, normally time vector
- Type
1darray
- data
array containing the data, the number of rows should be equal to the len(x)
- Type
2darray
- exp_no
number of exponential that will be used to fit the data.
- Type
int
- params
object containing the initial parameters values used to build an exponential model. These parameters are iteratively optimize to reduce the residual matrix formed by data-model (error matrix) using Levenberg-Marquardt algorithm.
- Type
lmfit parameters object
- deconv
If True the fitting functions will search for the deconvolution parameter (“fwhm”) in the params attribute, and the the model is a weighted sum of Gauss modified exponential functions. If False the the model is a weighted sum of exponential functions, and params should not contain the fwhm entrance.
- Type
bool
- tau_inf
An extra decay time use to evaluate possible photoproduct. This should be used if the signal at long delay times is not completely recovered and if deconv is set to True. If the signal at long delay times is zero tau_inf should be set to None. (only affects if deconv is True)
- Type
float or int or None
- GVD_corrected
Defines if the chrip or group velocity dispersion (GVD) has been corrected. If True t0 is globally optimized (faster). If False t0 is separately optimized for each trace (slower). Notice in some cases even if the chirp or GVD has been corrected, very small variations of t0 that might be imperceptible and small may generate problems in the fit, setting this parameter to False can help to acquire overcome this problem although the fit will take longer. (only affects if deconv is True)
- Type
bool
- weights
This dictionary controls if the fitting weights are applied, the keys are: “apply”: Bool “vector”: weighting vector. ‘type’: type of vector defined in the , ‘range’: time range according to x-vector of the weights that are
different than 1
‘value’: val weighting value
The dictionary keys can be passes as kwargs when instantiating the object
- Type
dictionary
- global_fit(vary_taus=True, maxfev=None, time_constraint=False, apply_weights=False)
Method to fit the data to a model. Returns a modified lmfit result object.
- Parameters
vary_taus (bool or list of bool) – If True or False all taus are optimized or fixed. If a list, should be a list of bool equal with len equal to the number of taus. Each entry defines if a initial taus should be optimized or not.
maxfev (int (default 5000)) – maximum number of iterations of the fit.
time_constraint (bool (default False)) – If True and there are more than one tau to optimized force: tau2 > tau1, tau3 > tau2 and so on If self.deconv and True a Gaussian modified exponential model is applied and tau1 > fwhm.
apply_weights (bool (default False)) – If True and weights have been defined, this will be applied in the fit (for defining weights) check the function define_weights.
- pre_fit()
Method that optimized the pre_exponential factors trace by trace without optimizing the decay times (taus). It is automatically ran before a global fit.
- ultrapyfit.old.ExponentialFit.globalfit_exponential(x, data, *taus, vary=True, t0=0, maxfev=5000, **kwargs)
Function that does a global fit of a weighted sum of exponential equal to the number of time constants (taus) pass. It gives a result object which is modified object with added properties. The result can be evaluated with the explore result class.
A global fit evaluate the times from all the traces (taus are globally fitted), while the pre_exponential values (pre_exp) are estimated independently from each trace. The pre_exp values give later the decay associated spectra (DAS). The function generates the parameters automatically.
- Parameters
x (1darray) – x-vector, normally time vector
data (2d array) – Array containing the data, the number of rows should be equal to the len(x)
taus (float or int) – Initial estimates for the exponential decay times. There is no limit of tau numbers. each tau correspond to an exponential function. Is recommended to use the minimum number of exponential that correctly describe the data set.
vary (bool or list of bool) – If True or False all taus are optimized or fixed. If a list, should be a list of bool equal with len equal to the number of taus. Each entry defines if a initial taus should be optimized or not.
t0 (int) – Initial time value where to start evaluating the function. Only x vector values higher than t0 will be take into consideration.
maxfev (int (default 5000)) – Maximum number of iterations of the fit.
kwargs – Related for applying weight to the fit. The dictionary obtained from the function define_weights can be directly pass as *+weights
e.g.1 (globalFitSumExponential(x, data, 8,30, 200, vary=True, t0=3)) – A weighted sum of three exponential function will be fitted to the data set the initial estimates are 8, 30 and 200, where all will be optimized. The function is only evaluated from x values higher than 3
e.g.2 (globalFitSumExponential(x, data, 8,30, 200, vary=[True, False, True])) – A weighted sum of three exponential function will be fitted to the data set the initial estimates are 8, 30 and 200 where 8 and 200 are optimized and 30 is fixed. function is only evaluated from x values higher than 0, t0 by default is 0.
- ultrapyfit.old.ExponentialFit.globalfit_gauss_exponential(x, data, *taus, vary=True, fwhm=0.12, tau_inf=1000000000000.0, t0=0, vary_t0=True, vary_fwhm=False, maxfev=5000, GVD_corrected=True, **kwargs)
Function that does a global fit of a weighted sum of gaussian modified exponential equal to the number of time constants (taus) pass. It gives a result object which is a modified object with added properties. The result can be evaluated with the explore result class.
A global fit evaluate the times from all the traces (taus are globally fitted), while the pre_exponential values (pre_exp) are estimated independently from each trace. The pre_exp values give later the decay associated spectra (DAS). The function generates the parameters automatically.
- Parameters
x (1darray) – x-vector, normally time vector
data (2d array) – Array containing the data, the number of rows should be equal to the len(x)
taus (float or int) – Initial estimates for the exponential decay times. There is no limit of tau numbers. each tau correspond to an exponential function. Is recommended to use the minimum number of exponential that correctly describe the data set.
vary (bool or list of bool) – If True or False all taus are optimized or fixed. If a list, should be a list of bool equal with len equal to the number of taus. Each entry defines if a initial taus should be optimized or not.
fwhm (int or float (default 0.12)) – Full width half maximum of the laser pulse length use in the experiment. This value is used to to fit a modified gaussian exponential function, and can be determined with an external measurement or for example in case of TRUV-vis data fitting the stimulated raman signal of the solvent to a gaussian function.
tau_inf (float or int or None (default 1E12)) – An extra decay time use to evaluate possible photoproduct. This should be used if the signal at long delay times is not completely recovered. If the signal at long delay times is zero tau_inf should be set to None.
t0 (int (default 0)) – t0 in a modified gaussian exponential fit defines the point where the signal start raising. This should be the 0, and is the time defining the time where the pump and probe overlaps. (notice is different from the t0 in a simple exponential fit)
vary_t0 (bool (default True)) – Defines if the t0 is optimized. We recommend to always set this value to True
vary_fwhm (bool (default False)) – Defines if the fwhm is optimized. We recommend to always set this value to False, and determine this value from an external measurement
GVD_corrected (bool (defautl True)) – Defines if the chrip or group velocity dispersion (GVD) has been corrected. If True t0 is globally optimized (faster). If False t0 is separately optimized for each trace (slower). Notice in some cases even if the chirp or GVD has been corrected, very small variations of t0 that might be imperceptible and small may generate problems in the fit, setting this parameter to False can help to acquire overcome this problem although the fit will take longer.
maxfev (int (default 5000)) – Maximum number of iterations of the fit.
kwargs – Related for applying weight to the fit. The dictionary obtained from the function define_weights can be directly pass as *+weights
e.g.1 (globalFitSumExponential(x, data, 8,30, 200, vary=True, fwhm=0.16)) – A weighted sum of three exponential function will be fitted to the data set the initial estimates are 8, 30 and 200, where all will be optimized. The fwhm of the Gauss function is 0.16.
e.g.2 (globalFitSumExponential(x, data, 8,30, 200, vary=[True, False, True],) – fwhm=0.12) A weighted sum of three Gauss modified exponential function will be fitted to the data set the initial estimates are 8, 30 and 200 where 8 and 200 are optimized and 30 is fixed. The fwhm of the Gauss function is 0.12.
ultrapyfit.old.Global_Fit_class module
ultrapyfit.old.TargetFit module
Created on Fri Nov 13 13:12:36 2020 @author: 79344
- class ultrapyfit.old.TargetFit.GlobalFitTargetModel(x, data, exp_no, params, deconv=True, GVD_corrected=True, **kwargs)
Bases:
Minimizer
,ModelCreator
Class that does a global target fit to a kinetic model. This class is uses a global fit evaluate the times from all the traces (kinetic constants are globally fitted), while the pre_exponential values (pre_exp) are estimated independently from each trace. The pre_exp values give later the species associated spectra (SAS). The Class do not generates the parameters automatically. .. attribute:: x
x-vector, normally time vector
- type
1darray
- data
array containing the data, the number of rows should be equal to the len(x)
- Type
2darray
- exp_no
number of exponential that will be used to fit the data.
- Type
int
- params
object containing the initial parameters values used to build an exponential model. These parameters are iteratively optimize to reduce the residual matrix formed by data-model (error matrix) using Levenberg-Marquardt algorithm.
- Type
lmfit parameters object
- deconv
If True the fitting functions will search for the deconvolution parameter (“fwhm”) in the params attribute, and the the model is a weighted sum of Gauss modified exponential functions. If False the the model is a weighted sum of exponential functions, and params should not contain the fwhm entrance.
- Type
bool
- GVD_corrected
Defines if the chrip or group velocity dispersion (GVD) has been corrected. If True t0 is globally optimized (faster). If False t0 is separately optimized for each trace (slower). Notice in some cases even if the chirp or GVD has been corrected, very small variations of t0 that might be imperceptible and small may generate problems in the fit, setting this parameter to False can help to acquire overcome this problem although the fit will take longer. (only affects if deconv is True)
- Type
bool
- weights
This dictionary controls if the fitting weights are applied, the keys are: “apply”: Bool “vector”: weighting vector. ‘type’: type of vector defined in the , ‘range’: time range according to x-vector of the weights that are
different than 1
‘value’: val weighting value The dictionary keys can be passes as kwargs when instantiating the object
- Type
dictionary
- global_fit(maxfev=None, apply_weights=False)
Method to fit the data to a model. Returns a modified lmfit result object. :Parameters: * maxfev (int (default 5000)) – maximum number of iterations of the fit.
apply_weights (bool (default False)) – If True and weights have been defined, this will be applied in the fit (for defining weights) check the function define_weights.
- preFit()
Method that optimized the pre_exponential factors trace by trace without optimizing the kinetic constants times. It is automatically ran before a global fit.
ultrapyfit.old.basicSpectrum module
Created on Wed Nov 11 15:05:16 2020
@author: lucas
- class ultrapyfit.old.basicSpectrum.BasicSpectrum(x, y, sort=True, name=None, name_x=None, name_y=None)
Bases:
object
Contain basic functions that every spectrum should have
- x: array type
independent variable of the spectrum
- y: array type
independent variable of the spectrum
- data_table: pandas dataFrame
data frame containig x and y with coulmn names x:’wavelengths’ y:’absorbances’
- sort: bool
if True sperctrum is order from the x minimum value to the x highest
- name: str
name given to the spectrum
- name_x: str
name of the x vector, i.e. ‘Wavelngth (nm)’
- name_y: str
name of the y vector, i.e. ‘Absorbance’
- averageOfRange(low=None, high=None, Print=False)
Returns the average value of “y” from the given “x” range
- low: float
minimum value of x
- high: float
maximum value of x
- Print: bool
print the results out
the average the range
- baselineCorrection(low=None, high=None, itself=True)
subrtact the average value of a range to the spectra acording to values of x
- low: float
minimum value of x range
- high: float
maximum value of x range
- itself: bool
if true subtract the spectrum else returns a new spectrum object
- Returns
x-position; y-maximum
- Return type
float, float
- calculateArea(low=None, high=None, Print=False)
cut the spectra acording to values of x
- low: float
minimum value of x
- high: float
maximum value of x
- Print: bool
print the results out
the are under the curve in the range
- cut(low=None, high=None, itself=True)
cut the spectra acording to values of x
- low: float
minimum value of x
- high: float
maximum value of x
- itself: bool
if true cut the spectrum else returns a new spectrum object
- Returns
x-position; y-maximum
- Return type
float, float
- forcePositive(itself=True)
add minimum value of the y vector to itself and thus force it to be positive
- normalize(wavelength=None, low=None, high=None, itself=True)
normalize the spectra so that the wavelenght value is 1. If wavelenght is None the maximum of the range between low and high values will be use to normalize the spectrum.
- wavelength: float
wavelenth value where the spectra shoudl be 1 if None the maximum will be chose
- low: float
minimum value of x range
- high: float
maximum value of x range
- itself: bool
if true normalize the spectrum else returns a new spectrum object
- obtainMax(low=None, high=None, Print=False)
returns the maximum of the y vecto and the correspodint x postion
- low: float
minimum value of x range
- high: float
maximum value of x range
- Print: bool
print the results out
- Returns
x-position; y-maximum
- Return type
float, float
- obtainMin(low=None, high=None, Print=False)
returns the minimum of the y vector and the correspodint x postion Paramaters ———- low: float
minimum value of x range
- high: float
maximum value of x range
- Print: bool
print the results out
- Returns
x-position; y-minimum
- Return type
float, float
- obtainValue(value)
returns the y value of the correspoding x value
- valu: float
value of x
- Returns
y value
- Return type
float
- plotSpectrum(axes='current', x_label=None, y_label=None, label=None, fill=False, two_Xaxes=True, **kwargs)
Plot the spectrum
- axes: str or matplotlib axes object
“current” plots in the last open axes
“new” create a new axes
pass a matplotlib axes where the spectra will be plot
- x_label: str
the x label of the plot
- y_label: str
the y label of the plot
- label: str
the legend to be display (pass “_” form no label)
- fill: bool
fill area under the spectrum curve
- two_Xaxes: bool
in case two x is tranformed (i.e. wavelenght and wavenumber) and if True, the old and new axis will be plot
- kwargs: dict
matplot lib kwargs for plt.plot()
- extra_kwargs: dict
- this parameters can be pases as kwargs eve if they are not from plt.plot()
fsize: 14 small_tick: True which:both direction:in
- Return type
matplotlib axex object
- transformXvector(func, new_name, undo=False)
make a tranformation of x verto according to the function pass
Paramaters
- func: func(x):
function that tranform x
- new_name: str
string of the new x vector
- undo: bool
if True and x has been transform, undo the tranformation, No need to pass func or new_name if True
ultrapyfit.old.data_containers module
Created on Mon Nov 23 18:04:41 2020
@author: 79344
- class ultrapyfit.old.data_containers.UnvariableContainer(**kws)
Bases:
object
- class ultrapyfit.old.data_containers.VariableContainer(**kws)
Bases:
object
- ultrapyfit.old.data_containers.froze_it(cls)
ultrapyfit.old.targetmodel module
- class ultrapyfit.old.targetmodel.ModPopulation(new_name)
Bases:
object
- countActive()
- countActiveSFs()
- countActiveSFsValues()
- countFixed()
- countOutgoingArrows()
- enableDisableKs()
- remove(model)
- updateBranchKs()
- updateState(c_edit, tau_edit, k_all_edit)
- class ultrapyfit.old.targetmodel.ModProcess(new_name, pop_source, pop_target)
Bases:
object
- contains(point)
- getsetLocation()
- paintYourself(painter)
- remove(model)
- updateState(k_edit, sf_edit)
- class ultrapyfit.old.targetmodel.Model
Bases:
object
- addPopulation(new_population)
- addProcess(new_process)
- checkParams(experiment)
- genParameters()
- load()
- manualModelBuild()
- save(filename)
- class ultrapyfit.old.targetmodel.ModelWindow(model_ref)
Bases:
QWidget
- button1Func()
- button31Func()
- button3Func()
- button41Func()
- button4Func()
- button5Func()
- countArrows(population1, population2)
- eventFilter(self, QObject, QEvent) bool
- isStrNumber(s)
- paintEvent(self, QPaintEvent)
- populationEditFunc()
- processEditFunc()
- class ultrapyfit.old.targetmodel.ParamControl(parent, name, callback)
Bases:
QWidget
- isActive()
- loadState(enabled, active, fixed, value)
- paintEvent(self, QPaintEvent)
- setActive(setactive)
- setEnabled(self, bool)
- ultrapyfit.old.targetmodel.isIdentifier(identifier)
- ultrapyfit.old.targetmodel.params_to_model()