{"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)\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\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\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":"2022-07-06T04:08:16.656965Z","iopub.execute_input":"2022-07-06T04:08:16.657694Z","iopub.status.idle":"2022-07-06T04:08:18.527222Z","shell.execute_reply.started":"2022-07-06T04:08:16.65759Z","shell.execute_reply":"2022-07-06T04:08:18.525924Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"path = '/kaggle/input/google-smartphone-decimeter-challenge/train/2021-04-29-US-SJC-2/Pixel4'\n\n#/kaggle/input/google-smartphone-decimeter-challenge/train/2021-04-29-US-SJC-2/Pixel4/Pixel4_derived.csv\n#/kaggle/input/google-smartphone-decimeter-challenge/train/2021-04-29-US-SJC-2/Pixel4/Pixel4_GnssLog.txt\n#/kaggle/input/google-smartphone-decimeter-challenge/train/2021-04-29-US-SJC-2/Pixel4/ground_truth.csv\n#/kaggle/input/google-smartphone-decimeter-challenge/train/2021-04-29-US-SJC-2/Pixel4/supplemental/Pixel4_GnssLog.21o\n#/kaggle/input/google-smartphone-decimeter-challenge/train/2021-04-29-US-SJC-2/Pixel4/supplemental/SPAN_Pixel4_10Hz.nmea\n\n\nPixel4_derived = pd.read_csv(f'{path}/Pixel4_derived.csv')\nground_truth = pd.read_csv(f'{path}/ground_truth.csv')\n\nPixel4_derived.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-06T04:10:04.269132Z","iopub.execute_input":"2022-07-06T04:10:04.269546Z","iopub.status.idle":"2022-07-06T04:10:04.763026Z","shell.execute_reply.started":"2022-07-06T04:10:04.269514Z","shell.execute_reply":"2022-07-06T04:10:04.761192Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.scatterplot(data=Pixel4_derived, x='millisSinceGpsEpoch', y='signalType', hue='signalType')","metadata":{"execution":{"iopub.status.busy":"2022-07-06T04:22:55.196434Z","iopub.execute_input":"2022-07-06T04:22:55.196869Z","iopub.status.idle":"2022-07-06T04:23:00.057859Z","shell.execute_reply.started":"2022-07-06T04:22:55.19683Z","shell.execute_reply":"2022-07-06T04:23:00.056504Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import seaborn as sns\nsns.scatterplot(data=Pixel4_derived, x='xSatPosM', y='ySatPosM', hue='signalType')","metadata":{"execution":{"iopub.status.busy":"2022-07-06T04:11:42.837865Z","iopub.execute_input":"2022-07-06T04:11:42.838268Z","iopub.status.idle":"2022-07-06T04:11:48.182513Z","shell.execute_reply.started":"2022-07-06T04:11:42.838236Z","shell.execute_reply":"2022-07-06T04:11:48.181246Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ground_truth['lngDeg'].median()","metadata":{"execution":{"iopub.status.busy":"2022-07-06T04:15:23.779541Z","iopub.execute_input":"2022-07-06T04:15:23.779989Z","iopub.status.idle":"2022-07-06T04:15:23.791525Z","shell.execute_reply.started":"2022-07-06T04:15:23.779956Z","shell.execute_reply":"2022-07-06T04:15:23.790168Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.scatterplot(data=ground_truth, x='latDeg', y='lngDeg', hue='timeSinceFirstFixSeconds')","metadata":{"execution":{"iopub.status.busy":"2022-07-06T04:13:05.050396Z","iopub.execute_input":"2022-07-06T04:13:05.050873Z","iopub.status.idle":"2022-07-06T04:13:05.644252Z","shell.execute_reply.started":"2022-07-06T04:13:05.050837Z","shell.execute_reply":"2022-07-06T04:13:05.6432Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import plotly.express as px\nfig = px.scatter_mapbox(ground_truth,\n                    # Here, plotly gets, (x,y) coordinates\n                    lat=\"latDeg\",\n                    lon=\"lngDeg\",\n                    text='phoneName',\n\n                    #Here, plotly detects color of series\n                    color=\"heightAboveWgs84EllipsoidM\",\n                    labels=\"collectionName\",\n\n                    zoom=14.5,\n                    center={\"lat\":37.3346657612, \"lon\":-121.88833361},\n                    height=600,\n                    width=800)\nfig.update_layout(mapbox_style='stamen-terrain')\nfig.update_layout(margin={\"r\": 0, \"t\": 0, \"l\": 0, \"b\": 0})\nfig.update_layout(title_text=\"GPS trafic\")\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-06T04:19:01.066921Z","iopub.execute_input":"2022-07-06T04:19:01.067934Z","iopub.status.idle":"2022-07-06T04:19:01.16231Z","shell.execute_reply.started":"2022-07-06T04:19:01.067877Z","shell.execute_reply":"2022-07-06T04:19:01.16111Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ground_truth","metadata":{"execution":{"iopub.status.busy":"2022-07-06T04:10:09.991267Z","iopub.execute_input":"2022-07-06T04:10:09.991647Z","iopub.status.idle":"2022-07-06T04:10:10.025026Z","shell.execute_reply.started":"2022-07-06T04:10:09.991615Z","shell.execute_reply":"2022-07-06T04:10:10.023445Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ground_truth['millisSinceGpsEpoch'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-07-06T04:26:52.997011Z","iopub.execute_input":"2022-07-06T04:26:52.99763Z","iopub.status.idle":"2022-07-06T04:26:53.013121Z","shell.execute_reply.started":"2022-07-06T04:26:52.997594Z","shell.execute_reply":"2022-07-06T04:26:53.011965Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def gnss_log_to_dataframes(path):\n    print('Loading ' + path, flush=True)\n    gnss_section_names = {'Raw','UncalAccel', 'UncalGyro', 'UncalMag', 'Fix', 'Status', 'OrientationDeg'}\n    with open(path) as f_open:\n        datalines = f_open.readlines()\n\n    datas = {k: [] for k in gnss_section_names}\n    gnss_map = {k: [] for k in gnss_section_names}\n    for dataline in datalines:\n        is_header = dataline.startswith('#')\n        dataline = dataline.strip('#').strip().split(',')\n        # skip over notes, version numbers, etc\n        if is_header and dataline[0] in gnss_section_names:\n            gnss_map[dataline[0]] = dataline[1:]\n        elif not is_header:\n            datas[dataline[0]].append(dataline[1:])\n\n    results = dict()\n    for k, v in datas.items():\n        results[k] = pd.DataFrame(v, columns=gnss_map[k])\n    # pandas doesn't properly infer types from these lists by default\n    for k, df in results.items():\n        for col in df.columns:\n            if col == 'CodeType':\n                continue\n            results[k][col] = pd.to_numeric(results[k][col])\n\n    return results","metadata":{"execution":{"iopub.status.busy":"2022-07-06T04:27:53.878434Z","iopub.execute_input":"2022-07-06T04:27:53.878865Z","iopub.status.idle":"2022-07-06T04:27:53.892876Z","shell.execute_reply.started":"2022-07-06T04:27:53.878832Z","shell.execute_reply":"2022-07-06T04:27:53.891795Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"Pixel4_GnssLog = gnss_log_to_dataframes(path+'/Pixel4_GnssLog.txt')\nPixel4_GnssLog.keys()","metadata":{"execution":{"iopub.status.busy":"2022-07-06T04:29:44.851376Z","iopub.execute_input":"2022-07-06T04:29:44.855305Z","iopub.status.idle":"2022-07-06T04:30:07.21265Z","shell.execute_reply.started":"2022-07-06T04:29:44.8552Z","shell.execute_reply":"2022-07-06T04:30:07.211166Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"Pixel4_GnssLog['Raw'].head()","metadata":{"execution":{"iopub.status.busy":"2022-07-06T04:30:10.243763Z","iopub.execute_input":"2022-07-06T04:30:10.244335Z","iopub.status.idle":"2022-07-06T04:30:10.276023Z","shell.execute_reply.started":"2022-07-06T04:30:10.244299Z","shell.execute_reply":"2022-07-06T04:30:10.274635Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}