{"cells":[{"metadata":{"_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","trusted":true},"cell_type":"code","source":"import os\nprint(os.listdir(\"../input\"))\nimport numpy as np \nimport matplotlib.pyplot as plt\nfrom plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot\nimport plotly.offline as py\nimport plotly.graph_objs as go\ninit_notebook_mode(connected=True) #do not miss this line\nfrom trackml.dataset import load_event","execution_count":40,"outputs":[]},{"metadata":{"trusted":true,"collapsed":true,"_uuid":"8e4e647834e1d2f2bdc5c8d7c9ae3b1b3c9cf6a3"},"cell_type":"code","source":"hits, cells, particles, truth = load_event('../input/train_1/event000001000')","execution_count":41,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"8facba8635d9cc56868a65a48066b25f584f11eb","scrolled":true},"cell_type":"code","source":"fig = plt.figure()\nnp.random.seed(2500)\nhits_sample=hits.sample(n=2000,random_state=100)\nvolumes=hits.volume_id.unique()\nres_final=[]\nfor volume in volumes:\n                        v=hits_sample[hits_sample.volume_id==volume]\n                        hits_rep=go.Scatter3d(x=v.x,y=v.y,z=v.z,\n                                              mode='markers',\n                                              marker=dict(\n                                                          size=4,\n                                                          line=dict(\n                                                                        color=volume,\n                                                                        width=0.5\n                                                                    ),\n                                                           opacity=0.8         \n                                                        ),\n                                              name = 'volume ' + str(volume)\n                                                )                \n                        res_final.append(hits_rep)\n                                                                                          \nlayout = go.Layout(\n    title = 'Particles hits in 3D space (mm)',\n    titlefont = dict(size=8),\n    margin=dict(\n        l=0,\n        r=0,\n        b=0,\n        t=0\n    )\n)\nfig = go.Figure(data=res_final, layout=layout)\npy.iplot(fig, filename='simple-3d-scatter')","execution_count":4,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"4d93ad46593679b78a1acaee6677018e3e9b17a8"},"cell_type":"code","source":"fig=plt.figure()\nparticles_sample=particles.sample(n=len(particles.particle_id),random_state=100)\nnhits=particles.nhits.unique()\nparticles_final=[]\nfor nhit in nhits:\n                        v=particles_sample[particles_sample.nhits==nhit]\n                        particles_rep=go.Scatter3d(x=v.vx,y=v.vy,z=v.vz,\n                                              mode='markers',\n                                              marker=dict(\n                                                          size=4,\n                                                          line=dict(\n                                                                        color=nhit,\n                                                                        width=0.5\n                                                                    ),\n                                                           opacity=0.8         \n                                                        ),\n                                                   name = str(nhit) + ' hits ' \n                                                          + '[' + str(round((len(v.particle_id)/len(particles_sample.particle_id))*100)) + '%]'\n                                                )                \n                        particles_final.append(particles_rep)\n                                                                                          \nlayout = go.Layout(\n    title = 'Particles and their nhits (mm)',\n    titlefont = dict(size=8),\n    margin=dict(\n        l=0,\n        r=0,\n        b=0,\n        t=0\n    )\n)\nfig = go.Figure(data=particles_final, layout=layout)\npy.iplot(fig, filename='simple-3d-scatter')\n    ","execution_count":45,"outputs":[]},{"metadata":{"trusted":true,"collapsed":true,"_uuid":"56ecdf25ed05897629f136df6ec7bf5268b76f59"},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"name":"python","version":"3.6.5","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat":4,"nbformat_minor":1}