Circuits

class impedance.models.circuits.circuits.BaseCircuit(initial_guess=[], constants=None, name=None)[source]

Base class for equivalent circuit models

Methods

fit(frequencies, impedance[, bounds, ...])

Fit the circuit model

get_param_names()

Converts circuit string to names and units

load(filepath[, fitted_as_initial])

Imports a model from JSON

plot([ax, f_data, Z_data, kind])

visualizes the model and optional data as a nyquist,

predict(frequencies[, use_initial])

Predict impedance using an equivalent circuit model

save(filepath)

Exports a model to JSON

fit(frequencies, impedance, bounds=None, weight_by_modulus=False, **kwargs)[source]

Fit the circuit model

Parameters:
frequencies: numpy array

Frequencies

impedance: numpy array of dtype ‘complex128’

Impedance values to 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

weight_by_modulusbool, optional

Uses the modulus of each data (|Z|) as the weighting factor. Standard weighting scheme when experimental variances are unavailable. Only applicable when global_opt = False

kwargs

Keyword arguments passed to impedance.models.circuits.fitting.circuit_fit, and subsequently to scipy.optimize.curve_fit or scipy.optimize.basinhopping

Returns:
self: returns an instance of self
get_param_names()[source]

Converts circuit string to names and units

load(filepath, fitted_as_initial=False)[source]

Imports a model from JSON

Parameters:
filepath: str

filepath to JSON file to load model from

fitted_as_initial: bool

If true, loads the model’s fitted parameters as initial guesses

Otherwise, loads the model’s initial and fitted parameters as a completed model

plot(ax=None, f_data=None, Z_data=None, kind='altair', **kwargs)[source]
visualizes the model and optional data as a nyquist,

bode, or altair (interactive) plots

Parameters:
ax: matplotlib.axes

axes to plot on

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

kind: {‘altair’, ‘nyquist’, ‘bode’}

type of plot to visualize

Returns:
ax: matplotlib.axes

axes of the created nyquist plot

Other Parameters:
**kwargsoptional
If kind is ‘nyquist’ or ‘bode’, used to specify additional

matplotlib.pyplot.Line2D properties like linewidth, line color, marker color, and labels.

If kind is ‘altair’, used to specify nyquist height as size

predict(frequencies, use_initial=False)[source]

Predict impedance using an equivalent circuit model

Parameters:
frequencies: array-like of numeric type
use_initial: boolean

If true and the model was previously fit use the initial parameters instead

Returns:
impedance: ndarray of dtype ‘complex128’

Predicted impedance at each frequency

save(filepath)[source]

Exports a model to JSON

Parameters:
filepath: str

Destination for exporting model object

class impedance.models.circuits.circuits.CustomCircuit(circuit='', **kwargs)[source]

Methods

fit(frequencies, impedance[, bounds, ...])

Fit the circuit model

get_param_names()

Converts circuit string to names and units

load(filepath[, fitted_as_initial])

Imports a model from JSON

plot([ax, f_data, Z_data, kind])

visualizes the model and optional data as a nyquist,

predict(frequencies[, use_initial])

Predict impedance using an equivalent circuit model

save(filepath)

Exports a model to JSON

class impedance.models.circuits.circuits.Randles(CPE=False, **kwargs)[source]

A Randles circuit model class

Methods

fit(frequencies, impedance[, bounds, ...])

Fit the circuit model

get_param_names()

Converts circuit string to names and units

load(filepath[, fitted_as_initial])

Imports a model from JSON

plot([ax, f_data, Z_data, kind])

visualizes the model and optional data as a nyquist,

predict(frequencies[, use_initial])

Predict impedance using an equivalent circuit model

save(filepath)

Exports a model to JSON