Notebook for generation of Figure 3(a)


In [1]:
%load_ext autoreload
%autoreload 2
from extremefill2D.tools import getSMTRecords, smt_ipy_table
records = getSMTRecords(tags=['fig3a_nx200'], path='../extremefill2D')


Created Django record store using PostgreSQL

In [5]:
from extremefill2D.multiViewer import MultiViewer
from extremefill2D.tools import getRecord

kPluses = np.logspace(1, 4, 20)[[5, 10, 15, 19]][::-1]
kMinuses = np.logspace(6, 9, 20)[[5, 10, 15, 19]]

reorderedRecords = [[getRecord(records=records, kPlus=kPlus, kMinus=kMinus) for kMinus in kMinuses] for kPlus in kPluses]

def me(n):
    s = '%1.1e' % n
    m, e = s.split('e')
    return float(m), int(e)

def rowlabel(r):
    m, e = me(r.parameters['kPlus'])
    return '${0:1.1f}\\times 10^{{{1}}}$'.format(m, e)


def columnlabel(r):
#    m, e = me(r.parameters['kMinus'] * 10**6)
    return '${0:1.1f}$'.format(r.parameters['kMinus'] / 10**6)
#    return '${0:1.1f}\\times 10^{{{1}}}$'.format(m, e)


viewer = MultiViewer(reorderedRecords,
                     rowtitle=rowlabel,
                     columntitle=columnlabel,
                     figsize=(1.15, 5.),
                     xlabel='$k_-$ ($10^{{{6}}}\per\meter$)',
                     ylabel='$k_+$ ($\power{\meter}{3}\per\mole\cdot\second$)',
                     axislabelfontsize=24)

## remove wierd looking void. 
times = np.arange(40) * 5000. / 39

viewer.plot(times=times, filename='../figures/fig3a.png')

smt_ipy_table([j for i in reorderedRecords for j in i if j],
              fields=['label', 'timestamp', 'parameters', 'duration', 'version', 'tags'],
              parameters=['kPlus', 'kMinus', 'appliedPotential', 'bulkSuppressor', 'Nx'])


Out[5]:
LabelTimestampParametersDurationVersionTags
ce1057ad2013-11-01 19:01kPlus: 10000.0, kMinus: 6158482.11066, appliedPotential: -0.25, bulkSuppressor: 0.02, Nx: 20010m 46.53s71e554bd8a2afig3a_nx200
289187a12013-11-01 19:02kPlus: 10000.0, kMinus: 37926901.9073, appliedPotential: -0.25, bulkSuppressor: 0.02, Nx: 2001h 10m 14.36s71e554bd8a2afig3a_nx200
b66e270a2013-11-01 19:01kPlus: 10000.0, kMinus: 233572146.909, appliedPotential: -0.25, bulkSuppressor: 0.02, Nx: 2002h 3m 50.32s71e554bd8a2afig3a_nx200
af1b6c932013-11-01 19:01kPlus: 10000.0, kMinus: 1000000000.0, appliedPotential: -0.25, bulkSuppressor: 0.02, Nx: 2003h 5m 9.44s71e554bd8a2afig3a_nx200
2cca56b42013-11-01 19:02kPlus: 2335.72146909, kMinus: 6158482.11066, appliedPotential: -0.25, bulkSuppressor: 0.02, Nx: 20012m 30.03s71e554bd8a2afig3a_nx200
ea4e58782013-11-01 19:01kPlus: 2335.72146909, kMinus: 37926901.9073, appliedPotential: -0.25, bulkSuppressor: 0.02, Nx: 2001h 38m 27.88s71e554bd8a2afig3a_nx200
6a8d5cf72013-11-01 19:01kPlus: 2335.72146909, kMinus: 233572146.909, appliedPotential: -0.25, bulkSuppressor: 0.02, Nx: 2002h 30m 26.38s71e554bd8a2afig3a_nx200
37e05d4d2013-11-01 19:01kPlus: 2335.72146909, kMinus: 1000000000.0, appliedPotential: -0.25, bulkSuppressor: 0.02, Nx: 2002h 28m 59.01s71e554bd8a2afig3a_nx200
74956cdd2013-11-01 19:02kPlus: 379.269019073, kMinus: 6158482.11066, appliedPotential: -0.25, bulkSuppressor: 0.02, Nx: 20012m 35.75s71e554bd8a2afig3a_nx200
051d09bd2013-11-01 19:01kPlus: 379.269019073, kMinus: 37926901.9073, appliedPotential: -0.25, bulkSuppressor: 0.02, Nx: 2001h 36m 2.71s71e554bd8a2afig3a_nx200
376771f12013-11-01 19:01kPlus: 379.269019073, kMinus: 233572146.909, appliedPotential: -0.25, bulkSuppressor: 0.02, Nx: 2002h 37m 20.17s71e554bd8a2afig3a_nx200
48fc04a52013-11-01 19:01kPlus: 379.269019073, kMinus: 1000000000.0, appliedPotential: -0.25, bulkSuppressor: 0.02, Nx: 2002h 25m 12.70s71e554bd8a2afig3a_nx200
8cd5b45f2013-11-01 19:02kPlus: 61.5848211066, kMinus: 6158482.11066, appliedPotential: -0.25, bulkSuppressor: 0.02, Nx: 20013m 0.36s71e554bd8a2afig3a_nx200
a369d1312013-11-01 19:01kPlus: 61.5848211066, kMinus: 37926901.9073, appliedPotential: -0.25, bulkSuppressor: 0.02, Nx: 2002h 29m 40.42s71e554bd8a2afig3a_nx200
fb30bcbf2013-11-01 19:01kPlus: 61.5848211066, kMinus: 233572146.909, appliedPotential: -0.25, bulkSuppressor: 0.02, Nx: 2002h 13m 55.22s71e554bd8a2afig3a_nx200
08e894db2013-11-01 19:01kPlus: 61.5848211066, kMinus: 1000000000.0, appliedPotential: -0.25, bulkSuppressor: 0.02, Nx: 2002h 10m 32.52s71e554bd8a2afig3a_nx200

In [4]:
from multiViewer import MultiViewer
from tools import getRecord

kPluses = np.logspace(1, 4, 20)[[5, 10, 15, 19]][::-1]
kMinuses = np.logspace(6, 9, 20)[[5, 10, 15, 19]]

reorderedRecords = [[getRecord(records=records, kPlus=kPlus, kMinus=kMinus) for kMinus in kMinuses] for kPlus in kPluses]

def me(n):
    s = '%1.1e' % n
    m, e = s.split('e')
    return float(m), int(e)

def rowlabel(r):
    m, e = me(r.parameters['kPlus'])
    return '${0:1.1f}\\times 10^{{{1}}}$'.format(m, e)

def columnlabel(r):
    m, e = me(r.parameters['kMinus'])
    return '${0:1.1f}\\times 10^{{{1}}}$'.format(m, e)

viewer = MultiViewer(reorderedRecords,
                     rowtitle=rowlabel,
                     columntitle=columnlabel,
                     figsize=(1.15, 5.),
                     xlabel='$k_-$ ($1\per\meter$)',
                     ylabel='$k_+$ ($\power{\meter}{3}\per\mole\cdot\second$)')

## remove wierd looking void. 
times = np.arange(40) * 5000. / 39

viewer.plot(times=times, labels=True)

smt_ipy_table([j for i in reorderedRecords for j in i if j],
              fields=['label', 'timestamp', 'parameters', 'duration', 'version', 'tags'],
              parameters=['kPlus', 'kMinus', 'appliedPotential', 'bulkSuppressor', 'Nx'])


Out[4]:
LabelTimestampParametersDurationVersionTags
ce1057ad2013-11-01 19:01kPlus: 10000.0, kMinus: 6158482.11066, appliedPotential: -0.25, bulkSuppressor: 0.02, Nx: 20010m 46.53s71e554bd8a2afig3a_nx200
289187a12013-11-01 19:02kPlus: 10000.0, kMinus: 37926901.9073, appliedPotential: -0.25, bulkSuppressor: 0.02, Nx: 2001h 10m 14.36s71e554bd8a2afig3a_nx200
b66e270a2013-11-01 19:01kPlus: 10000.0, kMinus: 233572146.909, appliedPotential: -0.25, bulkSuppressor: 0.02, Nx: 2002h 3m 50.32s71e554bd8a2afig3a_nx200
af1b6c932013-11-01 19:01kPlus: 10000.0, kMinus: 1000000000.0, appliedPotential: -0.25, bulkSuppressor: 0.02, Nx: 2003h 5m 9.44s71e554bd8a2afig3a_nx200
2cca56b42013-11-01 19:02kPlus: 2335.72146909, kMinus: 6158482.11066, appliedPotential: -0.25, bulkSuppressor: 0.02, Nx: 20012m 30.03s71e554bd8a2afig3a_nx200
ea4e58782013-11-01 19:01kPlus: 2335.72146909, kMinus: 37926901.9073, appliedPotential: -0.25, bulkSuppressor: 0.02, Nx: 2001h 38m 27.88s71e554bd8a2afig3a_nx200
6a8d5cf72013-11-01 19:01kPlus: 2335.72146909, kMinus: 233572146.909, appliedPotential: -0.25, bulkSuppressor: 0.02, Nx: 2002h 30m 26.38s71e554bd8a2afig3a_nx200
37e05d4d2013-11-01 19:01kPlus: 2335.72146909, kMinus: 1000000000.0, appliedPotential: -0.25, bulkSuppressor: 0.02, Nx: 2002h 28m 59.01s71e554bd8a2afig3a_nx200
74956cdd2013-11-01 19:02kPlus: 379.269019073, kMinus: 6158482.11066, appliedPotential: -0.25, bulkSuppressor: 0.02, Nx: 20012m 35.75s71e554bd8a2afig3a_nx200
051d09bd2013-11-01 19:01kPlus: 379.269019073, kMinus: 37926901.9073, appliedPotential: -0.25, bulkSuppressor: 0.02, Nx: 2001h 36m 2.71s71e554bd8a2afig3a_nx200
376771f12013-11-01 19:01kPlus: 379.269019073, kMinus: 233572146.909, appliedPotential: -0.25, bulkSuppressor: 0.02, Nx: 2002h 37m 20.17s71e554bd8a2afig3a_nx200
48fc04a52013-11-01 19:01kPlus: 379.269019073, kMinus: 1000000000.0, appliedPotential: -0.25, bulkSuppressor: 0.02, Nx: 2002h 25m 12.70s71e554bd8a2afig3a_nx200
8cd5b45f2013-11-01 19:02kPlus: 61.5848211066, kMinus: 6158482.11066, appliedPotential: -0.25, bulkSuppressor: 0.02, Nx: 20013m 0.36s71e554bd8a2afig3a_nx200
a369d1312013-11-01 19:01kPlus: 61.5848211066, kMinus: 37926901.9073, appliedPotential: -0.25, bulkSuppressor: 0.02, Nx: 2002h 29m 40.42s71e554bd8a2afig3a_nx200
fb30bcbf2013-11-01 19:01kPlus: 61.5848211066, kMinus: 233572146.909, appliedPotential: -0.25, bulkSuppressor: 0.02, Nx: 2002h 13m 55.22s71e554bd8a2afig3a_nx200
08e894db2013-11-01 19:01kPlus: 61.5848211066, kMinus: 1000000000.0, appliedPotential: -0.25, bulkSuppressor: 0.02, Nx: 2002h 10m 32.52s71e554bd8a2afig3a_nx200

In [5]:
import pandas as pd
from featureProperty import FeatureProperty
import itertools

flatRecords = []
for l in reorderedRecords:
    for r in l:
        flatRecords.append(r)
        
fps = [FeatureProperty(r) for r in flatRecords]

latestIndex = max([fp.getLatestIndex() for fp in fps])

columns = zip(*list(itertools.product(flatRecords, ('times', 'heights'))))
columns = pd.MultiIndex.from_arrays(columns)

height_df = pd.DataFrame(columns=columns, index=np.arange(0, latestIndex + 1, 100))

for fp in fps:
    latestIndex = fp.getLatestIndex()
    for i in np.arange(0, latestIndex + 1, 100):
        height_df[(fp.record, 'times')][i] = fp.getTime(i)
        height_df[(fp.record, 'heights')][i] = fp.getHeight(i)
    fp.close()

In [6]:
from matplotlib.ticker import MultipleLocator
ml = MultipleLocator(100)

for r in flatRecords:
    x, y = np.array(height_df[(r, 'times')].dropna()[1:]), np.array(height_df[(r, 'heights')].dropna()[1:])
    plt.figure()
    ax = plt.subplot(111)
    plt.title(r.label[:8])
    if x[-1] < 500:
        ml = MultipleLocator(10)
    else:
        ml = MultipleLocator(100)
    ax.xaxis.set_minor_locator(ml)
    
    plt.grid(b=True, which='major', linestyle='solid')
    plt.grid(b=True, which='minor', linestyle='dashed') 
    plt.plot(x, y)



In [ ]:


In [ ]: