From: Dan White Date: Tue, 12 Feb 2013 15:30:04 +0000 (-0600) Subject: add temp testing script X-Git-Tag: bootrom-initial-submission~42 X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=403531fd2e33ea47d5b177bcdc74bfdd40ed481b;p=430.git add temp testing script --- diff --git a/python-lib/test-data/chip01/foo.py b/python-lib/test-data/chip01/foo.py new file mode 100644 index 0000000..7e52b4e --- /dev/null +++ b/python-lib/test-data/chip01/foo.py @@ -0,0 +1,136 @@ +#!/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 = [] + +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 = 4 +N_PLOTS = 0 +#sample_channels = sorted(rand_sample(range(48), N_PLOTS)) +sample_channels = range(N_PLOTS) +#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] + + 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], '-') + + 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 0: + figure() + for i,k in enumerate(sample_channels): + 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)) + + subplot(N_PLOTS, N_COLS, 1) + title('Offset DAC value') + subplot(N_PLOTS, N_COLS, (N_PLOTS-1)*N_COLS+1) + xlabel('Iteration step') + + subplot(N_PLOTS, N_COLS, 2) + title('Vout (mV)') + subplot(N_PLOTS, N_COLS, (N_PLOTS-1)*N_COLS+2) + xlabel('Iteration step') + + subplot(N_PLOTS, N_COLS, 3) + title('Offset DAC histogram') + subplot(N_PLOTS, N_COLS, (N_PLOTS-1)*N_COLS+3) + xlabel('OTA tuning DAC') + + subplot(N_PLOTS, N_COLS, 4) + title('Vout (mV) histogram') + subplot(N_PLOTS, N_COLS, (N_PLOTS-1)*N_COLS+4) + xlabel('Residual Voos (mV)') + + suptitle('Calibration data from %s\nNruns = %i' % + (os.path.basename(os.getcwd()), + len(infiles))) + +interactive(False) + +if 1: + 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] +