def PlotFFTInput(self): """Plot Time Domain of FFT Input Slice for Last Measurement""" fig = self.CreateFigure("FFT Input") sp = fig.add_subplot(111) xaxis = range(0,self.fftn) sp.plot(xaxis,[x.real for x in self.fftia],'.-',color='b',label='I') sp.plot(xaxis,[x.imag for x in self.fftia],'.-',color='r',label='Q') sp.set_ylabel("Magnitude") sp.set_xlabel("Sample") #sp.legend(bbox_to_anchor=(1,-0.1)) sp.legend(loc=2,bbox_to_anchor=(0,-0.1),ncol=4) plt.show()
def PlotFD(self,dbfs=True): """Plot Frequency Domain for Last Measurement""" freqspectrum = np.abs(self.fftoa) freqspectrum = np.concatenate( [freqspectrum[self.fftn/2:self.fftn],freqspectrum[0:self.fftn/2]] ) if dbfs: zerodb = 20*np.log10(self.fftn/2) freqspectrum = (20*np.log10(abs(freqspectrum))) - zerodb fig = self.CreateFigure("Frequency Domain") sp = fig.add_subplot(111) xaxis = np.r_[0:self.fftn] * (self.Sr/self.fftn) xaxis = np.concatenate( [(xaxis[self.fftn/2:self.fftn] - self.Sr),xaxis[0:self.fftn/2]]) sp.plot(xaxis,freqspectrum,'.-',color='b',label='Spectrum') sp.set_ylabel("dBFS") sp.set_xlabel("Frequency") sp.legend(loc=2,bbox_to_anchor=(0,-0.1),ncol=4) plt.show()
def PlotTD(self): """Plot Time Domain of Jack Input and Output Arrays for Last Measurement""" fig = self.CreateFigure("Time Domain") sp = fig.add_subplot(111) xaxis = range(0,len(self.iIa)) sp.plot(xaxis,self.iIa,'.-',color='b',label='iI') ## 180 phase shift as complex portion is created with -1j sp.plot(xaxis,-1*self.iQa,'.-',color='r',label='iQ') sp.plot(xaxis,self.oIa,'.-',color='c',label='oI') sp.plot(xaxis,self.oQa,'.-',color='m',label='oQ') ## Identify RTFrames maxy = self.oIa.max() sp.plot([self.rtframes,self.rtframes],[-maxy,maxy],'k-',lw=3,label='RT Frames') ## Identify Sync Index sp.plot([self.synci+self.sync2fft,self.synci+self.sync2fft],[-maxy,maxy],'g-',lw=3,label='FFT Start') sp.plot([self.synci+self.sync2fft+self.fftn,self.synci+self.sync2fft+self.fftn],[-maxy,maxy],'y-',lw=3,label='FFT End') sp.set_ylabel("Magnitude") sp.set_xlabel("Sample") #sp.legend(bbox_to_anchor=(1,-0.1)) sp.legend(loc=2,bbox_to_anchor=(0,-0.1),ncol=7) plt.show()
# fit and plot a new linear model regr = linear_model.LinearRegression() regr.fit(pd.DataFrame(x),pd.DataFrame(y)) x_prime = np.linspace(x.min(),x.max(),num=10)[:,np.newaxis] y_hat = regr.predict(x_prime) sp.plot(x_prime,y_hat,linewidth=2,linestyle='dashed',color='green',alpha=0.8) ss_res = regr.residues_[0] ss_tot = np.sum((y - np.mean(y))**2) rsq = 1 - (ss_res/ss_tot) sp.annotate('R^2: {:.2f}\nCoef: {:.2f}\nIntr: {:.2f}'.format(rsq,regr.coef_[0][0],regr.intercept_[0]) ,xy=(1,0),xycoords='axes fraction',xytext=(-12,6),textcoords='offset points' ,color='green',weight='bold',size=12,ha='right',va='bottom') sp.set_ylabel('Post-test Score') sp.set_xlabel('Pre-test Score') sp.axes.grid(True,linestyle='-',color='lightgrey') plt.subplots_adjust(top=0.95) plt.show() ## TODO: ## scores pre vs post for test type # <codecell> ## What's the range of deltas? df['staard_score_delta'] = df['staard_score_post'] - df['staard_score_pre'] df.boxplot(column='staard_score_delta',by='testtype',sym='k+',vert=False