{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nfrom mpl_toolkits import mplot3d\nimport matplotlib.pyplot as plt\nimport re, seaborn as sns\nfrom mpl_toolkits.mplot3d import Axes3D\nfrom matplotlib.colors import ListedColormap\n%matplotlib inline\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-02-19T12:22:30.235362Z","iopub.execute_input":"2023-02-19T12:22:30.235890Z","iopub.status.idle":"2023-02-19T12:22:30.851838Z","shell.execute_reply.started":"2023-02-19T12:22:30.235788Z","shell.execute_reply":"2023-02-19T12:22:30.850220Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_meta_train=pd.read_parquet('/kaggle/input/icecube-neutrinos-in-deep-ice/train_meta.parquet', engine='pyarrow')","metadata":{"execution":{"iopub.status.busy":"2023-02-19T12:22:30.855064Z","iopub.execute_input":"2023-02-19T12:22:30.855698Z","iopub.status.idle":"2023-02-19T12:22:49.607104Z","shell.execute_reply.started":"2023-02-19T12:22:30.855642Z","shell.execute_reply":"2023-02-19T12:22:49.605576Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_geometry=pd.read_csv('/kaggle/input/icecube-neutrinos-in-deep-ice/sensor_geometry.csv')","metadata":{"execution":{"iopub.status.busy":"2023-02-19T12:22:49.608321Z","iopub.execute_input":"2023-02-19T12:22:49.608696Z","iopub.status.idle":"2023-02-19T12:22:49.622519Z","shell.execute_reply.started":"2023-02-19T12:22:49.608664Z","shell.execute_reply":"2023-02-19T12:22:49.621044Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Exploring Train Meta file","metadata":{}},{"cell_type":"code","source":"df_meta_train","metadata":{"execution":{"iopub.status.busy":"2023-02-19T12:22:49.624040Z","iopub.execute_input":"2023-02-19T12:22:49.624468Z","iopub.status.idle":"2023-02-19T12:22:49.649537Z","shell.execute_reply.started":"2023-02-19T12:22:49.624431Z","shell.execute_reply":"2023-02-19T12:22:49.648663Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"event_id=24\n\nindex=df_meta_train.loc[df_meta_train['event_id']==event_id]\nfirst_index=list(index['first_pulse_index'])\nlast_index=list(index['last_pulse_index'])\nfirst_pulse_index=first_index[0]\nlast_pulse_index=last_index[0]","metadata":{"execution":{"iopub.status.busy":"2023-02-19T12:22:49.652374Z","iopub.execute_input":"2023-02-19T12:22:49.652946Z","iopub.status.idle":"2023-02-19T12:22:50.694571Z","shell.execute_reply.started":"2023-02-19T12:22:49.652886Z","shell.execute_reply":"2023-02-19T12:22:50.692952Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"list(index['zenith'])[0]","metadata":{"execution":{"iopub.status.busy":"2023-02-19T12:22:50.696645Z","iopub.execute_input":"2023-02-19T12:22:50.697116Z","iopub.status.idle":"2023-02-19T12:22:50.706633Z","shell.execute_reply.started":"2023-02-19T12:22:50.697081Z","shell.execute_reply":"2023-02-19T12:22:50.705059Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"first_pulse_index,last_pulse_index","metadata":{"execution":{"iopub.status.busy":"2023-02-19T12:22:50.709149Z","iopub.execute_input":"2023-02-19T12:22:50.710307Z","iopub.status.idle":"2023-02-19T12:22:50.720468Z","shell.execute_reply.started":"2023-02-19T12:22:50.710247Z","shell.execute_reply":"2023-02-19T12:22:50.719053Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def corrdinate(azimuth,zenith):\n    x = np.cos(azimuth) * np.sin(zenith)\n    y = np.sin(azimuth) * np.sin(zenith)\n    z = np.cos(zenith)\n    return [x,y,z]\n\nazimuth=list(index['azimuth'])[0]\nzenith=list(index['zenith'])[0]\nx,y,z=corrdinate(azimuth,zenith)\nlabel_x=x\nlabel_y=y\nlabel_z=z","metadata":{"execution":{"iopub.status.busy":"2023-02-19T12:22:50.722092Z","iopub.execute_input":"2023-02-19T12:22:50.722513Z","iopub.status.idle":"2023-02-19T12:22:50.733175Z","shell.execute_reply.started":"2023-02-19T12:22:50.722478Z","shell.execute_reply":"2023-02-19T12:22:50.732051Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"azimuth,zenith","metadata":{"execution":{"iopub.status.busy":"2023-02-19T12:22:50.734752Z","iopub.execute_input":"2023-02-19T12:22:50.735899Z","iopub.status.idle":"2023-02-19T12:22:50.748661Z","shell.execute_reply.started":"2023-02-19T12:22:50.735851Z","shell.execute_reply":"2023-02-19T12:22:50.747167Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x,y,z","metadata":{"execution":{"iopub.status.busy":"2023-02-19T12:22:50.750105Z","iopub.execute_input":"2023-02-19T12:22:50.751227Z","iopub.status.idle":"2023-02-19T12:22:50.762275Z","shell.execute_reply.started":"2023-02-19T12:22:50.751159Z","shell.execute_reply":"2023-02-19T12:22:50.761139Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# saving modified parquet data in dataFrame format","metadata":{}},{"cell_type":"code","source":"df_train_batch=pd.read_parquet('/kaggle/input/icecube-neutrinos-in-deep-ice/train/batch_1.parquet', engine='pyarrow')","metadata":{"execution":{"iopub.status.busy":"2023-02-19T12:22:50.763669Z","iopub.execute_input":"2023-02-19T12:22:50.764143Z","iopub.status.idle":"2023-02-19T12:22:52.175437Z","shell.execute_reply.started":"2023-02-19T12:22:50.764105Z","shell.execute_reply":"2023-02-19T12:22:52.174230Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_geometry","metadata":{"execution":{"iopub.status.busy":"2023-02-19T12:22:52.176725Z","iopub.execute_input":"2023-02-19T12:22:52.177247Z","iopub.status.idle":"2023-02-19T12:22:52.196320Z","shell.execute_reply.started":"2023-02-19T12:22:52.177205Z","shell.execute_reply":"2023-02-19T12:22:52.195249Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train_batch","metadata":{"execution":{"iopub.status.busy":"2023-02-19T12:22:52.198020Z","iopub.execute_input":"2023-02-19T12:22:52.198785Z","iopub.status.idle":"2023-02-19T12:22:52.216169Z","shell.execute_reply.started":"2023-02-19T12:22:52.198744Z","shell.execute_reply":"2023-02-19T12:22:52.214771Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"xaxis=[]\nyaxis=[]\nzaxis=[]\nsensor_xaxis=df_geometry['x']\nsensor_yaxis=df_geometry['y']\nsensor_zaxis=df_geometry['z']\nindex_with_auxiliary_false=[]\ntime_by_event_id=df_train_batch['time'][first_pulse_index:last_pulse_index+1]\ncharge_by_event_id=df_train_batch['charge'][first_pulse_index:last_pulse_index+1]\nauxiliary_by_event_id=df_train_batch['auxiliary'][first_pulse_index:last_pulse_index+1]\n\nfor i in range(first_pulse_index,last_pulse_index+1):\n    sensor_id=list(df_train_batch['sensor_id'])[i]\n    xaxis.append(df_geometry['x'][sensor_id])\n    yaxis.append(df_geometry['y'][sensor_id])\n    zaxis.append(df_geometry['z'][sensor_id])\n    \n\n    ","metadata":{"execution":{"iopub.status.busy":"2023-02-19T12:53:58.673128Z","iopub.execute_input":"2023-02-19T12:53:58.673572Z","iopub.status.idle":"2023-02-19T13:03:30.388539Z","shell.execute_reply.started":"2023-02-19T12:53:58.673537Z","shell.execute_reply":"2023-02-19T13:03:30.386001Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"time=[]\ncharge=[]\nre_sensor_id=[]\nfor i in range(first_pulse_index,last_pulse_index+1):\n    if list(df_train_batch['auxiliary'])[i]==False:\n        re_sensor_id.append(list(df_train_batch['sensor_id'])[i])\n        index_with_auxiliary_false.append(i)\n        time.append(list(df_train_batch['time'])[i])\n        charge.append(list(df_train_batch['charge'])[i])","metadata":{"execution":{"iopub.status.busy":"2023-02-19T13:23:00.900443Z","iopub.execute_input":"2023-02-19T13:23:00.901056Z","iopub.status.idle":"2023-02-19T13:29:11.144148Z","shell.execute_reply.started":"2023-02-19T13:23:00.901008Z","shell.execute_reply":"2023-02-19T13:29:11.142724Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(time, charge, '.')  # Plot the chart\nplt.show() ","metadata":{"execution":{"iopub.status.busy":"2023-02-19T13:11:13.096898Z","iopub.execute_input":"2023-02-19T13:11:13.097447Z","iopub.status.idle":"2023-02-19T13:11:13.326692Z","shell.execute_reply.started":"2023-02-19T13:11:13.097401Z","shell.execute_reply":"2023-02-19T13:11:13.325180Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = plt.figure(figsize = (10,10))\nax = plt.axes(projection='3d')\nax.grid()\n\nax.scatter(x, y, z, c = 'BLACK', s = 10)\nax.scatter(xaxis, yaxis, zaxis, c = 'r', s = 10)\nax.set_title('3D Scatter Plot')\n\n# Set axes label\nax.set_xlabel('x', labelpad=20)\nax.set_ylabel('y', labelpad=20)\nax.set_zlabel('z', labelpad=20)\n\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-02-19T12:27:10.950084Z","iopub.execute_input":"2023-02-19T12:27:10.950496Z","iopub.status.idle":"2023-02-19T12:27:11.284909Z","shell.execute_reply.started":"2023-02-19T12:27:10.950463Z","shell.execute_reply":"2023-02-19T12:27:11.282874Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = plt.figure(figsize = (8,8))\nax = plt.axes(projection='3d')\nax.grid()\nax.plot3D(xaxis, yaxis, zaxis)\nax.set_title('3D Parametric Plot')\n\n# Set axes label\nax.set_xlabel('x', labelpad=20)\nax.set_ylabel('y', labelpad=20)\nax.set_zlabel('t', labelpad=20)\n\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-02-19T12:27:11.286434Z","iopub.execute_input":"2023-02-19T12:27:11.287053Z","iopub.status.idle":"2023-02-19T12:27:11.483039Z","shell.execute_reply.started":"2023-02-19T12:27:11.286998Z","shell.execute_reply":"2023-02-19T12:27:11.481679Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig, ax = plt.subplots(subplot_kw=dict(projection='3d'))\nax.stem(xaxis, yaxis, zaxis)\n\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-02-19T12:27:11.484357Z","iopub.execute_input":"2023-02-19T12:27:11.484760Z","iopub.status.idle":"2023-02-19T12:27:11.730198Z","shell.execute_reply.started":"2023-02-19T12:27:11.484724Z","shell.execute_reply":"2023-02-19T12:27:11.728419Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig, ax = plt.subplots(subplot_kw=dict(projection='3d'))\nmarkerline, stemlines, baseline = ax.stem(\n    xaxis, yaxis, zaxis, linefmt='grey', markerfmt='D', bottom=np.pi)\nmarkerline.set_markerfacecolor('none')\n\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-02-19T12:27:11.731979Z","iopub.execute_input":"2023-02-19T12:27:11.732378Z","iopub.status.idle":"2023-02-19T12:27:11.982412Z","shell.execute_reply.started":"2023-02-19T12:27:11.732346Z","shell.execute_reply":"2023-02-19T12:27:11.981049Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = plt.figure(figsize = (6, 6))\nax = plt.axes(projection = '3d')\n\nax.plot3D(xaxis, yaxis, zaxis, 'blue')\nax.set_title('3D plotting of line chart')\n\n# Print the chart\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-02-19T12:27:11.984257Z","iopub.execute_input":"2023-02-19T12:27:11.984644Z","iopub.status.idle":"2023-02-19T12:27:12.235995Z","shell.execute_reply.started":"2023-02-19T12:27:11.984611Z","shell.execute_reply":"2023-02-19T12:27:12.234545Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = plt.figure(figsize = (8, 8))\nax =plt.axes(projection = '3d')\n\nax.scatter(x, y, z, c = 'BLACK', s = 10)\nax.scatter(sensor_xaxis, sensor_yaxis, sensor_zaxis, c='WHITE')\nax.scatter(xaxis, yaxis, zaxis, c='Red')\nax.set_title('3D plotting of scatter chart')\n\n# Print the chart\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-02-19T12:27:12.237557Z","iopub.execute_input":"2023-02-19T12:27:12.238030Z","iopub.status.idle":"2023-02-19T12:27:12.614540Z","shell.execute_reply.started":"2023-02-19T12:27:12.237977Z","shell.execute_reply":"2023-02-19T12:27:12.613469Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = plt.figure(figsize = (6, 6))\nax = plt.axes(projection = '3d')\n\n#Plot in 3D\nax.plot3D(xaxis, yaxis, zaxis,'blue')\nax.view_init(90, 60)\nax.set_title('3D Plotting of Line Chart from Different View Angle')\n\n# Print the chart\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-02-19T12:27:12.615905Z","iopub.execute_input":"2023-02-19T12:27:12.616912Z","iopub.status.idle":"2023-02-19T12:27:12.866909Z","shell.execute_reply.started":"2023-02-19T12:27:12.616863Z","shell.execute_reply":"2023-02-19T12:27:12.865113Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# axes instance\nfig = plt.figure(figsize=(6,6))\nax = Axes3D(fig, auto_add_to_figure=False)\nfig.add_axes(ax)\n\n# get colormap from seaborn\ncmap = ListedColormap(sns.color_palette(\"husl\", 256).as_hex())\n\n# plot\nsc = ax.scatter(xaxis, yaxis, zaxis, s=40, c=xaxis, marker='o', cmap=cmap, alpha=1)\nax.set_xlabel('X Label')\nax.set_ylabel('Y Label')\nax.set_zlabel('Z Label')\n\n# legend\nplt.legend(*sc.legend_elements(), bbox_to_anchor=(1.05, 1), loc=2)\n\n# save\nplt.savefig(\"scatter_hue\", bbox_inches='tight')","metadata":{"execution":{"iopub.status.busy":"2023-02-19T12:27:12.868423Z","iopub.execute_input":"2023-02-19T12:27:12.868838Z","iopub.status.idle":"2023-02-19T12:27:14.021496Z","shell.execute_reply.started":"2023-02-19T12:27:12.868801Z","shell.execute_reply":"2023-02-19T12:27:14.020089Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# axes instance\nfig = plt.figure(figsize=(6,6))\nax = Axes3D(fig, auto_add_to_figure=False)\nfig.add_axes(ax)\n\n# get colormap from seaborn\ncmap = ListedColormap(sns.color_palette(\"husl\", 256).as_hex())\n\n# plot\nax.scatter(sensor_xaxis, sensor_yaxis, sensor_zaxis, c='WHITE')\n\nsc = ax.scatter(xaxis, yaxis, zaxis, s=40, c=xaxis, marker='o', cmap=cmap, alpha=1)\nax.set_xlabel('X Label')\nax.set_ylabel('Y Label')\nax.set_zlabel('Z Label')\n# legend\nplt.legend(*sc.legend_elements(), bbox_to_anchor=(1.05, 1), loc=2)\n\n# save\nplt.savefig(\"scatter_hue\", bbox_inches='tight')\n","metadata":{"execution":{"iopub.status.busy":"2023-02-19T12:27:14.022985Z","iopub.execute_input":"2023-02-19T12:27:14.023399Z","iopub.status.idle":"2023-02-19T12:27:15.451659Z","shell.execute_reply.started":"2023-02-19T12:27:14.023366Z","shell.execute_reply":"2023-02-19T12:27:15.449895Z"},"trusted":true},"execution_count":null,"outputs":[]}]}