Skip to content

Commit 68af42f

Browse files
committed
updated example and version
1 parent 367dfac commit 68af42f

File tree

2 files changed

+68
-21
lines changed

2 files changed

+68
-21
lines changed

pandas3js/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
"""
77

8-
__version__ = '0.1.5.2'
8+
__version__ = '0.1.6'
99

1010
from pandas3js import models
1111
from pandas3js import views

pandas3js_example.ipynb

Lines changed: 67 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,19 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": null,
5+
"execution_count": 1,
66
"metadata": {
77
"init_cell": true
88
},
9-
"outputs": [],
9+
"outputs": [
10+
{
11+
"name": "stdout",
12+
"output_type": "stream",
13+
"text": [
14+
"0.1.6\n"
15+
]
16+
}
17+
],
1018
"source": [
1119
"import numpy as np \n",
1220
"import pandas as pd\n",
@@ -93,6 +101,15 @@
93101
"# Object Types"
94102
]
95103
},
104+
{
105+
"cell_type": "code",
106+
"execution_count": null,
107+
"metadata": {
108+
"collapsed": true
109+
},
110+
"outputs": [],
111+
"source": []
112+
},
96113
{
97114
"cell_type": "code",
98115
"execution_count": null,
@@ -108,6 +125,8 @@
108125
" 'otype':['pandas3js.models.'+options['Object']],\n",
109126
" 'position':[(options['x'],0,0)],\n",
110127
" 'visible':[options['Visible']]})\n",
128+
" if 'Icosahedron' in options['Object']:\n",
129+
" df['detail'] = 1\n",
111130
" if 'Triclinic' in options['Object']:\n",
112131
" pjs.utils.tuple_to_df(df,'b',(0.5,1,0))\n",
113132
" pjs.utils.tuple_to_df(df,'c',(0,.5,1))\n",
@@ -166,7 +185,7 @@
166185
" for q in cdata['charge']]\n",
167186
" geometry.change_by_df(df,otype_column='otype')\n",
168187
"\n",
169-
"gui, gcollect, opts = pjs.views.create_gui(geometry,callback,\n",
188+
"gui, gcollect, opts = pjs.views.create_gui(callback=callback,\n",
170189
" height=200,width=200,camera_position=[.5,0,-4],\n",
171190
" show_object_info=True,otype_column='otype',\n",
172191
" opts_choice={'Color':['c1','c2']},\n",
@@ -220,16 +239,28 @@
220239
"outputs": [],
221240
"source": [
222241
"# pip install jsonextended\n",
223-
"import jsonextended as ejson\n",
224-
"import urllib #urllib2 for python3\n",
225-
"f = urllib.urlopen(\n",
226-
" 'https://raw.githubusercontent.com/chrisjsewell'\n",
227-
" '/jsonextended/master/jsonextended/parsers/crystal_test.data')\n",
228-
"parser = ejson.parsers.CrystalDFTParser()\n",
229-
"parser.read_file(f)\n",
230-
"f.close()\n",
231-
"\n",
232-
"data = ejson.dict_combine_lists(parser.data,['id','x/a','y/b','z/c','atomic_number'],'ixyzn')\n",
242+
"from jsonextended import edict, utils, _example_data_folder\n",
243+
"from jsonextended.complex_parsers import crystal_dft"
244+
]
245+
},
246+
{
247+
"cell_type": "code",
248+
"execution_count": null,
249+
"metadata": {},
250+
"outputs": [],
251+
"source": [
252+
"datapath = utils.get_data_path('data.crystal.out',_example_data_folder)\n",
253+
"parser = crystal_dft.CrystalDFTParser()\n",
254+
"data = parser.read_file(datapath)"
255+
]
256+
},
257+
{
258+
"cell_type": "code",
259+
"execution_count": null,
260+
"metadata": {},
261+
"outputs": [],
262+
"source": [
263+
"data = edict.combine_lists(data,['id','x/a','y/b','z/c','atomic_number'],'ixyzn')\n",
233264
"geometry = pjs.models.GeometricCollection()\n",
234265
"\n",
235266
"# create bounding box\n",
@@ -242,7 +273,8 @@
242273
"# create atoms\n",
243274
"for d in data['initial']['primitive']['geometry']['ixyzn'].values():\n",
244275
" x,y,z = d['x/a']*a_vec+d['y/b']*b_vec+d['z/c']*c_vec\n",
245-
" atom = pjs.models.Sphere(id=d['id'],position=(x,y,z))\n",
276+
" #atom = pjs.models.Sphere(id=d['id'],position=(x,y,z))\n",
277+
" atom = pjs.models.Icosahedron(id=d['id'],position=(x,y,z),detail=1)\n",
246278
" atom.color = atom.label_color = pjs.atom.map_atoms(d['atomic_number'],'color')\n",
247279
" atom.radius = pjs.atom.map_atoms(d['atomic_number'],'RCov')\n",
248280
" atom.label = pjs.atom.map_atoms(d['atomic_number'],'Symbol')\n",
@@ -278,31 +310,46 @@
278310
"metadata": {
279311
"hide_input": false,
280312
"kernelspec": {
281-
"display_name": "Python 2",
313+
"display_name": "Python 3",
282314
"language": "python",
283-
"name": "python2"
315+
"name": "python3"
284316
},
285317
"language_info": {
286318
"codemirror_mode": {
287319
"name": "ipython",
288-
"version": 2
320+
"version": 3
289321
},
290322
"file_extension": ".py",
291323
"mimetype": "text/x-python",
292324
"name": "python",
293325
"nbconvert_exporter": "python",
294-
"pygments_lexer": "ipython2",
295-
"version": "2.7.13"
326+
"pygments_lexer": "ipython3",
327+
"version": "3.6.1"
296328
},
297329
"nav_menu": {},
298330
"toc": {
331+
"colors": {
332+
"hover_highlight": "#DAA520",
333+
"navigate_num": "#000000",
334+
"navigate_text": "#333333",
335+
"running_highlight": "#FF0000",
336+
"selected_highlight": "#FFD700",
337+
"sidebar_border": "#EEEEEE",
338+
"wrapper_background": "#FFFFFF"
339+
},
340+
"moveMenuLeft": true,
341+
"nav_menu": {
342+
"height": "105px",
343+
"width": "252px"
344+
},
299345
"navigate_menu": true,
300346
"number_sections": true,
301347
"sideBar": true,
302348
"threshold": 4,
303349
"toc_cell": false,
304350
"toc_section_display": "block",
305-
"toc_window_display": false
351+
"toc_window_display": false,
352+
"widenNotebook": false
306353
}
307354
},
308355
"nbformat": 4,

0 commit comments

Comments
 (0)