prettify iout-gm figure
authorDan White <dan@whiteaudio.com>
Sun, 9 Feb 2014 18:59:21 +0000 (12:59 -0600)
committerDan White <dan@whiteaudio.com>
Sun, 9 Feb 2014 18:59:21 +0000 (12:59 -0600)
python-lib/test-data/chip14/arb0/vios-offset-gm/arb0-chip14-iout-gm.pdf [new file with mode: 0644]
python-lib/test-data/chip14/arb0/vios-offset-gm/gm2.py [new file with mode: 0644]

diff --git a/python-lib/test-data/chip14/arb0/vios-offset-gm/arb0-chip14-iout-gm.pdf b/python-lib/test-data/chip14/arb0/vios-offset-gm/arb0-chip14-iout-gm.pdf
new file mode 100644 (file)
index 0000000..89a5274
Binary files /dev/null and b/python-lib/test-data/chip14/arb0/vios-offset-gm/arb0-chip14-iout-gm.pdf differ
diff --git a/python-lib/test-data/chip14/arb0/vios-offset-gm/gm2.py b/python-lib/test-data/chip14/arb0/vios-offset-gm/gm2.py
new file mode 100644 (file)
index 0000000..b59c2d3
--- /dev/null
@@ -0,0 +1,150 @@
+#!/usr/bin/env python
+
+from pylab import *
+
+from glob import glob
+import yaml
+import scipy.signal as sig
+
+
+
+
+
+close('all')
+
+
+def circular_cycle(a, b):
+    from itertools import cycle
+
+    a_cycler = cycle(a)
+    b_cycler = cycle(b)
+
+    while True:
+        yield a_cycler.next() + b_cycler.next()
+
+def style_cycle():
+    lines = ('-', '--', '-.', ':')
+    colors = ('b', 'g', 'r', 'k', 'm', 'c')
+    return circular_cycle(lines, colors)
+
+
+def mkgm(vd, vout, tint, Cint=50e-12):
+    dvout = diff(vout / tint)
+    dvd = diff(vd)
+    gm = Cint * dvout / dvd
+    return (vd[:-1], gm)
+
+
+def smooth(x, npoints=21.0):
+    return sig.filtfilt(ones(npoints)/npoints, [1], x)
+
+
+# collect data to plot sorted by offset value
+d = {}
+for npz in glob('arb0-2013*.npz'):
+    data = np.load(npz)
+    cfg = yaml.load(open(npz.replace('.npz', '.yaml'), 'rb'))
+    ios = cfg['arb']['harmonics'][0]['otaA']['offset']
+
+    d[ios] = {'data':data, 'fname':npz}
+
+
+if 0:
+    figure(figsize=(5.0, 3.5))
+    subplots_adjust(top=0.98, bottom=0.12, left=0.15, right=0.95)
+
+    for ios in sorted(d.keys()):
+        if ios == 100:
+            continue
+
+        data = d[ios]['data']
+        tint = data['tint']
+        vd = data['vd']
+        vout = data['vout']
+
+        vdgm, dgm = mkgm(vd, vout, tint)
+
+        #plot(vdgm, dgm, 'b.', label='raw')
+        plot(vdgm, 1e12*smooth(dgm, 15.0),
+                linewidth=2.0,
+                label=ios)
+
+
+    legend(loc='best', ncol=2)
+
+    #xlim((-2.0, 2.0))
+    xlabel('$V_d$ (V)')
+    ylim((0, 100))
+    ylabel('$g_m$ (pA/V)')
+
+    savefig('arb0-chip14-gm.pdf')
+
+
+
+
+
+if 1:
+    figure(figsize=(5.0, 5.5))
+    subplots_adjust(top=0.98, bottom=0.08, left=0.14, right=0.98)
+
+
+    subplot(211)
+    styler = style_cycle()
+    for ios in sorted(d.keys()):
+        #if ios == 100:
+            #continue
+
+        data = d[ios]['data']
+        tint = data['tint']
+        vd = data['vd']
+        vout = data['vout']
+
+        iout = 50e-12 * vout / tint
+        plot(vd, 1e12*iout,
+                styler.next(),
+                label='%i'%ios)
+
+
+    hlines(0, -10, 10, linewidth=0.5, color='0.40')
+    vlines(0, -1000, 1000, linewidth=0.5, color='0.40')
+
+    xlim((-2.5, 2.5))
+    ylim((-180, 180))
+    ylabel('$I_{out}$ (pA)')
+
+    legend(title='offset code',
+            loc='lower right',
+            ncol=2,
+            fontsize='medium',
+            handletextpad=0.2,
+            labelspacing=0.2)
+
+    subplot(212)
+    styler = style_cycle() #reset iterator
+    for ios in sorted(d.keys()):
+        #if ios == 100:
+            #continue
+
+        data = d[ios]['data']
+        tint = data['tint']
+        vd = data['vd']
+        vout = data['vout']
+
+        vdgm, dgm = mkgm(vd, vout, tint)
+
+        #plot(vdgm, dgm, 'b.', label='raw')
+        #plot(vd, 1e12*smooth(50e-12*vout/tint, 15.0)/vd,
+        plot(vdgm, 1e12*smooth(dgm, 15.0),
+                styler.next(),
+                label=ios)
+
+    xlim((-2.5, 2.5))
+    hlines(0, -10, 10, linewidth=0.5, color='0.40')
+    vlines(0, -1000, 1000, linewidth=0.5, color='0.40')
+    ylim((-5, 100))
+    #ylabel(r'$g_m = dI_{out}/dV_d$ (pA/V)')
+    ylabel(r'$G_m$ (pA/V)')
+    xlabel('$V_d$ (V)')
+
+    savefig('arb0-chip14-iout-gm.pdf')
+