In [1]:
data_s_gm8 = '''
|| MPI-ESM-LR/rcp45/day/atmos/day/r1i1p1/latest/tas/ || 7.40 || (107746, 96, 192) || 189 || 38.3 || 4.93 ||
|| MPI-ESM-LR/rcp45/day/atmos/day/r1i1p1/latest/hur/ || 50.79 || (49306, 15, 96, 192) || 276 || 48.7 || 5.67 ||
|| IPSL-CM5A-MR/rcp45/3hr/atmos/3hr/r1i1p1/latest/ps/ || 16.80 || (219000, 143, 144) || 368 || 110 || 3.35 ||
|| MPI-ESM-LR/rcp45/day/atmos/day/r1i1p1/latest/zg/ || 50.79 || (49306, 15, 96, 192) || 284 || 49.8 || 5.70 ||
|| MPI-ESM-LR/rcp45/day/atmos/day/r1i1p1/latest/pr/ || 7.40 || (107746, 96, 192) || 162 || 36.6 || 4.43 ||
|| MPI-ESM-LR/rcp45/day/atmos/day/r1i1p1/latest/ta/ || 50.79 || (49306, 15, 96, 192) || 276 || 50.8 || 5.43 ||
|| IPSL-CM5A-MR/rcp85/3hr/atmos/3hr/r1i1p1/latest/huss/ || 16.80 || (219000, 143, 144) || 427 || 114 || 3.75 ||
|| IPSL-CM5A-MR/rcp85/day/atmos/cfDay/r1i1p1/latest/clw/|| 106.40 || (34675, 39, 143, 144) || 228 || 43.3 || 5.27 ||
|| IPSL-CM5A-MR/rcp85/6hr/atmos/6hrLev/r1i1p1/latest/ua/|| 425.59 || (138700, 39, 143, 144)|| 920 || 176 || 5.23 ||
|| MPI-ESM-LR/rcp45/day/atmos/day/r1i1p1/latest/pr/ || 7.40 || (107746, 96, 192) || 204 || 37.7 || 5.41 ||
|| MPI-ESM-LR/rcp45/day/atmos/day/r1i1p1/latest/wap/ || 50.79 || (49306, 15, 96, 192) || 271 || 48 || 5.65 ||
'''
data_s_gm4 = '''
|| MPI-ESM-LR/rcp45/day/atmos/day/r1i1p1/latest/tas/ || 7.40 || (107746, 96, 192) || 203 || 66.8 || 3.04 ||
|| MPI-ESM-LR/rcp45/day/atmos/day/r1i1p1/latest/hur/ || 50.79 || (49306, 15, 96, 192) || 272 || 81.5 || 3.34 ||
|| IPSL-CM5A-MR/rcp45/3hr/atmos/3hr/r1i1p1/latest/ps/ || 16.80 || (219000, 143, 144) || 369 || 126 || 2.93 ||
|| MPI-ESM-LR/rcp45/day/atmos/day/r1i1p1/latest/zg/ || 50.79 || (49306, 15, 96, 192) || 271 || 80.9 || 3.35 ||
|| MPI-ESM-LR/rcp45/day/atmos/day/r1i1p1/latest/pr/ || 7.40 || (107746, 96, 192) || 156 || 63.9 || 2.44 ||
|| MPI-ESM-LR/rcp45/day/atmos/day/r1i1p1/latest/ta/ || 50.79 || (49306, 15, 96, 192) || 270 || 78.6 || 3.44 ||
|| IPSL-CM5A-MR/rcp85/3hr/atmos/3hr/r1i1p1/latest/huss/ || 16.80 || (219000, 143, 144) || 354 || 131 || 2.70 ||
|| IPSL-CM5A-MR/rcp85/day/atmos/cfDay/r1i1p1/latest/clw/ || 106.40 || (34675, 39, 143, 144) || 229 || 76.8 || 2.98 ||
|| MPI-ESM-LR/rcp45/day/atmos/day/r1i1p1/latest/pr/ || 7.40 || (107746, 96, 192) || 188 || 61.4 || 3.06 ||
|| MPI-ESM-LR/rcp45/day/atmos/day/r1i1p1/latest/wap/ || 50.79 || (49306, 15, 96, 192) || 272 || 81.6 || 3.33 ||
'''
data_s_rg4 = '''
|| MPI-ESM-LR/rcp45/day/atmos/day/r1i1p1/latest/tas/ || 34675 || 169 || 48.7 || 3.47 ||
|| MPI-ESM-LR/rcp85/day/atmos/day/r1i1p1/latest/pr/ || 34675 || 185 || 47.3 || 3.91 ||
|| MPI-ESM-LR/rcp85/day/atmos/day/r2i1p1/latest/prc/ || 34698 || 167 || 47.5 || 3.51 ||
|| MPI-ESM-LR/rcp45/6hr/atmos/6hrPlev/r3i1p1/latest/psl/ || 138700 || 649 || 215 || 3.02 ||
|| IPSL-CM5A-MR/rcp85/day/atmos/cfDay/r1i1p1/latest/rsus/|| 34675 || 191 || 76.5 || 2.50 ||
|| MPI-ESM-LR/rcp85/day/atmos/day/r2i1p1/latest/vas/ || 34698 || 178 || 49.1 || 3.63 ||
|| MPI-ESM-LR/rcp85/day/atmos/day/r1i1p1/latest/prsn/ || 49306 || 245 || 76.7 || 3.19 ||
|| IPSL-CM5A-MR/rcp85/day/atmos/day/r1i1p1/latest/rsds/ || 34675 || 197 || 73 || 2.70 ||
|| MPI-ESM-LR/rcp85/day/atmos/day/r1i1p1/latest/sfcWind/ || 34675 || 170 || 50 || 3.40 ||
'''
In [2]:
data_s = data_s_gm4
row_split, cell_split = [
('\n', '||'),
('\n\n', '\n')
][0]
types = (str, float, eval, float, float, float)
data = []
for l in data_s.split(row_split):
l = l.strip()
if l:
line = []
data.append(line)
i = 0
for x in l.split(cell_split):
x = x.strip()
if x:
line.append(types[i](x))
i += 1
In [3]:
def draw_tbl (tbl):
ws = [max(len(s) for s in col) + 2 for col in zip(*tbl)]
for row in tbl:
print ''.join(val.rjust(n) for n, val in zip(ws, row))
In [4]:
tbl = [('used', 'total rate', 'used rate', 'total rate (//)', 'used rate (//)')]
plot_data = []
for row in data:
path, sz, shape, t_s, t_p, r = row[:6]
p_tot = reduce(int.__mul__, shape)
p_used = shape[0] * shape[-2] * shape[-1]
used = float(p_used) / p_tot
used_rate = float(p_used) / t_s
plot_data.append(row + [used, used_rate])
row = (used, p_tot / (t_s * 10 ** 6), used_rate / (10 ** 6), p_tot / (t_p * 10 ** 6), p_used / (t_p * 10 ** 6))
tbl.append(['%.3f' % (s,) for s in row])
draw_tbl(tbl)
In [26]:
x, y = zip(*(row[-2:] for row in plot_data))
plot(x, y, 'x')
axis((0, 1.1, 0, None))
None