def test_plot_nyquist(): frequencies = [1000.0, 1.0, 0.01] Z = np.array([1, 2, 3]) + 1j * np.array([2, 3, 4]) _, ax = plt.subplots() ax = plot_nyquist(ax, frequencies, Z) xs, ys = ax.lines[0].get_xydata().T assert (xs == Z.real).all() and (ys == -Z.imag).all()
"pulse_params": { "centers": centers, "pots": pots, "widths": widths }, "eis_params": { "start_freq": start_freq, "end_freq": end_freq, "points": points, }, "eis_results": eis_exp, "pulse_results": pulse_exp, } ana_results[sno] = {"randles": copy(res_randles), "rrc": copy(res_rrc)} import matplotlib.pyplot as plt from impedance.plotting import plot_nyquist fig, ax = plt.subplots(figsize=(5, 5)) plot_nyquist(ax, frequencies, Z) plot_nyquist(ax, frequencies, RRC.predict(frequencies)) plot_nyquist(ax, frequencies, randles.predict(frequencies)) plt.show() fig, ax = plt.subplots(3, 3) ax = ax.flatten() for i in range(9): ax[i].plot(np.array(pulse_exp["data"])[:, i]) plt.show()
] # ФИТТИНГ Z_fitB = circuitB.predict(frequencies) # Погрешность res_meas_real = (Z - circuitB.predict(frequencies)).real / np.abs(Z) res_meas_imag = (Z - circuitB.predict(frequencies)).imag / np.abs(Z) # ploting plt.figure(figsize=(6, 6)) ax1 = plt.subplot(221) ax2 = plt.subplot(222) ax3 = plt.subplot(223) ax4 = plt.subplot(224) #GRAFS plot_bode(axes=(ax1, ax2), f=frequencies, Z=Z, fmt='o') plot_bode(axes=(ax1, ax2), f=frequencies, Z=Z_fitB) plot_nyquist(ax3, frequencies, Z, fmt='o') plot_nyquist(ax3, frequencies, Z_fitB) #ERROR ax4.plot(frequencies, res_meas_real, '-', label=r'$\Delta_{\mathrm{Real}}$') ax4.plot(frequencies, res_meas_imag, '-', label=r'$\Delta_{\mathrm{Imag}}$') ax4.set_title('Measurement Model Error', fontsize=12) ax4.tick_params(axis='both', which='major', labelsize=12) ax4.set_ylabel('$\Delta$ $(\%)$', fontsize=10) ax4.set_xlabel('$f$ [Hz]', fontsize=10) ax4.set_xscale('log')
del connection pstat.SetCell(GamryCOM.CellOff) pstat.Close() import matplotlib.pyplot as plt plt.scatter(np.array(Zreal),-np.array(Zimag),c=np.log(Zfreq)) plt.colorbar() plt.axis('equal') plt.show() from impedance.circuits import CustomCircuit frequencies = np.array(Zfreq) Z = np.array(Zreal)+1j*np.array(Zimag) circuit = 'R0-p(R1,C1)' guess = [np.min(Z.real),np.max(Z.real),10**-6] circuit_mod = CustomCircuit(circuit,initial_guess=guess) circuit_mod.fit(frequencies, Z) Z_fit = circuit_mod.predict(frequencies) import matplotlib.pyplot as plt from impedance.plotting import plot_nyquist fig, ax = plt.subplots() plot_nyquist(ax, frequencies, Z, fmt='o') plot_nyquist(ax, frequencies, Z_fit, fmt='-') plt.legend(['Data', 'Fit']) plt.show()