import matplotlib.pyplot as plt import matplotlib.ticker as mpt import matplotlib as mpl import mpl_toolkits.axes_grid1.inset_locator as ins import matplotlib.cm as cm 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_reg_theory(): xdata = np.linspace(0, 150, 1001) # consts rpar = 75000 rser = 9400 r0 = 1.0029e-3 r1 = 15.966e-3 iret = 9.1 plt.clf() plt.figure(figsize=(8, 4)) for n, voff in enumerate([1.75, 1.8, 1.85, 1.9]): ydata = iret * r1 + r0 * xdata + voff ydata = (.7*30100 / (ydata - .7)) - 6490 - rser ydata = rpar * ydata / (rpar + ydata) * 256 / 10000 plt.plot( [x for x, y in zip(xdata, ydata) if y >= 0], [y for y in ydata if y >= 0], color=f"C{n}", label=f"V$_{{off}}$ = {voff} V" ) plt.plot( xdata, ydata, color=f"C{n}", linestyle='dotted' ) plt.legend() plt.xlabel("current (analog / digital) I / A") plt.ylabel("P$_{val}$") plt.savefig('reg.pdf') 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', transparent=True) def gen_reticle_patterns(): plt.clf() f, sax = plt.subplots(2, 2, figsize=(8, 6)) sax = np.resize(sax, 4) patterns = [ [0, 2, 8, 10, 12, 14, 25, 27, 29, 31, 41, 43], [1, 9, 11, 13, 24, 26, 28, 30, 32, 40, 42, 44], [3, 5, 7, 15, 17, 19, 21, 23, 34, 36, 38, 46], [4, 6, 16, 18, 20, 22, 33, 35, 37, 39, 45, 47] ] for ax, p in zip(sax, patterns): w = wafer.WaferRepr() for r in p: w.set(r, .2) w.placeim(ax, (0, 0), cmap=cm.tab20c, nonumber=True) ax.set_ylim([-.6, 7.6]) ax.set_xlim([-.6, 8.6]) ax.set_aspect('equal') ax.axis('off') ax.invert_yaxis() plt.tight_layout() plt.savefig('wpattern.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, 1, dtype=int) ydata = (xdata / 256 * 10000) ydata = ydata * rpara / (ydata + rpara) + rseri ydata = 30100 / (ydata + 6490) * .7 + .7 print(f'vmin: {(ydata[-2]-ydata[-1])*1000} mV') print(f'vmin: {(ydata[0]-ydata[1])*1000} mV') plt.clf() plt.step(xdata, ydata, label="Equation after Datasheet", where='mid', linewidth=.1) 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.gca().xaxis.set_major_formatter(mpt.FuncFormatter( lambda v, x: '0x{:02x}'.format(int(v)) )) plt.xlabel("Potentiometer Setting P$_{val}$") plt.ylabel("V$_{MONITOR\_1V8}$ / V") rect = mpl.patches.Rectangle((48,1.81),32,.08,linewidth=1, edgecolor='gray',facecolor='none') plt.gca().add_patch(rect) plt.savefig('v18.pdf', transparent=True) plt.cla() plt.clf() plt.figure(figsize=(4, 2)) plt.step(xdata[48:80], ydata[48:80], label="Equation after Datasheet", where='mid', linewidth=.1) plt.gca().xaxis.set_major_formatter(mpt.FuncFormatter( lambda v, x: '0x{:02x}'.format(int(v)) )) plt.savefig('v18_zoom.pdf', transparent=True) if __name__ == "__main__": gen_48v_theory() gen_48i_theory() gen_1v8_theory() gen_reticle_empty() gen_reg_theory() gen_reticle_patterns()