{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "%matplotlib inline\n", "import matplotlib.pyplot as plt\n", "import pandas\n", "import math\n", "import os\n", "import folium\n", "import geopy.distance" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "pos_df = pandas.DataFrame(\n", " data = [\n", " [\"walking\", \"50.81652\", \"8.77124\"],\n", " [\"city\", \"50.81774\", \"8.77236\"],\n", " [\"rural\", \"50.85028\", \"8.90166\"],\n", " ], \n", " columns = [\"scenario\", \"static_lat\", \"static_lon\"], \n", ")" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "def load_csv(name):\n", " scenario, mode, iteration = name.split(\".\")[0].split(\"_\")\n", " print(f\"Loading {scenario}, mode {mode}, iteration {iteration}...\")\n", " \n", " df = pandas.read_csv(name)\n", " df[\"recv_ts\"] = df[\"unix_nanosec\"] / 10**9\n", " df[\"payload\"] = df.apply(lambda row: bytes.fromhex(row[\"payload\"]).decode(\"utf-8\"), axis=1)\n", " df[\"channel\"] = df.apply(lambda row: row[\"payload\"].split(\"|\")[0], axis=1)\n", " df[\"sender\"] = df.apply(lambda row: row[\"payload\"].split(\"|\")[1], axis=1)\n", " df[\"gps_lat\"] = df.apply(lambda row: row[\"payload\"].split(\"|\")[2].split(\",\")[1], axis=1)\n", " df[\"gps_lon\"] = df.apply(lambda row: row[\"payload\"].split(\"|\")[2].split(\",\")[0], axis=1)\n", " df[\"send_ts\"] = df.apply(lambda row: int(row[\"payload\"].split(\"|\")[3]) / 1000, axis=1)\n", " df[\"delay_s\"] = df[\"recv_ts\"] - df[\"send_ts\"]\n", " df[\"scenario\"] = scenario\n", " df[\"mode\"] = mode\n", " df[\"iteration\"] = iteration\n", " \n", " return df" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Loading city, mode 3, iteration 0...\n", "Loading city, mode 3, iteration 1...\n", "Loading city, mode 3, iteration 2...\n", "Loading city, mode 0, iteration 1...\n", "Loading city, mode 0, iteration 0...\n", "Loading walking, mode 0, iteration 2...\n", "Loading walking, mode 0, iteration 1...\n", "Loading walking, mode 0, iteration 0...\n", "Loading rural, mode 3, iteration 0...\n", "Loading rural, mode 0, iteration 0...\n" ] } ], "source": [ "# load and merge all data\n", "dfs = [load_csv(name) for name in os.listdir(\".\") if name.endswith(\".csv\")]\n", "df = pandas.concat(dfs)\n", "df = pandas.merge(df, pos_df, on=\"scenario\", how=\"inner\")" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "# compute distances\n", "df[\"distance\"] = df.apply(lambda row: float(geopy.distance.distance(\n", " (row[\"gps_lat\"], row[\"gps_lon\"]),\n", " (row[\"static_lat\"], row[\"static_lon\"])\n", " ).km), axis=1)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | unix_nanosec | \n", "payload | \n", "rssi | \n", "snr | \n", "recv_ts | \n", "channel | \n", "sender | \n", "gps_lat | \n", "gps_lon | \n", "send_ts | \n", "delay_s | \n", "scenario | \n", "mode | \n", "iteration | \n", "static_lat | \n", "static_lon | \n", "distance | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
410 | \n", "1576940039423670773 | \n", "eval0|sender|8.901639149976264,50.850471349016... | \n", "-56 | \n", "10 | \n", "1.576940e+09 | \n", "eval0 | \n", "sender | \n", "50.85047134901676 | \n", "8.901639149976264 | \n", "1.576940e+09 | \n", "0.745671 | \n", "rural | \n", "0 | \n", "0 | \n", "50.85028 | \n", "8.90166 | \n", "0.021337 | \n", "
411 | \n", "1576940054425122206 | \n", "eval0|sender|8.901673044751822,50.850309930046... | \n", "-52 | \n", "9 | \n", "1.576940e+09 | \n", "eval0 | \n", "sender | \n", "50.850309930046706 | \n", "8.901673044751822 | \n", "1.576940e+09 | \n", "0.732122 | \n", "rural | \n", "0 | \n", "0 | \n", "50.85028 | \n", "8.90166 | \n", "0.003454 | \n", "
412 | \n", "1576940069425578433 | \n", "eval0|sender|8.901673044751822,50.850309930046... | \n", "-49 | \n", "9 | \n", "1.576940e+09 | \n", "eval0 | \n", "sender | \n", "50.850309930046706 | \n", "8.901673044751822 | \n", "1.576940e+09 | \n", "0.733579 | \n", "rural | \n", "0 | \n", "0 | \n", "50.85028 | \n", "8.90166 | \n", "0.003454 | \n", "
413 | \n", "1576940084426011375 | \n", "eval0|sender|8.901673044751822,50.850309930046... | \n", "-49 | \n", "10 | \n", "1.576940e+09 | \n", "eval0 | \n", "sender | \n", "50.850309930046706 | \n", "8.901673044751822 | \n", "1.576940e+09 | \n", "0.734011 | \n", "rural | \n", "0 | \n", "0 | \n", "50.85028 | \n", "8.90166 | \n", "0.003454 | \n", "
414 | \n", "1576940099426344525 | \n", "eval0|sender|8.901673044751822,50.850309930046... | \n", "-55 | \n", "9 | \n", "1.576940e+09 | \n", "eval0 | \n", "sender | \n", "50.850309930046706 | \n", "8.901673044751822 | \n", "1.576940e+09 | \n", "0.734344 | \n", "rural | \n", "0 | \n", "0 | \n", "50.85028 | \n", "8.90166 | \n", "0.003454 | \n", "