raw offset calibration example runs
authorDan White <dan@whiteaudio.com>
Mon, 10 Feb 2014 06:17:39 +0000 (00:17 -0600)
committerDan White <dan@whiteaudio.com>
Mon, 10 Feb 2014 06:17:39 +0000 (00:17 -0600)
python-lib/test-data/chip01/chip01-cal-raw.pdf
python-lib/test-data/chip01/chip01-cal-raw.py
python-lib/test-data/chip02/chip02-cal-raw.pdf [new file with mode: 0644]
python-lib/test-data/chip02/chip02-cal-raw.py [new file with mode: 0644]
python-lib/test-data/chip02/matplotlibrc [new symlink]

index 9fc2662ffc6e8552f4083545b9ef68269ef810b6..4f1deee588106e25fb2cc3039c38e09d334cf20f 100644 (file)
Binary files a/python-lib/test-data/chip01/chip01-cal-raw.pdf and b/python-lib/test-data/chip01/chip01-cal-raw.pdf differ
index da3247cff3df17bcc31d7c815634886ad1432e50..927a2a350948d271dd387125a5dcc64064c497c3 100644 (file)
@@ -90,21 +90,22 @@ co = array(cal_outs)
 
 if 1:
     figure(figsize=(6.0, 3.5))
-    subplots_adjust(top=0.93, bottom=0.12, left=0.12, right=0.98)
+    subplots_adjust(top=0.93, bottom=0.12, left=0.10, right=0.98)
 
     for i,k in enumerate(sample_channels):
         g = guesses[:, 0, k]
         r = 1e3*(2.5/2/2**13)*results[:, 0, k]
 
         subplot(N_PLOTS, N_COLS, N_COLS*i+1)
-        plot(g[:nevals[0,k]+1], '-')
+        plot(g[:nevals[0,k]+1], '.-')
         ylim((0, 127))
         ylabel('Channel %02i-A' % k)
-        xlim((0, 12))
+        xlim((-1, 13))
 
         subplot(N_PLOTS, N_COLS, N_COLS*i+2)
-        plot(1e-3*r[:nevals[0,k]+1], '-')
-        xlim((0, 12))
+        plot(1e-3*r[:nevals[0,k]+1], '.-')
+        hlines(0, -1, 15, linewidth=0.5, color='0.40')
+        xlim((-1, 13))
 
         subplot(N_PLOTS, N_COLS, N_COLS*i+3)
         data = cv[:, 0, k]
@@ -124,8 +125,8 @@ if 1:
         dstd = data.std()
         print nrun, dmean, dstd
 
-        text(0.03, 0.95, r'$\sigma\!=\!%4.1f$' % dstd,
-                horizontalalignment='left',
+        text(0.97, 0.95, r'$\sigma\!=\!%4.1f$mV' % dstd,
+                horizontalalignment='right',
                 verticalalignment='top',
                 bbox=dict(facecolor='r', alpha=0.5, boxstyle="round"),
                 transform = ax.transAxes)
@@ -140,6 +141,7 @@ if 1:
     ax.set_xticks(range(0, 15, 4))
     xlabel('Step')
 
+
     subplot(N_PLOTS, N_COLS, 2)
     ax = plt.gca()
     title('$V_{out}$', fontsize='medium')
@@ -152,20 +154,22 @@ if 1:
     ax.set_yticklabels([''] * len(ax.get_yticks()))
     xlabel('Step')
 
+
     subplot(N_PLOTS, N_COLS, 3)
     ax = plt.gca()
     title('Code hist.', fontsize='medium')
-    ax.set_xticks(range(0, 128, 32))
+    ax.set_xticks(range(0, 129, 64))
     ax.set_xticklabels([''] * len(ax.get_xticks()))
     ax.set_yticklabels([''] * len(ax.get_yticks()))
 
     subplot(N_PLOTS, N_COLS, (N_PLOTS-1)*N_COLS+3)
     ax = plt.gca()
-    ax.set_xticks(range(0, 128, 32))
+    ax.set_xticks(range(0, 129, 64))
     #ax.set_xticklabels([''] * len(ax.get_xticks()))
     ax.set_yticklabels([''] * len(ax.get_yticks()))
     xlabel('OTA tuning DAC')
 
+
     subplot(N_PLOTS, N_COLS, 4)
     ax = plt.gca()
     ax.set_xticks(range(-80, 81, 40))
@@ -184,7 +188,7 @@ if 1:
             #(os.path.basename(os.getcwd()),
                 #len(infiles)))
 
-    savefig('chip01-cal-raw.pdf')
+    savefig(os.path.basename(os.getcwd()) + '-cal-raw.pdf')
 
 #interactive(False)
 interactive(True)
diff --git a/python-lib/test-data/chip02/chip02-cal-raw.pdf b/python-lib/test-data/chip02/chip02-cal-raw.pdf
new file mode 100644 (file)
index 0000000..1b6df77
Binary files /dev/null and b/python-lib/test-data/chip02/chip02-cal-raw.pdf differ
diff --git a/python-lib/test-data/chip02/chip02-cal-raw.py b/python-lib/test-data/chip02/chip02-cal-raw.py
new file mode 100644 (file)
index 0000000..0493eae
--- /dev/null
@@ -0,0 +1,216 @@
+#!/usr/bin/env python
+
+from pylab import *
+
+import os
+from glob import glob
+from random import sample as rand_sample
+
+
+cal_values = []
+cal_outs = []
+cal_nevals = []
+cal_means = []
+cal_stds = []
+
+infiles = sorted(glob('*.npz'))
+#N_RUNS = min(len(infiles), 8)
+N_RUNS = 0
+sample_runs = sorted(rand_sample(range(len(infiles)), N_RUNS))
+N_PLOTS = 2
+#N_PLOTS = 0
+#sample_channels = sorted(rand_sample(range(48), N_PLOTS))
+sample_channels = (0, 2)
+N_COLS = 4
+#N_COLS = 0
+nrun = 0
+for infile in infiles:
+#for infile in sorted(glob('*.npz')):
+#for infile in sorted(glob('2012-09-03_1*.npz')):
+    d = np.load(infile)
+
+    #print infile, d.keys()
+
+    guesses = d['guesses']
+    results = d['results']
+    nevals = d['nevals']
+
+    d.close() # close file descriptor
+
+    if nrun in sample_runs:
+        for i,k in enumerate(sample_channels):
+            g = guesses[:, 0, k]
+            r = 1e3*(2.5/2/2**13)*results[:, 0, k]
+
+            if 0:
+                subplot(N_PLOTS, N_COLS, N_COLS*i+1)
+                plot(g[:nevals[0,k]+1], '-')
+                ylim((0, 127))
+                ylabel('Channel %02i-A' % k)
+
+                subplot(N_PLOTS, N_COLS, N_COLS*i+2)
+                plot(r[:nevals[0,k]+1], '-')
+
+                subplot(N_PLOTS, N_COLS, N_COLS*i+3)
+                data = cv[:, 0, k]
+                hist(data, bins=range(128), align='left')
+                xlim((data.min()-1, data.max()+1))
+                xlim((0, 127))
+
+                subplot(N_PLOTS, N_COLS, N_COLS*i+4)
+                data = 1e3*(2.5/2/2**13)*co[:, 0, k]
+                dm = max((abs(data.min()), abs(data.max())))
+                print dm
+                dm = max(dm, 50)
+                hist(data, bins=100, range=(-dm, dm), align='left')
+                xlim((-dm, dm))
+                #ylim((0, 50))
+
+
+    cal_values.append(guesses[-1, :, :])
+
+    # results are zeros after [nevals:]
+    # pick off the last real measurement
+    r = zeros_like(results[-1, :, :])
+    for i in range(r.shape[0]):
+        for j in range(r.shape[1]):
+            r[i, j] = results[nevals[i,j]-1, i, j]
+    cal_outs.append(r)
+
+    map(cal_nevals.append, nevals.flat)
+
+    #cal_outs.append(results[-1, :, :])
+    nrun += 1
+
+cv = array(cal_values)
+co = array(cal_outs)
+
+
+
+
+if 1:
+    figure(figsize=(6.0, 3.5))
+    subplots_adjust(top=0.93, bottom=0.12, left=0.10, right=0.98)
+
+    for i,k in enumerate(sample_channels):
+        g = guesses[:, 0, k]
+        r = 1e3*(2.5/2/2**13)*results[:, 0, k]
+
+        subplot(N_PLOTS, N_COLS, N_COLS*i+1)
+        plot(g[:nevals[0,k]+1], '.-')
+        ylim((0, 127))
+        ylabel('Channel %02i-A' % k)
+        xlim((-1, 13))
+
+        subplot(N_PLOTS, N_COLS, N_COLS*i+2)
+        plot(1e-3*r[:nevals[0,k]+1], '.-')
+        hlines(0, -1, 15, linewidth=0.5, color='0.40')
+        xlim((-1, 13))
+
+        subplot(N_PLOTS, N_COLS, N_COLS*i+3)
+        data = cv[:, 0, k]
+        hist(data, bins=range(128), align='left')
+        xlim((data.min()-1, data.max()+1))
+        xlim((0, 128))
+
+        ax = subplot(N_PLOTS, N_COLS, N_COLS*i+4)
+        data = 1e3*(2.5/2/2**13)*co[:, 0, k]
+        dm = max((abs(data.min()), abs(data.max())))
+        print dm
+        dm = max(dm, 50)
+        hist(data, bins=100, range=(-dm, dm), align='left')
+        xlim((-dm, dm))
+        ylim((0, 15))
+        dmean = data.mean()
+        dstd = data.std()
+        print nrun, dmean, dstd
+
+        text(0.97, 0.95, r'$\sigma\!=\!%4.1f$mV' % dstd,
+                horizontalalignment='right',
+                verticalalignment='top',
+                bbox=dict(facecolor='r', alpha=0.5, boxstyle="round"),
+                transform = ax.transAxes)
+
+    subplot(N_PLOTS, N_COLS, 1)
+    ax = plt.gca()
+    title('Offset code', fontsize='medium')
+    ax.set_xticks(range(0, 15, 4))
+
+    subplot(N_PLOTS, N_COLS, (N_PLOTS-1)*N_COLS+1)
+    ax = plt.gca()
+    ax.set_xticks(range(0, 15, 4))
+    xlabel('Step')
+
+
+    subplot(N_PLOTS, N_COLS, 2)
+    ax = plt.gca()
+    title('$V_{out}$', fontsize='medium')
+    ax.set_xticks(range(0, 15, 4))
+    ax.set_yticklabels([''] * len(ax.get_yticks()))
+
+    subplot(N_PLOTS, N_COLS, (N_PLOTS-1)*N_COLS+2)
+    ax = plt.gca()
+    ax.set_xticks(range(0, 15, 4))
+    ax.set_yticklabels([''] * len(ax.get_yticks()))
+    xlabel('Step')
+
+
+    subplot(N_PLOTS, N_COLS, 3)
+    ax = plt.gca()
+    title('Code hist.', fontsize='medium')
+    ax.set_xticks(range(0, 129, 64))
+    ax.set_xticklabels([''] * len(ax.get_xticks()))
+    ax.set_yticklabels([''] * len(ax.get_yticks()))
+
+    subplot(N_PLOTS, N_COLS, (N_PLOTS-1)*N_COLS+3)
+    ax = plt.gca()
+    ax.set_xticks(range(0, 129, 64))
+    #ax.set_xticklabels([''] * len(ax.get_xticks()))
+    ax.set_yticklabels([''] * len(ax.get_yticks()))
+    xlabel('OTA tuning DAC')
+
+
+    subplot(N_PLOTS, N_COLS, 4)
+    ax = plt.gca()
+    ax.set_xticks(range(-80, 81, 40))
+    ax.set_xticklabels([''] * len(ax.get_xticks()))
+    ax.set_yticklabels([''] * len(ax.get_yticks()))
+    title('$V_{out}$ hist.', fontsize='medium')
+
+    subplot(N_PLOTS, N_COLS, (N_PLOTS-1)*N_COLS+4)
+    ax = plt.gca()
+    ax.set_xticks(range(-80, 81, 40))
+    #ax.set_xticklabels([''] * len(ax.get_xticks()))
+    ax.set_yticklabels([''] * len(ax.get_yticks()))
+    xlabel('V_{oos}$ (mV)')
+
+    #suptitle('Calibration data from %s\nNruns = %i' %
+            #(os.path.basename(os.getcwd()),
+                #len(infiles)))
+
+    savefig(os.path.basename(os.getcwd()) + '-cal-raw.pdf')
+
+#interactive(False)
+interactive(True)
+
+if 0:
+    figure()
+    data = cv.flatten()
+    hist(data, bins=range(128), align='left')
+    xlabel('OTA tuning DAC value')
+    title('Channel offset tuning histogram\n48x2 channels x %i runs' %
+            (len(infiles),))
+    savefig('caldac-hist.pdf')
+
+
+    figure()
+    data = co.flatten()
+    hist(data, bins=range(-1500, 1500, 10), align='left')
+    xlabel('Tuned channel output offset voltage (mV)')
+    title('Channel offset tuning histogram\n48x2 channels x %i runs' %
+            (len(infiles),))
+    savefig('calout-hist.pdf')
+
+print sample_runs
+print [infiles[s] for s in sample_runs]
+
diff --git a/python-lib/test-data/chip02/matplotlibrc b/python-lib/test-data/chip02/matplotlibrc
new file mode 120000 (symlink)
index 0000000..3ed05f3
--- /dev/null
@@ -0,0 +1 @@
+../chip14/arb0/vios-offset-gm/matplotlibrc
\ No newline at end of file