Last active
February 19, 2022 12:05
-
-
Save redraw/59cd1fec480eb2bdde11eac0aee94d95 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "cells": [ | |
| { | |
| "cell_type": "code", | |
| "execution_count": 1, | |
| "id": "93c08bd6-c694-4a69-bf65-5d3ea0e088fa", | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "import pandas as pd" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 2, | |
| "id": "8ab71b03-7c9a-4f42-8aaf-3a918c8ed0f2", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/html": [ | |
| "<div>\n", | |
| "<style scoped>\n", | |
| " .dataframe tbody tr th:only-of-type {\n", | |
| " vertical-align: middle;\n", | |
| " }\n", | |
| "\n", | |
| " .dataframe tbody tr th {\n", | |
| " vertical-align: top;\n", | |
| " }\n", | |
| "\n", | |
| " .dataframe thead th {\n", | |
| " text-align: right;\n", | |
| " }\n", | |
| "</style>\n", | |
| "<table border=\"1\" class=\"dataframe\">\n", | |
| " <thead>\n", | |
| " <tr style=\"text-align: right;\">\n", | |
| " <th></th>\n", | |
| " <th>kernel</th>\n", | |
| " <th>bios</th>\n", | |
| " <th>state</th>\n", | |
| " <th>bat</th>\n", | |
| " <th>total</th>\n", | |
| " <th>value</th>\n", | |
| " <th>timestamp</th>\n", | |
| " </tr>\n", | |
| " </thead>\n", | |
| " <tbody>\n", | |
| " <tr>\n", | |
| " <th>21</th>\n", | |
| " <td>5.8.0-38-generic</td>\n", | |
| " <td>R1BET60W(1.29 )</td>\n", | |
| " <td>resume</td>\n", | |
| " <td>BAT0/</td>\n", | |
| " <td>51480000</td>\n", | |
| " <td>28230000</td>\n", | |
| " <td>1626478223</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>22</th>\n", | |
| " <td>5.8.0-38-generic</td>\n", | |
| " <td>R1BET60W(1.29 )</td>\n", | |
| " <td>suspend-then-hibernate</td>\n", | |
| " <td>BAT0/</td>\n", | |
| " <td>51480000</td>\n", | |
| " <td>45660000</td>\n", | |
| " <td>1626500709</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>23</th>\n", | |
| " <td>5.8.0-38-generic</td>\n", | |
| " <td>R1BET60W(1.29 )</td>\n", | |
| " <td>resume</td>\n", | |
| " <td>BAT0/</td>\n", | |
| " <td>51480000</td>\n", | |
| " <td>45260000</td>\n", | |
| " <td>1626504311</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>24</th>\n", | |
| " <td>5.8.0-38-generic</td>\n", | |
| " <td>R1BET60W(1.29 )</td>\n", | |
| " <td>suspend-then-hibernate</td>\n", | |
| " <td>BAT0/</td>\n", | |
| " <td>51480000</td>\n", | |
| " <td>45260000</td>\n", | |
| " <td>1626504311</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>25</th>\n", | |
| " <td>5.8.0-38-generic</td>\n", | |
| " <td>R1BET60W(1.29 )</td>\n", | |
| " <td>resume</td>\n", | |
| " <td>BAT0/</td>\n", | |
| " <td>51480000</td>\n", | |
| " <td>44770000</td>\n", | |
| " <td>1626651606</td>\n", | |
| " </tr>\n", | |
| " </tbody>\n", | |
| "</table>\n", | |
| "</div>" | |
| ], | |
| "text/plain": [ | |
| " kernel bios state bat \\\n", | |
| "21 5.8.0-38-generic R1BET60W(1.29 ) resume BAT0/ \n", | |
| "22 5.8.0-38-generic R1BET60W(1.29 ) suspend-then-hibernate BAT0/ \n", | |
| "23 5.8.0-38-generic R1BET60W(1.29 ) resume BAT0/ \n", | |
| "24 5.8.0-38-generic R1BET60W(1.29 ) suspend-then-hibernate BAT0/ \n", | |
| "25 5.8.0-38-generic R1BET60W(1.29 ) resume BAT0/ \n", | |
| "\n", | |
| " total value timestamp \n", | |
| "21 51480000 28230000 1626478223 \n", | |
| "22 51480000 45660000 1626500709 \n", | |
| "23 51480000 45260000 1626504311 \n", | |
| "24 51480000 45260000 1626504311 \n", | |
| "25 51480000 44770000 1626651606 " | |
| ] | |
| }, | |
| "execution_count": 2, | |
| "metadata": {}, | |
| "output_type": "execute_result" | |
| } | |
| ], | |
| "source": [ | |
| "df = pd.read_csv(\"/var/log/battery.csv\", names=[\"kernel\", \"bios\", \"state\", \"bat\", \"total\", \"value\", \"timestamp\"])\n", | |
| "df.tail()" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 3, | |
| "id": "aac26701-f704-459f-9009-e237cfcf68aa", | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "df.timestamp = pd.to_datetime(df.timestamp, unit=\"s\", utc=True)\n", | |
| "df.timestamp = df.timestamp.dt.tz_convert(\"America/Buenos_Aires\")\n", | |
| "df.state = df.state.astype(\"category\")\n", | |
| "df[\"prev_state\"] = df.state.shift(1)\n", | |
| "df[\"total_watt\"] = df.total / 1e6\n", | |
| "df[\"value_watt\"] = df.value / 1e6\n", | |
| "df = df.set_index(\"timestamp\")" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 4, | |
| "id": "1d70e991-055c-41f3-9ba3-bfe650a89fe3", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/html": [ | |
| "<div>\n", | |
| "<style scoped>\n", | |
| " .dataframe tbody tr th:only-of-type {\n", | |
| " vertical-align: middle;\n", | |
| " }\n", | |
| "\n", | |
| " .dataframe tbody tr th {\n", | |
| " vertical-align: top;\n", | |
| " }\n", | |
| "\n", | |
| " .dataframe thead th {\n", | |
| " text-align: right;\n", | |
| " }\n", | |
| "</style>\n", | |
| "<table border=\"1\" class=\"dataframe\">\n", | |
| " <thead>\n", | |
| " <tr style=\"text-align: right;\">\n", | |
| " <th></th>\n", | |
| " <th>kernel</th>\n", | |
| " <th>bios</th>\n", | |
| " <th>state</th>\n", | |
| " <th>bat</th>\n", | |
| " <th>total</th>\n", | |
| " <th>value</th>\n", | |
| " <th>prev_state</th>\n", | |
| " <th>total_watt</th>\n", | |
| " <th>value_watt</th>\n", | |
| " <th>value_diff_watt</th>\n", | |
| " <th>time_diff</th>\n", | |
| " <th>rate_per_hour_watt</th>\n", | |
| " <th>charge</th>\n", | |
| " <th>charge_diff</th>\n", | |
| " <th>charge_per_hour_diff</th>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>timestamp</th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " </tr>\n", | |
| " </thead>\n", | |
| " <tbody>\n", | |
| " <tr>\n", | |
| " <th>2021-07-13 20:18:08-03:00</th>\n", | |
| " <td>5.8.0-38-generic</td>\n", | |
| " <td>R1BET60W(1.29 )</td>\n", | |
| " <td>suspend</td>\n", | |
| " <td>BAT0/</td>\n", | |
| " <td>51480000</td>\n", | |
| " <td>16810000</td>\n", | |
| " <td>NaN</td>\n", | |
| " <td>51.48</td>\n", | |
| " <td>16.81</td>\n", | |
| " <td>NaN</td>\n", | |
| " <td>NaT</td>\n", | |
| " <td>NaN</td>\n", | |
| " <td>33.0</td>\n", | |
| " <td>NaN</td>\n", | |
| " <td>NaN</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>2021-07-13 20:18:22-03:00</th>\n", | |
| " <td>5.8.0-38-generic</td>\n", | |
| " <td>R1BET60W(1.29 )</td>\n", | |
| " <td>resume</td>\n", | |
| " <td>BAT0/</td>\n", | |
| " <td>51480000</td>\n", | |
| " <td>16800000</td>\n", | |
| " <td>suspend</td>\n", | |
| " <td>51.48</td>\n", | |
| " <td>16.80</td>\n", | |
| " <td>-0.01</td>\n", | |
| " <td>0 days 00:00:14</td>\n", | |
| " <td>-2.571429</td>\n", | |
| " <td>33.0</td>\n", | |
| " <td>-0.019425</td>\n", | |
| " <td>-4.995005</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>2021-07-13 21:09:52-03:00</th>\n", | |
| " <td>5.8.0-38-generic</td>\n", | |
| " <td>R1BET60W(1.29 )</td>\n", | |
| " <td>suspend-then-hibernate</td>\n", | |
| " <td>BAT0/</td>\n", | |
| " <td>51480000</td>\n", | |
| " <td>32220000</td>\n", | |
| " <td>resume</td>\n", | |
| " <td>51.48</td>\n", | |
| " <td>32.22</td>\n", | |
| " <td>15.42</td>\n", | |
| " <td>0 days 00:51:30</td>\n", | |
| " <td>17.965049</td>\n", | |
| " <td>63.0</td>\n", | |
| " <td>29.953380</td>\n", | |
| " <td>34.897142</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>2021-07-13 22:09:54-03:00</th>\n", | |
| " <td>5.8.0-38-generic</td>\n", | |
| " <td>R1BET60W(1.29 )</td>\n", | |
| " <td>resume</td>\n", | |
| " <td>BAT0/</td>\n", | |
| " <td>51480000</td>\n", | |
| " <td>31820000</td>\n", | |
| " <td>suspend-then-hibernate</td>\n", | |
| " <td>51.48</td>\n", | |
| " <td>31.82</td>\n", | |
| " <td>-0.40</td>\n", | |
| " <td>0 days 01:00:02</td>\n", | |
| " <td>-0.399778</td>\n", | |
| " <td>62.0</td>\n", | |
| " <td>-0.777001</td>\n", | |
| " <td>-0.776569</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>2021-07-13 22:09:55-03:00</th>\n", | |
| " <td>5.8.0-38-generic</td>\n", | |
| " <td>R1BET60W(1.29 )</td>\n", | |
| " <td>suspend-then-hibernate</td>\n", | |
| " <td>BAT0/</td>\n", | |
| " <td>51480000</td>\n", | |
| " <td>31820000</td>\n", | |
| " <td>resume</td>\n", | |
| " <td>51.48</td>\n", | |
| " <td>31.82</td>\n", | |
| " <td>0.00</td>\n", | |
| " <td>0 days 00:00:01</td>\n", | |
| " <td>0.000000</td>\n", | |
| " <td>62.0</td>\n", | |
| " <td>0.000000</td>\n", | |
| " <td>0.000000</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>2021-07-13 22:34:42-03:00</th>\n", | |
| " <td>5.8.0-38-generic</td>\n", | |
| " <td>R1BET60W(1.29 )</td>\n", | |
| " <td>resume</td>\n", | |
| " <td>BAT0/</td>\n", | |
| " <td>51480000</td>\n", | |
| " <td>31530000</td>\n", | |
| " <td>suspend-then-hibernate</td>\n", | |
| " <td>51.48</td>\n", | |
| " <td>31.53</td>\n", | |
| " <td>-0.29</td>\n", | |
| " <td>0 days 00:24:47</td>\n", | |
| " <td>-0.702085</td>\n", | |
| " <td>61.0</td>\n", | |
| " <td>-0.563326</td>\n", | |
| " <td>-1.363801</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>2021-07-13 22:52:54-03:00</th>\n", | |
| " <td>5.8.0-38-generic</td>\n", | |
| " <td>R1BET60W(1.29 )</td>\n", | |
| " <td>suspend-then-hibernate</td>\n", | |
| " <td>BAT0/</td>\n", | |
| " <td>51480000</td>\n", | |
| " <td>30010000</td>\n", | |
| " <td>resume</td>\n", | |
| " <td>51.48</td>\n", | |
| " <td>30.01</td>\n", | |
| " <td>-1.52</td>\n", | |
| " <td>0 days 00:18:12</td>\n", | |
| " <td>-5.010989</td>\n", | |
| " <td>58.0</td>\n", | |
| " <td>-2.952603</td>\n", | |
| " <td>-9.733856</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>2021-07-13 23:52:55-03:00</th>\n", | |
| " <td>5.8.0-38-generic</td>\n", | |
| " <td>R1BET60W(1.29 )</td>\n", | |
| " <td>resume</td>\n", | |
| " <td>BAT0/</td>\n", | |
| " <td>51480000</td>\n", | |
| " <td>29670000</td>\n", | |
| " <td>suspend-then-hibernate</td>\n", | |
| " <td>51.48</td>\n", | |
| " <td>29.67</td>\n", | |
| " <td>-0.34</td>\n", | |
| " <td>0 days 01:00:01</td>\n", | |
| " <td>-0.339906</td>\n", | |
| " <td>58.0</td>\n", | |
| " <td>-0.660451</td>\n", | |
| " <td>-0.660267</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>2021-07-13 23:52:56-03:00</th>\n", | |
| " <td>5.8.0-38-generic</td>\n", | |
| " <td>R1BET60W(1.29 )</td>\n", | |
| " <td>suspend-then-hibernate</td>\n", | |
| " <td>BAT0/</td>\n", | |
| " <td>51480000</td>\n", | |
| " <td>29670000</td>\n", | |
| " <td>resume</td>\n", | |
| " <td>51.48</td>\n", | |
| " <td>29.67</td>\n", | |
| " <td>0.00</td>\n", | |
| " <td>0 days 00:00:01</td>\n", | |
| " <td>0.000000</td>\n", | |
| " <td>58.0</td>\n", | |
| " <td>0.000000</td>\n", | |
| " <td>0.000000</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>2021-07-14 00:55:43-03:00</th>\n", | |
| " <td>5.8.0-38-generic</td>\n", | |
| " <td>R1BET60W(1.29 )</td>\n", | |
| " <td>resume</td>\n", | |
| " <td>BAT0/</td>\n", | |
| " <td>51480000</td>\n", | |
| " <td>29380000</td>\n", | |
| " <td>suspend-then-hibernate</td>\n", | |
| " <td>51.48</td>\n", | |
| " <td>29.38</td>\n", | |
| " <td>-0.29</td>\n", | |
| " <td>0 days 01:02:47</td>\n", | |
| " <td>-0.277144</td>\n", | |
| " <td>57.0</td>\n", | |
| " <td>-0.563326</td>\n", | |
| " <td>-0.538352</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>2021-07-14 02:39:08-03:00</th>\n", | |
| " <td>5.8.0-38-generic</td>\n", | |
| " <td>R1BET60W(1.29 )</td>\n", | |
| " <td>suspend-then-hibernate</td>\n", | |
| " <td>BAT0/</td>\n", | |
| " <td>51480000</td>\n", | |
| " <td>18560000</td>\n", | |
| " <td>resume</td>\n", | |
| " <td>51.48</td>\n", | |
| " <td>18.56</td>\n", | |
| " <td>-10.82</td>\n", | |
| " <td>0 days 01:43:25</td>\n", | |
| " <td>-6.277518</td>\n", | |
| " <td>36.0</td>\n", | |
| " <td>-21.017871</td>\n", | |
| " <td>-12.194091</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>2021-07-14 03:39:10-03:00</th>\n", | |
| " <td>5.8.0-38-generic</td>\n", | |
| " <td>R1BET60W(1.29 )</td>\n", | |
| " <td>resume</td>\n", | |
| " <td>BAT0/</td>\n", | |
| " <td>51480000</td>\n", | |
| " <td>18210000</td>\n", | |
| " <td>suspend-then-hibernate</td>\n", | |
| " <td>51.48</td>\n", | |
| " <td>18.21</td>\n", | |
| " <td>-0.35</td>\n", | |
| " <td>0 days 01:00:02</td>\n", | |
| " <td>-0.349806</td>\n", | |
| " <td>35.0</td>\n", | |
| " <td>-0.679876</td>\n", | |
| " <td>-0.679498</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>2021-07-14 03:39:11-03:00</th>\n", | |
| " <td>5.8.0-38-generic</td>\n", | |
| " <td>R1BET60W(1.29 )</td>\n", | |
| " <td>suspend-then-hibernate</td>\n", | |
| " <td>BAT0/</td>\n", | |
| " <td>51480000</td>\n", | |
| " <td>18210000</td>\n", | |
| " <td>resume</td>\n", | |
| " <td>51.48</td>\n", | |
| " <td>18.21</td>\n", | |
| " <td>0.00</td>\n", | |
| " <td>0 days 00:00:01</td>\n", | |
| " <td>0.000000</td>\n", | |
| " <td>35.0</td>\n", | |
| " <td>0.000000</td>\n", | |
| " <td>0.000000</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>2021-07-15 14:38:59-03:00</th>\n", | |
| " <td>5.8.0-38-generic</td>\n", | |
| " <td>R1BET60W(1.29 )</td>\n", | |
| " <td>resume</td>\n", | |
| " <td>BAT0/</td>\n", | |
| " <td>51480000</td>\n", | |
| " <td>17700000</td>\n", | |
| " <td>suspend-then-hibernate</td>\n", | |
| " <td>51.48</td>\n", | |
| " <td>17.70</td>\n", | |
| " <td>-0.51</td>\n", | |
| " <td>1 days 10:59:48</td>\n", | |
| " <td>-0.046378</td>\n", | |
| " <td>34.0</td>\n", | |
| " <td>-0.990676</td>\n", | |
| " <td>-0.090089</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>2021-07-15 18:19:15-03:00</th>\n", | |
| " <td>5.8.0-38-generic</td>\n", | |
| " <td>R1BET60W(1.29 )</td>\n", | |
| " <td>suspend-then-hibernate</td>\n", | |
| " <td>BAT0/</td>\n", | |
| " <td>51480000</td>\n", | |
| " <td>45430000</td>\n", | |
| " <td>resume</td>\n", | |
| " <td>51.48</td>\n", | |
| " <td>45.43</td>\n", | |
| " <td>27.73</td>\n", | |
| " <td>0 days 03:40:16</td>\n", | |
| " <td>7.553571</td>\n", | |
| " <td>88.0</td>\n", | |
| " <td>53.865579</td>\n", | |
| " <td>14.672827</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>2021-07-15 18:35:18-03:00</th>\n", | |
| " <td>5.8.0-38-generic</td>\n", | |
| " <td>R1BET60W(1.29 )</td>\n", | |
| " <td>resume</td>\n", | |
| " <td>BAT0/</td>\n", | |
| " <td>51480000</td>\n", | |
| " <td>45330000</td>\n", | |
| " <td>suspend-then-hibernate</td>\n", | |
| " <td>51.48</td>\n", | |
| " <td>45.33</td>\n", | |
| " <td>-0.10</td>\n", | |
| " <td>0 days 00:16:03</td>\n", | |
| " <td>-0.373832</td>\n", | |
| " <td>88.0</td>\n", | |
| " <td>-0.194250</td>\n", | |
| " <td>-0.726169</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>2021-07-15 20:32:22-03:00</th>\n", | |
| " <td>5.8.0-38-generic</td>\n", | |
| " <td>R1BET60W(1.29 )</td>\n", | |
| " <td>suspend</td>\n", | |
| " <td>BAT0/</td>\n", | |
| " <td>51480000</td>\n", | |
| " <td>35600000</td>\n", | |
| " <td>resume</td>\n", | |
| " <td>51.48</td>\n", | |
| " <td>35.60</td>\n", | |
| " <td>-9.73</td>\n", | |
| " <td>0 days 01:57:04</td>\n", | |
| " <td>-4.986902</td>\n", | |
| " <td>69.0</td>\n", | |
| " <td>-18.900544</td>\n", | |
| " <td>-9.687067</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>2021-07-15 20:34:23-03:00</th>\n", | |
| " <td>5.8.0-38-generic</td>\n", | |
| " <td>R1BET60W(1.29 )</td>\n", | |
| " <td>resume</td>\n", | |
| " <td>BAT0/</td>\n", | |
| " <td>51480000</td>\n", | |
| " <td>35600000</td>\n", | |
| " <td>suspend</td>\n", | |
| " <td>51.48</td>\n", | |
| " <td>35.60</td>\n", | |
| " <td>0.00</td>\n", | |
| " <td>0 days 00:02:01</td>\n", | |
| " <td>0.000000</td>\n", | |
| " <td>69.0</td>\n", | |
| " <td>0.000000</td>\n", | |
| " <td>0.000000</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>2021-07-15 21:41:39-03:00</th>\n", | |
| " <td>5.8.0-38-generic</td>\n", | |
| " <td>R1BET60W(1.29 )</td>\n", | |
| " <td>suspend</td>\n", | |
| " <td>BAT0/</td>\n", | |
| " <td>51480000</td>\n", | |
| " <td>35590000</td>\n", | |
| " <td>resume</td>\n", | |
| " <td>51.48</td>\n", | |
| " <td>35.59</td>\n", | |
| " <td>-0.01</td>\n", | |
| " <td>0 days 01:07:16</td>\n", | |
| " <td>-0.008920</td>\n", | |
| " <td>69.0</td>\n", | |
| " <td>-0.019425</td>\n", | |
| " <td>-0.017327</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>2021-07-15 22:04:54-03:00</th>\n", | |
| " <td>5.8.0-38-generic</td>\n", | |
| " <td>R1BET60W(1.29 )</td>\n", | |
| " <td>resume</td>\n", | |
| " <td>BAT0/</td>\n", | |
| " <td>51480000</td>\n", | |
| " <td>35590000</td>\n", | |
| " <td>suspend</td>\n", | |
| " <td>51.48</td>\n", | |
| " <td>35.59</td>\n", | |
| " <td>0.00</td>\n", | |
| " <td>0 days 00:23:15</td>\n", | |
| " <td>0.000000</td>\n", | |
| " <td>69.0</td>\n", | |
| " <td>0.000000</td>\n", | |
| " <td>0.000000</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>2021-07-15 22:24:08-03:00</th>\n", | |
| " <td>5.8.0-38-generic</td>\n", | |
| " <td>R1BET60W(1.29 )</td>\n", | |
| " <td>suspend</td>\n", | |
| " <td>BAT0/</td>\n", | |
| " <td>51480000</td>\n", | |
| " <td>35590000</td>\n", | |
| " <td>resume</td>\n", | |
| " <td>51.48</td>\n", | |
| " <td>35.59</td>\n", | |
| " <td>0.00</td>\n", | |
| " <td>0 days 00:19:14</td>\n", | |
| " <td>0.000000</td>\n", | |
| " <td>69.0</td>\n", | |
| " <td>0.000000</td>\n", | |
| " <td>0.000000</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>2021-07-16 20:30:23-03:00</th>\n", | |
| " <td>5.8.0-38-generic</td>\n", | |
| " <td>R1BET60W(1.29 )</td>\n", | |
| " <td>resume</td>\n", | |
| " <td>BAT0/</td>\n", | |
| " <td>51480000</td>\n", | |
| " <td>28230000</td>\n", | |
| " <td>suspend</td>\n", | |
| " <td>51.48</td>\n", | |
| " <td>28.23</td>\n", | |
| " <td>-7.36</td>\n", | |
| " <td>0 days 22:06:15</td>\n", | |
| " <td>-0.332969</td>\n", | |
| " <td>55.0</td>\n", | |
| " <td>-14.296814</td>\n", | |
| " <td>-0.646793</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>2021-07-17 02:45:09-03:00</th>\n", | |
| " <td>5.8.0-38-generic</td>\n", | |
| " <td>R1BET60W(1.29 )</td>\n", | |
| " <td>suspend-then-hibernate</td>\n", | |
| " <td>BAT0/</td>\n", | |
| " <td>51480000</td>\n", | |
| " <td>45660000</td>\n", | |
| " <td>resume</td>\n", | |
| " <td>51.48</td>\n", | |
| " <td>45.66</td>\n", | |
| " <td>17.43</td>\n", | |
| " <td>0 days 06:14:46</td>\n", | |
| " <td>2.790536</td>\n", | |
| " <td>89.0</td>\n", | |
| " <td>33.857809</td>\n", | |
| " <td>5.420622</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>2021-07-17 03:45:11-03:00</th>\n", | |
| " <td>5.8.0-38-generic</td>\n", | |
| " <td>R1BET60W(1.29 )</td>\n", | |
| " <td>resume</td>\n", | |
| " <td>BAT0/</td>\n", | |
| " <td>51480000</td>\n", | |
| " <td>45260000</td>\n", | |
| " <td>suspend-then-hibernate</td>\n", | |
| " <td>51.48</td>\n", | |
| " <td>45.26</td>\n", | |
| " <td>-0.40</td>\n", | |
| " <td>0 days 01:00:02</td>\n", | |
| " <td>-0.399778</td>\n", | |
| " <td>88.0</td>\n", | |
| " <td>-0.777001</td>\n", | |
| " <td>-0.776569</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>2021-07-17 03:45:11-03:00</th>\n", | |
| " <td>5.8.0-38-generic</td>\n", | |
| " <td>R1BET60W(1.29 )</td>\n", | |
| " <td>suspend-then-hibernate</td>\n", | |
| " <td>BAT0/</td>\n", | |
| " <td>51480000</td>\n", | |
| " <td>45260000</td>\n", | |
| " <td>resume</td>\n", | |
| " <td>51.48</td>\n", | |
| " <td>45.26</td>\n", | |
| " <td>0.00</td>\n", | |
| " <td>0 days 00:00:00</td>\n", | |
| " <td>NaN</td>\n", | |
| " <td>88.0</td>\n", | |
| " <td>0.000000</td>\n", | |
| " <td>NaN</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>2021-07-18 20:40:06-03:00</th>\n", | |
| " <td>5.8.0-38-generic</td>\n", | |
| " <td>R1BET60W(1.29 )</td>\n", | |
| " <td>resume</td>\n", | |
| " <td>BAT0/</td>\n", | |
| " <td>51480000</td>\n", | |
| " <td>44770000</td>\n", | |
| " <td>suspend-then-hibernate</td>\n", | |
| " <td>51.48</td>\n", | |
| " <td>44.77</td>\n", | |
| " <td>-0.49</td>\n", | |
| " <td>1 days 16:54:55</td>\n", | |
| " <td>-0.028968</td>\n", | |
| " <td>87.0</td>\n", | |
| " <td>-0.951826</td>\n", | |
| " <td>-0.056270</td>\n", | |
| " </tr>\n", | |
| " </tbody>\n", | |
| "</table>\n", | |
| "</div>" | |
| ], | |
| "text/plain": [ | |
| " kernel bios \\\n", | |
| "timestamp \n", | |
| "2021-07-13 20:18:08-03:00 5.8.0-38-generic R1BET60W(1.29 ) \n", | |
| "2021-07-13 20:18:22-03:00 5.8.0-38-generic R1BET60W(1.29 ) \n", | |
| "2021-07-13 21:09:52-03:00 5.8.0-38-generic R1BET60W(1.29 ) \n", | |
| "2021-07-13 22:09:54-03:00 5.8.0-38-generic R1BET60W(1.29 ) \n", | |
| "2021-07-13 22:09:55-03:00 5.8.0-38-generic R1BET60W(1.29 ) \n", | |
| "2021-07-13 22:34:42-03:00 5.8.0-38-generic R1BET60W(1.29 ) \n", | |
| "2021-07-13 22:52:54-03:00 5.8.0-38-generic R1BET60W(1.29 ) \n", | |
| "2021-07-13 23:52:55-03:00 5.8.0-38-generic R1BET60W(1.29 ) \n", | |
| "2021-07-13 23:52:56-03:00 5.8.0-38-generic R1BET60W(1.29 ) \n", | |
| "2021-07-14 00:55:43-03:00 5.8.0-38-generic R1BET60W(1.29 ) \n", | |
| "2021-07-14 02:39:08-03:00 5.8.0-38-generic R1BET60W(1.29 ) \n", | |
| "2021-07-14 03:39:10-03:00 5.8.0-38-generic R1BET60W(1.29 ) \n", | |
| "2021-07-14 03:39:11-03:00 5.8.0-38-generic R1BET60W(1.29 ) \n", | |
| "2021-07-15 14:38:59-03:00 5.8.0-38-generic R1BET60W(1.29 ) \n", | |
| "2021-07-15 18:19:15-03:00 5.8.0-38-generic R1BET60W(1.29 ) \n", | |
| "2021-07-15 18:35:18-03:00 5.8.0-38-generic R1BET60W(1.29 ) \n", | |
| "2021-07-15 20:32:22-03:00 5.8.0-38-generic R1BET60W(1.29 ) \n", | |
| "2021-07-15 20:34:23-03:00 5.8.0-38-generic R1BET60W(1.29 ) \n", | |
| "2021-07-15 21:41:39-03:00 5.8.0-38-generic R1BET60W(1.29 ) \n", | |
| "2021-07-15 22:04:54-03:00 5.8.0-38-generic R1BET60W(1.29 ) \n", | |
| "2021-07-15 22:24:08-03:00 5.8.0-38-generic R1BET60W(1.29 ) \n", | |
| "2021-07-16 20:30:23-03:00 5.8.0-38-generic R1BET60W(1.29 ) \n", | |
| "2021-07-17 02:45:09-03:00 5.8.0-38-generic R1BET60W(1.29 ) \n", | |
| "2021-07-17 03:45:11-03:00 5.8.0-38-generic R1BET60W(1.29 ) \n", | |
| "2021-07-17 03:45:11-03:00 5.8.0-38-generic R1BET60W(1.29 ) \n", | |
| "2021-07-18 20:40:06-03:00 5.8.0-38-generic R1BET60W(1.29 ) \n", | |
| "\n", | |
| " state bat total value \\\n", | |
| "timestamp \n", | |
| "2021-07-13 20:18:08-03:00 suspend BAT0/ 51480000 16810000 \n", | |
| "2021-07-13 20:18:22-03:00 resume BAT0/ 51480000 16800000 \n", | |
| "2021-07-13 21:09:52-03:00 suspend-then-hibernate BAT0/ 51480000 32220000 \n", | |
| "2021-07-13 22:09:54-03:00 resume BAT0/ 51480000 31820000 \n", | |
| "2021-07-13 22:09:55-03:00 suspend-then-hibernate BAT0/ 51480000 31820000 \n", | |
| "2021-07-13 22:34:42-03:00 resume BAT0/ 51480000 31530000 \n", | |
| "2021-07-13 22:52:54-03:00 suspend-then-hibernate BAT0/ 51480000 30010000 \n", | |
| "2021-07-13 23:52:55-03:00 resume BAT0/ 51480000 29670000 \n", | |
| "2021-07-13 23:52:56-03:00 suspend-then-hibernate BAT0/ 51480000 29670000 \n", | |
| "2021-07-14 00:55:43-03:00 resume BAT0/ 51480000 29380000 \n", | |
| "2021-07-14 02:39:08-03:00 suspend-then-hibernate BAT0/ 51480000 18560000 \n", | |
| "2021-07-14 03:39:10-03:00 resume BAT0/ 51480000 18210000 \n", | |
| "2021-07-14 03:39:11-03:00 suspend-then-hibernate BAT0/ 51480000 18210000 \n", | |
| "2021-07-15 14:38:59-03:00 resume BAT0/ 51480000 17700000 \n", | |
| "2021-07-15 18:19:15-03:00 suspend-then-hibernate BAT0/ 51480000 45430000 \n", | |
| "2021-07-15 18:35:18-03:00 resume BAT0/ 51480000 45330000 \n", | |
| "2021-07-15 20:32:22-03:00 suspend BAT0/ 51480000 35600000 \n", | |
| "2021-07-15 20:34:23-03:00 resume BAT0/ 51480000 35600000 \n", | |
| "2021-07-15 21:41:39-03:00 suspend BAT0/ 51480000 35590000 \n", | |
| "2021-07-15 22:04:54-03:00 resume BAT0/ 51480000 35590000 \n", | |
| "2021-07-15 22:24:08-03:00 suspend BAT0/ 51480000 35590000 \n", | |
| "2021-07-16 20:30:23-03:00 resume BAT0/ 51480000 28230000 \n", | |
| "2021-07-17 02:45:09-03:00 suspend-then-hibernate BAT0/ 51480000 45660000 \n", | |
| "2021-07-17 03:45:11-03:00 resume BAT0/ 51480000 45260000 \n", | |
| "2021-07-17 03:45:11-03:00 suspend-then-hibernate BAT0/ 51480000 45260000 \n", | |
| "2021-07-18 20:40:06-03:00 resume BAT0/ 51480000 44770000 \n", | |
| "\n", | |
| " prev_state total_watt value_watt \\\n", | |
| "timestamp \n", | |
| "2021-07-13 20:18:08-03:00 NaN 51.48 16.81 \n", | |
| "2021-07-13 20:18:22-03:00 suspend 51.48 16.80 \n", | |
| "2021-07-13 21:09:52-03:00 resume 51.48 32.22 \n", | |
| "2021-07-13 22:09:54-03:00 suspend-then-hibernate 51.48 31.82 \n", | |
| "2021-07-13 22:09:55-03:00 resume 51.48 31.82 \n", | |
| "2021-07-13 22:34:42-03:00 suspend-then-hibernate 51.48 31.53 \n", | |
| "2021-07-13 22:52:54-03:00 resume 51.48 30.01 \n", | |
| "2021-07-13 23:52:55-03:00 suspend-then-hibernate 51.48 29.67 \n", | |
| "2021-07-13 23:52:56-03:00 resume 51.48 29.67 \n", | |
| "2021-07-14 00:55:43-03:00 suspend-then-hibernate 51.48 29.38 \n", | |
| "2021-07-14 02:39:08-03:00 resume 51.48 18.56 \n", | |
| "2021-07-14 03:39:10-03:00 suspend-then-hibernate 51.48 18.21 \n", | |
| "2021-07-14 03:39:11-03:00 resume 51.48 18.21 \n", | |
| "2021-07-15 14:38:59-03:00 suspend-then-hibernate 51.48 17.70 \n", | |
| "2021-07-15 18:19:15-03:00 resume 51.48 45.43 \n", | |
| "2021-07-15 18:35:18-03:00 suspend-then-hibernate 51.48 45.33 \n", | |
| "2021-07-15 20:32:22-03:00 resume 51.48 35.60 \n", | |
| "2021-07-15 20:34:23-03:00 suspend 51.48 35.60 \n", | |
| "2021-07-15 21:41:39-03:00 resume 51.48 35.59 \n", | |
| "2021-07-15 22:04:54-03:00 suspend 51.48 35.59 \n", | |
| "2021-07-15 22:24:08-03:00 resume 51.48 35.59 \n", | |
| "2021-07-16 20:30:23-03:00 suspend 51.48 28.23 \n", | |
| "2021-07-17 02:45:09-03:00 resume 51.48 45.66 \n", | |
| "2021-07-17 03:45:11-03:00 suspend-then-hibernate 51.48 45.26 \n", | |
| "2021-07-17 03:45:11-03:00 resume 51.48 45.26 \n", | |
| "2021-07-18 20:40:06-03:00 suspend-then-hibernate 51.48 44.77 \n", | |
| "\n", | |
| " value_diff_watt time_diff \\\n", | |
| "timestamp \n", | |
| "2021-07-13 20:18:08-03:00 NaN NaT \n", | |
| "2021-07-13 20:18:22-03:00 -0.01 0 days 00:00:14 \n", | |
| "2021-07-13 21:09:52-03:00 15.42 0 days 00:51:30 \n", | |
| "2021-07-13 22:09:54-03:00 -0.40 0 days 01:00:02 \n", | |
| "2021-07-13 22:09:55-03:00 0.00 0 days 00:00:01 \n", | |
| "2021-07-13 22:34:42-03:00 -0.29 0 days 00:24:47 \n", | |
| "2021-07-13 22:52:54-03:00 -1.52 0 days 00:18:12 \n", | |
| "2021-07-13 23:52:55-03:00 -0.34 0 days 01:00:01 \n", | |
| "2021-07-13 23:52:56-03:00 0.00 0 days 00:00:01 \n", | |
| "2021-07-14 00:55:43-03:00 -0.29 0 days 01:02:47 \n", | |
| "2021-07-14 02:39:08-03:00 -10.82 0 days 01:43:25 \n", | |
| "2021-07-14 03:39:10-03:00 -0.35 0 days 01:00:02 \n", | |
| "2021-07-14 03:39:11-03:00 0.00 0 days 00:00:01 \n", | |
| "2021-07-15 14:38:59-03:00 -0.51 1 days 10:59:48 \n", | |
| "2021-07-15 18:19:15-03:00 27.73 0 days 03:40:16 \n", | |
| "2021-07-15 18:35:18-03:00 -0.10 0 days 00:16:03 \n", | |
| "2021-07-15 20:32:22-03:00 -9.73 0 days 01:57:04 \n", | |
| "2021-07-15 20:34:23-03:00 0.00 0 days 00:02:01 \n", | |
| "2021-07-15 21:41:39-03:00 -0.01 0 days 01:07:16 \n", | |
| "2021-07-15 22:04:54-03:00 0.00 0 days 00:23:15 \n", | |
| "2021-07-15 22:24:08-03:00 0.00 0 days 00:19:14 \n", | |
| "2021-07-16 20:30:23-03:00 -7.36 0 days 22:06:15 \n", | |
| "2021-07-17 02:45:09-03:00 17.43 0 days 06:14:46 \n", | |
| "2021-07-17 03:45:11-03:00 -0.40 0 days 01:00:02 \n", | |
| "2021-07-17 03:45:11-03:00 0.00 0 days 00:00:00 \n", | |
| "2021-07-18 20:40:06-03:00 -0.49 1 days 16:54:55 \n", | |
| "\n", | |
| " rate_per_hour_watt charge charge_diff \\\n", | |
| "timestamp \n", | |
| "2021-07-13 20:18:08-03:00 NaN 33.0 NaN \n", | |
| "2021-07-13 20:18:22-03:00 -2.571429 33.0 -0.019425 \n", | |
| "2021-07-13 21:09:52-03:00 17.965049 63.0 29.953380 \n", | |
| "2021-07-13 22:09:54-03:00 -0.399778 62.0 -0.777001 \n", | |
| "2021-07-13 22:09:55-03:00 0.000000 62.0 0.000000 \n", | |
| "2021-07-13 22:34:42-03:00 -0.702085 61.0 -0.563326 \n", | |
| "2021-07-13 22:52:54-03:00 -5.010989 58.0 -2.952603 \n", | |
| "2021-07-13 23:52:55-03:00 -0.339906 58.0 -0.660451 \n", | |
| "2021-07-13 23:52:56-03:00 0.000000 58.0 0.000000 \n", | |
| "2021-07-14 00:55:43-03:00 -0.277144 57.0 -0.563326 \n", | |
| "2021-07-14 02:39:08-03:00 -6.277518 36.0 -21.017871 \n", | |
| "2021-07-14 03:39:10-03:00 -0.349806 35.0 -0.679876 \n", | |
| "2021-07-14 03:39:11-03:00 0.000000 35.0 0.000000 \n", | |
| "2021-07-15 14:38:59-03:00 -0.046378 34.0 -0.990676 \n", | |
| "2021-07-15 18:19:15-03:00 7.553571 88.0 53.865579 \n", | |
| "2021-07-15 18:35:18-03:00 -0.373832 88.0 -0.194250 \n", | |
| "2021-07-15 20:32:22-03:00 -4.986902 69.0 -18.900544 \n", | |
| "2021-07-15 20:34:23-03:00 0.000000 69.0 0.000000 \n", | |
| "2021-07-15 21:41:39-03:00 -0.008920 69.0 -0.019425 \n", | |
| "2021-07-15 22:04:54-03:00 0.000000 69.0 0.000000 \n", | |
| "2021-07-15 22:24:08-03:00 0.000000 69.0 0.000000 \n", | |
| "2021-07-16 20:30:23-03:00 -0.332969 55.0 -14.296814 \n", | |
| "2021-07-17 02:45:09-03:00 2.790536 89.0 33.857809 \n", | |
| "2021-07-17 03:45:11-03:00 -0.399778 88.0 -0.777001 \n", | |
| "2021-07-17 03:45:11-03:00 NaN 88.0 0.000000 \n", | |
| "2021-07-18 20:40:06-03:00 -0.028968 87.0 -0.951826 \n", | |
| "\n", | |
| " charge_per_hour_diff \n", | |
| "timestamp \n", | |
| "2021-07-13 20:18:08-03:00 NaN \n", | |
| "2021-07-13 20:18:22-03:00 -4.995005 \n", | |
| "2021-07-13 21:09:52-03:00 34.897142 \n", | |
| "2021-07-13 22:09:54-03:00 -0.776569 \n", | |
| "2021-07-13 22:09:55-03:00 0.000000 \n", | |
| "2021-07-13 22:34:42-03:00 -1.363801 \n", | |
| "2021-07-13 22:52:54-03:00 -9.733856 \n", | |
| "2021-07-13 23:52:55-03:00 -0.660267 \n", | |
| "2021-07-13 23:52:56-03:00 0.000000 \n", | |
| "2021-07-14 00:55:43-03:00 -0.538352 \n", | |
| "2021-07-14 02:39:08-03:00 -12.194091 \n", | |
| "2021-07-14 03:39:10-03:00 -0.679498 \n", | |
| "2021-07-14 03:39:11-03:00 0.000000 \n", | |
| "2021-07-15 14:38:59-03:00 -0.090089 \n", | |
| "2021-07-15 18:19:15-03:00 14.672827 \n", | |
| "2021-07-15 18:35:18-03:00 -0.726169 \n", | |
| "2021-07-15 20:32:22-03:00 -9.687067 \n", | |
| "2021-07-15 20:34:23-03:00 0.000000 \n", | |
| "2021-07-15 21:41:39-03:00 -0.017327 \n", | |
| "2021-07-15 22:04:54-03:00 0.000000 \n", | |
| "2021-07-15 22:24:08-03:00 0.000000 \n", | |
| "2021-07-16 20:30:23-03:00 -0.646793 \n", | |
| "2021-07-17 02:45:09-03:00 5.420622 \n", | |
| "2021-07-17 03:45:11-03:00 -0.776569 \n", | |
| "2021-07-17 03:45:11-03:00 NaN \n", | |
| "2021-07-18 20:40:06-03:00 -0.056270 " | |
| ] | |
| }, | |
| "execution_count": 4, | |
| "metadata": {}, | |
| "output_type": "execute_result" | |
| } | |
| ], | |
| "source": [ | |
| "df[\"value_diff_watt\"] = df.value_watt.diff()\n", | |
| "df[\"time_diff\"] = df.index.to_series().diff()\n", | |
| "df[\"rate_per_hour_watt\"] = 3600 * df.value_diff_watt / df.time_diff.dt.seconds\n", | |
| "df[\"charge\"] = round(df.value_watt / df.total_watt * 100)\n", | |
| "df[\"charge_diff\"] = (df.value_diff_watt / df.total_watt) * 100\n", | |
| "df[\"charge_per_hour_diff\"] = (df.rate_per_hour_watt / df.total_watt) * 100\n", | |
| "df" | |
| ] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "id": "e2b1a6f6-a316-4d5a-b310-b3c99f32145c", | |
| "metadata": {}, | |
| "source": [ | |
| "## Sleep drain\n", | |
| "\n", | |
| "I've configured my system to hibernate ie. after 1 hour being suspended. \n", | |
| "That value can be read from `/etc/systemd/sleep.conf` file.\n", | |
| "\n", | |
| "Usually system would enter `suspend-then-hibernate` state by itself, or `suspend` state if I manually suspend it." | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 5, | |
| "id": "83985563-9eaf-4d39-afd0-db482346e60d", | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "from configparser import ConfigParser\n", | |
| "config = ConfigParser()\n", | |
| "config.read(\"/etc/systemd/sleep.conf\")\n", | |
| "hibernate_delay = config[\"Sleep\"].get(\"HibernateDelaySec\")" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 6, | |
| "id": "3124ca82-ea1c-44e4-b826-372ed7dd9e5b", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/html": [ | |
| "<div>\n", | |
| "<style scoped>\n", | |
| " .dataframe tbody tr th:only-of-type {\n", | |
| " vertical-align: middle;\n", | |
| " }\n", | |
| "\n", | |
| " .dataframe tbody tr th {\n", | |
| " vertical-align: top;\n", | |
| " }\n", | |
| "\n", | |
| " .dataframe thead th {\n", | |
| " text-align: right;\n", | |
| " }\n", | |
| "</style>\n", | |
| "<table border=\"1\" class=\"dataframe\">\n", | |
| " <thead>\n", | |
| " <tr style=\"text-align: right;\">\n", | |
| " <th></th>\n", | |
| " <th>kernel</th>\n", | |
| " <th>bios</th>\n", | |
| " <th>state</th>\n", | |
| " <th>bat</th>\n", | |
| " <th>total</th>\n", | |
| " <th>value</th>\n", | |
| " <th>prev_state</th>\n", | |
| " <th>total_watt</th>\n", | |
| " <th>value_watt</th>\n", | |
| " <th>value_diff_watt</th>\n", | |
| " <th>time_diff</th>\n", | |
| " <th>rate_per_hour_watt</th>\n", | |
| " <th>charge</th>\n", | |
| " <th>charge_diff</th>\n", | |
| " <th>charge_per_hour_diff</th>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>timestamp</th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " </tr>\n", | |
| " </thead>\n", | |
| " <tbody>\n", | |
| " <tr>\n", | |
| " <th>2021-07-13 22:09:54-03:00</th>\n", | |
| " <td>5.8.0-38-generic</td>\n", | |
| " <td>R1BET60W(1.29 )</td>\n", | |
| " <td>resume</td>\n", | |
| " <td>BAT0/</td>\n", | |
| " <td>51480000</td>\n", | |
| " <td>31820000</td>\n", | |
| " <td>suspend-then-hibernate</td>\n", | |
| " <td>51.48</td>\n", | |
| " <td>31.82</td>\n", | |
| " <td>-0.40</td>\n", | |
| " <td>0 days 01:00:02</td>\n", | |
| " <td>-0.399778</td>\n", | |
| " <td>62.0</td>\n", | |
| " <td>-0.777001</td>\n", | |
| " <td>-0.776569</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>2021-07-13 22:34:42-03:00</th>\n", | |
| " <td>5.8.0-38-generic</td>\n", | |
| " <td>R1BET60W(1.29 )</td>\n", | |
| " <td>resume</td>\n", | |
| " <td>BAT0/</td>\n", | |
| " <td>51480000</td>\n", | |
| " <td>31530000</td>\n", | |
| " <td>suspend-then-hibernate</td>\n", | |
| " <td>51.48</td>\n", | |
| " <td>31.53</td>\n", | |
| " <td>-0.29</td>\n", | |
| " <td>0 days 00:24:47</td>\n", | |
| " <td>-0.702085</td>\n", | |
| " <td>61.0</td>\n", | |
| " <td>-0.563326</td>\n", | |
| " <td>-1.363801</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>2021-07-13 23:52:55-03:00</th>\n", | |
| " <td>5.8.0-38-generic</td>\n", | |
| " <td>R1BET60W(1.29 )</td>\n", | |
| " <td>resume</td>\n", | |
| " <td>BAT0/</td>\n", | |
| " <td>51480000</td>\n", | |
| " <td>29670000</td>\n", | |
| " <td>suspend-then-hibernate</td>\n", | |
| " <td>51.48</td>\n", | |
| " <td>29.67</td>\n", | |
| " <td>-0.34</td>\n", | |
| " <td>0 days 01:00:01</td>\n", | |
| " <td>-0.339906</td>\n", | |
| " <td>58.0</td>\n", | |
| " <td>-0.660451</td>\n", | |
| " <td>-0.660267</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>2021-07-14 03:39:10-03:00</th>\n", | |
| " <td>5.8.0-38-generic</td>\n", | |
| " <td>R1BET60W(1.29 )</td>\n", | |
| " <td>resume</td>\n", | |
| " <td>BAT0/</td>\n", | |
| " <td>51480000</td>\n", | |
| " <td>18210000</td>\n", | |
| " <td>suspend-then-hibernate</td>\n", | |
| " <td>51.48</td>\n", | |
| " <td>18.21</td>\n", | |
| " <td>-0.35</td>\n", | |
| " <td>0 days 01:00:02</td>\n", | |
| " <td>-0.349806</td>\n", | |
| " <td>35.0</td>\n", | |
| " <td>-0.679876</td>\n", | |
| " <td>-0.679498</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>2021-07-15 18:35:18-03:00</th>\n", | |
| " <td>5.8.0-38-generic</td>\n", | |
| " <td>R1BET60W(1.29 )</td>\n", | |
| " <td>resume</td>\n", | |
| " <td>BAT0/</td>\n", | |
| " <td>51480000</td>\n", | |
| " <td>45330000</td>\n", | |
| " <td>suspend-then-hibernate</td>\n", | |
| " <td>51.48</td>\n", | |
| " <td>45.33</td>\n", | |
| " <td>-0.10</td>\n", | |
| " <td>0 days 00:16:03</td>\n", | |
| " <td>-0.373832</td>\n", | |
| " <td>88.0</td>\n", | |
| " <td>-0.194250</td>\n", | |
| " <td>-0.726169</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>2021-07-16 20:30:23-03:00</th>\n", | |
| " <td>5.8.0-38-generic</td>\n", | |
| " <td>R1BET60W(1.29 )</td>\n", | |
| " <td>resume</td>\n", | |
| " <td>BAT0/</td>\n", | |
| " <td>51480000</td>\n", | |
| " <td>28230000</td>\n", | |
| " <td>suspend</td>\n", | |
| " <td>51.48</td>\n", | |
| " <td>28.23</td>\n", | |
| " <td>-7.36</td>\n", | |
| " <td>0 days 22:06:15</td>\n", | |
| " <td>-0.332969</td>\n", | |
| " <td>55.0</td>\n", | |
| " <td>-14.296814</td>\n", | |
| " <td>-0.646793</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>2021-07-17 03:45:11-03:00</th>\n", | |
| " <td>5.8.0-38-generic</td>\n", | |
| " <td>R1BET60W(1.29 )</td>\n", | |
| " <td>resume</td>\n", | |
| " <td>BAT0/</td>\n", | |
| " <td>51480000</td>\n", | |
| " <td>45260000</td>\n", | |
| " <td>suspend-then-hibernate</td>\n", | |
| " <td>51.48</td>\n", | |
| " <td>45.26</td>\n", | |
| " <td>-0.40</td>\n", | |
| " <td>0 days 01:00:02</td>\n", | |
| " <td>-0.399778</td>\n", | |
| " <td>88.0</td>\n", | |
| " <td>-0.777001</td>\n", | |
| " <td>-0.776569</td>\n", | |
| " </tr>\n", | |
| " </tbody>\n", | |
| "</table>\n", | |
| "</div>" | |
| ], | |
| "text/plain": [ | |
| " kernel bios state bat \\\n", | |
| "timestamp \n", | |
| "2021-07-13 22:09:54-03:00 5.8.0-38-generic R1BET60W(1.29 ) resume BAT0/ \n", | |
| "2021-07-13 22:34:42-03:00 5.8.0-38-generic R1BET60W(1.29 ) resume BAT0/ \n", | |
| "2021-07-13 23:52:55-03:00 5.8.0-38-generic R1BET60W(1.29 ) resume BAT0/ \n", | |
| "2021-07-14 03:39:10-03:00 5.8.0-38-generic R1BET60W(1.29 ) resume BAT0/ \n", | |
| "2021-07-15 18:35:18-03:00 5.8.0-38-generic R1BET60W(1.29 ) resume BAT0/ \n", | |
| "2021-07-16 20:30:23-03:00 5.8.0-38-generic R1BET60W(1.29 ) resume BAT0/ \n", | |
| "2021-07-17 03:45:11-03:00 5.8.0-38-generic R1BET60W(1.29 ) resume BAT0/ \n", | |
| "\n", | |
| " total value prev_state \\\n", | |
| "timestamp \n", | |
| "2021-07-13 22:09:54-03:00 51480000 31820000 suspend-then-hibernate \n", | |
| "2021-07-13 22:34:42-03:00 51480000 31530000 suspend-then-hibernate \n", | |
| "2021-07-13 23:52:55-03:00 51480000 29670000 suspend-then-hibernate \n", | |
| "2021-07-14 03:39:10-03:00 51480000 18210000 suspend-then-hibernate \n", | |
| "2021-07-15 18:35:18-03:00 51480000 45330000 suspend-then-hibernate \n", | |
| "2021-07-16 20:30:23-03:00 51480000 28230000 suspend \n", | |
| "2021-07-17 03:45:11-03:00 51480000 45260000 suspend-then-hibernate \n", | |
| "\n", | |
| " total_watt value_watt value_diff_watt \\\n", | |
| "timestamp \n", | |
| "2021-07-13 22:09:54-03:00 51.48 31.82 -0.40 \n", | |
| "2021-07-13 22:34:42-03:00 51.48 31.53 -0.29 \n", | |
| "2021-07-13 23:52:55-03:00 51.48 29.67 -0.34 \n", | |
| "2021-07-14 03:39:10-03:00 51.48 18.21 -0.35 \n", | |
| "2021-07-15 18:35:18-03:00 51.48 45.33 -0.10 \n", | |
| "2021-07-16 20:30:23-03:00 51.48 28.23 -7.36 \n", | |
| "2021-07-17 03:45:11-03:00 51.48 45.26 -0.40 \n", | |
| "\n", | |
| " time_diff rate_per_hour_watt charge \\\n", | |
| "timestamp \n", | |
| "2021-07-13 22:09:54-03:00 0 days 01:00:02 -0.399778 62.0 \n", | |
| "2021-07-13 22:34:42-03:00 0 days 00:24:47 -0.702085 61.0 \n", | |
| "2021-07-13 23:52:55-03:00 0 days 01:00:01 -0.339906 58.0 \n", | |
| "2021-07-14 03:39:10-03:00 0 days 01:00:02 -0.349806 35.0 \n", | |
| "2021-07-15 18:35:18-03:00 0 days 00:16:03 -0.373832 88.0 \n", | |
| "2021-07-16 20:30:23-03:00 0 days 22:06:15 -0.332969 55.0 \n", | |
| "2021-07-17 03:45:11-03:00 0 days 01:00:02 -0.399778 88.0 \n", | |
| "\n", | |
| " charge_diff charge_per_hour_diff \n", | |
| "timestamp \n", | |
| "2021-07-13 22:09:54-03:00 -0.777001 -0.776569 \n", | |
| "2021-07-13 22:34:42-03:00 -0.563326 -1.363801 \n", | |
| "2021-07-13 23:52:55-03:00 -0.660451 -0.660267 \n", | |
| "2021-07-14 03:39:10-03:00 -0.679876 -0.679498 \n", | |
| "2021-07-15 18:35:18-03:00 -0.194250 -0.726169 \n", | |
| "2021-07-16 20:30:23-03:00 -14.296814 -0.646793 \n", | |
| "2021-07-17 03:45:11-03:00 -0.777001 -0.776569 " | |
| ] | |
| }, | |
| "execution_count": 6, | |
| "metadata": {}, | |
| "output_type": "execute_result" | |
| } | |
| ], | |
| "source": [ | |
| "battery_mode = (df.value_diff_watt < 0)\n", | |
| "suspend_mode = (\n", | |
| " (df.state == \"resume\") & \n", | |
| " (df.prev_state == \"suspend\") & \n", | |
| " (df.time_diff > pd.Timedelta(\"1min\"))\n", | |
| ")\n", | |
| "suspend_then_hibernate_mode = (\n", | |
| " (df.state == \"resume\") & \n", | |
| " (df.prev_state == \"suspend-then-hibernate\") & \n", | |
| " (df.time_diff.between(pd.Timedelta(\"1min\"), pd.Timedelta(f\"{hibernate_delay} + 1min\")))\n", | |
| ")\n", | |
| "\n", | |
| "sleep = df[(suspend_mode | suspend_then_hibernate_mode) & battery_mode]\n", | |
| "sleep" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 7, | |
| "id": "61ee5274-df56-4eba-8c07-0ecdb8ec3f31", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/html": [ | |
| "<div>\n", | |
| "<style scoped>\n", | |
| " .dataframe tbody tr th:only-of-type {\n", | |
| " vertical-align: middle;\n", | |
| " }\n", | |
| "\n", | |
| " .dataframe tbody tr th {\n", | |
| " vertical-align: top;\n", | |
| " }\n", | |
| "\n", | |
| " .dataframe thead tr th {\n", | |
| " text-align: left;\n", | |
| " }\n", | |
| "</style>\n", | |
| "<table border=\"1\" class=\"dataframe\">\n", | |
| " <thead>\n", | |
| " <tr>\n", | |
| " <th></th>\n", | |
| " <th>bios</th>\n", | |
| " <th>R1BET60W(1.29 )</th>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th></th>\n", | |
| " <th>kernel</th>\n", | |
| " <th>5.8.0-38-generic</th>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th></th>\n", | |
| " <th>bat</th>\n", | |
| " <th>BAT0/</th>\n", | |
| " </tr>\n", | |
| " </thead>\n", | |
| " <tbody>\n", | |
| " <tr>\n", | |
| " <th rowspan=\"8\" valign=\"top\">rate_per_hour_watt</th>\n", | |
| " <th>count</th>\n", | |
| " <td>7.000000</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>mean</th>\n", | |
| " <td>-0.414022</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>std</th>\n", | |
| " <td>0.129864</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>min</th>\n", | |
| " <td>-0.702085</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>25%</th>\n", | |
| " <td>-0.399778</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>50%</th>\n", | |
| " <td>-0.373832</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>75%</th>\n", | |
| " <td>-0.344856</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>max</th>\n", | |
| " <td>-0.332969</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th rowspan=\"8\" valign=\"top\">charge_per_hour_diff</th>\n", | |
| " <th>count</th>\n", | |
| " <td>7.000000</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>mean</th>\n", | |
| " <td>-0.804238</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>std</th>\n", | |
| " <td>0.252261</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>min</th>\n", | |
| " <td>-1.363801</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>25%</th>\n", | |
| " <td>-0.776569</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>50%</th>\n", | |
| " <td>-0.726169</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>75%</th>\n", | |
| " <td>-0.669883</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>max</th>\n", | |
| " <td>-0.646793</td>\n", | |
| " </tr>\n", | |
| " </tbody>\n", | |
| "</table>\n", | |
| "</div>" | |
| ], | |
| "text/plain": [ | |
| "bios R1BET60W(1.29 )\n", | |
| "kernel 5.8.0-38-generic\n", | |
| "bat BAT0/\n", | |
| "rate_per_hour_watt count 7.000000\n", | |
| " mean -0.414022\n", | |
| " std 0.129864\n", | |
| " min -0.702085\n", | |
| " 25% -0.399778\n", | |
| " 50% -0.373832\n", | |
| " 75% -0.344856\n", | |
| " max -0.332969\n", | |
| "charge_per_hour_diff count 7.000000\n", | |
| " mean -0.804238\n", | |
| " std 0.252261\n", | |
| " min -1.363801\n", | |
| " 25% -0.776569\n", | |
| " 50% -0.726169\n", | |
| " 75% -0.669883\n", | |
| " max -0.646793" | |
| ] | |
| }, | |
| "execution_count": 7, | |
| "metadata": {}, | |
| "output_type": "execute_result" | |
| } | |
| ], | |
| "source": [ | |
| "sleep_stats = sleep.groupby([\"bios\", \"kernel\", \"bat\"])[[\"rate_per_hour_watt\", \"charge_per_hour_diff\"]]\n", | |
| "sleep_stats.describe().T" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 8, | |
| "id": "7e3921a7-5006-4352-933f-deb4bd19d82c", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "bios kernel bat \n", | |
| "R1BET60W(1.29 ) 5.8.0-38-generic BAT0/ AxesSubplot(0.125,0.125;0.775x0.755)\n", | |
| "dtype: object" | |
| ] | |
| }, | |
| "execution_count": 8, | |
| "metadata": {}, | |
| "output_type": "execute_result" | |
| }, | |
| { | |
| "data": { | |
| "image/png": "iVBORw0KGgoAAAANSUhEUgAAAc0AAAD4CAYAAACOhb23AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAThklEQVR4nO3df5TldX3f8efLZRUSfqjFEgVxrGIcsgipg1FYMEPVNkqitFI7Wl1ytrFJzEZNOc32jK3VnOkBbdM0mMSDTgMYM6mYqCipQHAUhoiyiyy7MCGkCIaWIkSzCmXNsrz7x/2uDjg789mdO3N3l+fjnDnzvZ/v934+78+dc+Z1v9/P986kqpAkSYt7yqALkCTpQGFoSpLUyNCUJKmRoSlJUiNDU5KkRocMugAtr6OPPrqGhoYGXYYkHTA2b978YFU9a759huZBbmhoiE2bNg26DEk6YCS5Z0/7vDwrSVIjQ1OSpEaGpiRJjQxNSZIaGZqSJDUyNCVJamRoSpLUyNCUJKmRoSlJUiNDU5KkRoamJEmNDE1JkhoZmpIkNTI0JUlqZGhKktTI0JQkqZGhKUlSI0NTkqRGhqYkSY0MTUmSGhmakiQ1MjQlSWpkaEqS1MjQlCSpkaEpSVIjQ1OSpEaGpiRJjQxNSZIaGZqSJDUyNCVJamRoSpLUyNCUJKmRoSlJUiNDU5KkRoamJEmNDE1JkhoZmpIkNTI0JUlqZGhKktTI0JQkqZGhKUlSI0NTkqRGhqYkSY0MTUmSGhmakiQ1OmTQBUhSv5z8vqvZ/sjOfXruEcMb+e7sBUsa/6jDVrPlva9ZUh/avxmakg4a2x/Zyd0XvG6fnnvSpRv3+bm7DW28cknP1/7Py7OSJDUyNCVJamRoSjpo3HPh2YMuYV5JBl2C+mSfQjPJJUne2O9i9gdJhpJsG+D4339tk3w0yYnd9rlJZpNMd4+nktya5N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7Ja+ld4joyyR9U1b9cenX91Ye5kmQ1vcD8eFX9ydKrWh59mOv/Bp475/FxXdt+Z6G5Jrk/ybOr6r4kz2b+9btzgBur6qHuOf8TeAWw34VmH+Z6L3BLVd3VPefT9Nbn97vQ7MNcXwGckeSXgcOBpyZ5qKoGdlObl2dFVf27qjquqoaAfwF8YX8MzH7o7qicBGar6jcHXc8yuwk4IcnzkzyV3s/2igHXtC+uANZ12+uA+c6yvwG8Mskh3ZuiV3Jg3tTWMtebgKcn2f1fOM4Cbl+B2vpt0blW1Vuq6vjud9P5wGWDDEwwNA96Sc5Jci+9d2xXJrmqa39Okj8dbHX91TjX04G3AmcluaX7eu2ASt5nLXOtqkeBXwGuohcgn6iq2wZV8xJcALw6yZ3Aq7rHJBlJsvvGtU8C/wvYCmwBtlTVZwdR7BItOteq2kUvQK5NshUI8JEB1bsULT/X/Y5/Rk+SpEaeaUqS1MjQlCSpkaEpSVIjQ1OSpEaGpiRJjQxNSZIaGZqSJDX6/9MRToKfsFigAAAAAElFTkSuQmCC\n", | |
| "text/plain": [ | |
| "<Figure size 432x288 with 1 Axes>" | |
| ] | |
| }, | |
| "metadata": { | |
| "needs_background": "light" | |
| }, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "sleep_stats.plot.box(vert=False)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "id": "06e3a474-c567-4f0d-abf6-a1071445b9bc", | |
| "metadata": {}, | |
| "source": [ | |
| "## Hibernate / Power off drain" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 9, | |
| "id": "40ae08ad-a260-499f-844f-d6910068980f", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/html": [ | |
| "<div>\n", | |
| "<style scoped>\n", | |
| " .dataframe tbody tr th:only-of-type {\n", | |
| " vertical-align: middle;\n", | |
| " }\n", | |
| "\n", | |
| " .dataframe tbody tr th {\n", | |
| " vertical-align: top;\n", | |
| " }\n", | |
| "\n", | |
| " .dataframe thead th {\n", | |
| " text-align: right;\n", | |
| " }\n", | |
| "</style>\n", | |
| "<table border=\"1\" class=\"dataframe\">\n", | |
| " <thead>\n", | |
| " <tr style=\"text-align: right;\">\n", | |
| " <th></th>\n", | |
| " <th>kernel</th>\n", | |
| " <th>bios</th>\n", | |
| " <th>state</th>\n", | |
| " <th>bat</th>\n", | |
| " <th>total</th>\n", | |
| " <th>value</th>\n", | |
| " <th>prev_state</th>\n", | |
| " <th>total_watt</th>\n", | |
| " <th>value_watt</th>\n", | |
| " <th>value_diff_watt</th>\n", | |
| " <th>time_diff</th>\n", | |
| " <th>rate_per_hour_watt</th>\n", | |
| " <th>charge</th>\n", | |
| " <th>charge_diff</th>\n", | |
| " <th>charge_per_hour_diff</th>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>timestamp</th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " </tr>\n", | |
| " </thead>\n", | |
| " <tbody>\n", | |
| " <tr>\n", | |
| " <th>2021-07-15 14:38:59-03:00</th>\n", | |
| " <td>5.8.0-38-generic</td>\n", | |
| " <td>R1BET60W(1.29 )</td>\n", | |
| " <td>resume</td>\n", | |
| " <td>BAT0/</td>\n", | |
| " <td>51480000</td>\n", | |
| " <td>17700000</td>\n", | |
| " <td>suspend-then-hibernate</td>\n", | |
| " <td>51.48</td>\n", | |
| " <td>17.70</td>\n", | |
| " <td>-0.51</td>\n", | |
| " <td>1 days 10:59:48</td>\n", | |
| " <td>-0.046378</td>\n", | |
| " <td>34.0</td>\n", | |
| " <td>-0.990676</td>\n", | |
| " <td>-0.090089</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>2021-07-18 20:40:06-03:00</th>\n", | |
| " <td>5.8.0-38-generic</td>\n", | |
| " <td>R1BET60W(1.29 )</td>\n", | |
| " <td>resume</td>\n", | |
| " <td>BAT0/</td>\n", | |
| " <td>51480000</td>\n", | |
| " <td>44770000</td>\n", | |
| " <td>suspend-then-hibernate</td>\n", | |
| " <td>51.48</td>\n", | |
| " <td>44.77</td>\n", | |
| " <td>-0.49</td>\n", | |
| " <td>1 days 16:54:55</td>\n", | |
| " <td>-0.028968</td>\n", | |
| " <td>87.0</td>\n", | |
| " <td>-0.951826</td>\n", | |
| " <td>-0.056270</td>\n", | |
| " </tr>\n", | |
| " </tbody>\n", | |
| "</table>\n", | |
| "</div>" | |
| ], | |
| "text/plain": [ | |
| " kernel bios state bat \\\n", | |
| "timestamp \n", | |
| "2021-07-15 14:38:59-03:00 5.8.0-38-generic R1BET60W(1.29 ) resume BAT0/ \n", | |
| "2021-07-18 20:40:06-03:00 5.8.0-38-generic R1BET60W(1.29 ) resume BAT0/ \n", | |
| "\n", | |
| " total value prev_state \\\n", | |
| "timestamp \n", | |
| "2021-07-15 14:38:59-03:00 51480000 17700000 suspend-then-hibernate \n", | |
| "2021-07-18 20:40:06-03:00 51480000 44770000 suspend-then-hibernate \n", | |
| "\n", | |
| " total_watt value_watt value_diff_watt \\\n", | |
| "timestamp \n", | |
| "2021-07-15 14:38:59-03:00 51.48 17.70 -0.51 \n", | |
| "2021-07-18 20:40:06-03:00 51.48 44.77 -0.49 \n", | |
| "\n", | |
| " time_diff rate_per_hour_watt charge \\\n", | |
| "timestamp \n", | |
| "2021-07-15 14:38:59-03:00 1 days 10:59:48 -0.046378 34.0 \n", | |
| "2021-07-18 20:40:06-03:00 1 days 16:54:55 -0.028968 87.0 \n", | |
| "\n", | |
| " charge_diff charge_per_hour_diff \n", | |
| "timestamp \n", | |
| "2021-07-15 14:38:59-03:00 -0.990676 -0.090089 \n", | |
| "2021-07-18 20:40:06-03:00 -0.951826 -0.056270 " | |
| ] | |
| }, | |
| "execution_count": 9, | |
| "metadata": {}, | |
| "output_type": "execute_result" | |
| } | |
| ], | |
| "source": [ | |
| "hibernate_mode = (\n", | |
| " (df.state == \"resume\") &\n", | |
| " (df.prev_state == \"suspend-then-hibernate\") &\n", | |
| " (df.time_diff > pd.Timedelta(f\"{hibernate_delay} + 5min\"))\n", | |
| ")\n", | |
| "hibernate = df[hibernate_mode & battery_mode]\n", | |
| "hibernate" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 10, | |
| "id": "182efdbd-7e0f-4ce0-9f08-670312af96a8", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/html": [ | |
| "<div>\n", | |
| "<style scoped>\n", | |
| " .dataframe tbody tr th:only-of-type {\n", | |
| " vertical-align: middle;\n", | |
| " }\n", | |
| "\n", | |
| " .dataframe tbody tr th {\n", | |
| " vertical-align: top;\n", | |
| " }\n", | |
| "\n", | |
| " .dataframe thead tr th {\n", | |
| " text-align: left;\n", | |
| " }\n", | |
| "</style>\n", | |
| "<table border=\"1\" class=\"dataframe\">\n", | |
| " <thead>\n", | |
| " <tr>\n", | |
| " <th></th>\n", | |
| " <th>bios</th>\n", | |
| " <th>R1BET60W(1.29 )</th>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th></th>\n", | |
| " <th>kernel</th>\n", | |
| " <th>5.8.0-38-generic</th>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th></th>\n", | |
| " <th>bat</th>\n", | |
| " <th>BAT0/</th>\n", | |
| " </tr>\n", | |
| " </thead>\n", | |
| " <tbody>\n", | |
| " <tr>\n", | |
| " <th rowspan=\"8\" valign=\"top\">rate_per_hour_watt</th>\n", | |
| " <th>count</th>\n", | |
| " <td>2.000000</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>mean</th>\n", | |
| " <td>-0.037673</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>std</th>\n", | |
| " <td>0.012311</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>min</th>\n", | |
| " <td>-0.046378</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>25%</th>\n", | |
| " <td>-0.042025</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>50%</th>\n", | |
| " <td>-0.037673</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>75%</th>\n", | |
| " <td>-0.033320</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>max</th>\n", | |
| " <td>-0.028968</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th rowspan=\"8\" valign=\"top\">charge_per_hour_diff</th>\n", | |
| " <th>count</th>\n", | |
| " <td>2.000000</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>mean</th>\n", | |
| " <td>-0.073179</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>std</th>\n", | |
| " <td>0.023913</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>min</th>\n", | |
| " <td>-0.090089</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>25%</th>\n", | |
| " <td>-0.081634</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>50%</th>\n", | |
| " <td>-0.073179</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>75%</th>\n", | |
| " <td>-0.064725</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>max</th>\n", | |
| " <td>-0.056270</td>\n", | |
| " </tr>\n", | |
| " </tbody>\n", | |
| "</table>\n", | |
| "</div>" | |
| ], | |
| "text/plain": [ | |
| "bios R1BET60W(1.29 )\n", | |
| "kernel 5.8.0-38-generic\n", | |
| "bat BAT0/\n", | |
| "rate_per_hour_watt count 2.000000\n", | |
| " mean -0.037673\n", | |
| " std 0.012311\n", | |
| " min -0.046378\n", | |
| " 25% -0.042025\n", | |
| " 50% -0.037673\n", | |
| " 75% -0.033320\n", | |
| " max -0.028968\n", | |
| "charge_per_hour_diff count 2.000000\n", | |
| " mean -0.073179\n", | |
| " std 0.023913\n", | |
| " min -0.090089\n", | |
| " 25% -0.081634\n", | |
| " 50% -0.073179\n", | |
| " 75% -0.064725\n", | |
| " max -0.056270" | |
| ] | |
| }, | |
| "execution_count": 10, | |
| "metadata": {}, | |
| "output_type": "execute_result" | |
| } | |
| ], | |
| "source": [ | |
| "hibernate_stats = hibernate.groupby([\"bios\", \"kernel\", \"bat\"])[[\"rate_per_hour_watt\", \"charge_per_hour_diff\"]]\n", | |
| "hibernate_stats.describe().T" | |
| ] | |
| } | |
| ], | |
| "metadata": { | |
| "kernelspec": { | |
| "display_name": "Python 3 (ipykernel)", | |
| "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.8.7" | |
| } | |
| }, | |
| "nbformat": 4, | |
| "nbformat_minor": 5 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment