In [1]:
%load_ext autoreload
%autoreload 4
from sumatra.projects import load_project

project = load_project('../extremefill2D')
records1 = project.record_store.list(project.name, tags=['annular58'])
records2 = project.record_store.list(project.name, tags=['annular58_refinement1'])
records = records1 + records2


Created Django record store using PostgreSQL

In [4]:
%load_ext autoreload
%autoreload 4
from extremefill2D.featureProperty import FeatureProperty

void_size = []
height = []
kMinus = []
kPlus = []

for r in records:
    if len(r.output_data) > 0:
        fp = FeatureProperty(r)
        void_size.append(fp.getVoidSize())
        height.append(fp.getHeight())
        fp.close()
        kMinus.append(r.parameters['kMinus'])
        kPlus.append(r.parameters['kPlus'])
    
void_size = np.array(void_size)
height = np.array(height)
kMinus = np.array(kMinus)
kPlus = np.array(kPlus)

In [5]:
print len(records)


593

In [6]:
import pandas as pd

df = pd.DataFrame({'kMinus' : kMinus, 'kPlus' : kPlus, 'void_size' : void_size, 'height' : height})

In [8]:
import matplotlib as mpl
from matplotlib.mlab import griddata
import prettyplotlib as ppl
import brewer2mpl

almost_black = '#262626'


# Another ColorBrewer scale. This one has nice "traditional" colors like
# reds and blues
set1 = brewer2mpl.get_map('Set1', 'qualitative', 9).mpl_colors
set2 = brewer2mpl.get_map('Set2', 'qualitative', 8).mpl_colors
mpl.rcParams['axes.color_cycle'] = set2


# Set some commonly used colors
almost_black = '#262626'
light_grey = np.array([float(248) / float(255)] * 3)

reds = mpl.cm.Reds
reds.set_bad('white')
reds.set_under('white')

blues_r = mpl.cm.Blues_r
blues_r.set_bad('white')
blues_r.set_under('white')

# Need to 'reverse' red to blue so that blue=cold=small numbers,
# and red=hot=large numbers with '_r' suffix
blue_red = brewer2mpl.get_map('RdBu', 'Diverging', 11,
                              reverse=True).mpl_colormap
map1 = brewer2mpl.get_map('Set1', 'qualitative', 9).mpl_colormap
map2 = brewer2mpl.get_map('Set2', 'qualitative', 8).mpl_colormap

# Default "patches" like scatterplots
mpl.rcParams['patch.linewidth'] = 0.75     # edge width in points

# Default empty circle with a colored outline
mpl.rcParams['patch.facecolor'] = 'none'
mpl.rcParams['patch.edgecolor'] = set2[0]

# Change the default axis colors from black to a slightly lighter black,
# and a little thinner (0.5 instead of 1)
mpl.rcParams['axes.edgecolor'] = almost_black
mpl.rcParams['axes.labelcolor'] = almost_black
mpl.rcParams['axes.linewidth'] = 0.5

# Make the default grid be white so it "removes" lines rather than adds
mpl.rcParams['grid.color'] = 'white'

# change the tick colors also to the almost black
mpl.rcParams['ytick.color'] = almost_black
mpl.rcParams['xtick.color'] = almost_black

# change the text colors also to the almost black
mpl.rcParams['text.color'] = almost_black


titlefontsize = 24
fontdict = {'fontsize' : 24}
tickfontsize = 20
Ngrid = 1000
clevels = 11

xi = np.linspace(6, 9, Ngrid)
yi = np.linspace(0, 4, Ngrid)

x = np.log10(df.kMinus)
y = np.log10(df.kPlus)

zi_void = griddata(x, y, np.array(df.void_size), xi, yi)
zi_height = griddata(x, y, np.array(df.height), xi, yi)

fig = plt.figure(figsize=(15, 6), dpi=200)

xlabelstring = r'$k_-$ $\left(1\per\metre\right)$'
ylabelstring = r'$k_+$ $\left(\power{\meter}{3}\per\mole\cdot\second\right)$'

ax1 = fig.add_subplot(1, 3, 2)
ax1.contourf(10**xi, 10**yi, zi_void, np.linspace(0, 1, clevels), cmap=blue_red)
ax1.set_xlabel(xlabelstring, fontdict=fontdict, color=almost_black)

ax2 = fig.add_subplot(1, 3, 1)
ax2.contourf(10**xi, 10**yi, zi_height, np.linspace(0, 1, clevels), cmap=blue_red)
ax2.set_ylabel(ylabelstring, fontdict=fontdict, color=almost_black)

ax3 = fig.add_subplot(1, 3, 3)
a = ax3.contourf(10**xi, 10**yi, zi_height - zi_void, np.linspace(0, 1, clevels), cmap=blue_red)

for ax, title in zip((ax1, ax2, ax3), ('b', 'a', 'c')):
    ax.text(0.5, 1.02, r'$\text{{({0})}}$'.format(title),
            horizontalalignment='center',
            fontsize=titlefontsize,
            transform = ax.transAxes, color=almost_black)
    ax.tick_params(axis='both', which='major', labelsize=tickfontsize, length=8, width=1.5)
    ax.tick_params(axis='both', which='minor', labelsize=tickfontsize, length=5, width=1.2)
    ax.set_xscale('log')
    ax.set_yscale('log')
    if ax in (ax1, ax3):
        ax.set_yticklabels([r''] * len(ax.get_yticks()))
    ppl.remove_chartjunk(ax, ['top', 'right'])

## colorbar
from mpl_toolkits.axes_grid1 import make_axes_locatable
divider = make_axes_locatable(ax3)
cax = divider.append_axes("right", size="5%", pad=0.05)
cb = plt.colorbar(a, cax=cax, ticks=(0, 0.2, 0.4, 0.6, 0.8, 1))
cb.ax.tick_params(labelsize=20) 
for t in cb.ax.get_yticklabels():
    t.set_color(almost_black)
#plt.subplots_adjust(top=2.0)
plt.tight_layout(pad=3.0)
plt.savefig("../figures/fig6.png")



In [ ]: