1 '''
 2 Python script to plot FHT and FFT C performance data from file
 3 John Bryan
 4 Python 2.7.3
 5 '''
 6 
 7 
 8 import numpy as np
 9 import matplotlib.pyplot as plt
10 import warnings
11 np.set_printoptions(threshold = np.nan, precision = 3, suppress = 1)
12 warnings.filterwarnings("ignore")
13 
14 
15 def plot():
16     '''Reads FHT and FFT performance data from file
17        and plots '''
18     number = 10
19     data = np.loadtxt('file.txt',  usecols = range(0, 2))
20     datamatrix = np.array(data)
21     lengths = np.zeros(number, dtype = int)
22     fft = np.zeros(number, dtype = float)
23     fht = np.zeros(number, dtype = float)
24     for i in range (0, number, 1):
25         lengths[i] = datamatrix[i][0]
26         fft[i] = datamatrix[i][1]/1000.
27     for i in range (0, number, 1):
28         index = int(number+i)
29         fht[i] = datamatrix[index][1]/1000.
30     plt.figure(figsize = (7, 5))
31     plt.rc("font", size = 9)
32     plt.loglog(lengths, fft, 'D', markeredgecolor = 'blue', \
33                basex = 2,  basey = 10,  label = 'FFT')
34     plt.loglog(lengths, fht, 's', markeredgecolor = 'black', \
35                basex = 2,  basey = 10,  label = 'FHT')
36     plt.legend(loc = 2)
37     plt.grid()
38     plt.xlim([10, 10000])
39     plt.ylabel("time (microseconds)")
40     plt.xlabel("sequence length")
41     plt.title("FHT and FFT Performance vs Sequence Length in C")
42     plt.savefig('htvl.png',  bbox_inches = 'tight')
43     plt.show()
44     return None
45 
46 plot()