Skip to content

Instantly share code, notes, and snippets.

@domitry
Created May 28, 2015 10:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save domitry/d5f1131717db31678539 to your computer and use it in GitHub Desktop.
Save domitry/d5f1131717db31678539 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Requirements\n",
"This notebook needs WebGL support. \n",
"Please check it with http://get.webgl.org/ \n",
"If you can see the cube movie, your browser supports WebGL."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from ecell4.core import *\n",
"from ecell4.bd import BDWorld\n",
"from ecell4.lattice import LatticeWorld\n",
"from ecell4.util import viz"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"w = LatticeWorld(Real3(1, 1, 1), voxel_radius=0.0025)\n",
"#w = BDWorld(Real3(1, 1, 1))"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"A = Species(\"A\", \"0.0025\", \"1\")\n",
"w.add_molecules(A, 60)\n",
"w.add_molecules(Species(\"B\", \"0.005\", \"0.5\"), 60)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<html>\n",
" <head>\n",
" <script type=\"text/javascript\">\n",
" (function(){\n",
" if(window[\"THREE\"] === undefined || window[\"d3\"] === undefined){\n",
"\t require.config({\n",
"\t paths:{\n",
"\t d3: [\n",
"\t 'https://cdnjs.cloudflare.com/ajax/libs/d3/3.4.4/d3.min',\n",
"\t 'custom/d3.min'\n",
"\t ],\n",
"\t THREE: [\n",
"\t 'https://cdnjs.cloudflare.com/ajax/libs/three.js/r66/three.min',\n",
"\t 'custom/three.min'\n",
"\t ],\n",
" Elegans: [\n",
"\t 'https://rawgit.com/domitry/elegans/master/release/elegans',\n",
"\t 'custom/elegans'\n",
"\t ]\n",
"\t },\n",
"\t shim:{\n",
"\t THREE: {\n",
"\t exports: 'THREE'\n",
"\t },\n",
"\t Elegans: {\n",
"\t deps: ['THREE'],\n",
"\t exports: 'Elegans'\n",
"\t }\n",
"\t }\n",
"\t });\n",
"\n",
"\t require([\"d3\", \"THREE\"], function(d3){\n",
"\t window[\"d3\"] = d3;\n",
"\t });\n",
" }\n",
"\n",
" require([\"Elegans\"], function(){\n",
"\t console.log(\"Begin rendering...\");\n",
"\t var model = {\"plots\": [{\"data\": {\"y\": [0.7707626093681504, 0.7014805770653953, 0.42146569650842686, 0.98726896031426, 0.694263698700525, 0.2352702346947725, 0.33486315612998296, 0.5297188719814816, 0.40847531545166027, 0.9930424630061563, 0.783752990424917, 0.7794228634059948, 0.4820874747733375, 0.09670617008926231, 0.3117691453623979, 0.14000744027848425, 0.3262029020921386, 0.8588085254195683, 0.919430303684479, 0.5802370205355739, 0.8400446416709055, 0.515285115251741, 0.2352702346947725, 0.9959292143521045, 0.5297188719814816, 0.4344560775651934, 0.22516660498395405, 0.5990009042842367, 0.07072540797572915, 0.39115480737597147, 0.2569208697893835, 0.031754264805429415, 0.48497422611928565, 0.8270542606141389, 0.34785353718674955, 0.3767210506462308, 0.538379126019326, 0.783752990424917, 0.41713556948950464, 0.3940415587219196, 0.5066248612138966, 0.11258330249197702, 0.34208003449485325, 0.3507402885326977, 0.42868257487329714, 0.22516660498395405, 0.5282754963085076, 0.7794228634059948, 0.536935750346352, 0.672613063605914, 0.4763139720814413, 0.41569219381653055, 0.2958920129596832, 0.9713918279115453, 0.7678758580222023, 0.6798299419707844, 0.762102355330306, 0.650962428511303, 0.9454110657980122, 0.134233937586588], \"x\": [0.7675067860720626, 0.31026870075253593, 0.1755467648994611, 0.1469693845669907, 0.8124140980230875, 0.4123307733685017, 0.5429702263169379, 0.6327848502189878, 0.796084166404533, 0.6899396108839285, 0.6776921621700127, 0.8246615467370034, 0.5837950553633242, 0.8777338244973056, 0.3184336665618132, 0.6654447134560968, 0.19187669651801564, 0.3878358759406699, 0.10206207261596577, 0.8328265125462806, 0.9308061022576077, 0.47356801693808115, 0.8532389270694738, 0.5225578117937447, 0.7062695425024831, 0.012247448713915893, 0.7430118886442307, 0.08573214099741125, 0.2816913204200655, 0.6409498160282651, 0.9348885851622464, 0.5103103630798288, 0.07348469228349536, 0.4164132562731403, 0.16738179909018386, 0.5062278801751902, 0.796084166404533, 0.8573214099741124, 0.6899396108839285, 0.15513435037626797, 0.28577380332470415, 0.718516991216399, 0.7348469228349536, 0.5797125724586856, 0.9226411364483306, 0.563382640840131, 0.6695271963607354, 0.17962924780409975, 0.12247448713915891, 0.07756717518813398, 0.22045407685048604, 0.9879608629225486, 0.6817746450746514, 0.6246198844097105, 0.6736096792653741, 0.08164965809277261, 0.6695271963607354, 0.31435118365717457, 0.6981045766932058, 0.5143928459844674], \"z\": [0.76, 0.705, 0.26, 0.965, 0.9625, 0.6075, 0.335, 0.23750000000000002, 0.6325000000000001, 0.5750000000000001, 0.5325, 0.23500000000000001, 0.735, 0.4875, 0.745, 0.7975, 0.15, 0.4325, 0.2675, 0.765, 0.185, 0.8525, 0.7925, 0.86, 0.7525000000000001, 0.9525, 0.555, 0.9975, 0.1075, 0.7575000000000001, 0.72, 0.595, 0.8, 0.0425, 0.47250000000000003, 0.0475, 0.7325, 0.9775, 0.7725, 0.7175, 0.2575, 0.14, 0.5575, 0.5575, 0.47250000000000003, 0.515, 0.04, 0.925, 0.645, 0.46, 0.485, 0.0, 0.2525, 0.6425, 0.895, 0.6625, 0.27, 0.3275, 0.0275, 0.7625000000000001]}, \"type\": \"Particles\", \"options\": {\"color\": \"#a6cee3\", \"name\": \"A\", \"size\": 0.075}}, {\"data\": {\"y\": [0.8010734985006057, 0.8400446416709055, 0.1053664241271067, 0.005773502691896258, 0.6408587988004846, 0.14289419162443237, 0.9497411928169344, 0.07938566201357354, 0.1818653347947321, 0.2035159698893431, 0.6235382907247958, 0.07794228634059948, 0.6812733176437584, 0.6018876556301849, 0.7274613391789284, 0.11835680518387329, 0.15732794835417302, 0.3391932831489052, 0.6812733176437584, 0.1991858428704209, 0.05196152422706632, 0.8891194145520237, 0.15732794835417302, 0.08227241335952168, 0.6018876556301849, 0.98726896031426, 0.6336419204356143, 0.246817240078565, 0.27424137786507224, 0.46043683967872656, 0.98726896031426, 0.6552925555302253, 0.9540713198358566, 0.18330871046770617, 0.3088823940164498, 0.07938566201357354, 0.04330127018922193, 0.6423021744734586, 0.5455960043841963, 0.7418950959086691, 0.76354573100328, 0.2944486372867091, 0.8313843876330611, 0.9887123359872341, 0.381051177665153, 0.29011851026778696, 0.41569219381653055, 0.9497411928169344, 0.9439676901250381, 0.5470393800571703, 0.34641016151377546, 0.31609927238132013, 0.9843822089683119, 0.6321985447626403, 0.5513695070760926, 0.027424137786507225, 0.5672466394788073, 0.672613063605914, 0.2554774941164094, 0.23382685902179845], \"x\": [0.27760883751542687, 0.7266819570256763, 0.12655697004379754, 0.7879192005952557, 0.32659863237109044, 0.5715476066494083, 0.0530722777603022, 0.8614038928787511, 0.47356801693808115, 0.48173298274735843, 0.9634659654947169, 0.9144761706390533, 0.9267236193529691, 0.8164965809277261, 0.0, 0.24086649137367921, 0.6981045766932058, 0.04490731195102494, 0.8042491322138102, 0.016329931618554522, 0.17962924780409975, 0.265361388801511, 0.3306811152757291, 0.68585712797929, 0.5552176750308537, 0.718516991216399, 0.36334097851283814, 0.5388877434122993, 0.03674234614174768, 0.2735263546107882, 0.4164132562731403, 0.20820662813657015, 0.24086649137367921, 0.37150594432211537, 0.3470110468942836, 0.7552593373581467, 0.8818163074019442, 0.5511351921262151, 0.342928563989645, 0.6082899527911559, 0.6246198844097105, 0.040824829046386304, 0.3674234614174768, 0.11022703842524302, 0.2939387691339814, 0.9634659654947169, 0.530722777603022, 0.3306811152757291, 0.30210373494325865, 0.5103103630798288, 0.7920016834998943, 0.43274318789169486, 0.265361388801511, 0.7021870595978444, 0.6981045766932058, 0.22453655975512468, 0.9634659654947169, 0.22453655975512468, 0.06531972647421809, 0.47356801693808115], \"z\": [0.28750000000000003, 0.715, 0.5425, 0.465, 0.68, 0.1325, 0.615, 0.8875000000000001, 0.8, 0.6875, 0.365, 0.74, 0.385, 0.0625, 0.6950000000000001, 0.47500000000000003, 0.6975, 0.2525, 0.19, 0.545, 0.88, 0.20500000000000002, 0.7175, 0.4575, 0.7775, 0.515, 0.1675, 0.7375, 0.62, 0.4325, 0.915, 0.96, 0.1475, 0.2525, 0.015, 0.3275, 0.675, 0.9775, 0.38, 0.5650000000000001, 0.5725, 0.6900000000000001, 0.065, 0.8925000000000001, 0.28500000000000003, 0.2725, 0.97, 0.71, 0.68, 0.8125, 0.925, 0.9375, 0.09, 0.525, 0.335, 0.6125, 0.2475, 0.24, 0.9625, 0.62]}, \"type\": \"Particles\", \"options\": {\"color\": \"#1f78b4\", \"name\": \"B\", \"size\": 0.15}}], \"options\": {\"save_image\": true, \"height\": 500, \"width\": 500, \"range\": {\"y\": [0.0, 1.0], \"x\": [0.0, 1.0], \"z\": [0.0, 1.0]}, \"grid\": true, \"autorange\": false}};\n",
"\t Elegans.Embed.parse(\"#\"+\"vizc6d43a2b-ba29-4b52-8cf8-6055a1a9e089\",model).render();\n",
" });\n",
" })();\n",
" </script>\n",
" </head>\n",
" <body>\n",
" <div id=\"vizc6d43a2b-ba29-4b52-8cf8-6055a1a9e089\"></div>\n",
" </body>\n",
"</html>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"config = viz.plot_world(w,save_image=True)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"w2 = BDWorld(Real3(1, 1, 1))\n",
"w2.add_molecules(Species(\"A\", \"0.0025\", \"1\"), 60)\n",
"w2.add_molecules(Species(\"B\", \"0.005\", \"0.5\"), 60)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<html>\n",
" <head>\n",
" <script type=\"text/javascript\">\n",
" (function(){\n",
" if(window[\"THREE\"] === undefined || window[\"d3\"] === undefined){\n",
"\t require.config({\n",
"\t paths:{\n",
"\t d3: [\n",
"\t 'https://cdnjs.cloudflare.com/ajax/libs/d3/3.4.4/d3.min',\n",
"\t 'custom/d3.min'\n",
"\t ],\n",
"\t THREE: [\n",
"\t 'https://cdnjs.cloudflare.com/ajax/libs/three.js/r66/three.min',\n",
"\t 'custom/three.min'\n",
"\t ],\n",
" Elegans: [\n",
"\t 'https://rawgit.com/domitry/elegans/master/release/elegans',\n",
"\t 'custom/elegans'\n",
"\t ]\n",
"\t },\n",
"\t shim:{\n",
"\t THREE: {\n",
"\t exports: 'THREE'\n",
"\t },\n",
"\t Elegans: {\n",
"\t deps: ['THREE'],\n",
"\t exports: 'Elegans'\n",
"\t }\n",
"\t }\n",
"\t });\n",
"\n",
"\t require([\"d3\", \"THREE\"], function(d3){\n",
"\t window[\"d3\"] = d3;\n",
"\t });\n",
" }\n",
"\n",
" require([\"Elegans\"], function(){\n",
"\t console.log(\"Begin rendering...\");\n",
"\t var model = {\"plots\": [{\"data\": {\"y\": [0.25703822332434356, 0.9581517204642296, 0.17814941657707095, 0.769920929800719, 0.3985509311314672, 0.4358166086021811, 0.3581561620812863, 0.7247430712450296, 0.9316782364621758, 0.811030545970425, 0.7429781584069133, 0.2920287305023521, 0.21863888180814683, 0.3081168986391276, 0.095880470238626, 0.9705153224058449, 0.6705589634366333, 0.39159945445135236, 0.07403740240260959, 0.8585072439163923, 0.49452689243480563, 0.3534219909925014, 0.2155438878107816, 0.9611692051403224, 0.9895203567575663, 0.7566761723719537, 0.9236432139296085, 0.8995427712798119, 0.2918903701938689, 0.7113813555333763, 0.22703596344217658, 0.26433434803038836, 0.4757940268609673, 0.7565349084325135, 0.9019936611875892, 0.9009291373658925, 0.8767324683722109, 0.5205310876481235, 0.8149475285317749, 0.7631048720795661, 0.20835761609487236, 0.3832484348677099, 0.7237466312944889, 0.7773479884490371, 0.30277953553013504, 0.723000320373103, 0.5859906482510269, 0.6288033921737224, 0.6705468241125345, 0.22183974995277822, 0.9530849871225655, 0.256391140865162, 0.08504689624533057, 0.20838033803738654, 0.5098025742918253, 0.7569901966489851, 0.23675262369215488, 0.7492298826109618, 0.30926024285145104, 0.9370297945570201], \"x\": [0.38225445430725813, 0.5830796943046153, 0.9598902612924576, 0.9450626084581017, 0.0831020234618336, 0.8013147949241102, 0.40215870668180287, 0.21978963539004326, 0.734535813331604, 0.23244700487703085, 0.15482988627627492, 0.9782727204728872, 0.0626243210863322, 0.9373690146021545, 0.251013292465359, 0.22492280113510787, 0.33945828187279403, 0.38784922333434224, 0.46640525152906775, 0.5051999965216964, 0.25929532246664166, 0.4855964928865433, 0.6768967632669955, 0.881524421973154, 0.1809160264674574, 0.8858665097504854, 0.10241238214075565, 0.9422144142445177, 0.18883523880504072, 0.4988688859157264, 0.24938959907740355, 0.7918808227404952, 0.11374216759577394, 0.9669492414686829, 0.5402579833753407, 0.22010675654746592, 0.6754184658639133, 0.8247119644656777, 0.17351289954967797, 0.21235612081363797, 0.5643304598052055, 0.8341082732658833, 0.803286510752514, 0.6741919226478785, 0.6603459489997476, 0.47769270301796496, 0.24780066963285208, 0.10604573832824826, 0.791772787924856, 0.6612614239566028, 0.5717560895718634, 0.3203537499066442, 0.12740059266798198, 0.9056829111650586, 0.49381640926003456, 0.35463880840688944, 0.7460214216262102, 0.617693250766024, 0.9380705987568945, 0.016801654594019055], \"z\": [0.9087892293464392, 0.2183338322211057, 0.6346527813002467, 0.8225691721308976, 0.3110531859565526, 0.7320440257899463, 0.2696343653369695, 0.8388676678296179, 0.6672645274084061, 0.2485917250160128, 0.31125159026123583, 0.8631274062208831, 0.008632202167063951, 0.6192297136876732, 0.3203275599516928, 0.8378392953891307, 0.7982449571136385, 0.31649424927309155, 0.40076137403957546, 0.021439650794491172, 0.39004484424367547, 0.4188316287472844, 0.459485370432958, 0.9282583720050752, 0.8111790216062218, 0.31117049255408347, 0.21123848878778517, 0.12518712738528848, 0.09663880057632923, 0.2624217621050775, 0.4614489609375596, 0.6592204994522035, 0.24482636828906834, 0.8783676335588098, 0.6951864284928888, 0.6299095700960606, 0.1473218642640859, 0.8846810800023377, 0.0440687935333699, 0.9899783381260931, 0.2637038540560752, 0.8975029424764216, 0.6685780344996601, 0.537343050353229, 0.9432844035327435, 0.7214304613880813, 0.8188463668338954, 0.9230485789012164, 0.1288588559255004, 0.5067621674388647, 0.9444234117399901, 0.40179212018847466, 0.14430274674668908, 0.47936464729718864, 0.5502578699961305, 0.053250825963914394, 0.49660315993241966, 0.07894239109009504, 0.19384606671519578, 0.6451009227894247]}, \"type\": \"Particles\", \"options\": {\"color\": \"#a6cee3\", \"name\": \"A\", \"size\": 0.075}}, {\"data\": {\"y\": [0.9197858076076955, 0.44990720110945404, 0.5996752714272588, 0.14087183470837772, 0.19636087003163993, 0.5855204029940069, 0.9092581062577665, 0.19410860119387507, 0.46157061983831227, 0.33664570841938257, 0.11127660423517227, 0.16736053302884102, 0.5547133437357843, 0.03183102048933506, 0.21996160107664764, 0.6402678745798767, 0.658582967473194, 0.7458648106548935, 0.4272851785644889, 0.5342959084082395, 0.08097804407589138, 0.9850332960486412, 0.6855802435893565, 0.2536878869868815, 0.014741345308721066, 0.6463039638474584, 0.014248241670429707, 0.950195305980742, 0.5921006591524929, 0.10567467263899744, 0.6836787008214742, 0.8280171437654644, 0.28205630159936845, 0.7968575942795724, 0.46396692330017686, 0.35529500991106033, 0.5178331874776632, 0.4890769992489368, 0.14940920285880566, 0.9700497195590287, 0.91076066554524, 0.020054230699315667, 0.2904380224645138, 0.3703489874023944, 0.6513963779434562, 0.6562113771215081, 0.5817426030989736, 0.5377130815759301, 0.9658290266525, 0.7360700783319771, 0.5159220779314637, 0.14064105972647667, 0.8248597418423742, 0.10388662293553352, 0.6763584280852228, 0.5059954405296594, 0.5887974330689758, 0.019723626086488366, 0.3558145905844867, 0.8547883091960102], \"x\": [0.03837114665657282, 0.15488278889097273, 0.31651485385373235, 0.1237714714370668, 0.7248164794873446, 0.583859245525673, 0.7888835777994245, 0.35527553386054933, 0.07063354458659887, 0.8982360593508929, 0.8860831076744944, 0.26178569230251014, 0.10698666330426931, 0.5239194047171623, 0.7065555814187974, 0.028057955903932452, 0.3627342637628317, 0.2537586255930364, 0.0895674282219261, 0.10155944339931011, 0.902590521145612, 0.8682507306803018, 0.8551142977084965, 0.780748134944588, 0.4576220375020057, 0.27118392870761454, 0.6492087456863374, 0.2954484508372843, 0.04522363282740116, 0.5144037359859794, 0.5951058978680521, 0.6066052010282874, 0.10761014395393431, 0.13158598192967474, 0.9990482858847827, 0.44608045485801995, 0.3891179084312171, 0.64789745118469, 0.6015464151278138, 0.4341107571963221, 0.12595278210937977, 0.17328640120103955, 0.5871380548924208, 0.9966123246122152, 0.8106276229955256, 0.23254281259141862, 0.5957927852869034, 0.17983563360758126, 0.12167474953457713, 0.6300119026564062, 0.8683184003457427, 0.7213385810609907, 0.043787911999970675, 0.000965694198384881, 0.8807877621147782, 0.5602398701012135, 0.37111326097510755, 0.17197199608199298, 0.9056849654298276, 0.3018101896159351], \"z\": [0.8348721514921635, 0.47434819978661835, 0.2283367079216987, 0.7764621912501752, 0.9428268086630851, 0.4483622561674565, 0.8978801830671728, 0.2647245731204748, 0.4246724774129689, 0.008712587878108025, 0.8307397325988859, 0.1829251463059336, 0.07714865379966795, 0.5568657487165183, 0.8483055355027318, 0.1267984388396144, 0.8249336632434279, 0.2062547707464546, 0.7281222415622324, 0.2213442346546799, 0.3330426518805325, 0.3894046051427722, 0.0924888220615685, 0.5938155683688819, 0.4163796214852482, 0.017202228540554643, 0.6134289551991969, 0.18305278872139752, 0.056773776886984706, 0.9016539126168936, 0.9901128229685128, 0.6190285251941532, 0.2130553564056754, 0.41478242399170995, 0.29164668219164014, 0.751994656631723, 0.6155622226651758, 0.8609446648042649, 0.5571045910473913, 0.06871415977366269, 0.4039121849928051, 0.39471045369282365, 0.7195343358907849, 0.7756643767934293, 0.6715197125449777, 0.5938779802527279, 0.37447410728782415, 0.4019359287340194, 0.6753804618492723, 0.3702026733662933, 0.2001696105580777, 0.1713781231082976, 0.24528901581652462, 0.49368640407919884, 0.9419027778785676, 0.9046419195365161, 0.47118639620020986, 0.21413945662789047, 0.09683964471332729, 0.31853490346111357]}, \"type\": \"Particles\", \"options\": {\"color\": \"#1f78b4\", \"name\": \"B\", \"size\": 0.15}}], \"options\": {\"save_image\": false, \"height\": 500, \"width\": 500, \"range\": {\"y\": [0.0, 1.0], \"x\": [0.0, 1.0], \"z\": [0.0, 1.0]}, \"grid\": true, \"autorange\": false}};\n",
"\t Elegans.Embed.parse(\"#\"+\"viz8d43ead8-c4f8-4fcc-ada9-34679a291adf\",model).render();\n",
" });\n",
" })();\n",
" </script>\n",
" </head>\n",
" <body>\n",
" <div id=\"viz8d43ead8-c4f8-4fcc-ada9-34679a291adf\"></div>\n",
" </body>\n",
"</html>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"{'A': '#a6cee3', 'B': '#1f78b4'}"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"viz.plot_world(w2, config=config)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from ecell4.util import viz"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<html>\n",
" <head>\n",
" <script type=\"text/javascript\">\n",
" (function(){\n",
" if(window[\"THREE\"] === undefined || window[\"d3\"] === undefined){\n",
"\t require.config({\n",
"\t paths:{\n",
"\t d3: [\n",
"\t 'https://cdnjs.cloudflare.com/ajax/libs/d3/3.4.4/d3.min',\n",
"\t 'custom/d3.min'\n",
"\t ],\n",
"\t THREE: [\n",
"\t 'https://cdnjs.cloudflare.com/ajax/libs/three.js/r66/three.min',\n",
"\t 'custom/three.min'\n",
"\t ],\n",
" Elegans: [\n",
"\t 'https://rawgit.com/domitry/elegans/master/release/elegans',\n",
"\t 'custom/elegans'\n",
"\t ]\n",
"\t },\n",
"\t shim:{\n",
"\t THREE: {\n",
"\t exports: 'THREE'\n",
"\t },\n",
"\t Elegans: {\n",
"\t deps: ['THREE'],\n",
"\t exports: 'Elegans'\n",
"\t }\n",
"\t }\n",
"\t });\n",
"\n",
"\t require([\"d3\", \"THREE\"], function(d3){\n",
"\t window[\"d3\"] = d3;\n",
"\t });\n",
" }\n",
"\n",
" require([\"Elegans\"], function(){\n",
"\t console.log(\"Begin rendering...\");\n",
"\t var model = {\"plots\": [{\"data\": {\"y\": [0.046959246741607785, 0.6131232092157006, 0.5427065775729716, 0.3873701731208712, 0.13250695122405887, 0.850381079595536, 0.38214708236046135, 0.737603758694604, 0.5432912320829928, 0.7568529273848981, 0.0372636194806546, 0.7345998208038509, 0.32929920265451074, 0.5684568202123046, 0.7867014112416655, 0.35387130244635046, 0.8638097541406751, 0.531254738336429, 0.9331832034513354, 0.4460128059145063, 0.5305350774433464, 0.9894155429210514, 0.5810057718772441, 0.33415698423050344, 0.40211319690570235, 0.7297535897232592, 0.731245385017246, 0.8208279872778803, 0.3034139131195843, 0.2955765963997692, 0.40037154383026063, 0.2322824103757739, 0.1434189125429839, 0.38591794669628143, 0.9028631430119276, 0.07697103964164853, 0.9653140113223344, 0.9915469440165907, 0.20375736360438168, 0.01109724910929799, 0.8869718238711357, 0.37939025997184217, 0.8905892779584974, 0.1938172890804708, 0.45905678579583764, 0.7421238243114203, 0.9085576042998582, 0.6837345147505403, 0.6312036125455052, 0.10959152085706592, 0.6601419844664633, 0.24788689706474543, 0.3262588642537594, 0.14804636454209685, 0.29135677334852517, 0.21972225070931017, 0.7681246979627758, 0.6269518453627825, 0.48688019695691764, 0.8390182945877314], \"x\": [0.9511311000678688, 0.8567655275110155, 0.6390326258260757, 0.605217510368675, 0.19435864523984492, 0.96796730812639, 0.9010047928895801, 0.6230165672022849, 0.5653864967171103, 0.6732969211880118, 0.8049992665182799, 0.9347646832466125, 0.5438526074867696, 0.5802501495927572, 0.40976904751732945, 0.001929574878886342, 0.7621521053370088, 0.3951857932843268, 0.7949611193034798, 0.35634718323126435, 0.10949247563257813, 0.1561776853632182, 0.6380696173291653, 0.31269887718372047, 0.25551029574126005, 0.15255652810446918, 0.46402494655922055, 0.7348328288644552, 0.03358916286379099, 0.23399338964372873, 0.31680053658783436, 0.38524901820346713, 0.9130258341319859, 0.32863407698459923, 0.9008528131525964, 0.5010559533257037, 0.3390383003279567, 0.8363470146432519, 0.2998347473330796, 0.3819466163404286, 0.308303558267653, 0.4394092874135822, 0.8552710581570864, 0.8299801042303443, 0.09227716806344688, 0.9505002677906305, 0.670337131479755, 0.319160093087703, 0.6664217344950885, 0.9797305823303759, 0.5456912377849221, 0.6651115706190467, 0.5044428729452193, 0.9660294055938721, 0.2712543837260455, 0.31838432140648365, 0.05575602198950946, 0.5894159469753504, 0.9854870822746307, 0.6671913405880332], \"z\": [0.010367459384724498, 0.044043604750186205, 0.9064676333218813, 0.6852235405240208, 0.7486800472252071, 0.6450750667136163, 0.322061879793182, 0.37154940352775156, 0.8945697541348636, 0.16073271189816296, 0.9007023484446108, 0.43408071412704885, 0.6052148346789181, 0.8819183444138616, 0.3077465344686061, 0.07100900379009545, 0.2507731562945992, 0.1002472722902894, 0.8351990194059908, 0.30452856863848865, 0.6624285564757884, 0.8827031690161675, 0.2620891926344484, 0.17378004384227097, 0.3848750351462513, 0.19721062574535608, 0.24393926677294075, 0.9172927073668689, 0.13648272375576198, 0.9244626241270453, 0.9051470817066729, 0.4447696499992162, 0.5311690559610724, 0.604180741822347, 0.848367412108928, 0.40074621536768973, 0.21561749395914376, 0.11591585422866046, 0.2892311541363597, 0.8218096650671214, 0.43983563198708, 0.37343172333203256, 0.16565207880921662, 0.7250724283512682, 0.30224912660196424, 0.6279083278495818, 0.7409055687021464, 0.11819208692759275, 0.44420837238430977, 0.4585388891864568, 0.9744651254732162, 0.43246732489205897, 0.7036065452266484, 0.5537459184415638, 0.38954674475826323, 0.5684219901449978, 0.9585032816976309, 0.023326148511841893, 0.44693920155987144, 0.9581013955175877]}, \"type\": \"Particles\", \"options\": {\"color\": \"#a6cee3\", \"name\": \"A\", \"size\": 0.075}}, {\"data\": {\"y\": [0.07968562562018633, 0.7075592975597829, 0.11818830063566566, 0.15241741901263595, 0.049080769531428814, 0.9417805070988834, 0.6491096534300596, 0.2166565340012312, 0.0689095736015588, 0.9362132239621133, 0.22017111745662987, 0.23312052222900093, 0.9277431222144514, 0.36004890012554824, 0.26144441892392933, 0.759291113121435, 0.21911863377317786, 0.3421774101443589, 0.6371408458799124, 0.8371626005973667, 0.009091347688809037, 0.5448347250930965, 0.7128532719798386, 0.8645369550213218, 0.5502260983921587, 0.6135116633959115, 0.055479545844718814, 0.6749554905109107, 0.6071568788029253, 0.577265621162951, 0.3277653439436108, 0.6595168141648173, 0.8171932394616306, 0.8763133089523762, 0.7906513910274953, 0.0185195105150342, 0.3629429661668837, 0.9464772585779428, 0.932531954254955, 0.19148454489186406, 0.3747351181227714, 0.2594944969750941, 0.38049133913591504, 0.7450078607071191, 0.6256745080463588, 0.3818163357209414, 0.7045479984954, 0.7162787704728544, 0.6485766377300024, 0.6065100119449198, 0.5442459043115377, 0.4208108971361071, 0.7108464180491865, 0.6756268457975239, 0.27494629961438477, 0.9171713695395738, 0.013732332270592451, 0.5224477329757065, 0.0577472026925534, 0.3143993974663317], \"x\": [0.7015755786560476, 0.9812788597773761, 0.1959909910801798, 0.2530297657940537, 0.7395738861523569, 0.7360622775740921, 0.715822015190497, 0.055459268391132355, 0.7676036967895925, 0.7331610980909318, 0.8055432541295886, 0.9853406171314418, 0.6641708000097424, 0.17102273949421942, 0.5327770155854523, 0.9452421164605767, 0.11150144319981337, 0.5689750926103443, 0.20816945331171155, 0.20375780621543527, 0.10127577395178378, 0.5743547393940389, 0.8888249881565571, 0.9288931675255299, 0.2390967032406479, 0.9908797654788941, 0.2711034535896033, 0.6851575244218111, 0.6158640165813267, 0.6392564787529409, 0.3548821466974914, 0.03266271320171654, 0.1190484412945807, 0.3716993348207325, 0.6532351796049625, 0.5146475108340383, 0.9213942305650562, 0.4046999590937048, 0.571431307354942, 0.8766124600078911, 0.7928362716920674, 0.8008945502806455, 0.7959705861285329, 0.522882976802066, 0.6008108786772937, 0.233331456547603, 0.6605638228356838, 0.6705508639570326, 0.22305443440563977, 0.3115145636256784, 0.8860200445633382, 0.6299804006703198, 0.79811085248366, 0.696199564030394, 0.1599142523482442, 0.13683987664990127, 0.10116690769791603, 0.06245461502112448, 0.333376306341961, 0.2373976542148739], \"z\": [0.4703559058252722, 0.10570031264796853, 0.24976375931873918, 0.26112930569797754, 0.5951877711340785, 0.8389222626574337, 0.9045808995142579, 0.7284336017910391, 0.5422316386830062, 0.26037846389226615, 0.23000984569080174, 0.2617095729801804, 0.40810164087451994, 0.4402750905137509, 0.6034889614675194, 0.9292901763692498, 0.9617991209961474, 0.36055441410280764, 0.9742855343502015, 0.7741924189031124, 0.2734783736523241, 0.32808378618210554, 0.3907074297312647, 0.3287961264140904, 0.3480217959731817, 0.5682682504411787, 0.5823530496563762, 0.46688860398717225, 0.3932993372436613, 0.05553136090748012, 1.1337688192725182e-05, 0.32542907097376883, 0.45882420311681926, 0.16980780358426273, 0.9245011815801263, 0.6516565626952797, 0.5743687297217548, 0.32314020465128124, 0.7528290434274822, 0.8057643566280603, 0.45597958215512335, 0.6733163502067327, 0.08666012575849891, 0.176216448424384, 0.5536635254975408, 0.3318187107797712, 0.20157826016657054, 0.40992426802404225, 0.9955383343622088, 0.48999927192926407, 0.7460769962053746, 0.7983956399839371, 0.7085803372319788, 0.062239193357527256, 0.5582397000398487, 0.5343918774742633, 0.4613129901699722, 0.8171990250702947, 0.061848267912864685, 0.9555300674401224]}, \"type\": \"Particles\", \"options\": {\"color\": \"#1f78b4\", \"name\": \"B\", \"size\": 0.15}}, {\"data\": {\"y\": [0.2, 0.5, 0.5, 0.5], \"x\": [0.2, 0.5, 0.5, 0.5], \"z\": [0.5, 0.5, 1.0, 0.7], \"type\": [\"box\", \"sphere\", \"plane\", \"cylinder\"], \"options\": [{\"width\": 0.1, \"depth\": 0.1, \"height\": 0.1}, {\"radius\": 0.1}, {\"width\": 0.7, \"height\": 0.7}, {\"radius\": 0.2, \"height\": 0.3}]}, \"type\": \"DebugObject\", \"options\": {}}], \"options\": {\"width\": 500, \"range\": {\"y\": [0.0, 1.0], \"x\": [0.0, 1.0], \"z\": [0.0, 1.0]}, \"grid\": true, \"autorange\": false, \"height\": 500}};\n",
"\t Elegans.Embed.parse(\"#\"+\"viz4fb40163-428f-424b-ac32-129adba775d8\",model).render();\n",
" });\n",
" })();\n",
" </script>\n",
" </head>\n",
" <body>\n",
" <div id=\"viz4fb40163-428f-424b-ac32-129adba775d8\"></div>\n",
" </body>\n",
"</html>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"{'A': '#a6cee3', 'B': '#1f78b4'}"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"viz.plot_world(w2, debug = [\n",
" {'type': 'box', 'x': 0.2, 'y': 0.2, 'z': 0.5, 'options': {'width': 0.1, 'height': 0.1, 'depth': 0.1}},\n",
" {'type': 'sphere', 'x': 0.5, 'y': 0.5, 'z': 0.5, 'options': {'radius': 0.1}},\n",
" {'type': 'plane', 'x': 0.5, 'y': 0.5, 'z': 1.0, 'options': {'width': 0.7, 'height': 0.7}},\n",
" {'type': 'cylinder', 'x': 0.5, 'y': 0.5, 'z': 0.7, 'options': {'radius': 0.2, 'height': 0.3}}\n",
"])"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"id = w.list_particles()[0][0]"
]
},
{
"cell_type": "code",
"execution_count": 41,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"vs = w.list_voxels(A)"
]
},
{
"cell_type": "code",
"execution_count": 44,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"v = vs[0][1]"
]
},
{
"cell_type": "code",
"execution_count": 62,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"0.0025"
]
},
"execution_count": 62,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"w.voxel_radius()"
]
},
{
"cell_type": "code",
"execution_count": 61,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"''"
]
},
"execution_count": 61,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"vs[1][1].loc()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment