In [1]:
%matplotlib notebook
import numpy as np
import matplotlib
from matplotlib import pyplot as plt
import pandas as pd
df=pd.read_table('./data/pressure.txt',sep='\s',header=0, engine='python')
df.head()
Out[1]:
In [92]:
fig, ax1 = plt.subplots()
ax1.plot(df.Xi, 'b')
ax1.plot(df.Y1, 'y')
#ax1.set_xlabel('time (s)')
# Make the y-axis label, ticks and tick labels match the line color.
ax2 = ax1.twinx()
ax2.plot(df.Xi, 'r')
ax2.plot(df.Y1, 'r')
ax2.set_ylabel('ax2', color='r')
ax2.tick_params('y', colors='r')
fig.tight_layout()
In [93]:
fig, ax1 = plt.subplots()
ax1.set_title('Y1(xi)')
ax1.set_ylabel('Saída Bruta (V)', color='b')
ax1.set_xlabel('mensurando (Pa)', color='g')
plt.plot(df.Xi,df.Y1,'o')
plt.show()
In [3]:
#N = 13
N = df.Y1.size
D = N * sum(df.Y1**2) - sum(df.Y1)**2
#592.08848258 print(D)
c0 = ( (sum(df.Xi) * sum(df.Y1**2)) - (sum(df.Y1) * sum(df.Xi * df.Y1)) ) / D
c1 = ( (N * sum(df.Xi * df.Y1) - (sum(df.Xi) * sum(df.Y1))) ) / D
print(' N = %s \n D = %s \n c0 = %s Pa \n c1 = %s Pa/V' % (N,D,c0,c1))
In [95]:
df['X1'] = c0+c1*df.Y1 # Saída calibrada
df['erro'] = df.X1 - df.Xi # Estimatíva de erro
In [96]:
print(df)
In [102]:
# Viés (bias)
vies = df.erro.mean()
erro2 = (df.erro**2).mean()
desvio_padrao = np.sqrt( sum((df.erro - vies)**2)/(N-1) )
print(" Bias/viés = %s # ~0,0 Pa \n Imprecisão = %s # Pa \n Inacurácia = %s ± %s Pa" % (vies,desvio_padrao,vies,desvio_padrao))
In [ ]: