In [400]:
%matplotlib inline

In [401]:
import numpy as np
import scipy as sp
import matplotlib.pyplot as plt
import matplotlib.colors as colors
import matplotlib.cm as cm

import mpmath as mp
mp.mp.dps = 100
import polyhedra as poly
import bga_4_0 as bga

bga = reload(bga)

In [402]:
#poly_name = "rhombicuboctahedron"
#poly_name = "truncated_octahedron"
#poly_name = "truncated_cuboctahedron"
#poly_name = "rhombic_triacontahedron"
#poly_name = "rhombic_dodecahedron"

#poly_name, PolyName = "tetrahedron", "Tetrahedron"
#poly_name, PolyName = "cube", "Cube"
#poly_name, PolyName = "octahedron", "Octahedron"
#poly_name, PolyName = "dodecahedron", "Dodecahedron"
#poly_name, PolyName = "icosahedron", "Icosahedron"

#poly_name, PolyName = "truncated_tetrahedron", "Truncated Tetrahedron"
#poly_name, PolyName = "cuboctahedron", "Cuboctahedron"
#poly_name, PolyName = "truncated_cube", "Truncated Cube"
#poly_name, PolyName = "truncated_octahedron", "Truncated Octahedron"

#poly_name, PolyName = "triakis_tetrahedron", "Triakis Tetrahedron"
#ERR#poly_name, PolyName = "rhombic_dodecahedron", "Rhombic Dodecahedron"
#ERR#poly_name, PolyName = "triakis_octahedron", "Triakis Octahedron"

In [403]:
verts, face_inds, cents = getattr(poly, poly_name)()
V, E, F, S, species, f_types, adj_list, dual = bga.get_poly(poly_name)
ints, ids, paths, shell_int, shell_paths, edges, shell_edge, degens = bga.get_bg_ss(poly_name, get_degens=True)

In [404]:
from matplotlib import rc
rc('font', **{'family':'serif','serif':['Palatino']})
rc('text', usetex=True)

fig_width = 10
fig_height = 10
fig_dpi = 200

In [405]:
Rs = bga.generate_rotations(adj_list)
print len(Rs)


24

In [406]:
#rs = bga.get_rs(ints, adj_list, Rs)

In [407]:
#Ss, Ts = bga.get_degeneracies(ints, edges, adj_list, Rs=Rs)

In [408]:
#edge_adj, edge_adj_inds = bga.edge_adj_list(edges, inds=True)

In [409]:
#shellings = bga.get_shellings(edges,ints,degens,shell_int,adj_list)
#print shellings[-5:]

In [410]:
#shellings[-1]

In [411]:
def int_hist(data):
    counts = np.zeros(int(data.max()) - int(data.min()) + 1)
    for x in data:
        counts[int(round(x))] += 1
    return counts, data.min(), data.max()

In [412]:
dofs = np.zeros(len(ints))
for k, int_num in enumerate(range(len(ints))):
    dofs[k] = bga.DoF(ints[int_num], verts, face_inds)[0]

dof_max = int(dofs.max())
counts, dmin, dmax = int_hist(dofs)
N = dmax - dmin + 1

ind = np.arange(N)  # the x locations for the groups
width = 0.65       # the width of the bars

fig, ax = plt.subplots()
rects1 = ax.bar(ind, counts, width)

ax.set_ylabel('Number of Intermediates')
ax.set_xlabel('Degrees of Freedom')
ax.set_title(PolyName+' Degrees of Freedom Histogram')
ax.set_xticks(ind+width*0.5)
ax.set_xticklabels(range(dof_max+1))
ax.set_xlim(dmin - 0.25, dmax+1)
ax.set_ylim(0,1.2*counts.max())

plt.savefig(poly_name+"_dof_hist.eps", dpi=fig_dpi, format='eps')



In [413]:
M = int(round(max(dofs)))
N = len(ints[0,:])
w = 0.8

inds = np.arange(N+1)
df_dist = np.zeros((M+1,N+1))

for k,d in enumerate(dofs):
    t = sum([1 for x in ints[k,:] if x != 0])
    df_dist[d,t] += 1.0

for j in range(N+1):
    df_dist[:,j] /= sum(df_dist[:,j])

fig = plt.figure(202)
plt.clf()
ax = fig.add_subplot(111)

rects_total = np.zeros((N+1))
for i in range(M+1):
    colour = colors.rgb2hex(sp.rand(3))
    rects = ax.bar(inds,df_dist[i,:],width=w,color=colour,bottom=rects_total)
    rects_total += df_dist[i,:]

ax.set_xlabel('Number of faces of intermediate')
ax.set_ylabel('Distribution of degrees of freedom')
ax.set_title('Degrees of freedom distribution by size of intermediate for the '+PolyName)
ax.set_xticks(inds+w*.5)
ax.set_xticklabels(inds)
ax.set_xlim(-0.5*w,N+1.5*w)
ax.set_ylim(0.0,1.0)


Out[413]:
(0.0, 1.0)
M = int(round(max(dofs))) N = len(ints[0,:]) w = 0.8 inds = np.arange(N+1) df_dist = np.zeros((M+1,N+1)) for k,d in enumerate(dofs): t = sum([1 for x in ints[k,:] if x != 0]) df_dist[d,t] += 1.0 for j in range(N+1): df_dist[:,j] /= sum(df_dist[:,j]) fig = plt.figure(202) plt.clf() ax = fig.add_subplot(111) for i in range(M+1): colour = colors.rgb2hex(sp.rand(3)) rects = ax.plot(inds,df_dist[i,:],color=colour) ax.set_xlabel('Number of faces of intermediate') ax.set_ylabel('Proportion of intermediates') ax.set_title('Degrees of freedom distribution by size of intermediate for the '+poly_name) ax.set_xticks(inds) ax.set_xticklabels(inds) #ax.legend() #ax.set_xlim(-0.5w,N+1.5w) #ax.set_ylim(0.0,1.0)

In [414]:
M = int(round(max(dofs)))
N = len(ints[0,:])
w = 0.8

inds = np.arange(N+1)
df_dist = np.zeros((M+1,N+1))

for k,d in enumerate(dofs):
    t = sum([1 for x in ints[k,:] if x != 0])
    df_dist[d,t] += 1.0

for j in range(N+1):
    df_dist[:,j] /= sum(df_dist[:,j])

amp = 1.0
fig = plt.figure(num=None, figsize=(amp*fig_width, 0.4*fig_height), dpi=fig_dpi, facecolor='w', edgecolor='k')
plt.clf()
ax = fig.add_subplot(111)

plt.tick_params(
    axis='both',          # changes apply to the x-axis
    which='both',      # both major and minor ticks are affected
    bottom='off',      # ticks along the bottom edge are off
    top='off',         # ticks along the top edge are off
    left='off',
    right='off')

#grd = ax.imshow(df_dist, cmap=cm.gist_earth, interpolation='nearest')
grd = ax.imshow(df_dist, cmap=cm.bone_r, interpolation='nearest')
plt.colorbar(grd)
ax.set_xlabel('Faces in Intermediate')
ax.set_ylabel('Degrees of Freedom Proportion')
ax.set_title(PolyName + ' Degrees of Freedom Histograms by Face Count')
ax.set_xticks(inds)
ax.set_xticklabels(inds)
#ax.set_xlim(-0.5*w,N+1.5*w)
#ax.set_ylim(0.0,1.0)


plt.savefig(poly_name+"_dof_hist_facecount.eps", dpi=fig_dpi, format='eps')