EISFitpython.EIS_Batchfit¶
This module fits a list of spectra in sequence. It also calculates the conductivity, the activation energy and the effective capacitance.
The functions write their figures and reports into the current working directory. For the procedure and an example, see Batch and Arrhenius analysis.
Batch_fit¶
Batch_fit(
files,
params,
circuit,
Temp,
UB,
LB,
weight_mtd,
method,
single_chi="No",
min_value=None,
max_value=None,
return_cov=False,
)
Fits one circuit to each file in sequence. The fitted parameters of one file are the start values for the next file.
| Parameter | Description |
|---|---|
files |
List of file paths in the order of the fit. The formats .txt and .csv are possible. |
params |
Start values for the first file. |
circuit |
Circuit string. |
Temp |
Temperatures in degrees Celsius, one for each file. The labels Data_<K>K use them. |
UB, LB |
Upper bounds and lower bounds of the parameters. |
weight_mtd |
"M", "P" or "U". |
method |
Method of SciPy. |
single_chi |
Use "No". |
min_value, max_value |
Limits of the frequency range for the fit. Set the two values together. |
return_cov |
If True, the function also returns the covariance matrices. |
Returns (all_params, all_fit_perror). Each array has one row for each file.
With return_cov=True, a third array contains the covariance matrix of each
fit. Its shape is (n_files, n_params, n_params).
A .txt file can be a NEISYS file or a text file with three columns.
The function writes one report for all files and one stacked Bode figure. For each spectrum, it writes one file with the fitted data and one Nyquist figure.
Batch_bootstrap¶
Batch_bootstrap(
files,
fit_params,
circuit,
UB,
LB,
weight_mtd,
method,
n_boot=1000,
seed=0,
noise="gaussian",
min_value=None,
max_value=None,
)
Does EISFit_main.bootstrap_fit for each file. Each fit starts at the
parameters that Batch_fit returned for that file. Give the same circuit,
bounds, weighting, method and frequency limits as in Batch_fit.
Returns an array with the shape (n_boot, n_files, n_params).
samples[:, i, j] contains the values of parameter j for file i. A fit that
does not converge gives NaN. File i uses the random start value seed + i.
Nyq_stack_plot¶
Draws the spectra of all files in one Nyquist plot with one common impedance
unit. Temp contains the temperatures in degrees Celsius, as in Batch_fit.
The legend shows the temperatures in kelvin.
Returns the Matplotlib axes. The function writes Nyq_stackplot.svg and shows
the figure.
plot_arrhenius¶
Calculates the conductivity from the resistances. Then the function does the
Arrhenius analysis with EISFit_main.EA and saves a figure and a report.
| Parameter | Description |
|---|---|
R_values |
One resistance array, or a list with one array for each component, in ohms. |
R_err |
Errors of the resistances, in the same form as R_values. |
temp |
Temperatures in degrees Celsius. The function adds 273.15. |
diameter |
Diameter of the pellet in centimeters. |
thickness |
Thickness of the pellet in centimeters. |
labels |
One label, or a list with one label for each component. |
Returns (conductivities, conductivity_errors). Each result is a list with one
array for each component. The function writes Arrhenius_plot.svg and
Arrhenius_Analysis_Report.txt. It shows the figure and prints the report.
C_eff¶
C_eff(
R_arrays,
R_err_arrays,
Q_arrays,
Q_err_arrays,
n_arrays,
n_err_arrays,
T,
labels=None,
error=None,
boot=None,
cov=None,
)
Calculates the effective capacitance C = (Q * R**(1 - n))**(1 / n) of a
resistor in parallel with a constant phase element. The function also
calculates the error of the capacitance.
Each argument is a list with one entry for each component. The arguments give
the resistance, the CPE coefficient, the CPE exponent and their errors. T
contains the temperatures in degrees Celsius.
The fit gives a strong correlation between R, Q and n of one arc. Thus
the error of C depends on the method that you use for this correlation.
Select one of three methods with error:
error |
Necessary input | Error in the result |
|---|---|---|
"bootstrap" |
boot: one tuple (R_samples, Q_samples, n_samples) for each component, from Batch_bootstrap or singlechi.Single_chi_bootstrap. Each array has the shape (n_boot, n_temperatures). A global parameter has the shape (n_boot,). |
Standard deviation of C for all fits. The report also gives the range from the 2.5 percentile to the 97.5 percentile. |
"covariance" |
cov: one covariance array for each component, in the order (R, Q, n). The shape is (n_temperatures, 3, 3) or (3, 3). |
Error propagation sqrt(g^T cov g). g is the gradient of C. |
"standard" |
Only R_err_arrays, Q_err_arrays and n_err_arrays. |
Error propagation for independent parameters: C * sqrt((Q_err/(n*Q))**2 + ((1-n)*R_err/(n*R))**2 + (ln(Q*R)*n_err/n**2)**2). |
The standard method ignores the covariance terms. For a fitted CPE, Q and n
usually have a strong correlation. The standard method then gives an error
that is too large.
The report shows only the selected method. Without error, the function uses
"bootstrap" if you give boot. If you give only cov, it uses
"covariance". If you give no input, the function calculates no error and
C_err is NaN.
Returns a list with one tuple (C, C_err) for each component. The function
writes Effective_Capacitance_Values.txt and prints the report.