bath/data/theory/mktheory.py

80 lines
1.8 KiB
Python

import matplotlib.pyplot as plt
import numpy as np
import wafer
import VisTools.plotting as vtp
import VisTools.tex as vtt
plt.style.use('bmh')
plt.rcParams['axes.facecolor'] = 'white'
plt.figure(figsize=(8, 4))
def gen_reticle_empty():
plt.clf()
w = wafer.WaferRepr()
_, ax = plt.subplots()
w.placeim(ax, (0, 0))
ax.axis('off')
ax.set_aspect("equal")
plt.savefig('wafer.pdf')
def gen_48v_theory():
xdata = np.linspace(43, 53, 100)
ydata = xdata / 241 * 8 * 1.1
plt.clf()
plt.plot(ydata, xdata)
plt.xlabel('V$_{pin}$ / V')
plt.ylabel('V$_{48V in}$ / V')
plt.savefig('v48.pdf')
def gen_48i_theory():
xdata = np.linspace(0, 2000/48, 100)
ydata = xdata * 500e-6 * 8 * 1.1
plt.clf()
plt.plot(ydata, xdata)
plt.xlabel('V$_{pin}$ / V')
plt.ylabel('I$_{48V in}$ / A')
plt.savefig('i48.pdf')
def gen_1v8_theory():
rpara = 75000
rseri = 2*4700
xdata = np.arange(0, 256, 4)
ydata = (xdata / 256 * 10000)
ydata = ydata * rpara / (ydata + rpara) + rseri
ydata = 30100 / (ydata + 6490) * .7 + .7
plt.clf()
plt.plot(xdata, ydata, label="Equation after Datasheet")
vps = vtp.fit(xdata, ydata, lambda x,m,p,a,c: a/(m*x-p)+c, [.1, -1, 1, 1.5])
#plt.plot(xdata, vps[2].n / (vps[0].n * xdata - vps[1].n) + vps[3].n)
vtt.unc_tolatex(vps[0], None, 'theo.tex', name="m")
vtt.unc_tolatex(vps[1], None, 'theo.tex', name="p")
vtt.unc_tolatex(vps[2], None, 'theo.tex', name="a")
vtt.unc_tolatex(vps[3], None, 'theo.tex', name="c")
plt.xlabel("Potentiometer Setting P$_{val}$")
plt.ylabel("V$_{1.8V out}$")
plt.savefig('v18.pdf')
if __name__ == "__main__":
gen_48v_theory()
gen_48i_theory()
gen_1v8_theory()
gen_reticle_empty()