3 # With analog output 0 cabled directly to analog input 0
4 # output a single period of a 1000kHz sine wave
5 # and perform a linear regression between the output and input data.
6 # If the input is closely correlated to the output (gradient > 0.7)
7 # consider the synchronized input/output a success.
8 # Prints the success rate for num_runs
10 from scipy.stats import linregress
11 from scipy.io import read_array, write_array
13 from numpy import zeros
15 # I had been checking at different waits between AO arming and AI triggering,
16 # thinking that the problem might be due to my patch.
17 # But I get failure rates of ~ 20% regardless of the wait time (-t option)
18 # So currently only use waits of 0 seconds to get more data.
21 #waits = range(5, -1, -1)
25 runs = range(0, num_runs)
26 results = zeros((1, num_runs))
34 call = './simult_aio -n 50 -F 50000 -w 1000 -t%d' % wait
35 if system(call) != 0 :
37 if system('int16s_to_ascii_array out in > data') != 0 :
39 data = read_array('data')
40 gradient, intercept, r_value, p_value, std_err = linregress(data)
41 results[wait,run] = gradient
42 print "wait %2d, run %2d, gradient %g" % (wait, run, gradient)
45 good_run_arr.append(good_run)
50 print "failure rate ", (float(fails)/float(fails+successes))
52 for num in good_run_arr :
54 call += '" | stem_leaf 2'
58 if __name__ == "__main__" :