{"cells":[{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"code","source":"import numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport os\nimport glob\nimport matplotlib.pyplot as plt\n\n!ls ../input/indoor-location-navigation","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"trainfiles = glob.glob('../input/indoor-location-navigation/train/*/*/*')\nlen(trainfiles), trainfiles[0]","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"!head ../input/indoor-location-navigation/train/5cd56c0ce2acfd2d33b6ab27/B1/5d09a625bd54340008acddb9.txt","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"def load_dict( filename ):\n    with open(filename) as f:\n        lines = f.readlines()\n\n    proc = {}\n    for l in lines:\n        l = l.replace('\\n','')\n        \n        if l[0]!='#':\n            val = l.split('\\t')\n            if val[0] not in proc:\n                proc[val[0]] = {}\n            proc[val[0]][val[1]] = val[2:]\n\n    return proc","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"path = load_dict( trainfiles[0] )\n\nlen(path)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"path['1560913374746']","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"def plot_values( path, var='TYPE_ACCELEROMETER', cumsum=False ):\n    x = [ float(path[p][var][0]) for p in path if var in path[p] ]\n    y = [ float(path[p][var][1]) for p in path if var in path[p] ]\n    if cumsum:\n        plt.plot( np.cumsum(x), np.cumsum(y) )\n    else:\n        plt.plot( x, y )","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"plot_values( path, var='TYPE_ACCELEROMETER', cumsum=True  )\nplot_values( path, var='TYPE_ACCELEROMETER_UNCALIBRATED', cumsum=True  )","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"plot_values( path, var='TYPE_MAGNETIC_FIELD', cumsum=False  )\nplot_values( path, var='TYPE_MAGNETIC_FIELD_UNCALIBRATED', cumsum=False  )","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"plot_values( path, var='TYPE_GYROSCOPE', cumsum=True  )\nplot_values( path, var='TYPE_GYROSCOPE_UNCALIBRATED', cumsum=True  )","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"plot_values( path, var='TYPE_ROTATION_VECTOR', cumsum=False  )","execution_count":null,"outputs":[]}],"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":4,"nbformat_minor":4}