def plot1D(self, data, fig): vnafreqs = self.vnafreqs plt.figure(fig.number) plt.clf() fig.suptitle(self.image_filename + '\n' + self.data_filename + '/' + self.expNum) ax1 = fig.add_subplot(221) ax1.plot(np.real(data), np.imag(data)) ax1.set_xlabel('Re(a)') ax1.set_ylabel('Im(a)') ax1.ticklabel_format(useOffset=False) ax2 = fig.add_subplot(222) ax2.plot(vnafreqs * 1e-9, np.abs(data)) ax2.set_xlabel('VNA freq (GHz)') ax2.set_ylabel('|a|') ax2.ticklabel_format(useOffset=False) ax3 = fig.add_subplot(223) ax3.plot(vnafreqs * 1e-9, np.angle(data, deg=True)) ax3.set_xlabel('VNA freq (GHz)') ax3.set_ylabel('angle(a)') ax3.ticklabel_format(useOffset=False) ax4 = fig.add_subplot(224) ax4.plot(vnafreqs * 1e-9, 20 * np.log(np.abs(data)) / np.log(10)) ax4.set_xlabel('VNA freq (GHz)') ax4.set_ylabel('20 log|a|') ax4.ticklabel_format(useOffset=False) if self.fitdata and len(self.fitparams) > 0: popt = self.fitparams data_fit = af.complex_a_out(vnafreqs, *popt) ax1.plot(np.real(data_fit), np.imag(data_fit), '--') ax2.plot(vnafreqs * 1e-9, np.abs(data_fit), '--') ax3.plot(vnafreqs * 1e-9, np.angle(data_fit, deg=True), '--') ax4.plot(vnafreqs * 1e-9, 20 * np.log(np.abs(data_fit)) / np.log(10)) plt.show() self.saveimage(fig, self.image_filename) plt.pause(0.1)
def plot1D(self, data, fig): vnafreqs = self.vnafreqs plt.figure(fig.number) plt.clf() fig.suptitle(self.image_filename+'\n'+self.data_filename+'/'+self.expNum) ax1 = fig.add_subplot(221) ax1.plot(np.real(data), np.imag(data)) ax1.set_xlabel('Re(a)') ax1.set_ylabel('Im(a)') ax1.ticklabel_format(useOffset=False) ax2 = fig.add_subplot(222) ax2.plot(vnafreqs*1e-9, np.abs(data)) ax2.set_xlabel('VNA freq (GHz)') ax2.set_ylabel('|a|') ax2.ticklabel_format(useOffset=False) ax3 = fig.add_subplot(223) ax3.plot(vnafreqs*1e-9, np.angle(data, deg=True)) ax3.set_xlabel('VNA freq (GHz)') ax3.set_ylabel('angle(a)') ax3.ticklabel_format(useOffset=False) ax4 = fig.add_subplot(224) ax4.plot(vnafreqs*1e-9, 20 * np.log(np.abs(data)) / np.log(10)) ax4.set_xlabel('VNA freq (GHz)') ax4.set_ylabel('20 log|a|') ax4.ticklabel_format(useOffset=False) if self.fitdata and len(self.fitparams)>0: popt = self.fitparams data_fit = af.complex_a_out(vnafreqs, *popt) ax1.plot(np.real(data_fit),np.imag(data_fit),'--') ax2.plot(vnafreqs*1e-9,np.abs(data_fit),'--') ax3.plot(vnafreqs*1e-9,np.angle(data_fit, deg=True),'--') ax4.plot(vnafreqs*1e-9, 20 * np.log(np.abs(data_fit)) / np.log(10)) plt.show() self.saveimage(fig, self.image_filename) plt.pause(0.1)
ki_fit = np.zeros(genpoints) f_0_guess = 13052250602 kc_guess = 18736539 ki_guess = 5465667 for n in range(genpoints): data_n = data_complex[n] popt = af.fit_complex_a_out(vna_freqs, data_n, f_0=None, kc=kc_guess, ki=ki_guess) freqs_fit[n] = popt[0] kc_fit[n] = popt[1] ki_fit[n] = popt[2] if debug_fits: data_n_fit = af.complex_a_out(vna_freqs, *popt) fig, ax = plt.subplots(2, 2) ax[0, 0].plot(vna_freqs, np.abs(data_n_fit)) ax[0, 0].plot(vna_freqs, np.abs(data_n)) ax[1, 0].plot(vna_freqs, np.angle(data_n_fit)) ax[1, 0].plot(vna_freqs, np.angle(data_n)) ax[1, 1].plot(np.real(data_n_fit), np.imag(data_n_fit)) ax[1, 1].plot(np.real(data_n_fit), np.imag(data_n)) fig, ax = plt.subplots(3, 1) ax[0].plot(genfreqs * 1e-9, freqs_fit * 1e-9) ax[0].set_ylabel('Freq (GHz)') ax[0].ticklabel_format(useOffset=False) ax[1].plot(genfreqs * 1e-9, kc_fit * 1e-6) ax[1].set_ylabel('kc (MHz)') ax[1].ticklabel_format(useOffset=False)
# freqs_fit = np.zeros(genpoints) kc_fit = np.zeros(genpoints) ki_fit = np.zeros(genpoints) f_0_guess = 13052250602 kc_guess = 18736539 ki_guess = 5465667 for n in range(genpoints): data_n = data_complex[n] popt = af.fit_complex_a_out(vna_freqs, data_n, f_0=None, kc=kc_guess, ki=ki_guess) freqs_fit[n]=popt[0] kc_fit[n]=popt[1] ki_fit[n]=popt[2] if debug_fits: data_n_fit = af.complex_a_out(vna_freqs, *popt) fig, ax = plt.subplots(2,2) ax[0,0].plot(vna_freqs, np.abs(data_n_fit)) ax[0,0].plot(vna_freqs, np.abs(data_n)) ax[1,0].plot(vna_freqs, np.angle(data_n_fit)) ax[1,0].plot(vna_freqs, np.angle(data_n)) ax[1,1].plot(np.real(data_n_fit),np.imag(data_n_fit)) ax[1,1].plot(np.real(data_n_fit),np.imag(data_n)) fig, ax =plt.subplots(3,1) ax[0].plot(genfreqs*1e-9, freqs_fit*1e-9) ax[0].set_ylabel('Freq (GHz)') ax[0].ticklabel_format(useOffset=False) ax[1].plot(genfreqs*1e-9, kc_fit*1e-6) ax[1].set_ylabel('kc (MHz)') ax[1].ticklabel_format(useOffset=False)