65 lines
1.3 KiB
Python
65 lines
1.3 KiB
Python
#! /usr/bin/python3
|
|
|
|
import scipy.optimize as opt
|
|
import numpy as np
|
|
import pandas as pd
|
|
import matplotlib.pyplot as plt
|
|
|
|
plt.ioff()
|
|
plt.style.use('bmh')
|
|
fig, axarr = plt.subplots(2,1, sharex='col',figsize=(11.88, 8.4))
|
|
data = pd.read_csv("./adccalib_48.csv")
|
|
|
|
data['Dv'] = data['v_pit48/v'] - data['v_keith/v']
|
|
print(data)
|
|
|
|
axarr[0].errorbar(
|
|
data['v_keith/v'],
|
|
data['v_pit48/v'],
|
|
yerr=data['dv_pit48/v'],
|
|
label="V$_{MONITOR\_48V}$",
|
|
fmt='.'
|
|
)
|
|
axarr[0].errorbar(
|
|
data['v_keith/v'],
|
|
data['v_ps/v'],
|
|
yerr=data['dv_ps/v'],
|
|
label="V$_{PS}$",
|
|
fmt='.'
|
|
)
|
|
|
|
axarr[1].errorbar(
|
|
data['v_keith/v'],
|
|
data['Dv'],
|
|
yerr=data['dv_pit48/v'],
|
|
label=" absolute Error of ADC",
|
|
fmt='.'
|
|
)
|
|
|
|
# fit to abs dist
|
|
linfnc = lambda x,m,c: x*m+c
|
|
|
|
pfinal, pcov = opt.curve_fit(
|
|
linfnc,
|
|
data['v_keith/v'],
|
|
data['Dv'],
|
|
p0=(.1,2.6),
|
|
sigma=[.5 for e in range(data['Dv'].size)]
|
|
)
|
|
|
|
print( pfinal )
|
|
|
|
axarr[1].plot(
|
|
data['v_keith/v'],
|
|
data['v_keith/v']*pfinal[0]+pfinal[1]
|
|
)
|
|
plt.xlabel('V$_{Keith}$/k$\Omega$')
|
|
axarr[0].set_ylabel('V$_{IN}$/V')
|
|
axarr[0].set_title("PowerIt ADC Calibration: 48V Input")
|
|
axarr[1].set_ylabel('$\Delta$V$_{IN}$ / V')
|
|
axarr[0].legend()
|
|
#-plt.savefig("2kw_direct.png")
|
|
|
|
plt.tight_layout()
|
|
plt.savefig("adccalib_48.eps", format='eps', dpi=1000)
|