91 lines
2.2 KiB
Python
91 lines
2.2 KiB
Python
#! /Usr/bin/python3
|
|
|
|
import scipy.optimize as opt
|
|
import numpy as np
|
|
import pandas as pd
|
|
import matplotlib.pyplot as plt
|
|
import VisTools.plotting as vt
|
|
import uncertainties as unc
|
|
import uncertainties.unumpy as unp
|
|
|
|
import statsmodels.api as sm
|
|
from statsmodels.stats.outliers_influence import summary_table as st
|
|
|
|
plt.ioff()
|
|
plt.style.use('bmh')
|
|
fig, axarr = plt.subplots(
|
|
2,
|
|
1,
|
|
figsize=(9, 8),
|
|
gridspec_kw = {'height_ratios':[4,1]}
|
|
)
|
|
plt.subplots_adjust(hspace=.5)
|
|
data = pd.read_csv("./" + __file__[:-3].split("_")[1] + ".csv", comment="#")
|
|
|
|
fits = np.array([])
|
|
errs = np.array([])
|
|
colors = np.array([])
|
|
|
|
data['Dv'] = data['v_pit48/v'] - data['v_set/v']
|
|
data['Dvk'] = data['v_keith/v'] - data['v_set/v']
|
|
print(data)
|
|
# fit to abs dist
|
|
linfnc = lambda x,m,c: x*m+c
|
|
|
|
def plot_and_linfit(col: str,fil, l: str):
|
|
p = axarr[0].errorbar(
|
|
data[fil]['v_set/v'],
|
|
data[fil][col],
|
|
alpha = 0,
|
|
label=None,
|
|
# fmt='.',
|
|
# antialiased=True
|
|
)
|
|
|
|
vals = vt.lm_plot(
|
|
data[fil],
|
|
'v_set/v',
|
|
col,
|
|
None,
|
|
'dv_pit48/v',
|
|
l,
|
|
fig=axarr[0],
|
|
color = p[0].get_color()
|
|
)
|
|
|
|
return vals, p
|
|
|
|
plot_and_linfit('Dvk', data.cycles == 0, 'ref')
|
|
for i in range(8):
|
|
val, p = plot_and_linfit('Dv', data.cycles == i, 'scaler: {}'.format(i))
|
|
fits = np.append(fits, val[0])
|
|
#errs = np.append(errs, np.sqrt(pcov[0][0]))
|
|
#colors = np.append(colors, p[0].get_color() )
|
|
|
|
|
|
print(fits[0].n)
|
|
for i in range(8):
|
|
axarr[1].errorbar(
|
|
i,
|
|
fits[i].n,
|
|
yerr = fits[i].s,
|
|
fmt='.',
|
|
#c = colors[i],
|
|
)
|
|
|
|
axarr[0].set_xlabel('V$_{set}$/V')
|
|
#axarr[0].set_title("PowerIt ADC Calibration: dependency on measurement cycles")
|
|
axarr[0].set_ylabel('$\Delta$V$_{IN}$ / V')
|
|
|
|
axarr[1].set_xlabel('sampleTicks scaler')
|
|
axarr[1].set_ylabel('$\Delta(\Delta$V$_{IN})$')
|
|
axarr[0].legend(bbox_to_anchor=(0, -.28,1, 1), loc="lower left",
|
|
mode="expand", borderaxespad=0, ncol=5)
|
|
#plt.tight_layout()
|
|
plt.savefig("./" + __file__[:-3].split("_")[1] + ".pdf", dpi=1000, bbox_inches='tight')
|
|
|
|
|
|
ss, d, ss2 = st(sm.OLS(data[data.cycles == 0]['v_pit48/v'], data[data.cycles == 0]['v_set/v']).fit(), alpha=.05)
|
|
|
|
low_ci, high_ci = d[:,4:6].T
|