$k^+$ v $k^-$ Contour Plot

The goal of this notebook is to produce the $k^+$ versus $k^-$ contour plot. The first stage is to produce two separate plots, one of void size and the other of the filling height. First off let's reproduce the old 1D extreme fill figure as a starting point.


In [1]:
from IPython.core.display import Image 
Image(filename='../extremefill/kPlusVkMinus.png')


Out[1]:

How to obtain the void size

Let's use an example simulation.


In [10]:
%load_ext autoreload
%autoreload 2

from tools import getSMTRecords, smt_ipy_table, switch_smt_database
switch_smt_database('extremefill')
records = getSMTRecords()
annular26Records = getSMTRecords(records=records, tags=['annular26'])
switch_smt_database('extremefill2D')


Created Django record store using PostgreSQL
/users/wd15/hg/sumatra/sumatra/programs.py:57: Warning: Python could not be found. Please supply the path to the /users/wd15/.virtualenvs/fipy/bin/python executable.
  warnings.warn(errmsg)
Out[10]:
u'extremefill'

In [2]:
print len(annular26Records)


400

The simulation below will act as a test case for obtaining the length of the void.


In [78]:
from tools import getSMTRecords
from tools import getRecord
from multiViewer import MultiViewer

kPlus=np.logspace(3, 4, 20)[0]
kMinus=np.logspace(7.6, 8.6, 20)[11]

record = getSMTRecords(annular26Records, parameters={'kPlus' : kPlus, 'kMinus' : kMinus})[0]
viewer = MultiViewer([record], figsize=(1.5, 6))
viewer.plot(times=np.arange(10) * 4000. / 9.)
smt_ipy_table([record], fields=['label', 'timestamp', 'parameters', 'duration', 'version', 'tags'], parameters=['kPlus', 'kMinus'])
print 'void_size, height:',find_void_size(record)


void_size, height: (0.35806954415124354, 1.0)

The find_void_size function returns the void size and fill height as a proportion of the trench depth.


In [58]:
from tools import find_void_size

print find_void_size(record)


0.358069544151

I messed with the Data directory so I need to create links back to the extremefill2D-old directory.


In [9]:
for record in annular26Records:
    newpath = os.path.join(record.datastore.root, record.output_data[0].path)
    oldpath = newpath.replace('extremefill2D', 'extremefill2D-old')
    !ln -s {oldpath} {newpath}


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-9-05ae7de9ccca> in <module>()
----> 1 for record in annular26Records:
      2     newpath = os.path.join(record.datastore.root, record.output_data[0].path)
      3     oldpath = newpath.replace('extremefill2D', 'extremefill2D-old')
      4     get_ipython().system(u'ln -s {oldpath} {newpath}')

NameError: name 'annular26Records' is not defined

Another test case


In [79]:
%load_ext autoreload
%autoreload 2

from tools import getSMTRecords
from tools import getRecord
from multiViewer import MultiViewer
from tools import find_void_size

kPlus=np.logspace(3, 4, 20)[0]
kMinus=np.logspace(7.6, 8.6, 20)[7]

record = getSMTRecords(annular26Records, parameters={'kPlus' : kPlus, 'kMinus' : kMinus})[0]
viewer = MultiViewer([record], figsize=(1.5, 6))
viewer.plot(times=np.arange(10) * 4000. / 9.)
smt_ipy_table([record], fields=['label', 'timestamp', 'parameters', 'duration', 'version', 'tags'], parameters=['kPlus', 'kMinus'])
print 'void_size, height:',find_void_size(record)


void_size, height: (0.0, 0.029775181523726536)

The above is not classed as a void as this is actually not disconnected.

No Void


In [80]:
%load_ext autoreload
%autoreload 2

from tools import getSMTRecords
from tools import getRecord
from multiViewer import MultiViewer
from tools import find_void_size

kPlus=np.logspace(3, 4, 20)[0]
kMinus=np.logspace(7.6, 8.6, 20)[2]

record = getSMTRecords(annular26Records, parameters={'kPlus' : kPlus, 'kMinus' : kMinus})[0]
viewer = MultiViewer([record], figsize=(1.5, 6))
viewer.plot(times=np.arange(10) * 4000. / 9.)
smt_ipy_table([record], fields=['label', 'timestamp', 'parameters', 'duration', 'version', 'tags'], parameters=['kPlus', 'kMinus'])
print 'void_size, height:',find_void_size(record)


void_size, height: (0.0, 0.91531295347580288)

Small void


In [81]:
%load_ext autoreload
%autoreload 2

from tools import getSMTRecords
from tools import getRecord
from multiViewer import MultiViewer
from tools import find_void_size

kPlus=np.logspace(3, 4, 20)[0]
kMinus=np.logspace(7.6, 8.6, 20)[5]

record = getSMTRecords(annular26Records, parameters={'kPlus' : kPlus, 'kMinus' : kMinus})[0]
viewer = MultiViewer([record], figsize=(1.5, 6))
viewer.plot(times=np.arange(10) * 4000. / 9.)
smt_ipy_table([record], fields=['label', 'timestamp', 'parameters', 'duration', 'version', 'tags'], parameters=['kPlus', 'kMinus'])
print 'void_size, height:',find_void_size(record)


void_size, height: (0.039121851105510953, 0.99789448815016379)

Contour plot of void size


In [38]:
!date
%load_ext autoreload
%autoreload 4
from tools import VoidSizeFinder

kPluses = np.logspace(3, 4, 20)
kMinuses = np.logspace(7.6, 8.6, 20)

N = 400
kPs, kMs = np.meshgrid(kPluses, kMinuses)
kPs = kPs.flatten()
kMs = kMs.flatten()
ks = np.array((kPs, kMs)).transpose()
                       
vv = VoidSizeFinder()

def void_size(kPlus, kMinus):
    record = getSMTRecords(annular26Records, parameters={'kPlus' : kPlus, 'kMinus' : kMinus})[0]
    return vv.find_void_size(record)

void_size_vectorized = np.vectorize(void_size)

import cProfile
#cProfile.run("void_sizes = void_size_vectorized(ks[:N,0], ks[:N,1])", filename='profile1.stats')
void_size, fill_height = void_size_vectorized(ks[:N,0], ks[:N,1])
#print void_sizes
!date


Tue Sep 17 11:48:02 EDT 2013
Tue Sep 17 11:48:45 EDT 2013

Void Size as Proportion of the height of the feature

Compare this with annular6 notebook.


In [44]:
void_sizes_reshape = void_size.reshape((20, 20)).transpose()

plt.figure(figsize=(8, 6))
a = plt.contourf(kMinuses, kPluses, void_sizes_reshape, np.linspace(0, 1, 11))
a.ax.set_xscale('log')
a.ax.set_yscale('log')
plt.xlabel(r'$k^-')
plt.ylabel(r'$k^+')
plt.colorbar()
plt.title(r'Void Size')


Out[44]:
<matplotlib.text.Text at 0x2cd3bb090>

Height of fill

Compare this with annular6 notebook.


In [43]:
fill_height_reshape = fill_height.reshape((20, 20)).transpose()

plt.figure(figsize=(8, 6))
a = plt.contourf(kMinuses, kPluses, fill_height_reshape, np.linspace(0, 1, 11))
a.ax.set_xscale('log')
a.ax.set_yscale('log')
plt.xlabel(r'$k^-')
plt.ylabel(r'$k^+')
plt.colorbar()
plt.title(r'Fill Height')


Out[43]:
<matplotlib.text.Text at 0x29ae5e450>

New data set annular25

See the notebook.


In [1]:
%load_ext autoreload
%autoreload 2

from tools import getSMTRecords, smt_ipy_table, switch_smt_database
switch_smt_database('extremefill')
records = getSMTRecords()
annular25Records = getSMTRecords(records=records, tags=['annular25'])
switch_smt_database('extremefill2D')


Created Django record store using PostgreSQL
/users/wd15/hg/sumatra/sumatra/programs.py:57: Warning: Python could not be found. Please supply the path to the /users/wd15/.virtualenvs/fipy/bin/python executable.
  warnings.warn(errmsg)
Out[1]:
u'extremefill'

Create links to these old records in new directory


In [4]:
import os
for record in annular25Records:
    newpath = os.path.join(record.datastore.root, record.output_data[0].path)
    oldpath = newpath.replace('extremefill2D', 'extremefill2D-old')
    !ln -s {oldpath} {newpath}

Pull out the fill_height and void_size arrays


In [6]:
!date
%load_ext autoreload
%autoreload 4
from tools import VoidSizeFinder

kPluses=np.logspace(1, 3, 20)
kMinuses=np.logspace(7, 8, 10)

N = 200
kPs, kMs = np.meshgrid(kPluses, kMinuses)
kPs = kPs.flatten()
kMs = kMs.flatten()
ks = np.array((kPs, kMs)).transpose()
                       
vv = VoidSizeFinder()

def void_size(kPlus, kMinus):
    record = getSMTRecords(annular25Records, parameters={'kPlus' : kPlus, 'kMinus' : kMinus})[0]
    return vv.find_void_size(record)

void_size_vectorized = np.vectorize(void_size)

import cProfile
#cProfile.run("void_sizes = void_size_vectorized(ks[:N,0], ks[:N,1])", filename='profile1.stats')
void_size, fill_height = void_size_vectorized(ks[:N,0], ks[:N,1])
#print void_sizes
!date


Tue Sep 17 12:15:16 EDT 2013
Tue Sep 17 12:15:28 EDT 2013

In [8]:
void_sizes_reshape = void_size.reshape((10, 20)).transpose()

plt.figure(figsize=(8, 6))
a = plt.contourf(kMinuses, kPluses, void_sizes_reshape, np.linspace(0, 1, 11))
a.ax.set_xscale('log')
a.ax.set_yscale('log')
plt.xlabel(r'$k^-')
plt.ylabel(r'$k^+')
plt.colorbar()
plt.title(r'Void Size')


Out[8]:
<matplotlib.text.Text at 0x337a4d0>

In [9]:
fill_height_reshape = fill_height.reshape((10, 20)).transpose()

plt.figure(figsize=(8, 6))
a = plt.contourf(kMinuses, kPluses, fill_height_reshape, np.linspace(0, 1, 11))
a.ax.set_xscale('log')
a.ax.set_yscale('log')
plt.xlabel(r'$k^-')
plt.ylabel(r'$k^+')
plt.colorbar()
plt.title(r'Fill Height')


Out[9]:
<matplotlib.text.Text at 0x1518a2550>

Fill Proportion

Subtracting the void_size from the the fill_height will give an overall quality of fill.


In [12]:
overall_reshape = fill_height_reshape - void_sizes_reshape

plt.figure(figsize=(8, 6))
a = plt.contourf(kMinuses, kPluses, overall_reshape, np.linspace(0, 1, 11))
a.ax.set_xscale('log')
a.ax.set_yscale('log')
plt.xlabel(r'$k^-')
plt.ylabel(r'$k^+')
plt.colorbar()
plt.title(r'Fill Proportion')


Out[12]:
<matplotlib.text.Text at 0x1db1a53d0>

In [ ]: