mash-server/bettwaage-plotter/data_analysis.ipynb

119 lines
33 KiB
Text
Raw Normal View History

2024-05-17 09:48:14 +02:00
{
"cells": [
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"\n",
"with open(\"latest_history.json\", \"r\") as fp:\n",
" data = json.load(fp)"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {},
"outputs": [],
"source": [
"data = data[int(-60 * 60 * 14.5):int(-60 * 60 * 13)]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Total bed weight: 78.98908\n"
]
}
],
"source": [
"# Get rough value for empty bed weight per leg\n",
"rough_bed_weight = 80\n",
"bed_only_weight = {}\n",
"for d in data:\n",
" if d[\"total\"] < rough_bed_weight:\n",
" bed_only_weight = {\n",
" \"tl\": d[\"tl\"],\n",
" \"tr\": d[\"tr\"],\n",
" \"bl\": d[\"bl\"],\n",
" \"br\": d[\"br\"],\n",
" }\n",
" total_bed_only_weight = sum(bed_only_weight.values())\n",
" break\n",
"\n",
"print(f\"Total bed weight: {total_bed_only_weight}\")"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [],
"source": [
"y = [d[\"total\"] - total_bed_only_weight for d in data]\n",
"y = [(i if i > 10 else None) for i in y]\n",
"\n",
"x = [i for i in range(len(y))]"
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjsAAAGwCAYAAABPSaTdAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8fJSN1AAAACXBIWXMAAA9hAAAPYQGoP6dpAABbB0lEQVR4nO3dd3wUdf4/8Nemh/RCGgQINSAtFDGAGCCKgCh2/HIccooNUQQbKuihAnJWFEE9D/B+ClYsKAhHLyH0EkpooQg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XrBNsz8JcOm59uTZFj7yZh6L2N9jIiIyDJMdlwQb32W8fasO1KNhz8a64ujZDMSExoiIvmwzw5pQtblUlwpqUCLMH/EhvgDADw96nL5xrMaqzGtMFmzo8aAiYhcCGt2SBM+WX8S9y1Kwy/7L4rbvDyka3aMZTuNOyPbk2NYW0tkKqHp3jLUjkiIyN2VVVbji82ncfZKqfmdNYrJjgvj6B3TvK43Y1U3bsYy9gSVNWPFhvgBAAa2j3R2OESkIfNWZ+LtP44i9f1NSoeiGFUnOzU1NZgxYwYSEhLg7++Pdu3a4c033zQY6SIIAmbOnInY2Fj4+/sjNTUVJ06cUDBqUoLUEPFrlTUAgOpGK5Eb7bPT6HdnrjYu9Va1189zNmORq5r63X489tVu5BSWKx2KW9txfYJTWxYq1gpVJzvvvPMOFi5ciE8++QRHjx7FO++8g3nz5uHjjz8W95k3bx7mz5+PRYsWIT09HQEBARg2bBjKy7V7cTnzJuxq9I/MY//dAwA4kVdi0XP
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import matplotlib.pyplot as plt\n",
"\n",
"fig, ax = plt.subplots()\n",
"\n",
"ax.set_xlabel(\"Time (s)\")\n",
"ax.set_ylabel(\"Weight (kg)\")\n",
"\n",
"ax.plot(x, y, color=\"tab:blue\")\n",
"\n",
"plt.show()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
}
},
"nbformat": 4,
"nbformat_minor": 2
}