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=['annular60'])
records2 = project.record_store.list(project.name, tags=['fig7_nx200_refinement1_1'])
records = records1 + records2
In [2]:
print len(records)
In [4]:
%load_ext autoreload
%autoreload 4
from extremefill2D.featureProperty import FeatureProperty
void_size = []
height = []
suppressor = []
potential = []
for r in records:
if len(r.output_data) > 0:
fp = FeatureProperty(r)
void_size.append(fp.getVoidSize())
height.append(fp.getHeight())
fp.close()
suppressor.append(r.parameters['bulkSuppressor'])
potential.append(r.parameters['appliedPotential'])
void_size = np.array(void_size)
height = np.array(height)
suppressor = np.array(suppressor)
potential = np.array(potential)
mask = (suppressor > 0.1) & (potential > -0.1)
height[mask] = 0.0
In [5]:
import pandas as pd
df = pd.DataFrame({'suppressor' : suppressor, 'potential' : potential, 'void_size' : void_size, 'height' : height})
In [6]:
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.log10(2 * np.logspace(-3, -1, Ngrid))
yi = np.log10(2.5 * np.logspace(-2, 0, Ngrid))
x = np.log10(df.suppressor)
y = np.log10(-df.potential)
yi = yi[yi < np.amax(y)]
#zi = griddata((x, y), z, (xi[None,:], yi[:,None]), method='cubic')
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'$C_{\text{Supp}}$ $\left(\mole\per\power{\metre}{3}\right)$'
ylabelstring = r'$-E_{\text{App}}$ $\left(\volt\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'])
ax3.plot((0.02,), (0.25,), 'ko', mec='k', ms=10)
ax3.plot((0.01,), (0.2,), 'ko', mec='k', ms=10)
## 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.tight_layout(pad=3.0)
plt.savefig("../figures/fig7.png")
In [ ]: