{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.13","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":60095,"databundleVersionId":6542333,"sourceType":"competition"}],"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"# Smartphone Decimeter: Device GNSS/IMU Data","metadata":{"papermill":{"duration":0.023455,"end_time":"2021-10-15T07:15:30.871323","exception":false,"start_time":"2021-10-15T07:15:30.847868","status":"completed"},"tags":[]}},{"cell_type":"code","source":"import os\nimport numpy as np\nimport pandas as pd\nimport random\nimport folium\nfrom folium import plugins\nimport seaborn as sns\nimport cv2\nimport matplotlib.pyplot as plt\nimport IPython\nimport time\nimport plotly.express as px\nimport matplotlib.pyplot as plt\nfrom mpl_toolkits.mplot3d import Axes3D\nfrom branca.colormap import linear","metadata":{"papermill":{"duration":3.207351,"end_time":"2021-10-15T07:15:34.18931","exception":false,"start_time":"2021-10-15T07:15:30.981959","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2024-02-21T10:35:44.756578Z","iopub.execute_input":"2024-02-21T10:35:44.757146Z","iopub.status.idle":"2024-02-21T10:35:44.766124Z","shell.execute_reply.started":"2024-02-21T10:35:44.757110Z","shell.execute_reply":"2024-02-21T10:35:44.764417Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# device_gnss.csv\n\n[train/test]/[drive_id]/[phone_name]/device_gnss.csv - Each row contains raw GNSS measurements, derived values, and a baseline estimated location. This baseline was computed using correctedPrM and the satellite positions, using a standard Weighted Least Squares (WLS) solver, with the phone's position (x, y, z), clock bias (t), and isrbM for each unique signal type as states for each epoch. Some of the raw measurement fields are not included in this file because they are deprecated or are not populated in the original gnss_log.txt.","metadata":{}},{"cell_type":"code","source":"gnss=pd.read_csv('/kaggle/input/smartphone-decimeter-2023/sdc2023/train/2020-06-25-00-34-us-ca-mtv-sb-101/pixel4/device_gnss.csv')\nprint(gnss.columns.tolist())\ndisplay(gnss[0:1])\ngnss['MessageType'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2024-02-21T10:35:44.768504Z","iopub.execute_input":"2024-02-21T10:35:44.768961Z","iopub.status.idle":"2024-02-21T10:35:45.490741Z","shell.execute_reply.started":"2024-02-21T10:35:44.768922Z","shell.execute_reply":"2024-02-21T10:35:45.489595Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# device_imu.csv \n\n[train/test]/[drive_id]/[phone_name]/device_imu.csv - Readings the phone's accelerometer, gyroscope, and magnetometer.\n","metadata":{}},{"cell_type":"code","source":"imu=pd.read_csv('/kaggle/input/smartphone-decimeter-2023/sdc2023/train/2020-06-25-00-34-us-ca-mtv-sb-101/pixel4/device_imu.csv')\nprint(imu.columns.tolist())\ndisplay(imu[0:1])\nimu['MessageType'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2024-02-21T10:35:45.492274Z","iopub.execute_input":"2024-02-21T10:35:45.492748Z","iopub.status.idle":"2024-02-21T10:35:45.747899Z","shell.execute_reply.started":"2024-02-21T10:35:45.492708Z","shell.execute_reply":"2024-02-21T10:35:45.746794Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# ground_truth.csv\n\n\ntrain/[drive_id]/[phone_name]/ground_truth.csv - Reference locations at expected timestamps.","metadata":{}},{"cell_type":"code","source":"\ntruth=pd.read_csv('/kaggle/input/smartphone-decimeter-2023/sdc2023/train/2020-06-25-00-34-us-ca-mtv-sb-101/pixel4/ground_truth.csv')\nprint(truth.columns.tolist())\ndisplay(truth[0:1])","metadata":{"papermill":{"duration":0.097915,"end_time":"2021-10-15T07:15:34.311617","exception":false,"start_time":"2021-10-15T07:15:34.213702","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2024-02-21T10:35:45.749484Z","iopub.execute_input":"2024-02-21T10:35:45.749879Z","iopub.status.idle":"2024-02-21T10:35:45.774847Z","shell.execute_reply.started":"2024-02-21T10:35:45.749850Z","shell.execute_reply":"2024-02-21T10:35:45.773555Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Check device_gnss data in the train dataset.","metadata":{}},{"cell_type":"code","source":"df=gnss\nprint(len(df))\nfor col in df.columns[2:]:\n    try:\n        plt.figure(figsize=(10,4))\n        plt.scatter(df['utcTimeMillis'], df[col], label=col)\n        plt.xlabel('utcTimeMillis')\n        plt.ylabel(col)\n        plt.title('Scatter Plots for '+col)\n        plt.legend()  \n        plt.show()\n    except:\n        print(col)\n        continue","metadata":{"execution":{"iopub.status.busy":"2024-02-21T10:35:45.786936Z","iopub.status.idle":"2024-02-21T10:35:45.787387Z","shell.execute_reply.started":"2024-02-21T10:35:45.787196Z","shell.execute_reply":"2024-02-21T10:35:45.787214Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Check device_imu data in the train dataset.","metadata":{}},{"cell_type":"code","source":"df2=imu\nprint(len(df2))\nfor col in df2.columns[2:]:\n    try:\n        plt.figure(figsize=(10,4))\n        plt.scatter(df2['utcTimeMillis'], df2[col], label=col)\n        plt.xlabel('utcTimeMillis')\n        plt.ylabel(col)\n        plt.title('Scatter Plots for '+col)\n        plt.legend()  \n        plt.show()\n    except:\n        print(col)\n        continue","metadata":{"execution":{"iopub.status.busy":"2024-02-21T10:35:45.788917Z","iopub.status.idle":"2024-02-21T10:35:45.789312Z","shell.execute_reply.started":"2024-02-21T10:35:45.789129Z","shell.execute_reply":"2024-02-21T10:35:45.789145Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = plt.figure(figsize=(10, 10))\nax = fig.add_subplot(111, projection='3d')\nax.scatter(df2['MeasurementX'], df2['MeasurementY'], df2['MeasurementZ'], label='X-Y-Z',alpha=0.2)\nax.set_xlabel('MeasurementX')\nax.set_ylabel('MeasurementY')\nax.set_zlabel('MeasurementZ')\nax.set_title('3D Scatter Plot for X-Y-Z')\nax.legend()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-02-21T10:35:45.791210Z","iopub.status.idle":"2024-02-21T10:35:45.791646Z","shell.execute_reply.started":"2024-02-21T10:35:45.791426Z","shell.execute_reply":"2024-02-21T10:35:45.791443Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}