Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import matplotlib.pyplot as plt
import numpy as np
import sys
sys.path.append('../')
# import Randles circuit object
from impedance.circuits import Randles # noqa E402
# read in data
data = np.genfromtxt('./data/exampleData.csv', delimiter=',')
f = data[:, 0]
Z = data[:, 1] + 1j*data[:, 2]
# initialize circuit objects
randles = Randles(initial_guess=[.01, .005, .1, .0001, 500])
randlesCPE = Randles(initial_guess=[.01, .005, .1, .9, .0001, 500], CPE=True)
# fit models
randles.fit(f, Z)
randlesCPE.fit(f, Z)
# print model objects
print(randles)
print(randlesCPE)
# impedance predictions based on model fits
Z_randles = randles.predict(f)
Z_randlesCPE = randlesCPE.predict(f)
# plot the data and the fits
fig, ax = plt.subplots(figsize=(5, 5))
ax.plot(np.real(Z), -np.imag(Z), 'o')
import matplotlib.pyplot as plt
import numpy as np
import sys
sys.path.append('../')
# import Randles circuit object
from impedance.circuits import Randles # noqa E402
# read in data
data = np.genfromtxt('./data/exampleData.csv', delimiter=',')
f = data[:, 0]
Z = data[:, 1] + 1j*data[:, 2]
# initialize circuit objects
randles = Randles(initial_guess=[.01, .005, .1, .0001, 500])
randlesCPE = Randles(initial_guess=[.01, .005, .1, .9, .0001, 500], CPE=True)
# fit models
randles.fit(f, Z)
randlesCPE.fit(f, Z)
# print model objects
print(randles)
print(randlesCPE)
# impedance predictions based on model fits
Z_randles = randles.predict(f)
Z_randlesCPE = randlesCPE.predict(f)
# plot the data and the fits
fig, ax = plt.subplots(figsize=(5, 5))