In [1]:
# reads a file generated by a central run to calculate split times more accurately
import numpy as np
import StringIO
import matplotlib.pyplot as plt
import pylab as P
minIndex = 5
maxIndex = 100
In [2]:
prefix = 'singleplants/scalability_'
column = 'runtimePerStepCentral'
plt.ioff()
averageRuntimes = []
for i in range(minIndex, maxIndex+1):
fileName = prefix+str(i)+'.csv'
data = np.genfromtxt(fileName,dtype=float, delimiter=';', skip_header=0,names=True)
runtimeCentral = data[column]
meanTime = np.mean(runtimeCentral)
stdTime = np.std(runtimeCentral)
averageRuntimes += [(i, meanTime, stdTime)]
mu = meanTime
sigma = stdTime
n, bins, patches = P.hist(runtimeCentral, 50, normed=1, histtype='bar')
P.setp(patches, 'facecolor', 'g', 'alpha', 0.75)
# add a line showing the expected distribution
y = P.normpdf( bins, mu, sigma)
l = P.plot(bins, y, 'k--', linewidth=1.5)
xlabel('Runtime (secs)')
ylabel('Rel frequency')
title(str(i) + ' power plants')
savefig('singleplants/plants_'+str(i)+'.pdf')
plt.figure()
plt.ion()
plt.figure()
averageRuntimes = np.array(averageRuntimes)
#plot(averageRuntimes[:,0],averageRuntimes[:,1], 'rx-')
plt.errorbar(averageRuntimes[:,0], averageRuntimes[:,1], averageRuntimes[:,2])
xlabel('# plants')
ylabel('runtime (secs)')
title('Mean runtimes per #plants')
fig = matplotlib.pyplot.gcf()
fig.set_size_inches(18.5,10.5)
savefig('singleplants/meantimes.pdf')
In [3]:
fileName = prefix+'5.csv'
data = np.genfromtxt(fileName,dtype=float, delimiter=';', skip_header=0,names=True)
runtimeCentral = data[column]
mu = np.mean(runtimeCentral)
sigma = np.mean(runtimeCentral)
n, bins, patches = P.hist(runtimeCentral, 50, normed=1, histtype='bar')
P.setp(patches, 'facecolor', 'g', 'alpha', 0.75)
# add a line showing the expected distribution
y = P.normpdf( bins, mu, sigma)
l = P.plot(bins, y, 'k--', linewidth=1.5)
xlabel('Runtime (secs)')
ylabel('Rel frequency')
title(str(5) + ' power plants')
savefig('fivePlants.pdf')
In [4]:
prefix = 'singleplants/scalability_'
column = 'runtimePerStepCentral'
plt.ioff()
averageRuntimes = []
for i in range(minIndex, maxIndex+1):
fileName = prefix+str(i)+'.csv'
data = np.genfromtxt(fileName,dtype=float, delimiter=';', skip_header=0,names=True)
runtimeCentral = data[column]
meanTime = np.mean(runtimeCentral)
stdTime = np.std(runtimeCentral)
averageRuntimes += [(i, meanTime, stdTime)]
plt.ion()
plt.figure()
averageRuntimes = np.array(averageRuntimes)
plot(averageRuntimes[:,0],averageRuntimes[:,1], 'rx-')
#plt.errorbar(averageRuntimes[:,0], averageRuntimes[:,1], averageRuntimes[:,2])
xlabel('# plants')
ylabel('runtime (secs)')
title('Mean runtimes per #plants')
fig = matplotlib.pyplot.gcf()
fig.set_size_inches(18.5,10.5)
savefig('singleplants/meantimes-nosigma.pdf')
In [5]:
from pylab import *
# fake up some data
spread= rand(50) * 100
center = ones(25) * 50
flier_high = rand(10) * 100 + 100
flier_low = rand(10) * -100
data =concatenate((spread, center, flier_high, flier_low), 0)
# fake up some more data
spread= rand(50) * 100
center = ones(25) * 40
flier_high = rand(10) * 100 + 100
flier_low = rand(10) * -100
d2 = concatenate( (spread, center, flier_high, flier_low), 0 )
data.shape = (-1, 1)
d2.shape = (-1, 1)
data = [data, d2, d2[::2,0]]
boxplot(data)
Out[5]:
In [4]:
from pylab import arange,pi,sin,cos,sqrt
fig_width_pt = 400 # Get this from LaTeX using \showthe\columnwidth
inches_per_pt = 1.0/72.27 # Convert pt to inch
golden_mean = (sqrt(5)-1.0)/2.0 # Aesthetic ratio
fig_width = fig_width_pt*inches_per_pt # width in inches
fig_height = fig_width*golden_mean # height in inches
fig_size = [fig_width,fig_height]
params = {'backend': 'ps',
'axes.labelsize': 12,
'text.fontsize': 12,
'legend.fontsize': 12,
'xtick.labelsize': 10,
'ytick.labelsize': 10,
'text.usetex': True,
'figure.figsize': fig_size}
pylab.rcParams.update(params)
In [5]:
prefix = 'singleplants/scalability_'
column = 'runtimePerStepCentral'
plt.ioff()
averageRuntimes = []
overallData = []
xlabels = []
for i in xrange(minIndex, maxIndex+1, 5):
fileName = prefix+str(i) + '.csv'
data = np.genfromtxt(fileName,dtype=float, delimiter=';', skip_header=0,names=True)
runtimeCentral = data[column]
runtimeCentralFiltered = runtimeCentral[runtimeCentral<5]
overallData += [runtimeCentralFiltered]
print i
xlabels += [i]
#averageRuntimes = np.array(averageRuntimes)
#plot(averageRuntimes[:,0],averageRuntimes[:,1], 'rx-')
#plt.errorbar(averageRuntimes[:,0], averageRuntimes[:,1], averageRuntimes[:,2])
fig, ax = plt.subplots()
boxplot(overallData)
xlabel('\# plants')
#xticks(np.arange(minIndex, maxIndex+1))
#xticks(xlabels)
ax.set_xticklabels(xlabels)
ylabel('runtime per step (secs)')
#title('Mean runtimes per step for \#plants')
fig = matplotlib.pyplot.gcf()
#fig.set_size_inches(18.5,10.5)
savefig('singleplants/box-plot-times.pdf')
In [9]: