Circuits¶
-
class
impedance.circuits.
BaseCircuit
(initial_guess, name=None, bounds=None)[source]¶ Base class for equivalent circuit models
Methods
fit
(self, frequencies, impedance[, method, …])Fit the circuit model get_param_names
(self)Converts circuit string to names get_verbose_string
(self)Defines the pretty printing of all data in the circuit plot
(self[, ax, f_data, Z_data, …])a convenience method for plotting Nyquist plots predict
(self, frequencies[, use_initial])Predict impedance using a fit equivalent circuit model -
fit
(self, frequencies, impedance, method='lm', bounds=None)[source]¶ Fit the circuit model
Parameters: - frequencies: numpy array
Frequencies
- impedance: numpy array of dtype ‘complex128’
Impedance values to fit
- method: {‘lm’, ‘trf’, ‘dogbox’}, optional
Name of method to pass to scipy.optimize.curve_fit
- bounds: 2-tuple of array_like, optional
Lower and upper bounds on parameters. Defaults to bounds on all parameters of 0 and np.inf, except the CPE alpha which has an upper bound of 1
Returns: - self: returns an instance of self
-
plot
(self, ax=None, f_data=None, Z_data=None, conf_bounds=None, scale=1, units='Ohms')[source]¶ a convenience method for plotting Nyquist plots
Parameters: - f_data: np.array of type float
Frequencies of input data (for Bode plots)
- Z_data: np.array of type complex
Impedance data to plot
- conf_bounds: {‘error_bars’, ‘filled’, ‘filledx’, ‘filledy’}, optional
Include bootstrapped confidence bands (95%) on the predicted best fit model shown as either error bars or a filled confidence area. Confidence bands are estimated by simulating the spectra for 10000 randomly sampled parameter sets where each of the parameters is sampled from a normal distribution
Returns: - ax: matplotlib.axes
axes of the created nyquist plot
-
predict
(self, frequencies, use_initial=False)[source]¶ Predict impedance using a fit equivalent circuit model
Parameters: - frequencies: numpy array
Frequencies
- use_initial: boolean
If true and a fit was already completed, use the initial parameters instead
Returns: - impedance: numpy array of dtype ‘complex128’
Predicted impedance
-
-
class
impedance.circuits.
CustomCircuit
(circuit, **kwargs)[source]¶ Methods
fit
(self, frequencies, impedance[, method, …])Fit the circuit model get_param_names
(self)Converts circuit string to names get_verbose_string
(self)Defines the pretty printing of all data in the circuit plot
(self[, ax, f_data, Z_data, …])a convenience method for plotting Nyquist plots predict
(self, frequencies[, use_initial])Predict impedance using a fit equivalent circuit model
-
class
impedance.circuits.
Randles
(CPE=False, **kwargs)[source]¶ A Randles circuit model class
Methods
fit
(self, frequencies, impedance[, method, …])Fit the circuit model get_param_names
(self)Converts circuit string to names get_verbose_string
(self)Defines the pretty printing of all data in the circuit plot
(self[, ax, f_data, Z_data, …])a convenience method for plotting Nyquist plots predict
(self, frequencies[, use_initial])Predict impedance using a fit equivalent circuit model