This notebook imports OD600 data from each of the three ground plates and three space plates and writes plots and tables pertaining to the three space-based contests (Best Huddle, Best Tipoff, Best Sprint). It also writes the plots and tables comparing the growth results of the experiments aboard the Space Station to those conducted at UC Davis.
I regret that, although functional, this some of the worst code I've ever written. I beg forgiveness on the grounds that SpectraMax file format is mind-bendingly stupid. Also, we re-designed the project and switched goals and deadlines frequently as we adapted to launch window delay and conflicting information about the capabilities of the SpectraMax device aboard the International Space Station. I had considered re-writing it now that the project is complete, but in the interests of full disclosure, I decided to preserve it in its original form. This is a citizen science project, and I felt it was more impotant for the public to see how things were actually done. All that I've done is added comments where things are particularly confusing or stupid.
As we discovered the need for various different plots (and versions of plots), I found myself cutting and pasting a lot of this code. This is a terrible practice that ought to be avoided, and led to much of the needless complexity seen here.
I am especially sorry about this line :
for n,bug in enumerate(sorted(spacebugs, key=lambda k: k['sprint'], reverse=True)) :
First, run the first to code cells. The first one loads pylab inline, and the second one parses the raw data from the un-altered data files from the plate readers.
Then, choose the "event" you want to run (huddle, tipoff, print). Run the two cells for the event. If you want to run a different event, I suggeset re-loading the data by re-running the second cell in the notebook.
If you want to run the Space vs. Ground comparison, first load the data, then run one of the events (it shouldn't matter which one), and the run the cells for Space vs. Ground.
In [1]:
%pylab inline
In [1]:
import numpy
import csv
import copy
# Contrary to all reason, when you read multiple points in each well
# with a SpecraMax plate reader, it proceeds as follows :
#
# for each point
# for each row
# for each column
# for each replicate
# read OD600
# average replicates
#
# This maximizes the time it takes to complete a read cycle. It *should*
# read all nine points before moving on to the next well, there's no way
# to make it do that. There's also no way to make it read more than a 3x3
# grid, which is also unfortunate, though given the way it orders these
# operations, it's not surprising. The file format it writes reflects this
# bizarre design choice.
# This is the whitespace that marks the boundary between blocks of reads
stupid_delimeter = '\t\t\n\t\t\n'
stop_at = 273 # in case the run was not completed, stop here
#stupid_delimeter = '\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\n'
# import species metadata and plate map
spacebugs = []
with open('spacebugsnames_2.txt', 'rb') as csvfile :
csvreader = csv.reader(csvfile, delimiter='\t', quotechar='|')
for row in csvreader:
spacebugs.append( { 'source' : row[1],
'species' : row[2],
'name' : row[3],
'longname' : row[4],
'alive' : False,
'alpha' : 0,
'N0' : 0,
'Hsat' : 0,
'huddle' : 0,
'huddle_d' : '',
'tipoff' : 0,
'tipoff_d' : '',
'sprint' : 0,
'sprint_d' : '',
'data_1_1' : [],
'data_1_2' : [],
'data_2_1' : [],
'data_2_2' : [],
'data_3_1' : [],
'data_3_2' : [] } )
groundbugs = copy.deepcopy(spacebugs)
for experiment,venue in zip( ( spacebugs, groundbugs ), ( 'space', 'ground' ) ) :
for plateN in range(1,4) :
# import plate data
if venue == 'space' :
expN, mapdesig, datafileprefix = 'S', 'space', 'Space'
name = 'Space Plate ' + str(plateN)
prefix = 'Spaceplate3_timeseries'
if venue == 'ground' :
expN, mapdesig, datafileprefix = 'G', 'ground', 'Ground'
name = 'Ground Plate ' + str(plateN)
prefix = 'Groundplate3_timeseries'
files = [ ( 0, datafileprefix + 'plate' + str(plateN) + '_0.txt'),
( 24, datafileprefix + 'plate' + str(plateN) + '_24.txt'),
( 48, datafileprefix + 'plate' + str(plateN) + '_48.txt'),
( 72, datafileprefix + 'plate' + str(plateN) + '_72.txt'),
( 96, datafileprefix + 'plate' + str(plateN) + '_96.txt') ]
platemap = numpy.zeros((8,12),dtype=numpy.int)
with open('platemap_' + mapdesig + str(plateN) + '.csv', 'rb') as csvfile :
csvreader = csv.reader(csvfile, delimiter=',', quotechar='|')
for i,row in enumerate(csvreader) :
for j,n in enumerate(map(int,row)) :
platemap[i,j] = n
data = []
for TT,file in files :
blob = open( file ).read()
# different versions of the plate reader software put End tokens in different places.
# Sad panda is sad.
if venue == 'space' :
block = blob.split('End')[0]
if venue == 'ground' :
block = blob.split('End')[1]
ttimes = []
ttemps = []
frames = []
for tn,tpoint in enumerate(block.split(stupid_delimeter)[:stop_at]) :
if tn == 0 : # skip header stuff
tpoint = tpoint.split('12\t\t\n')[1]
if tn == 9 : break # stop after nine frames
frame = numpy.zeros((8,12))
for rn,row in enumerate(tpoint.split('\n')) :
for cn,col in enumerate(row.split('\t')) :
if rn != 0 and cn == 0 : continue
if rn != 0 and cn == 1 : continue
if cn == 14 : continue
if cn == 15 : continue
if rn == 0 and cn == 0 : ttimes.append(col); continue
if rn == 0 and cn == 1 : ttemps.append(col); continue
#print tn,rn,cn-2,col
frame[rn,cn-2] = float(col)
frames.append(frame)
frames = numpy.array(frames)
times = numpy.arange( 0, len(frames) / 96.0, 1/96.0 ) # not actual times here...
data.append(frames)
for TT,run in enumerate(data) :
for i in range(8) :
for j in range(12) :
n = platemap[i,j]-1
if i < 4 : replicate = 1
else : replicate = 2
experiment[n]['data_' + str(plateN) + '_' + str(replicate)].append( list(run[:,i,j]) )
In [2]:
from scipy import optimize
from numpy import median,array,exp,log,e
def N(n,a,x) :
return n*(1-exp(-a*x))
def residuals( p, y, x ) :
n, a = p
err = y - N(n,a,x)
return err
def Neval(x) :
return N(N0,a,x)
datasetnames = [ 'data_1_1', 'data_1_2', 'data_2_1', 'data_2_2', 'data_3_1', 'data_3_2' ]
# for each bug, choose their biggest increase in OD among the six trials
# as their 'huddle' score
for experiment in ( spacebugs, groundbugs ) :
for bug in experiment :
for name in datasetnames :
medians = map( median, bug[name] )
huddle = max(medians) - min(medians) # <- this line computes the actual 'huddle' values
# least squares fit to exponential saturation model
N0, a = optimize.leastsq(residuals, [1,0.5], args=(array(medians),array([1,2,3,4,5])))[0]
Hsat = -log(e**(-a)/2.0)/a
# mark bug as alive or dead
if Hsat > 1.6 and a < 1.5 :
alive = True
else :
alive = False
if bug['huddle'] < huddle and alive :
bug['N0'], bug['alpha'], bug['Hsat'] = N0, a, Hsat
bug['huddle'] = huddle
bug['huddle_d'] = name
bug['alive'] = True
# print the huddle rankings
f = open('BestHuddleRankings.tsv','w')
f.write('\t'.join( ( 'ranking', 'long name', 'sample name', 'gain in OD (space)', 'gain in OD (ground)', 'alive\n') ) )
for n,bug in enumerate(sorted(spacebugs, key=lambda k: k['huddle'], reverse=True)) :
groundbug = groundbugs[map( lambda k: k['name'], groundbugs ).index(bug['name'])]
f.write( '\t'.join( ( str(n+1), bug['longname'], bug['name'], str(bug['huddle']), str(groundbug['huddle']), str(bug['alive']) ) ) + '\n' )
print str(n+1), bug['name'], str(bug['huddle']), str(groundbug['huddle']), bug['alive']
f.close()
# plot the top players
fig, ax = pylab.subplots( 4, 12, figsize=(16,5))
fig.suptitle( 'Best Huddle', fontsize=18, x=0.05,y=1.05 )
for n,bug in enumerate(sorted(spacebugs, key=lambda k: k['huddle'], reverse=True)) :
groundbug = groundbugs[map( lambda k: k['name'], groundbugs ).index(bug['name'])]
pylab.subplot(4,12,n+1)
ylim((0,2.5))
yticks( linspace( 0.5, 2.0, 3 ) )
if bug['alive'] :
title(bug['name'])
boxplot(bug[bug['huddle_d']])
plot([1,2,3,4,5],map(median,bug[bug['huddle_d']]), color='green')
plot([1,2,3,4,5],map(median,groundbug[groundbug['huddle_d']]), color='brown')
N0, a = bug['N0'], bug['alpha']
plot(linspace(1,5),Neval(linspace(1,5)),'red')
else :
title(bug['name'], alpha=0.2)
boxplot(bug['data_1_1'])
plot([1,2,3,4,5],map(median,bug['data_1_1']), color='green')
fig.tight_layout()
savefig( 'BestHuddle.png', format='png', dpi=100 )
savefig( 'BestHuddle.pdf', format='pdf', dpi=100 )
In [16]:
# plot the top players
fig, ax = plt.subplots( 4, 12, figsize=(8,2.5))
#fig.suptitle( 'Best Huddle', fontsize=18, x=0.05,y=1.05 )
for n,bug in enumerate(sorted(spacebugs, key=lambda k: k['huddle'], reverse=True)[:3]) :
subplot(1,3,n+1)
ylim((0,2.5))
yticks( linspace( 0.5, 2.0, 3 ) )
if bug['alive'] :
title(bug['longname'] + '\n' + bug['species'])
boxplot(bug[bug['huddle_d']])
plot([1,2,3,4,5],map(median,bug[bug['huddle_d']]), color='green')
N0, a = bug['N0'], bug['alpha']
plot(linspace(1,5),Neval(linspace(1,5)),'red')
else :
title(bug['longname'], alpha=0.2)
boxplot(bug['data_1_1'])
plot([1,2,3,4,5],map(median,bug['data_1_1']), color='green')
fig.tight_layout()
savefig( 'BestHuddle_top3.png', format='png', dpi=100 )
savefig( 'BestHuddle_top3.pdf', format='pdf', dpi=100 )
In [17]:
from scipy import optimize
def N(n,a,x) :
return n*(1-exp(-a*x))
def residuals( p, y, x ) :
n, a = p
err = y - N(n,a,x)
return err
def Neval(x) :
return N(N0,a,x)
datasetnames = [ 'data_1_1', 'data_1_2', 'data_2_1', 'data_2_2', 'data_3_1', 'data_3_2' ]
# for each bug, choose their biggest first-day increase in OD among the six trials
# as their 'tipoff' score
for experiment in ( spacebugs, groundbugs ) :
for bug in experiment :
for name in datasetnames :
medians = map( median, bug[name] )
tipoff = medians[1] - medians[0] # <- this line computes the actual 'tipoff' values
# least squares fit to exponential saturation model
N0, a = optimize.leastsq(residuals, [1,0.5], args=(array(medians),array([1,2,3,4,5])))[0]
Hsat = -log(e**(-a)/2.0)/a
# mark bug as alive or dead
if Hsat > 1.6 and a < 1.5 :
alive = True
else :
alive = False
if bug['tipoff'] < tipoff and alive :
bug['N0'], bug['alpha'], bug['Hsat'] = N0, a, Hsat
bug['tipoff'] = tipoff
bug['tipoff_d'] = name
bug['alive'] = True
# print the tipoff rankings
f = open('BestTipoffRankings.tsv','w')
f.write('\t'.join( ( 'ranking', 'long name', 'sample name', 'gain in OD (space)', 'gain in OD (ground)', 'alive\n') ) )
for n,bug in enumerate(sorted(spacebugs, key=lambda k: k['tipoff'], reverse=True)) :
groundbug = groundbugs[map( lambda k: k['name'], groundbugs ).index(bug['name'])]
f.write( '\t'.join( ( str(n+1), bug['longname'], bug['name'], str(bug['tipoff']), str(groundbug['tipoff']), str(bug['alive']) ) ) + '\n' )
print str(n+1), bug['name'], str(bug['tipoff']), str(groundbug['tipoff']), bug['alive']
f.close()
# plot the top players
fig, ax = plt.subplots( 4, 12, figsize=(16,5))
fig.suptitle( 'Best Tipoff', fontsize=18, x=0.05,y=1.05 )
for n,bug in enumerate(sorted(spacebugs, key=lambda k: k['tipoff'], reverse=True)) :
groundbug = groundbugs[map( lambda k: k['name'], groundbugs ).index(bug['name'])]
subplot(4,12,n+1)
ylim((0,2.5))
yticks( linspace( 0.5, 2.0, 3 ) )
if bug['alive'] :
title(bug['name'])
boxplot(bug[bug['tipoff_d']])
plot([1,2,3,4,5],map(median,bug[bug['tipoff_d']]), color='green')
plot([1,2,3,4,5],map(median,groundbug[groundbug['tipoff_d']]), color='brown')
N0, a = bug['N0'], bug['alpha']
plot(linspace(1,5),Neval(linspace(1,5)),'red')
else :
title(bug['name'], alpha=0.2)
boxplot(bug['data_1_1'])
plot([1,2,3,4,5],map(median,bug['data_1_1']), color='green')
fig.tight_layout()
savefig( 'BestTipoff.png', format='png', dpi=100 )
savefig( 'BestTipoff.pdf', format='pdf', dpi=100 )
In [18]:
# plot the top players
fig, ax = plt.subplots( 4, 12, figsize=(8,2.5))
#fig.suptitle( 'Best Tipoff', fontsize=18, x=0.05,y=1.05 )
for n,bug in enumerate(sorted(spacebugs, key=lambda k: k['tipoff'], reverse=True)[:3]) :
subplot(1,3,n+1)
ylim((0,2.5))
yticks( linspace( 0.5, 2.0, 3 ) )
#fulltitle = r'' + bug['longname'].replace('&','\&') + '\n {\em ' + bug['species'] + '}'
if bug['alive'] :
title(bug['longname'] + '\n' + bug['species'])
boxplot(bug[bug['tipoff_d']])
plot([1,2,3,4,5],map(median,bug[bug['tipoff_d']]), color='green')
N0, a = bug['N0'], bug['alpha']
plot(linspace(1,5),Neval(linspace(1,5)),'red')
else :
title(fulltitle, alpha=0.2)
boxplot(bug['data_1_1'])
plot([1,2,3,4,5],map(median,bug['data_1_1']), color='green')
fig.tight_layout()
savefig( 'BestTipoff_top3.png', format='png', dpi=100 )
savefig( 'BestTipoff_top3.pdf', format='pdf', dpi=100 )
In [3]:
from scipy import optimize
def N(n,a,x) :
return n*(1-exp(-a*x))
def residuals( p, y, x ) :
n, a = p
err = y - N(n,a,x)
return err
def Neval(x) :
return N(N0,a,x)
datasetnames = [ 'data_1_1', 'data_1_2', 'data_2_1', 'data_2_2', 'data_3_1', 'data_3_2' ]
# for each bug, choose their biggest first-day increase in OD among the six trials
# as their 'tipoff' score
for experiment in ( spacebugs, groundbugs ) :
for bug in experiment :
for name in datasetnames :
medians = map( median, bug[name] )
# least squares fit to exponential saturation model
N0, a = optimize.leastsq(residuals, [1,0.5], args=(array(medians),array([1,2,3,4,5])))[0]
Hsat = -log(e**(-a)/2.0)/a
sprint = max( [ ( medians[1] - medians[0] ),
( medians[2] - medians[1] ),
( medians[3] - medians[2] ),
( medians[4] - medians[3] ) ] ) # <- this line computes the actual 'sprint' values
# mark bug as alive or dead
if Hsat > 1.6 and a < 1.5 :
alive = True
else :
alive = False
if bug['sprint'] < sprint and alive :
bug['N0'], bug['alpha'], bug['Hsat'] = N0, a, Hsat
bug['sprint'] = sprint
bug['sprint_d'] = name
bug['alive'] = True
# print the sprint rankings
f = open('BestSprintRankings.tsv','w')
f.write('\t'.join( ( 'ranking', 'long name', 'sample name', 'gain in OD (space)', 'gain in OD (ground)', 'alive\n') ) )
for n,bug in enumerate(sorted(spacebugs, key=lambda k: k['sprint'], reverse=True)) :
groundbug = groundbugs[map( lambda k: k['name'], groundbugs ).index(bug['name'])]
f.write( '\t'.join( ( str(n+1), bug['longname'], bug['name'], str(bug['sprint']), str(groundbug['sprint']), str(bug['alive']) ) ) + '\n' )
print str(n+1), bug['name'], str(bug['sprint']), str(groundbug['sprint']), bug['alive']
f.close()
# plot the top players
fig, ax = plt.subplots( 4, 12, figsize=(16,5))
fig.suptitle( 'Best Sprint', fontsize=18, x=0.05,y=1.05 )
for n,bug in enumerate(sorted(spacebugs, key=lambda k: k['sprint'], reverse=True)) :
groundbug = groundbugs[map( lambda k: k['name'], groundbugs ).index(bug['name'])]
subplot(4,12,n+1)
ylim((0,2.5))
yticks( linspace( 0.5, 2.0, 3 ) )
if bug['alive'] :
title(bug['name'])
boxplot(bug[bug['sprint_d']])
plot([1,2,3,4,5],map(median,bug[bug['sprint_d']]), color='green')
plot([1,2,3,4,5],map(median,groundbug[groundbug['sprint_d']]), color='brown')
N0, a = bug['N0'], bug['alpha']
plot(linspace(1,5),Neval(linspace(1,5)),'red')
else :
title(bug['name'], alpha=0.2)
boxplot(bug['data_1_1'])
plot([1,2,3,4,5],map(median,bug['data_1_1']), color='green')
fig.tight_layout()
savefig( 'BestSprint.png', format='png', dpi=100 )
savefig( 'BestSprint.pdf', format='pdf', dpi=100 )
In [20]:
# plot the top players
fig, ax = plt.subplots( 4, 12, figsize=(8,2.5))
#fig.suptitle( 'Best Tipoff', fontsize=18, x=0.05,y=1.05 )
for n,bug in enumerate(sorted(spacebugs, key=lambda k: k['sprint'], reverse=True)[:3]) :
subplot(1,3,n+1)
ylim((0,2.5))
yticks( linspace( 0.5, 2.0, 3 ) )
#fulltitle = r'' + bug['longname'].replace('&','\&') + '\n {\em ' + bug['species'] + '}'
if bug['alive'] :
title(bug['longname'] + '\n' + bug['species'])
boxplot(bug[bug['sprint_d']])
plot([1,2,3,4,5],map(median,bug[bug['sprint_d']]), color='green')
N0, a = bug['N0'], bug['alpha']
plot(linspace(1,5),Neval(linspace(1,5)),'red')
else :
title(fulltitle, alpha=0.2)
boxplot(bug['data_1_1'])
plot([1,2,3,4,5],map(median,bug['data_1_1']), color='green')
fig.tight_layout()
savefig( 'BestSprint_top3.png', format='png', dpi=100 )
savefig( 'BestSprint_top3.pdf', format='pdf', dpi=100 )
In [6]:
from scipy import optimize
def N(n,a,x) :
return n*(1-numpy.exp(-a*x))
def residuals( p, y, x ) :
n, a = p
err = y - N(n,a,x)
return err
def Neval(x) :
return N(N0,a,x)
datasetnames = [ 'data_1_1', 'data_1_2', 'data_2_1', 'data_2_2', 'data_3_1', 'data_3_2' ]
# for each bug, choose their biggest first-day increase in OD among the six trials
# as their 'tipoff' score
for experiment in ( spacebugs, groundbugs ) :
for bug in experiment :
bug['alldata'] = map( lambda x: x[0]+x[1]+x[2]+x[3]+x[4]+x[5],
zip( bug['data_1_1'], \
bug['data_1_2'], \
bug['data_2_1'], \
bug['data_2_2'], \
bug['data_3_1'], \
bug['data_3_2']))
medians = map( numpy.median, bug['alldata'] )
# least squares fit to exponential saturation model
N0, a = optimize.leastsq(residuals, [1,0.5], args=(numpy.array(medians),numpy.array([1,2,3,4,5])))[0]
Hsat = -numpy.log(numpy.e**(-a)/2.0)/a
# print the rankings
f = open('Space_vs_Ground.tsv','w')
f.write('\t'.join(( "n",
"short name",
"long name",
"space 96h OD",
"space 96h OD std",
"ground 96h OD",
"ground 96h OD std",
"alive")) + '\n' )
print '\t'.join(( "n",
"short name",
"long name",
"space 96h OD",
"space 96h OD std",
"ground 96h OD",
"ground 96h OD std",
"alive"))
for n,bug in enumerate(sorted(spacebugs, key=lambda k: k['sprint'], reverse=True)) :
groundbug = groundbugs[map( lambda k: k['name'], groundbugs ).index(bug['name'])]
space96OD = numpy.mean( bug['alldata'][-1])
space96ODstd = numpy.std( bug['alldata'][-1])
ground96OD = numpy.mean( groundbug['alldata'][-1])
ground96ODstd = numpy.std( groundbug['alldata'][-1])
f.write( '\t'.join((str(n+1), bug['name'], bug['longname'], str(space96OD), str(space96ODstd), str(ground96OD), str(ground96ODstd), str(bug['alive']), '\n')) )
print '\t'.join((str(n+1), bug['name'], bug['longname'], str(space96OD), str(space96ODstd), str(ground96OD), str(ground96ODstd), str(bug['alive'])))
f.close()
# plot the top players
fig, ax = subplots( 4, 12, figsize=(16,5))
fig.suptitle( 'Space vs. Ground', fontsize=18, x=0.05,y=1.05 )
for n,bug in enumerate(sorted(spacebugs, key=lambda k: k['sprint'], reverse=True)) :
subplot(4,12,n+1)
ylim((0,2.5))
yticks( linspace( 0.5, 2.0, 3 ) )
groundbug = groundbugs[n]
if bug['alive'] :
title(bug['name'])
boxplot(bug['alldata'])
plot([1,2,3,4,5],map(median,bug['alldata']), color='green')
plot([1,2,3,4,5],map(median,groundbug['alldata']), color='brown')
N0, a = bug['N0'], bug['alpha']
plot(linspace(1,5),Neval(linspace(1,5)),'red')
else :
title(bug['name'], alpha=0.2)
boxplot(bug['data_1_1'])
plot([1,2,3,4,5],map(median,bug['alldata']), color='green')
fig.tight_layout()
savefig( 'Space_vs_Ground.png', format='png', dpi=100 )
savefig( 'Space_vs_Ground.pdf', format='pdf', dpi=100 )
In [5]:
# write each space vs. ground plot to a seperate file
%matplotlib inline
from scipy import optimize
from pylab import *
def N(n,a,x) :
return n*(1-numpy.exp(-a*x))
def residuals( p, y, x ) :
n, a = p
err = y - N(n,a,x)
return err
def Neval(x) :
return N(N0,a,x)
datasetnames = [ 'data_1_1', 'data_1_2', 'data_2_1', 'data_2_2', 'data_3_1', 'data_3_2' ]
# for each bug, choose their biggest first-day increase in OD among the six trials
# as their 'tipoff' score
for experiment in ( spacebugs, groundbugs ) :
for bug in experiment :
bug['alldata'] = map( lambda x: x[0]+x[1]+x[2]+x[3]+x[4]+x[5],
zip( bug['data_1_1'], \
bug['data_1_2'], \
bug['data_2_1'], \
bug['data_2_2'], \
bug['data_3_1'], \
bug['data_3_2']))
medians = map( numpy.median, bug['alldata'] )
# least squares fit to exponential saturation model
N0, a = optimize.leastsq(residuals, [1,0.5], args=(numpy.array(medians),numpy.array([1,2,3,4,5])))[0]
Hsat = -numpy.log(numpy.e**(-a)/2.0)/a
# print the rankings
#f = open('BestSprintRankings.tsv','w')
#f.write('\t'.join( ( 'ranking', 'long name', 'sample name', 'gain in OD (space)', 'gain in OD (ground)', 'alive\n') ) )
#for n,bug in enumerate(sorted(spacebugs, key=lambda k: k['sprint'], reverse=True)) :
# groundbug = groundbugs[map( lambda k: k['name'], groundbugs ).index(bug['name'])]
# f.write( '\t'.join( ( str(n+1), bug['longname'], bug['name'], str(bug['sprint']), str(groundbug['sprint']), str(bug['alive']) ) ) + '\n' )
# print str(n+1), bug['name'], str(bug['sprint']), str(groundbug['sprint']), bug['alive']
#f.close()
# plot the top players
#fig, ax = plt.subplots( 4, 12, figsize=(32,8))
#fig.suptitle( 'Space vs. Ground', fontsize=18, x=0.05,y=1.05 )
for n,bug in enumerate(sorted(spacebugs, key=lambda k: k['sprint'], reverse=True)) :
#subplot(4,12,n+1)
ylim((0,2.5))
yticks( linspace( 0.5, 2.0, 3 ) )
groundbug = groundbugs[n]
if bug['alive'] :
title(bug['longname'])
#boxplot(bug['alldata'])
#plot([1,2,3,4,5],map(numpy.median,bug['alldata']), color='green')
errorbar( [1,2,3,4,5],map(numpy.median,bug['alldata']), yerr=map(numpy.std,bug['alldata']), color='green', label='Space' )
errorbar([1,2,3,4,5],map(numpy.median,groundbug['alldata']), yerr=map(numpy.std,groundbug['alldata']), color='brown', linestyle='--', label='Ground')
xticks([1,2,3,4,5],[0,24,48,72,96])
xlim([0.7, 5.3])
else :
title(bug['name'], alpha=0.2)
boxplot(bug['data_1_1'])
plot([1,2,3,4,5],map(numpy.median,bug['alldata']), color='green')
tight_layout()
lgd = legend(loc=9, bbox_to_anchor=(0.5, -0.1), ncol=2)
savefig( 'Space_v_Ground/' + bug['name'] + '.png', format='png',
dpi=100, additional_artists=[lgd], bbox_inches="tight" )
savefig( 'Space_v_Ground/' + bug['name'] + '.pdf', format='pdf',
dpi=100, additional_artists=[lgd], bbox_inches="tight" )
close()
In [ ]: