In [18]:
%%python3
# import cPickle as pickle
import pickle
import numpy as np
with open('tp','rb') as f:  # Python 3: open(..., 'rb')
   hdist,tst_data = pickle.load(f)
#    hdist = np.array(hdist).reshape([512,512]);
    
pickle.dump([hdist,tst_data], open('tp','wb'),protocol = 2)
# import hdi
# print( hdist.shape)
# print(len(tst_data[0][0][0]))
# print(list(hdist))
# print(tst_data)

In [50]:
import KBs
kb = KBs.kb_2dntca()
kb.rulestr2alias("184af6a375706e604132428008")


Out[50]:
'b3kqr2a5eijk4ikty7c6acn8s3eijky2a5cejknq4jnwyz7ce6ack'

In [52]:
%%bash
# python rstr2html.py 2dntca_184af6a375706e604132428008
export query=2dntca_184af6a375706e604132428008
runipy calc_temp.ipynb temp_$query.ipynb 2>&1 | tee -a some_file
# %%bash
query=2dntca_184af6a375706e604132428008
ipython nbconvert temp_$query.ipynb --to html 2>&1 | tee -a some_file


10/29/2017 01:56:13 AM INFO: Reading notebook calc_temp.ipynb
10/29/2017 01:56:14 AM INFO: Running cell:
from astropy.convolution import *
import sys
import os
sys.path.append(os.path.abspath('..'))
%matplotlib notebook
# utils=os.path.abspath('..')
from utils import *
import time
from KBs import *


global log
log = []

10/29/2017 01:56:15 AM INFO: Cell returned
10/29/2017 01:56:15 AM INFO: Running cell:
(HTML(tog))


10/29/2017 01:56:15 AM INFO: Cell returned
10/29/2017 01:56:15 AM INFO: Running cell:
# convolve_int=lambda a,fir,method:np.around(convolve(a,fir,method)).astype(np.int);

def csv2dat(fname):
    import csv 
    import numpy as np
    global log
    dat=[];
    with open(fname, 'r') as csvfile:
        spamreader = csv.reader(csvfile, delimiter='\t')
        for row in (spamreader):
            dat+=[row];

    log = log + ['Used \''+fname+'\' as input '];


    return (np.array(dat));

# if not 'input_rulestr' in locals():
#     input_rulestr='000000000060031c61c67f86a0';
# input_rulestr
# CA_sys

10/29/2017 01:56:15 AM INFO: Cell returned
10/29/2017 01:56:15 AM INFO: Running cell:
def profile(input_list, log = []):
    # global log
    output_data=[];    
    repeat=2;
    # input_list=[input_rulestr];
    ipt_list=input_list*repeat;
    # for i in range(5):
    l_ipt=len(input_list)
    log += ['Log of the process:'];
    logs='Starting to profile {:d} rules at {:d} replicates,\n totaling {:d} instances'.format(l_ipt,repeat,l_ipt*repeat);
    log += [logs];
    # print('Starting to profile {:d} rules at {:d} replicates,\n totaling {:d} instances'.format(l_ipt,repeat,l_ipt*repeat))

    for num,rulestr in enumerate(ipt_list):
        ca1=CA_sys(familyname,rulestr,[400,100,400]);
        ca1.rulestr2alias();
        s=measure_temperature(ca1,hdist);
        output_data+=[s];
    #     print('{:d} of {:d}'.format(num,len(ipt_list)))
        logs =('{:d} of {:d} '.format(num,len(ipt_list)));
        log += [logs];
    temp_data=[];
    # sample_data=[]
    for line in output_data:
        temp_data+=[line.rstrip('\n').split('\t')];
    sample_data=np.array(temp_data)
    # print('data is succesfully generated at {:d} replicates'.format(repeat))
    logs=('data is succesfully generated at {:d} replicates'.format(repeat))

    log  += [logs];

    # print('\n Detail of the input:')
    logs='\n Detail of the input:';
    log+=[logs];
    for k,v in ca1.__dict__.items():
        if not callable(v):
    #         print(k+str(v).ljust(-10))
    #         print("{:5} {:<15} {:<10}".format('',k, str(v)))

            logs=("{:5} {:<15} {:<10}".format('',k, str(v)));
            log+=[logs];
    return( [sample_data,log]);

10/29/2017 01:56:15 AM INFO: Cell returned
10/29/2017 01:56:15 AM INFO: Running cell:
# #test
# ca1=CA_sys('2dntca',input_rulestr,[600,100,400]);
# ca1.rulestr2alias();
# s=measure_temperature(ca1,hdist);
# output_data=[];
from os import environ
# global log
# log=[];
if 'query' not in locals():
    query = environ.get('query');
    
print query
if not query==None:        
    query = environ['query'];
    if query[-4:]=='.csv':
        query_type = 'csv';
    else:
        query_type = 'rulestr';
#             familyname, input_rulestr = query.split('_');
else:
#     familynam
    query='2dntca_000000000060031c61c67f86a0';
    query_type = 'rulestr'
#         familyname, input_rulestr = query.split('_');
    log+=['fail to fetch query, using default rule, B3/S23 \n' +
    'example query:'+query];
    ## Using B3/S23 as example

if query_type == 'csv':
#     sample_dat, log = 
    sample_data=csv2dat('../calc_temp_data/'+query);
    print('data loaded')
if query_type == 'rulestr':
    familyname, input_rulestr = query.split('_');
    sample_data,log = profile([input_rulestr],log)
    log+=['data generated for '+query];

10/29/2017 01:56:19 AM INFO: Cell returned
10/29/2017 01:56:19 AM INFO: Running cell:
# import numpy as np

# # TEST sample_data
# sample_data=np.array([['2dntca_b3ianjrecqyks2ac3i2e3a2k3nj2i3re2n3cqyk',
#         '000000000060031c61c67f86a0', '99', '0.148772', '0.087523',
#         '0.089563'],
#        ['2dntca_b3ianjrecqyks2ac3i2e3a2k3nj2i3re2n3cqyk',
#         '000000000060031c61c67f86a0', '99', '0.152794', '0.086693',
#         '0.091644'],
#        ['2dntca_b3ianjrecqyks2ac3i2e3a2k3nj2i3re2n3cqyk',
#         '000000000060031c61c67f86a0', '99', '0.148733', '0.089657',
#         '0.089387'],
#        ['2dntca_b3ianjrecqyks2ac3i2e3a2k3nj2i3re2n3cqyk',
#         '000000000060031c61c67f86a0', '99', '0.150105', '0.092000',
#         '0.090981'],
#        ['2dntca_b3ianjrecqyks2ac3i2e3a2k3nj2i3re2n3cqyk',
#         '000000000060031c61c67f86a0', '99', '0.153150', '0.089772',
#         '0.090938']], 
#       dtype='<U46')

10/29/2017 01:56:19 AM INFO: Cell returned
10/29/2017 01:56:19 AM INFO: Running cell:
viewer='''<script src="lv-plugin.js"></script>\n
<meta name="LifeViewer" content="viewer textarea 60 hide">\n
<div class="viewer" id="viewer"><textarea id="textarea">bob!</textarea><br><canvas id="cv1" width="480" height="480"></canvas></div>\n''';
# HTML(viewer)

10/29/2017 01:56:19 AM INFO: Cell returned
10/29/2017 01:56:19 AM INFO: Running cell:
%%html
<script>
String.prototype.formatUnicorn = String.prototype.formatUnicorn ||
function () {
    "use strict";
    var str = this.toString();
    if (arguments.length) {
        var t = typeof arguments[0];
        var key;
        var args = ("string" === t || "number" === t) ?
            Array.prototype.slice.call(arguments)
            : arguments[0];

        for (key in args) {
            str = str.replace(new RegExp("\\{" + key + "\\}", "gi"), args[key]);
        }
    }

    return str;
};

var s= new String("");
var soup=new String("3bo4b11o2b2ob2o2bobo$obobo2bo3bobo3bo2bob3ob2o$2b3obobob6o3b5o2bo2bo$bob2o3b2ob2ob3o4bo5bob2o$2o3b3o3bob4ob2o4bobob2o$5bo4bo4b2obo3b3o2bo$o2bob3obob4o4b3obob2obobo$3bo4bob5o5b3ob2o2b2o$2b3obob2ob4o2bo3bobo3bo$bo4bob2ob6obo3bo4bob2o$5b4obo3bo4bo5bo2bo$ob2obobo2bob2o2bobo2bo2b2o4bo$obo2b2ob2o2b2o3bo2b2obobob4o$6ob2ob2o3b2ob4obo3bob2o$3ob3obo2b3ob4ob4o5bo$obobo7bo3b2o6b3o3bo$bob3o6bob2ob2o3b4obob2o$o2b2o2bo2bo2bobob7ob2o3bo$2obo2bo2b5ob2obo3b2o4b2o$b2o2bob5obo2b5o2bob4o$2o2b4ob2ob4obo3bob3obo2bo$b2o3bo2bo3b6o2bo3bo2bo$bobo3b2ob2o3b3obo3bo5bo$o4b8obobobobob2ob2ob2o$3obo3b4obo3bob3obobo$o3b2obobob2o2b2o5bob2o$6bo5bob2o3b2obo2b2obo$7bo2b2obo2bobobo3bobo2b2o$2o4b7o4bo2b2ob2o3bo$o2bo3bobo3b4o2bo3b2obobo!");
var rule="b3s23578";
var template="x = 300, y = 300, rule = {0} \n {1}";
var div_template="<textarea>{0}</textarea><br><canvas width=\"480\" height=\"480\" tabindex=\"1\"></canvas>";

//s=template.formatUnicorn("B3/S23","bbboooobbbboo!");
//var s="<textarea>x = 300, y = 300, rule = B3/S238 \nbobbbbbbooooooo!</textarea><br><canvas width=\"480\" height=\"480\"></canvas>";
//alert(s)
var s = template.formatUnicorn(rule,soup)
//document.getElementById("viewer").innerHTML = s;
</script>





10/29/2017 01:56:19 AM INFO: Cell returned
10/29/2017 01:56:19 AM INFO: Running cell:


10/29/2017 01:56:19 AM INFO: Cell returned
10/29/2017 01:56:19 AM INFO: Running cell:
### Plotting sample_data

%matplotlib inline

# mpld3.enable_notebook()
from graphics import *
fig, ax = plt.subplots(subplot_kw=dict(axisbg='#DDDDDD'
#                                        ,projection='3d'
                                      ))
fig.set_size_inches([6,6])

ax.grid(color='white', linestyle='solid')
ax.set_ylim(-.1,0.38)
ax.set_xlim(0,1)

fig2,ax2=plt.subplots(subplot_kw=dict(axisbg='#DDDDDD'
                                       ,projection='3d'
                                      ))
fig2.set_size_inches([10,10])
# fig2.subplots_adjust(left=0.2, right=0.8, top=0.9, bottom=0.3)

ax2.grid(color='white', linestyle='solid')
ax2.set_ylim(-.1,0.38)
ax2.set_xlim(0,1)

fig,ax,fig2,ax2 = make_figure((fig,ax,fig2,ax2),sample_data)
fig.set_size_inches([7,7])
ax.set_ylim(-.1,0.38)
ax.set_xlim(0,1)

# display(HTML(viewer))



mpld3.display(fig)
# mpld3.display(fig2)





10/29/2017 01:56:20 AM INFO: Cell returned
10/29/2017 01:56:20 AM INFO: Running cell:
# len(KBs.henseldict)
# len(KBs.rca2ntca)
# KBs.henseldict[:51]
from KBs import *
import itertools
import collections
if 1:
        OUT = ''
        rulestr =  '000000000060031c61c67f86a0'
        r=hex2bin(rulestr,102);
        r=r[::-1];
        rule=[i for i,x in enumerate(r) if x=='1'];
#         print r
        lst = [henseldict[i] for i in rule]
        lst.sort()
        
        #### group by B/S
        d = collections.OrderedDict((('b',{}),('s',{}))) ### set default
#         d = {'b':{},'s':{}}   ### set default
        d.update(
            {k:list(gp) for k,gp in itertools.groupby(lst, lambda x:x[0])}        
        )
        for k,lst in d.iteritems():
            d[k] = {k:list(gp) for k,gp in itertools.groupby(lst, lambda x:x[1])}
            
        for bs, dd in d.iteritems():
            OUT += bs
            for k,lst in dd.iteritems():
                OUT += k + ''.join( conf[-1] for conf in lst)
        OUT = OUT.replace('_','')
        alias = OUT
#         return OUT
print OUT
# t

10/29/2017 01:56:20 AM INFO: Cell returned
10/29/2017 01:56:20 AM INFO: Running cell:
import numpy as np

sum(float(x)>0.3 for x in list(sample_data[:,3]))/sample_data.shape[0]

10/29/2017 01:56:20 AM INFO: Cell returned
10/29/2017 01:56:20 AM INFO: Running cell:
# len(ntca_list)
# .shape
# print(tst_data)
print('\n'.join(log));

10/29/2017 01:56:20 AM INFO: Cell returned
10/29/2017 01:56:20 AM INFO: Running cell:
# from nbconvert import HTMLExporter
# import codecs
# import nbformat
# exporter = HTMLExporter()
# # execfile()
# output_notebook = nbformat.read('calc_temp.ipynb', as_version=4)
# output, resources = exporter.from_notebook_node(output_notebook)
# codecs.open('test.html', 'w', encoding='utf-8').write(output)

10/29/2017 01:56:20 AM INFO: Cell returned
10/29/2017 01:56:20 AM INFO: Saving to temp_2dntca_184af6a375706e604132428008.ipynb
10/29/2017 01:56:20 AM INFO: Shutdown kernel
[TerminalIPythonApp] WARNING | Subcommand `ipython nbconvert` is deprecated and will be removed in future versions.
[TerminalIPythonApp] WARNING | You likely want to use `jupyter nbconvert` in the future
[NbConvertApp] Converting notebook temp_2dntca_184af6a375706e604132428008.ipynb to html
[NbConvertApp] Writing 488970 bytes to temp_2dntca_184af6a375706e604132428008.html

In [5]:
import KBs as 
def worker(x):
#         ca1=KBs.CA_sys(familyname,rulestr,[400,100,400]);
		# ca1.rulestr2alias();
		s = KBs.measure_temperature(ca1,hdist);
		sample_data = [s.rstrip('\n').split('\t')]
		#     return 1

import multiprocessing as mp

ncore = mp.cpu_count()
para = ncore // 2

def pmap(it,worker, para = 1):
    if __name__=='__main__':
        if para > 1:
            pool = mp.Pool( para)
            res = pool.map(worker, it)
    #         print res
    #         pool.join()
            pool.close()
        else:
            res = map(worker, it)
    return res
pmap([1],worker, mp.cpu_count() // 2 )


Out[5]:
[1]

In [53]:
%%bash 
python rstr2html.py ../calc_temp_data/result_count0.csv


../calc_temp_data/result_count0.csv
Created new window in existing browser session.
/home/shouldsee/.local/lib/python2.7/site-packages/IPython/nbformat.py:13: ShimWarning: The `IPython.nbformat` package has been deprecated since IPython 4.0. You should import from nbformat instead.
  "You should import from nbformat instead.", ShimWarning)
/home/shouldsee/.local/lib/python2.7/site-packages/nbformat/current.py:19: UserWarning: nbformat.current is deprecated.

- use nbformat for read/write/validate public API
- use nbformat.vX directly to composing notebooks of a particular version

  """)
10/29/2017 08:56:26 AM INFO: Reading notebook calc_temp.ipynb
10/29/2017 08:56:27 AM INFO: Running cell:
from astropy.convolution import *
import sys
import os
sys.path.append(os.path.abspath('..'))
%matplotlib notebook
# utils=os.path.abspath('..')
from utils import *
import time
from KBs import *


global log
log = []

10/29/2017 08:56:28 AM INFO: Cell returned
10/29/2017 08:56:28 AM INFO: Running cell:
(HTML(tog))


10/29/2017 08:56:28 AM INFO: Cell returned
10/29/2017 08:56:28 AM INFO: Running cell:
# convolve_int=lambda a,fir,method:np.around(convolve(a,fir,method)).astype(np.int);

def csv2dat(fname):
    import csv 
    import numpy as np
    global log
    dat=[];
    with open(fname, 'r') as csvfile:
        spamreader = csv.reader(csvfile, delimiter='\t')
        for row in (spamreader):
            dat+=[row];

    log = log + ['Used \''+fname+'\' as input '];


    return (np.array(dat));

# if not 'input_rulestr' in locals():
#     input_rulestr='000000000060031c61c67f86a0';
# input_rulestr
# CA_sys

10/29/2017 08:56:28 AM INFO: Cell returned
10/29/2017 08:56:28 AM INFO: Running cell:
def profile(input_list, log = []):
    # global log
    output_data=[];    
    repeat=2;
    # input_list=[input_rulestr];
    ipt_list=input_list*repeat;
    # for i in range(5):
    l_ipt=len(input_list)
    log += ['Log of the process:'];
    logs='Starting to profile {:d} rules at {:d} replicates,\n totaling {:d} instances'.format(l_ipt,repeat,l_ipt*repeat);
    log += [logs];
    # print('Starting to profile {:d} rules at {:d} replicates,\n totaling {:d} instances'.format(l_ipt,repeat,l_ipt*repeat))

    for num,rulestr in enumerate(ipt_list):
        ca1=CA_sys(familyname,rulestr,[400,100,400]);
        ca1.rulestr2alias();
        s=measure_temperature(ca1,hdist);
        output_data+=[s];
    #     print('{:d} of {:d}'.format(num,len(ipt_list)))
        logs =('{:d} of {:d} '.format(num,len(ipt_list)));
        log += [logs];
    temp_data=[];
    # sample_data=[]
    for line in output_data:
        temp_data+=[line.rstrip('\n').split('\t')];
    sample_data=np.array(temp_data)
    # print('data is succesfully generated at {:d} replicates'.format(repeat))
    logs=('data is succesfully generated at {:d} replicates'.format(repeat))

    log  += [logs];

    # print('\n Detail of the input:')
    logs='\n Detail of the input:';
    log+=[logs];
    for k,v in ca1.__dict__.items():
        if not callable(v):
    #         print(k+str(v).ljust(-10))
    #         print("{:5} {:<15} {:<10}".format('',k, str(v)))

            logs=("{:5} {:<15} {:<10}".format('',k, str(v)));
            log+=[logs];
    return( [sample_data,log]);

10/29/2017 08:56:28 AM INFO: Cell returned
10/29/2017 08:56:28 AM INFO: Running cell:
# #test
# ca1=CA_sys('2dntca',input_rulestr,[600,100,400]);
# ca1.rulestr2alias();
# s=measure_temperature(ca1,hdist);
# output_data=[];
from os import environ
# global log
# log=[];
if 'query' not in locals():
    query = environ.get('query',None);
    
# print query
if not query==None:        
    query = environ['query'];
    if query[-4:]=='.csv':
        query_type = 'csv';
    else:
        query_type = 'rulestr';
#             familyname, input_rulestr = query.split('_');
else:
#     familynam
    query='2dntca_000000000060031c61c67f86a0';
    query_type = 'rulestr'
#         familyname, input_rulestr = query.split('_');
    log+=['fail to fetch query, using default rule, B3/S23 \n' +
    'example query:'+query];
    ## Using B3/S23 as example

if query_type == 'csv':
#     sample_dat, log = 
    sample_data=csv2dat('../calc_temp_data/'+query);
    print('data loaded')
if query_type == 'rulestr':
    familyname, input_rulestr = query.split('_');
    sample_data,log = profile([input_rulestr],log)
    log+=['data generated for '+query];

10/29/2017 08:56:28 AM INFO: Cell returned
10/29/2017 08:56:28 AM INFO: Running cell:
# import numpy as np

# # TEST sample_data
# sample_data=np.array([['2dntca_b3ianjrecqyks2ac3i2e3a2k3nj2i3re2n3cqyk',
#         '000000000060031c61c67f86a0', '99', '0.148772', '0.087523',
#         '0.089563'],
#        ['2dntca_b3ianjrecqyks2ac3i2e3a2k3nj2i3re2n3cqyk',
#         '000000000060031c61c67f86a0', '99', '0.152794', '0.086693',
#         '0.091644'],
#        ['2dntca_b3ianjrecqyks2ac3i2e3a2k3nj2i3re2n3cqyk',
#         '000000000060031c61c67f86a0', '99', '0.148733', '0.089657',
#         '0.089387'],
#        ['2dntca_b3ianjrecqyks2ac3i2e3a2k3nj2i3re2n3cqyk',
#         '000000000060031c61c67f86a0', '99', '0.150105', '0.092000',
#         '0.090981'],
#        ['2dntca_b3ianjrecqyks2ac3i2e3a2k3nj2i3re2n3cqyk',
#         '000000000060031c61c67f86a0', '99', '0.153150', '0.089772',
#         '0.090938']], 
#       dtype='<U46')

10/29/2017 08:56:28 AM INFO: Cell returned
10/29/2017 08:56:28 AM INFO: Running cell:
viewer='''<script src="lv-plugin.js"></script>\n
<meta name="LifeViewer" content="viewer textarea 60 hide">\n
<div class="viewer" id="viewer"><textarea id="textarea">bob!</textarea><br><canvas id="cv1" width="480" height="480"></canvas></div>\n''';
# HTML(viewer)

10/29/2017 08:56:28 AM INFO: Cell returned
10/29/2017 08:56:28 AM INFO: Running cell:
%%html
<script>
String.prototype.formatUnicorn = String.prototype.formatUnicorn ||
function () {
    "use strict";
    var str = this.toString();
    if (arguments.length) {
        var t = typeof arguments[0];
        var key;
        var args = ("string" === t || "number" === t) ?
            Array.prototype.slice.call(arguments)
            : arguments[0];

        for (key in args) {
            str = str.replace(new RegExp("\\{" + key + "\\}", "gi"), args[key]);
        }
    }

    return str;
};

var s= new String("");
var soup=new String("3bo4b11o2b2ob2o2bobo$obobo2bo3bobo3bo2bob3ob2o$2b3obobob6o3b5o2bo2bo$bob2o3b2ob2ob3o4bo5bob2o$2o3b3o3bob4ob2o4bobob2o$5bo4bo4b2obo3b3o2bo$o2bob3obob4o4b3obob2obobo$3bo4bob5o5b3ob2o2b2o$2b3obob2ob4o2bo3bobo3bo$bo4bob2ob6obo3bo4bob2o$5b4obo3bo4bo5bo2bo$ob2obobo2bob2o2bobo2bo2b2o4bo$obo2b2ob2o2b2o3bo2b2obobob4o$6ob2ob2o3b2ob4obo3bob2o$3ob3obo2b3ob4ob4o5bo$obobo7bo3b2o6b3o3bo$bob3o6bob2ob2o3b4obob2o$o2b2o2bo2bo2bobob7ob2o3bo$2obo2bo2b5ob2obo3b2o4b2o$b2o2bob5obo2b5o2bob4o$2o2b4ob2ob4obo3bob3obo2bo$b2o3bo2bo3b6o2bo3bo2bo$bobo3b2ob2o3b3obo3bo5bo$o4b8obobobobob2ob2ob2o$3obo3b4obo3bob3obobo$o3b2obobob2o2b2o5bob2o$6bo5bob2o3b2obo2b2obo$7bo2b2obo2bobobo3bobo2b2o$2o4b7o4bo2b2ob2o3bo$o2bo3bobo3b4o2bo3b2obobo!");
var rule="b3s23578";
var template="x = 300, y = 300, rule = {0} \n {1}";
var div_template="<textarea>{0}</textarea><br><canvas width=\"480\" height=\"480\" tabindex=\"1\"></canvas>";

//s=template.formatUnicorn("B3/S23","bbboooobbbboo!");
//var s="<textarea>x = 300, y = 300, rule = B3/S238 \nbobbbbbbooooooo!</textarea><br><canvas width=\"480\" height=\"480\"></canvas>";
//alert(s)
var s = template.formatUnicorn(rule,soup)
//document.getElementById("viewer").innerHTML = s;
</script>





10/29/2017 08:56:28 AM INFO: Cell returned
10/29/2017 08:56:28 AM INFO: Running cell:


10/29/2017 08:56:28 AM INFO: Cell returned
10/29/2017 08:56:28 AM INFO: Running cell:
### Plotting sample_data

%matplotlib inline

# mpld3.enable_notebook()
from graphics import *
fig, ax = plt.subplots(subplot_kw=dict(axisbg='#DDDDDD'
#                                        ,projection='3d'
                                      ))
fig.set_size_inches([6,6])

ax.grid(color='white', linestyle='solid')
ax.set_ylim(-.1,0.38)
ax.set_xlim(0,1)

fig2,ax2=plt.subplots(subplot_kw=dict(axisbg='#DDDDDD'
                                       ,projection='3d'
                                      ))
fig2.set_size_inches([10,10])
# fig2.subplots_adjust(left=0.2, right=0.8, top=0.9, bottom=0.3)

ax2.grid(color='white', linestyle='solid')
ax2.set_ylim(-.1,0.38)
ax2.set_xlim(0,1)

fig,ax,fig2,ax2 = make_figure((fig,ax,fig2,ax2),sample_data)
fig.set_size_inches([7,7])
ax.set_ylim(-.1,0.38)
ax.set_xlim(0,1)

# display(HTML(viewer))



mpld3.display(fig)
# mpld3.display(fig2)





10/29/2017 08:56:31 AM INFO: Cell returned
10/29/2017 08:56:32 AM INFO: Running cell:
# len(KBs.henseldict)
# len(KBs.rca2ntca)
# KBs.henseldict[:51]
from KBs import *
import itertools
import collections
if 1:
        OUT = ''
        rulestr =  '000000000060031c61c67f86a0'
        r=hex2bin(rulestr,102);
        r=r[::-1];
        rule=[i for i,x in enumerate(r) if x=='1'];
#         print r
        lst = [henseldict[i] for i in rule]
        lst.sort()
        
        #### group by B/S
        d = collections.OrderedDict((('b',{}),('s',{}))) ### set default
#         d = {'b':{},'s':{}}   ### set default
        d.update(
            {k:list(gp) for k,gp in itertools.groupby(lst, lambda x:x[0])}        
        )
        for k,lst in d.iteritems():
            d[k] = {k:list(gp) for k,gp in itertools.groupby(lst, lambda x:x[1])}
            
        for bs, dd in d.iteritems():
            OUT += bs
            for k,lst in dd.iteritems():
                OUT += k + ''.join( conf[-1] for conf in lst)
        OUT = OUT.replace('_','')
        alias = OUT
#         return OUT
# print OUT
# t

10/29/2017 08:56:32 AM INFO: Cell returned
10/29/2017 08:56:32 AM INFO: Running cell:
import numpy as np

sum(float(x)>0.3 for x in list(sample_data[:,3]))/sample_data.shape[0]

10/29/2017 08:56:32 AM INFO: Cell returned
10/29/2017 08:56:32 AM INFO: Running cell:
# len(ntca_list)
# .shape
# print(tst_data)
print('\n'.join(log));

10/29/2017 08:56:32 AM INFO: Cell returned
10/29/2017 08:56:32 AM INFO: Running cell:
# from nbconvert import HTMLExporter
# import codecs
# import nbformat
# exporter = HTMLExporter()
# # execfile()
# output_notebook = nbformat.read('calc_temp.ipynb', as_version=4)
# output, resources = exporter.from_notebook_node(output_notebook)
# codecs.open('test.html', 'w', encoding='utf-8').write(output)

10/29/2017 08:56:32 AM INFO: Cell returned
10/29/2017 08:56:32 AM INFO: Saving to temp.ipynb
10/29/2017 08:56:32 AM INFO: Shutdown kernel

In [2]:



is in ipython: 1
[WARN] pymisca.vis_util cannot find network

In [30]:
from pymisca.util import *
from pymisca.vis_util import *
import KBs
kb = KBs.kb_2dntca()
r = "184af6a375706e604132428008"
kb.rulestr2alias(r)
# ??kb.rulestr2adv(r)


Out[30]:
'b3kqr2a5eijk4ikty7c6acn8s3eijky2a5cejknq4jnwyz7ce6ack'

In [27]:
# KBs.
# KBs.
# r = 
sysX = KBs.CA_sys('2dntca',r,(30,30,30))
sysX.rulestr2alias()
# KBs.
avc=sysX.rdf()
i = 1
# avc=(sysX.adv(avc,i))
# avc 
plt.imshow(avc[0,:,:])
plt.show()



In [21]:
??KBs.measure_temperature