{"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":"markdown","source":"This notebook shows the dependencies required to obtain Azimuth and Zenith angles of the neutrinos detected for an event.","metadata":{}},{"cell_type":"code","source":"import numpy as np\nimport pandas as pd\nimport os","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:41:55.145856Z","iopub.execute_input":"2023-04-29T04:41:55.146393Z","iopub.status.idle":"2023-04-29T04:41:55.181891Z","shell.execute_reply.started":"2023-04-29T04:41:55.146274Z","shell.execute_reply":"2023-04-29T04:41:55.180568Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!pip install fastparquet","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:41:55.184262Z","iopub.execute_input":"2023-04-29T04:41:55.184827Z","iopub.status.idle":"2023-04-29T04:42:10.193716Z","shell.execute_reply.started":"2023-04-29T04:41:55.184776Z","shell.execute_reply":"2023-04-29T04:42:10.192202Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import pandas as pd","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:42:10.195756Z","iopub.execute_input":"2023-04-29T04:42:10.196147Z","iopub.status.idle":"2023-04-29T04:42:10.201719Z","shell.execute_reply.started":"2023-04-29T04:42:10.196107Z","shell.execute_reply":"2023-04-29T04:42:10.200432Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from fastparquet import ParquetFile","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:42:10.205722Z","iopub.execute_input":"2023-04-29T04:42:10.206294Z","iopub.status.idle":"2023-04-29T04:42:10.376882Z","shell.execute_reply.started":"2023-04-29T04:42:10.206195Z","shell.execute_reply":"2023-04-29T04:42:10.375555Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pf = ParquetFile(\"/kaggle/input/icecube-neutrinos-in-deep-ice/train/batch_1.parquet\")\nb1df=pf.to_pandas()","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:42:10.378470Z","iopub.execute_input":"2023-04-29T04:42:10.378960Z","iopub.status.idle":"2023-04-29T04:42:15.750979Z","shell.execute_reply.started":"2023-04-29T04:42:10.378912Z","shell.execute_reply":"2023-04-29T04:42:15.749844Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tm = pd.read_parquet(\"/kaggle/input/icecube-neutrinos-in-deep-ice/train_meta.parquet\")","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:42:15.752484Z","iopub.execute_input":"2023-04-29T04:42:15.752855Z","iopub.status.idle":"2023-04-29T04:43:01.685697Z","shell.execute_reply.started":"2023-04-29T04:42:15.752818Z","shell.execute_reply":"2023-04-29T04:43:01.684319Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sensordf=pd.read_csv('/kaggle/input/icecube-neutrinos-in-deep-ice/sensor_geometry.csv')","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:43:01.687383Z","iopub.execute_input":"2023-04-29T04:43:01.687798Z","iopub.status.idle":"2023-04-29T04:43:01.708293Z","shell.execute_reply.started":"2023-04-29T04:43:01.687760Z","shell.execute_reply":"2023-04-29T04:43:01.707004Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tm.batch_id.value_counts()","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:43:01.710049Z","iopub.execute_input":"2023-04-29T04:43:01.710695Z","iopub.status.idle":"2023-04-29T04:43:02.882435Z","shell.execute_reply.started":"2023-04-29T04:43:01.710647Z","shell.execute_reply":"2023-04-29T04:43:02.881071Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sensordf.describe()","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:43:02.884230Z","iopub.execute_input":"2023-04-29T04:43:02.884793Z","iopub.status.idle":"2023-04-29T04:43:02.935415Z","shell.execute_reply.started":"2023-04-29T04:43:02.884741Z","shell.execute_reply":"2023-04-29T04:43:02.934205Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib.pyplot as plt","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:43:02.940513Z","iopub.execute_input":"2023-04-29T04:43:02.940917Z","iopub.status.idle":"2023-04-29T04:43:02.947449Z","shell.execute_reply.started":"2023-04-29T04:43:02.940883Z","shell.execute_reply":"2023-04-29T04:43:02.945276Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pip install scipy","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:43:02.949856Z","iopub.execute_input":"2023-04-29T04:43:02.951496Z","iopub.status.idle":"2023-04-29T04:43:14.876005Z","shell.execute_reply.started":"2023-04-29T04:43:02.951439Z","shell.execute_reply":"2023-04-29T04:43:14.874421Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import scipy","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:43:14.878227Z","iopub.execute_input":"2023-04-29T04:43:14.878646Z","iopub.status.idle":"2023-04-29T04:43:14.898278Z","shell.execute_reply.started":"2023-04-29T04:43:14.878606Z","shell.execute_reply":"2023-04-29T04:43:14.897177Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from scipy.special import huber","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:43:14.899852Z","iopub.execute_input":"2023-04-29T04:43:14.900174Z","iopub.status.idle":"2023-04-29T04:43:14.988345Z","shell.execute_reply.started":"2023-04-29T04:43:14.900145Z","shell.execute_reply":"2023-04-29T04:43:14.986407Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"b1df['elapsed_time']=b1df['time']-5928","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:43:14.991437Z","iopub.execute_input":"2023-04-29T04:43:14.992834Z","iopub.status.idle":"2023-04-29T04:43:15.207158Z","shell.execute_reply.started":"2023-04-29T04:43:14.992757Z","shell.execute_reply":"2023-04-29T04:43:15.206060Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"b1df['vel_dist']=1.58*(0.1)*b1df['elapsed_time']","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:43:15.208695Z","iopub.execute_input":"2023-04-29T04:43:15.209071Z","iopub.status.idle":"2023-04-29T04:43:15.393445Z","shell.execute_reply.started":"2023-04-29T04:43:15.209040Z","shell.execute_reply":"2023-04-29T04:43:15.392193Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import sklearn","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:43:15.394876Z","iopub.execute_input":"2023-04-29T04:43:15.395238Z","iopub.status.idle":"2023-04-29T04:43:15.847491Z","shell.execute_reply.started":"2023-04-29T04:43:15.395199Z","shell.execute_reply":"2023-04-29T04:43:15.846107Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"r=list(dict(b1df.sensor_id.value_counts()))","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:43:15.849195Z","iopub.execute_input":"2023-04-29T04:43:15.849753Z","iopub.status.idle":"2023-04-29T04:43:16.088659Z","shell.execute_reply.started":"2023-04-29T04:43:15.849709Z","shell.execute_reply":"2023-04-29T04:43:16.087069Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.linear_model import HuberRegressor\nfrom sklearn.datasets import make_regression","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:43:16.090306Z","iopub.execute_input":"2023-04-29T04:43:16.091035Z","iopub.status.idle":"2023-04-29T04:43:16.361888Z","shell.execute_reply.started":"2023-04-29T04:43:16.090983Z","shell.execute_reply":"2023-04-29T04:43:16.360554Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def predangle(df):\n    p=[]\n    p1c=np.cov(df['z'],df['x'])\n    a1=p1c[0][1]/p1c[0][0]\n    p2c=np.cov(df['z'],df['y'])\n    a2=p2c[0][1]/p2c[0][0]\n    d=np.sqrt(1+a1**2+a2**2)\n    azimuth=np.arctan2(a2,a1)\n    if azimuth<0:\n        azimuth=2*np.pi+azimuth\n    zenith=np.arccos(1/d)\n    p.append([azimuth,zenith])\n    return p","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:43:16.363454Z","iopub.execute_input":"2023-04-29T04:43:16.363820Z","iopub.status.idle":"2023-04-29T04:43:16.371470Z","shell.execute_reply.started":"2023-04-29T04:43:16.363790Z","shell.execute_reply":"2023-04-29T04:43:16.370560Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"testdf=ParquetFile('/kaggle/input/icecube-neutrinos-in-deep-ice/test_meta.parquet')\ntestdata=testdf.to_pandas()","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:43:16.372752Z","iopub.execute_input":"2023-04-29T04:43:16.373089Z","iopub.status.idle":"2023-04-29T04:43:16.395020Z","shell.execute_reply.started":"2023-04-29T04:43:16.373052Z","shell.execute_reply":"2023-04-29T04:43:16.393717Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"testdata","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:43:16.396529Z","iopub.execute_input":"2023-04-29T04:43:16.396979Z","iopub.status.idle":"2023-04-29T04:43:16.409621Z","shell.execute_reply.started":"2023-04-29T04:43:16.396945Z","shell.execute_reply":"2023-04-29T04:43:16.408023Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"event5=5\nevent5_pulse_info=b1df.iloc[tm.iloc[event5].first_pulse_index.astype(int):tm.iloc[event5].last_pulse_index.astype(int)+1].copy()","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:43:16.411485Z","iopub.execute_input":"2023-04-29T04:43:16.412531Z","iopub.status.idle":"2023-04-29T04:43:16.424507Z","shell.execute_reply.started":"2023-04-29T04:43:16.412491Z","shell.execute_reply":"2023-04-29T04:43:16.423174Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"event5_pulse_info.head()","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:43:16.426469Z","iopub.execute_input":"2023-04-29T04:43:16.426863Z","iopub.status.idle":"2023-04-29T04:43:16.444745Z","shell.execute_reply.started":"2023-04-29T04:43:16.426817Z","shell.execute_reply":"2023-04-29T04:43:16.443467Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"event5_pulse_info = event5_pulse_info.reset_index()\nevent5_pulse_info[['x', 'y', 'z']] = sensordf.loc[event5_pulse_info.sensor_id].reset_index()[['x','y','z']]\n","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:43:16.446435Z","iopub.execute_input":"2023-04-29T04:43:16.447176Z","iopub.status.idle":"2023-04-29T04:43:16.458719Z","shell.execute_reply.started":"2023-04-29T04:43:16.447138Z","shell.execute_reply":"2023-04-29T04:43:16.457431Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"event5_pulse_info.head()","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:43:16.460431Z","iopub.execute_input":"2023-04-29T04:43:16.461459Z","iopub.status.idle":"2023-04-29T04:43:16.478768Z","shell.execute_reply.started":"2023-04-29T04:43:16.461407Z","shell.execute_reply":"2023-04-29T04:43:16.477523Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"p_angle=predangle(event5_pulse_info)","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:43:16.480102Z","iopub.execute_input":"2023-04-29T04:43:16.481285Z","iopub.status.idle":"2023-04-29T04:43:16.494842Z","shell.execute_reply.started":"2023-04-29T04:43:16.481245Z","shell.execute_reply":"2023-04-29T04:43:16.493274Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"p_angle","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:43:16.496568Z","iopub.execute_input":"2023-04-29T04:43:16.496964Z","iopub.status.idle":"2023-04-29T04:43:16.504832Z","shell.execute_reply.started":"2023-04-29T04:43:16.496929Z","shell.execute_reply":"2023-04-29T04:43:16.503416Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def errorpred(true_az,pred_az,true_zen,pred_zen):\n    e=[]\n    da=abs(true_az-pred_az)\n    db=abs(true_zen-pred_zen)\n    e.append(da)\n    e.append(db)\n    return e","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:43:16.513786Z","iopub.execute_input":"2023-04-29T04:43:16.514414Z","iopub.status.idle":"2023-04-29T04:43:16.520386Z","shell.execute_reply.started":"2023-04-29T04:43:16.514351Z","shell.execute_reply":"2023-04-29T04:43:16.519396Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"e=errorpred(tm['azimuth'][event5],p_angle[0][0],tm['zenith'][event5],p_angle[0][1])","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:43:16.521630Z","iopub.execute_input":"2023-04-29T04:43:16.522853Z","iopub.status.idle":"2023-04-29T04:43:16.532768Z","shell.execute_reply.started":"2023-04-29T04:43:16.522812Z","shell.execute_reply":"2023-04-29T04:43:16.531645Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"e","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:43:16.534391Z","iopub.execute_input":"2023-04-29T04:43:16.535030Z","iopub.status.idle":"2023-04-29T04:43:16.547878Z","shell.execute_reply.started":"2023-04-29T04:43:16.534993Z","shell.execute_reply":"2023-04-29T04:43:16.546281Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"b1df.auxiliary.value_counts()","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:43:16.549862Z","iopub.execute_input":"2023-04-29T04:43:16.550750Z","iopub.status.idle":"2023-04-29T04:43:16.791170Z","shell.execute_reply.started":"2023-04-29T04:43:16.550699Z","shell.execute_reply":"2023-04-29T04:43:16.789716Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"b1df.tail()","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:43:16.792722Z","iopub.execute_input":"2023-04-29T04:43:16.793146Z","iopub.status.idle":"2023-04-29T04:43:16.812370Z","shell.execute_reply.started":"2023-04-29T04:43:16.793110Z","shell.execute_reply":"2023-04-29T04:43:16.810943Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Following the estimation of angle through the use of coordinates of sensors, a similar direction tracing through the overall distance covered in a batch of events would be understood. Each batch would have the estimated number of bouncing on the sensors followed from a muon hit and radiation emitted to obtain the looping.","metadata":{}},{"cell_type":"markdown","source":"","metadata":{}},{"cell_type":"code","source":"plt.xlabel('Distance Travelled By Muon')\nplt.ylabel('Sensors bounced on')\nplt.plot(event5_pulse_info['vel_dist'],event5_pulse_info['sensor_id'], color=\"green\")","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:43:16.813933Z","iopub.execute_input":"2023-04-29T04:43:16.814279Z","iopub.status.idle":"2023-04-29T04:43:17.077308Z","shell.execute_reply.started":"2023-04-29T04:43:16.814249Z","shell.execute_reply":"2023-04-29T04:43:17.075843Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def distcovered(df):\n    l=len(df)\n    dist=[]\n    for i in range(l-1):\n        p1=[df['x'][i+1],df['y'][i+1],df['z'][i+1]]\n        p2=[df['x'][i],df['y'][i],df['z'][i]]\n        dist.append(((((p2[0]-p1[0])**2)+((p2[1]-p1[1])**2)+((p2[2]-p1[2])**2))**0.5)+df['vel_dist'][i])\n    dist.append(df['vel_dist'][l-1])\n    return dist","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:43:17.078843Z","iopub.execute_input":"2023-04-29T04:43:17.079428Z","iopub.status.idle":"2023-04-29T04:43:17.090659Z","shell.execute_reply.started":"2023-04-29T04:43:17.079378Z","shell.execute_reply":"2023-04-29T04:43:17.088876Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"d=distcovered(event5_pulse_info)","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:43:17.092127Z","iopub.execute_input":"2023-04-29T04:43:17.092537Z","iopub.status.idle":"2023-04-29T04:43:17.105723Z","shell.execute_reply.started":"2023-04-29T04:43:17.092504Z","shell.execute_reply":"2023-04-29T04:43:17.104198Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.xlabel('Total distance Travelled By Muon')\nplt.ylabel('Sensors bounced on')\nplt.plot(d,event5_pulse_info['sensor_id'], color=\"green\")","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:43:17.108026Z","iopub.execute_input":"2023-04-29T04:43:17.108602Z","iopub.status.idle":"2023-04-29T04:43:17.343696Z","shell.execute_reply.started":"2023-04-29T04:43:17.108549Z","shell.execute_reply":"2023-04-29T04:43:17.342266Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dn=np.array(d)","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:43:17.345069Z","iopub.execute_input":"2023-04-29T04:43:17.345455Z","iopub.status.idle":"2023-04-29T04:43:17.351391Z","shell.execute_reply.started":"2023-04-29T04:43:17.345422Z","shell.execute_reply":"2023-04-29T04:43:17.349589Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dd=dn.reshape(-1,1)","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:43:17.353102Z","iopub.execute_input":"2023-04-29T04:43:17.353575Z","iopub.status.idle":"2023-04-29T04:43:17.365052Z","shell.execute_reply.started":"2023-04-29T04:43:17.353534Z","shell.execute_reply":"2023-04-29T04:43:17.363569Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"huberpred = HuberRegressor().fit(dd,event5_pulse_info['auxiliary'])","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:43:17.366738Z","iopub.execute_input":"2023-04-29T04:43:17.367125Z","iopub.status.idle":"2023-04-29T04:43:17.412652Z","shell.execute_reply.started":"2023-04-29T04:43:17.367093Z","shell.execute_reply":"2023-04-29T04:43:17.411212Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig1=plt.figure()\nfig1.set_figwidth(7)\nfig1.set_figheight(7)\nax1 = plt.axes(projection ='3d')\nax1.set_xlabel('Distance')\nax1.set_ylabel('Sensor Id')\nax1.set_zlabel('Clarity')\nax1.set_title('Variation')\nax1.scatter3D(d,event5_pulse_info['sensor_id'],huberpred.predict(dd),color='purple')\n","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:43:17.414686Z","iopub.execute_input":"2023-04-29T04:43:17.415042Z","iopub.status.idle":"2023-04-29T04:43:17.680379Z","shell.execute_reply.started":"2023-04-29T04:43:17.415011Z","shell.execute_reply":"2023-04-29T04:43:17.679402Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sensor=np.array(event5_pulse_info['sensor_id'])","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:43:17.681519Z","iopub.execute_input":"2023-04-29T04:43:17.681847Z","iopub.status.idle":"2023-04-29T04:43:17.687958Z","shell.execute_reply.started":"2023-04-29T04:43:17.681818Z","shell.execute_reply":"2023-04-29T04:43:17.686540Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"The path can be deduced following the distance covered by the pulse via each sensor and clarity of the signal when auxiliary=false through a line fit. They would be mapped to the path observed through the recorded azimuth and zenith angle. The fit score will be analysed on each batch on the set of events,to obtain the appropriate line fit based on the statistical convergence of the events in each batch.","metadata":{}},{"cell_type":"code","source":"event5_pulse_info['x_norm']=(event5_pulse_info['x']-np.min(event5_pulse_info['x']))/(np.max(event5_pulse_info['x'])-np.min(event5_pulse_info['x']))","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:43:17.689819Z","iopub.execute_input":"2023-04-29T04:43:17.690374Z","iopub.status.idle":"2023-04-29T04:43:17.703663Z","shell.execute_reply.started":"2023-04-29T04:43:17.690303Z","shell.execute_reply":"2023-04-29T04:43:17.702122Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"event5_pulse_info['y_norm']=(event5_pulse_info['y']-np.min(event5_pulse_info['y']))/(np.max(event5_pulse_info['y'])-np.min(event5_pulse_info['y']))","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:43:17.705720Z","iopub.execute_input":"2023-04-29T04:43:17.706589Z","iopub.status.idle":"2023-04-29T04:43:17.719374Z","shell.execute_reply.started":"2023-04-29T04:43:17.706534Z","shell.execute_reply":"2023-04-29T04:43:17.717662Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"event5_pulse_info['z_norm']=(event5_pulse_info['z']-np.min(event5_pulse_info['z']))/(np.max(event5_pulse_info['z'])-np.min(event5_pulse_info['z']))","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:43:17.721428Z","iopub.execute_input":"2023-04-29T04:43:17.721947Z","iopub.status.idle":"2023-04-29T04:43:17.733614Z","shell.execute_reply.started":"2023-04-29T04:43:17.721896Z","shell.execute_reply":"2023-04-29T04:43:17.732276Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import math\nimport warnings\nwarnings.filterwarnings('ignore')","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:44:45.153075Z","iopub.execute_input":"2023-04-29T04:44:45.153608Z","iopub.status.idle":"2023-04-29T04:44:45.160743Z","shell.execute_reply.started":"2023-04-29T04:44:45.153566Z","shell.execute_reply":"2023-04-29T04:44:45.158979Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def bouncedir(d1,d2,d3):\n    p=[]\n    if d1==0:\n        azimuth=np.pi/2\n    else:\n        azimuth=math.atan(d2/d1)\n    if azimuth<0:\n        azimuth=2*np.pi+azimuth\n    zenith=math.acos(d3)\n    p.append([azimuth,zenith])\n    return p","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:44:45.163554Z","iopub.execute_input":"2023-04-29T04:44:45.164574Z","iopub.status.idle":"2023-04-29T04:44:45.174317Z","shell.execute_reply.started":"2023-04-29T04:44:45.164503Z","shell.execute_reply":"2023-04-29T04:44:45.173025Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"l=len(event5_pulse_info)\ny1=[]\ny2=[]\nfor i in range(l):\n    p=bouncedir(event5_pulse_info['x_norm'][i],event5_pulse_info['y_norm'][i],event5_pulse_info['z_norm'][i])\n    y1.append(p[0][0])\n    y2.append(p[0][1])","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:44:45.175637Z","iopub.execute_input":"2023-04-29T04:44:45.176221Z","iopub.status.idle":"2023-04-29T04:44:45.187615Z","shell.execute_reply.started":"2023-04-29T04:44:45.176187Z","shell.execute_reply":"2023-04-29T04:44:45.186387Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"A Multiple Linear Regression Model to Understand the relationship between distance travelled by the muon, sensors hit, clarity of the signal to derive the azimuth and zenith angle tracked through each muon would be trained.","metadata":{}},{"cell_type":"code","source":"r=int(0.75*l)\ntr5=event5_pulse_info[0:r]\nte5=event5_pulse_info[r:l]","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:44:45.189736Z","iopub.execute_input":"2023-04-29T04:44:45.190279Z","iopub.status.idle":"2023-04-29T04:44:45.200588Z","shell.execute_reply.started":"2023-04-29T04:44:45.190246Z","shell.execute_reply":"2023-04-29T04:44:45.199208Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\nfrom sklearn.linear_model import LinearRegression","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:44:45.202227Z","iopub.execute_input":"2023-04-29T04:44:45.202617Z","iopub.status.idle":"2023-04-29T04:44:45.212839Z","shell.execute_reply.started":"2023-04-29T04:44:45.202582Z","shell.execute_reply":"2023-04-29T04:44:45.211111Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"yn=np.array(y2)","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:44:45.214211Z","iopub.execute_input":"2023-04-29T04:44:45.215040Z","iopub.status.idle":"2023-04-29T04:44:45.223834Z","shell.execute_reply.started":"2023-04-29T04:44:45.214993Z","shell.execute_reply":"2023-04-29T04:44:45.222809Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ys=yn.reshape(-1,1)","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:44:45.225180Z","iopub.execute_input":"2023-04-29T04:44:45.226444Z","iopub.status.idle":"2023-04-29T04:44:45.236238Z","shell.execute_reply.started":"2023-04-29T04:44:45.226395Z","shell.execute_reply":"2023-04-29T04:44:45.234634Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"hl=list(huberpred.predict(dd)[0:r])","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:44:45.237824Z","iopub.execute_input":"2023-04-29T04:44:45.239017Z","iopub.status.idle":"2023-04-29T04:44:45.250114Z","shell.execute_reply.started":"2023-04-29T04:44:45.238970Z","shell.execute_reply":"2023-04-29T04:44:45.249057Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"hlt=list(huberpred.predict(dd)[r:l])","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:44:45.254216Z","iopub.execute_input":"2023-04-29T04:44:45.254996Z","iopub.status.idle":"2023-04-29T04:44:45.262128Z","shell.execute_reply.started":"2023-04-29T04:44:45.254945Z","shell.execute_reply":"2023-04-29T04:44:45.260941Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ndf=tr5","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:44:45.263432Z","iopub.execute_input":"2023-04-29T04:44:45.264931Z","iopub.status.idle":"2023-04-29T04:44:45.277491Z","shell.execute_reply.started":"2023-04-29T04:44:45.264836Z","shell.execute_reply":"2023-04-29T04:44:45.275650Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ntdf=te5","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:44:45.280725Z","iopub.execute_input":"2023-04-29T04:44:45.281169Z","iopub.status.idle":"2023-04-29T04:44:45.287793Z","shell.execute_reply.started":"2023-04-29T04:44:45.281132Z","shell.execute_reply":"2023-04-29T04:44:45.286475Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ndf['total_dist']=d[0:r]","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:44:45.289701Z","iopub.execute_input":"2023-04-29T04:44:45.290476Z","iopub.status.idle":"2023-04-29T04:44:45.300463Z","shell.execute_reply.started":"2023-04-29T04:44:45.290435Z","shell.execute_reply":"2023-04-29T04:44:45.299075Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ntdf['total_dist']=d[r:l]","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:44:45.301884Z","iopub.execute_input":"2023-04-29T04:44:45.302961Z","iopub.status.idle":"2023-04-29T04:44:45.312919Z","shell.execute_reply.started":"2023-04-29T04:44:45.302926Z","shell.execute_reply":"2023-04-29T04:44:45.311833Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ntdf['predict_clarity']=hlt","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:44:45.314692Z","iopub.execute_input":"2023-04-29T04:44:45.315305Z","iopub.status.idle":"2023-04-29T04:44:45.327926Z","shell.execute_reply.started":"2023-04-29T04:44:45.315271Z","shell.execute_reply":"2023-04-29T04:44:45.326814Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ndf['predict_clarity']=hl","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:44:45.331036Z","iopub.execute_input":"2023-04-29T04:44:45.331946Z","iopub.status.idle":"2023-04-29T04:44:45.342699Z","shell.execute_reply.started":"2023-04-29T04:44:45.331909Z","shell.execute_reply":"2023-04-29T04:44:45.341140Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"reg=LinearRegression()","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:44:45.344023Z","iopub.execute_input":"2023-04-29T04:44:45.344483Z","iopub.status.idle":"2023-04-29T04:44:45.355542Z","shell.execute_reply.started":"2023-04-29T04:44:45.344441Z","shell.execute_reply":"2023-04-29T04:44:45.354176Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"regz=LinearRegression()","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:44:45.356695Z","iopub.execute_input":"2023-04-29T04:44:45.357471Z","iopub.status.idle":"2023-04-29T04:44:45.372078Z","shell.execute_reply.started":"2023-04-29T04:44:45.357436Z","shell.execute_reply":"2023-04-29T04:44:45.370882Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"reg.fit(ndf[['total_dist','sensor_id','predict_clarity']],y1[0:r])","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:44:45.373308Z","iopub.execute_input":"2023-04-29T04:44:45.373930Z","iopub.status.idle":"2023-04-29T04:44:45.389030Z","shell.execute_reply.started":"2023-04-29T04:44:45.373896Z","shell.execute_reply":"2023-04-29T04:44:45.387729Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"reg.intercept_","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:44:45.390907Z","iopub.execute_input":"2023-04-29T04:44:45.391594Z","iopub.status.idle":"2023-04-29T04:44:45.399093Z","shell.execute_reply.started":"2023-04-29T04:44:45.391557Z","shell.execute_reply":"2023-04-29T04:44:45.397612Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"paz=reg.predict(ntdf[['total_dist','sensor_id','predict_clarity']])","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:44:45.400405Z","iopub.execute_input":"2023-04-29T04:44:45.401387Z","iopub.status.idle":"2023-04-29T04:44:45.411379Z","shell.execute_reply.started":"2023-04-29T04:44:45.401317Z","shell.execute_reply":"2023-04-29T04:44:45.410421Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"paz","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:44:45.412587Z","iopub.execute_input":"2023-04-29T04:44:45.413498Z","iopub.status.idle":"2023-04-29T04:44:45.423571Z","shell.execute_reply.started":"2023-04-29T04:44:45.413450Z","shell.execute_reply":"2023-04-29T04:44:45.422460Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"np.array(y1[r:l])","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:44:45.425174Z","iopub.execute_input":"2023-04-29T04:44:45.425525Z","iopub.status.idle":"2023-04-29T04:44:45.436091Z","shell.execute_reply.started":"2023-04-29T04:44:45.425486Z","shell.execute_reply":"2023-04-29T04:44:45.434595Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"regz.fit(ndf[['total_dist','sensor_id','predict_clarity']],y2[0:r])","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:44:45.437830Z","iopub.execute_input":"2023-04-29T04:44:45.438209Z","iopub.status.idle":"2023-04-29T04:44:45.451550Z","shell.execute_reply.started":"2023-04-29T04:44:45.438175Z","shell.execute_reply":"2023-04-29T04:44:45.450627Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pr=regz.predict(ntdf[['total_dist','sensor_id','predict_clarity']])","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:44:45.452669Z","iopub.execute_input":"2023-04-29T04:44:45.453996Z","iopub.status.idle":"2023-04-29T04:44:45.461967Z","shell.execute_reply.started":"2023-04-29T04:44:45.453954Z","shell.execute_reply":"2023-04-29T04:44:45.460800Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pr","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:44:45.463251Z","iopub.execute_input":"2023-04-29T04:44:45.463605Z","iopub.status.idle":"2023-04-29T04:44:45.476837Z","shell.execute_reply.started":"2023-04-29T04:44:45.463572Z","shell.execute_reply":"2023-04-29T04:44:45.475764Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"np.array(y2[r:l])","metadata":{"execution":{"iopub.status.busy":"2023-04-29T04:44:45.478233Z","iopub.execute_input":"2023-04-29T04:44:45.478958Z","iopub.status.idle":"2023-04-29T04:44:45.490026Z","shell.execute_reply.started":"2023-04-29T04:44:45.478920Z","shell.execute_reply":"2023-04-29T04:44:45.488670Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"The predicted direction for each sensor through azimuth and zenith angle at the bouncing point taken on events used for training would be used to deduce the spotted positions, x, y, z coordinates for events in test to arrive at their azimuth and zenith angle.","metadata":{}}]}