From: Dan White Date: Mon, 3 Sep 2012 23:48:31 +0000 (-0500) Subject: Speedup calibration, run some more X-Git-Tag: calibrations~9 X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=da7c6e64ad363e54f5f5ccd79a91df99e0cd22d9;p=430.git Speedup calibration, run some more --- diff --git a/python-lib/calibrate.py b/python-lib/calibrate.py index 7dd6631..cb4397f 100644 --- a/python-lib/calibrate.py +++ b/python-lib/calibrate.py @@ -54,7 +54,7 @@ def bisect(fset, limits=[0.0, 1.0], dgmin=None, up='uk', down='dj'): -def secant_opt(func, x0, limits, x1scale=0.1, maxiter=100, k=1.0): +def secant_opt(func, x0, limits, x1scale=0.1, maxiter=50, k=1.0): """ Find the function's zero on a bounded interval using the secant method. @@ -81,19 +81,19 @@ def secant_opt(func, x0, limits, x1scale=0.1, maxiter=100, k=1.0): return int64(around(x)) #return int(round(max(min(x, xmax), xmin))) - def eval(x): - print 'eval:' - print x[0:N_CHANNELS] + def feval(x): + #print 'feval:' + #print x[0:N_CHANNELS] r = func(x) guesses.append(x) results.append(r) return r - q0 = eval(p0) + q0 = feval(p0) r = xmax - xmin p1 = saturate(p0 - sign(q0)*x1scale*r) - q1 = eval(p1) + q1 = feval(p1) for niter in range(maxiter): iz = find(q1==q0) q1.flat[iz] = q1.flat[iz] + 1e-6 @@ -113,7 +113,7 @@ def secant_opt(func, x0, limits, x1scale=0.1, maxiter=100, k=1.0): dp *= converging p = saturate(p1 - dp) - q = eval(p) + q = feval(p) # Convergence criteria # x to varies by (+1,-1) or (-1,+1) @@ -162,7 +162,7 @@ def mux_a_offset(x): values = [] for i in range(N_SAMPLES): values.append(offset2signed(adc.read(), 16)) - sleep(DELAY) + sleep(SAMPLE_DELAY) mv = mean(values) print tpx(xi), tplot(mv) return array((mv,)) @@ -175,7 +175,7 @@ def mux_b_offset(x): values = [] for i in range(N_SAMPLES): values.append(offset2signed(adc.read(), 16)) - sleep(DELAY) + sleep(SAMPLE_DELAY) mv = mean(values) print tpx(xi), tplot(mv) return array((mv,)) @@ -204,6 +204,7 @@ def chain_outputs(n): adc.triggerMode(adc.MODE_IDLE) adc.mux(4) #mux.otaA adc.fifo(1) + adc.triggerMode(adc.MODE_MANUAL_MANUAL) plotter = TermPlotter([-1000, 1000], width=80) @@ -213,26 +214,36 @@ def chain_outputs(n): mux.selB = i mux.write() + sleep(MUX_SETTLE_DELAY) for j in range(2): adc.mux(4+j) - sleep(0.1) - adc.triggerMode(adc.MODE_MANUAL_MANUAL) + #sleep(0.1) + #adc.triggerMode(adc.MODE_MANUAL_MANUAL) #adc.triggerMode(adc.MODE_AUTO_AUTO_SINGLE) adc.read() values = [] #print - for k in range(N_SAMPLES): + v = offset2signed(adc.read(), 16) + values.append(v) + for k in range(N_SAMPLES-1): + sleep(SAMPLE_DELAY) v = offset2signed(adc.read(), 16) #print plotter(v) values.append(v) - sleep(DELAY) - mv = mean(values[-1*min(10, N_SAMPLES):-1]) + if N_SAMPLES >= 2: + mv = mean(values[-1*min(10, N_SAMPLES):-1]) + else: + mv = values[0] outs[j, i] = mv + print '*** measured outputs: ***' print outs[:,0:N_CHANNELS] return outs def chain_offsets(values, mux_offset): + print + print '*** sending values: ***' + print values[0:N_CHANNELS] for i,n in enumerate(values[0]): chain.h[i].otaA.offset = int(n) chain.h[i].cal = 1 @@ -276,8 +287,10 @@ adc.triggerMode(adc.MODE_MANUAL_MANUAL) N_CHANNELS = 48 -N_SAMPLES = 10 -DELAY = 0.05 +MUX_SETTLE_DELAY = 0.1 +N_SAMPLES = 1 +SAMPLE_DELAY = 0.02 + import datetime as dt diff --git a/python-lib/test-data/chip02/2012-09-03_170725.npz b/python-lib/test-data/chip02/2012-09-03_170725.npz new file mode 100644 index 0000000..3bb25c5 Binary files /dev/null and b/python-lib/test-data/chip02/2012-09-03_170725.npz differ diff --git a/python-lib/test-data/chip02/2012-09-03_170912.npz b/python-lib/test-data/chip02/2012-09-03_170912.npz new file mode 100644 index 0000000..bb188ad Binary files /dev/null and b/python-lib/test-data/chip02/2012-09-03_170912.npz differ diff --git a/python-lib/test-data/chip02/2012-09-03_171055.npz b/python-lib/test-data/chip02/2012-09-03_171055.npz new file mode 100644 index 0000000..c8ffa45 Binary files /dev/null and b/python-lib/test-data/chip02/2012-09-03_171055.npz differ diff --git a/python-lib/test-data/chip02/2012-09-03_171250.npz b/python-lib/test-data/chip02/2012-09-03_171250.npz new file mode 100644 index 0000000..6b62342 Binary files /dev/null and b/python-lib/test-data/chip02/2012-09-03_171250.npz differ diff --git a/python-lib/test-data/chip02/2012-09-03_171450.npz b/python-lib/test-data/chip02/2012-09-03_171450.npz new file mode 100644 index 0000000..16514bd Binary files /dev/null and b/python-lib/test-data/chip02/2012-09-03_171450.npz differ diff --git a/python-lib/test-data/chip02/2012-09-03_171700.npz b/python-lib/test-data/chip02/2012-09-03_171700.npz new file mode 100644 index 0000000..f0a0a1c Binary files /dev/null and b/python-lib/test-data/chip02/2012-09-03_171700.npz differ diff --git a/python-lib/test-data/chip02/2012-09-03_171921.npz b/python-lib/test-data/chip02/2012-09-03_171921.npz new file mode 100644 index 0000000..a470e5f Binary files /dev/null and b/python-lib/test-data/chip02/2012-09-03_171921.npz differ diff --git a/python-lib/test-data/chip02/2012-09-03_172151.npz b/python-lib/test-data/chip02/2012-09-03_172151.npz new file mode 100644 index 0000000..21cd3a6 Binary files /dev/null and b/python-lib/test-data/chip02/2012-09-03_172151.npz differ diff --git a/python-lib/test-data/chip02/2012-09-03_172428.npz b/python-lib/test-data/chip02/2012-09-03_172428.npz new file mode 100644 index 0000000..61bc615 Binary files /dev/null and b/python-lib/test-data/chip02/2012-09-03_172428.npz differ diff --git a/python-lib/test-data/chip02/2012-09-03_172630.npz b/python-lib/test-data/chip02/2012-09-03_172630.npz new file mode 100644 index 0000000..214e0fd Binary files /dev/null and b/python-lib/test-data/chip02/2012-09-03_172630.npz differ diff --git a/python-lib/test-data/chip02/2012-09-03_172826.npz b/python-lib/test-data/chip02/2012-09-03_172826.npz new file mode 100644 index 0000000..c47633d Binary files /dev/null and b/python-lib/test-data/chip02/2012-09-03_172826.npz differ diff --git a/python-lib/test-data/chip02/2012-09-03_173105.npz b/python-lib/test-data/chip02/2012-09-03_173105.npz new file mode 100644 index 0000000..b7ab5e4 Binary files /dev/null and b/python-lib/test-data/chip02/2012-09-03_173105.npz differ diff --git a/python-lib/test-data/chip02/2012-09-03_173343.npz b/python-lib/test-data/chip02/2012-09-03_173343.npz new file mode 100644 index 0000000..1806acc Binary files /dev/null and b/python-lib/test-data/chip02/2012-09-03_173343.npz differ diff --git a/python-lib/test-data/chip02/2012-09-03_173559.npz b/python-lib/test-data/chip02/2012-09-03_173559.npz new file mode 100644 index 0000000..bb5d7f1 Binary files /dev/null and b/python-lib/test-data/chip02/2012-09-03_173559.npz differ diff --git a/python-lib/test-data/chip02/2012-09-03_173830.npz b/python-lib/test-data/chip02/2012-09-03_173830.npz new file mode 100644 index 0000000..853333f Binary files /dev/null and b/python-lib/test-data/chip02/2012-09-03_173830.npz differ diff --git a/python-lib/test-data/chip02/2012-09-03_174100.npz b/python-lib/test-data/chip02/2012-09-03_174100.npz new file mode 100644 index 0000000..b1d9bd4 Binary files /dev/null and b/python-lib/test-data/chip02/2012-09-03_174100.npz differ diff --git a/python-lib/test-data/chip02/2012-09-03_174310.npz b/python-lib/test-data/chip02/2012-09-03_174310.npz new file mode 100644 index 0000000..e55d91b Binary files /dev/null and b/python-lib/test-data/chip02/2012-09-03_174310.npz differ diff --git a/python-lib/test-data/chip02/2012-09-03_174657.npz b/python-lib/test-data/chip02/2012-09-03_174657.npz new file mode 100644 index 0000000..7147da0 Binary files /dev/null and b/python-lib/test-data/chip02/2012-09-03_174657.npz differ diff --git a/python-lib/test-data/chip02/2012-09-03_174934.npz b/python-lib/test-data/chip02/2012-09-03_174934.npz new file mode 100644 index 0000000..56ec801 Binary files /dev/null and b/python-lib/test-data/chip02/2012-09-03_174934.npz differ diff --git a/python-lib/test-data/chip02/2012-09-03_175151.npz b/python-lib/test-data/chip02/2012-09-03_175151.npz new file mode 100644 index 0000000..5466117 Binary files /dev/null and b/python-lib/test-data/chip02/2012-09-03_175151.npz differ diff --git a/python-lib/test-data/chip02/2012-09-03_175422.npz b/python-lib/test-data/chip02/2012-09-03_175422.npz new file mode 100644 index 0000000..79b333f Binary files /dev/null and b/python-lib/test-data/chip02/2012-09-03_175422.npz differ diff --git a/python-lib/test-data/chip02/2012-09-03_175714.npz b/python-lib/test-data/chip02/2012-09-03_175714.npz new file mode 100644 index 0000000..fd680bd Binary files /dev/null and b/python-lib/test-data/chip02/2012-09-03_175714.npz differ diff --git a/python-lib/test-data/chip02/2012-09-03_175953.npz b/python-lib/test-data/chip02/2012-09-03_175953.npz new file mode 100644 index 0000000..f9ea6e0 Binary files /dev/null and b/python-lib/test-data/chip02/2012-09-03_175953.npz differ diff --git a/python-lib/test-data/chip02/2012-09-03_180223.npz b/python-lib/test-data/chip02/2012-09-03_180223.npz new file mode 100644 index 0000000..c86c56f Binary files /dev/null and b/python-lib/test-data/chip02/2012-09-03_180223.npz differ diff --git a/python-lib/test-data/chip02/2012-09-03_180405.npz b/python-lib/test-data/chip02/2012-09-03_180405.npz new file mode 100644 index 0000000..01510e8 Binary files /dev/null and b/python-lib/test-data/chip02/2012-09-03_180405.npz differ diff --git a/python-lib/test-data/chip02/2012-09-03_180629.npz b/python-lib/test-data/chip02/2012-09-03_180629.npz new file mode 100644 index 0000000..a339808 Binary files /dev/null and b/python-lib/test-data/chip02/2012-09-03_180629.npz differ diff --git a/python-lib/test-data/chip02/2012-09-03_180811.npz b/python-lib/test-data/chip02/2012-09-03_180811.npz new file mode 100644 index 0000000..91cbe5e Binary files /dev/null and b/python-lib/test-data/chip02/2012-09-03_180811.npz differ diff --git a/python-lib/test-data/chip02/2012-09-03_180959.npz b/python-lib/test-data/chip02/2012-09-03_180959.npz new file mode 100644 index 0000000..c3fc6db Binary files /dev/null and b/python-lib/test-data/chip02/2012-09-03_180959.npz differ diff --git a/python-lib/test-data/chip02/2012-09-03_181142.npz b/python-lib/test-data/chip02/2012-09-03_181142.npz new file mode 100644 index 0000000..d741fcf Binary files /dev/null and b/python-lib/test-data/chip02/2012-09-03_181142.npz differ diff --git a/python-lib/test-data/chip02/2012-09-03_181351.npz b/python-lib/test-data/chip02/2012-09-03_181351.npz new file mode 100644 index 0000000..8e3bcf6 Binary files /dev/null and b/python-lib/test-data/chip02/2012-09-03_181351.npz differ diff --git a/python-lib/test-data/chip02/2012-09-03_181643.npz b/python-lib/test-data/chip02/2012-09-03_181643.npz new file mode 100644 index 0000000..40b1a3b Binary files /dev/null and b/python-lib/test-data/chip02/2012-09-03_181643.npz differ diff --git a/python-lib/test-data/chip02/2012-09-03_181915.npz b/python-lib/test-data/chip02/2012-09-03_181915.npz new file mode 100644 index 0000000..4b371e9 Binary files /dev/null and b/python-lib/test-data/chip02/2012-09-03_181915.npz differ diff --git a/python-lib/test-data/chip02/2012-09-03_182104.npz b/python-lib/test-data/chip02/2012-09-03_182104.npz new file mode 100644 index 0000000..4bd38a2 Binary files /dev/null and b/python-lib/test-data/chip02/2012-09-03_182104.npz differ diff --git a/python-lib/test-data/chip02/2012-09-03_182348.npz b/python-lib/test-data/chip02/2012-09-03_182348.npz new file mode 100644 index 0000000..67ee973 Binary files /dev/null and b/python-lib/test-data/chip02/2012-09-03_182348.npz differ diff --git a/python-lib/test-data/chip02/2012-09-03_182543.npz b/python-lib/test-data/chip02/2012-09-03_182543.npz new file mode 100644 index 0000000..1bbe9ac Binary files /dev/null and b/python-lib/test-data/chip02/2012-09-03_182543.npz differ diff --git a/python-lib/test-data/chip02/2012-09-03_182821.npz b/python-lib/test-data/chip02/2012-09-03_182821.npz new file mode 100644 index 0000000..dd52b2a Binary files /dev/null and b/python-lib/test-data/chip02/2012-09-03_182821.npz differ diff --git a/python-lib/test-data/chip02/2012-09-03_183017.npz b/python-lib/test-data/chip02/2012-09-03_183017.npz new file mode 100644 index 0000000..1670d4b Binary files /dev/null and b/python-lib/test-data/chip02/2012-09-03_183017.npz differ diff --git a/python-lib/test-data/chip02/2012-09-03_183234.npz b/python-lib/test-data/chip02/2012-09-03_183234.npz new file mode 100644 index 0000000..0242d85 Binary files /dev/null and b/python-lib/test-data/chip02/2012-09-03_183234.npz differ diff --git a/python-lib/test-data/chip02/2012-09-03_183512.npz b/python-lib/test-data/chip02/2012-09-03_183512.npz new file mode 100644 index 0000000..19c6255 Binary files /dev/null and b/python-lib/test-data/chip02/2012-09-03_183512.npz differ diff --git a/python-lib/test-data/chip02/2012-09-03_183730.npz b/python-lib/test-data/chip02/2012-09-03_183730.npz new file mode 100644 index 0000000..ecdd468 Binary files /dev/null and b/python-lib/test-data/chip02/2012-09-03_183730.npz differ diff --git a/python-lib/test-data/chip02/2012-09-03_184001.npz b/python-lib/test-data/chip02/2012-09-03_184001.npz new file mode 100644 index 0000000..778d48b Binary files /dev/null and b/python-lib/test-data/chip02/2012-09-03_184001.npz differ diff --git a/python-lib/test-data/chip02/2012-09-03_184232.npz b/python-lib/test-data/chip02/2012-09-03_184232.npz new file mode 100644 index 0000000..1fcca68 Binary files /dev/null and b/python-lib/test-data/chip02/2012-09-03_184232.npz differ diff --git a/python-lib/test-data/chip02/2012-09-03_184420.npz b/python-lib/test-data/chip02/2012-09-03_184420.npz new file mode 100644 index 0000000..bfce868 Binary files /dev/null and b/python-lib/test-data/chip02/2012-09-03_184420.npz differ diff --git a/python-lib/test-data/chip02/2012-09-03_184610.npz b/python-lib/test-data/chip02/2012-09-03_184610.npz new file mode 100644 index 0000000..ce66934 Binary files /dev/null and b/python-lib/test-data/chip02/2012-09-03_184610.npz differ diff --git a/python-lib/test-data/chip02/stats.py b/python-lib/test-data/chip02/stats.py index e263e24..873d7b5 100644 --- a/python-lib/test-data/chip02/stats.py +++ b/python-lib/test-data/chip02/stats.py @@ -11,34 +11,35 @@ cal_outs = [] N_RUNS = 8 sample_runs = randint(48, size=(N_RUNS,)) N_PLOTS = 4 +sample_channels = sorted(randint(48, size=(N_PLOTS,))) N_COLS = 4 nrun = 0 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 1: - for i in range(N_PLOTS): + for i,k in enumerate(sample_channels): if nrun not in sample_runs: continue - g = guesses[:, 0, i] - r = 1e3*(2.5/2/2**13)*results[:, 0, i] - #print g - #print r + 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, '-') + plot(g[:nevals[0,k]+1], '-') ylim((0, 127)) - ylabel('Channel %02i-A' % i) + ylabel('Channel %02i-A' % k) subplot(N_PLOTS, N_COLS, N_COLS*i+2) - plot(r, '-') + plot(r[:nevals[0,k]+1], '-') subplot(N_PLOTS, N_COLS, 1) title('calibration value')