1 ''' 2 Plot C bit reversal data from file. 3 John Bryan 2018 4 ''' 5 6 import numpy as np 7 import matplotlib.pyplot as plt 8 import warnings 9 np.set_printoptions(threshold = np.nan, precision = 3, suppress = 1) 10 warnings.filterwarnings("ignore") 11 12 13 def plot(): 14 ''' 15 Plots bit reversal performance times. 16 ''' 17 number = 9 18 data = np.loadtxt('file2.txt', usecols = range(0, 2)) 19 datamatrix = np.array(data) 20 lengths = np.zeros(number, dtype = int) 21 yulohmiller = np.zeros(number, dtype = float) 22 bracewellbuneman = np.zeros(number, dtype = float) 23 for numvar in range (0, number, 1): 24 lengths[numvar] = datamatrix[numvar][0] 25 yulohmiller[numvar] = datamatrix[numvar][1]/1000 26 for numvar in range (0, number, 1): 27 index = int(number+numvar) 28 bracewellbuneman[numvar] = datamatrix[index][1]/1000 29 plt.figure(figsize = (7, 5)) 30 plt.rc("font", size = 9) 31 plt.loglog(lengths, yulohmiller, 'D', markeredgecolor = 'blue', \ 32 basex = 2, basey = 10, label = 'Yu-Loh-Miller') 33 plt.loglog(lengths, bracewellbuneman, 's', markeredgecolor = 'black', \ 34 basex = 2, basey = 10, label = 'Bracewell-Buneman') 35 plt.legend(loc = 2) 36 plt.grid() 37 plt.xlim([25, 9200]) 38 plt.ylabel("time (microseconds)") 39 plt.xlabel("length") 40 plt.title("Bit Reversal Performance Comparison in C") 41 axvar = plt.gca() 42 plt.rcParams['axes.facecolor'] = '0.7' 43 plt.rcParams['axes.edgecolor'] = '0.7' 44 axvar.set_axis_bgcolor('0.7') 45 axvar.patch.set_facecolor('0.7') 46 axvar.patch.set_edgecolor('0.7') 47 plt.savefig('br2.png', facecolor = '0.7') 48 plt.show() 49 return None 50 51 52 plot()