Spaces:
Sleeping
Sleeping
File size: 41,914 Bytes
b510d23 2f26201 b510d23 3d4f3ff 2f26201 3d4f3ff 2f26201 3d4f3ff b510d23 3d4f3ff b510d23 831470f b510d23 831470f b510d23 831470f 3d4f3ff 831470f 2f26201 831470f b510d23 831470f b510d23 831470f 3d4f3ff 2f26201 3d4f3ff b510d23 831470f b510d23 831470f b510d23 831470f b510d23 831470f b510d23 3d4f3ff b510d23 831470f b510d23 831470f b510d23 831470f 3d4f3ff 2f26201 b510d23 831470f b510d23 831470f b510d23 831470f 3d4f3ff 831470f 3d4f3ff 831470f 3d4f3ff 2f26201 3d4f3ff 831470f b510d23 831470f 3d4f3ff b510d23 3d4f3ff b510d23 831470f b510d23 831470f b510d23 831470f b510d23 831470f b510d23 2f26201 831470f b510d23 3d4f3ff b510d23 3d4f3ff b510d23 831470f b510d23 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 |
{
"cells": [
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/var/folders/b4/lwfgccm95kqd2skcwvrt2fr00000gn/T/ipykernel_34004/147804699.py:17: FutureWarning:\n",
"\n",
"The behavior of DataFrame concatenation with empty or all-NA entries is deprecated. In a future version, this will no longer exclude empty or all-NA columns when determining the result dtypes. To retain the old behavior, exclude the relevant entries before the concat operation.\n",
"\n"
]
},
{
"ename": "FileNotFoundError",
"evalue": "[Errno 2] No such file or directory: 'data/water_consumption/montly/16NSJNnjLK4MndjZYaKYGKEV_month.csv'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mFileNotFoundError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m/Users/ruimelo/Documents/GitHub/atc-smart-shower/frontend/app/dashboard.ipynb Cell 1\u001b[0m line \u001b[0;36m8\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/ruimelo/Documents/GitHub/atc-smart-shower/frontend/app/dashboard.ipynb#W5sZmlsZQ%3D%3D?line=56'>57</a>\u001b[0m dataset_original_dfs \u001b[39m=\u001b[39m {\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/ruimelo/Documents/GitHub/atc-smart-shower/frontend/app/dashboard.ipynb#W5sZmlsZQ%3D%3D?line=57'>58</a>\u001b[0m \u001b[39m\"\u001b[39m\u001b[39m16NSJNnjLK4MndjZYaKYGKEV\u001b[39m\u001b[39m\"\u001b[39m: pd\u001b[39m.\u001b[39mread_csv(\u001b[39m'\u001b[39m\u001b[39mdata/original/16NSJNnjLK4MndjZYaKYGKEV.csv\u001b[39m\u001b[39m'\u001b[39m),\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/ruimelo/Documents/GitHub/atc-smart-shower/frontend/app/dashboard.ipynb#W5sZmlsZQ%3D%3D?line=58'>59</a>\u001b[0m \u001b[39m\"\u001b[39m\u001b[39m7uLwefnSt8CgVlmIGY8emqJK\u001b[39m\u001b[39m\"\u001b[39m: pd\u001b[39m.\u001b[39mread_csv(\u001b[39m'\u001b[39m\u001b[39mdata/original/7uLwefnSt8CgVlmIGY8emqJK.csv\u001b[39m\u001b[39m'\u001b[39m),\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/ruimelo/Documents/GitHub/atc-smart-shower/frontend/app/dashboard.ipynb#W5sZmlsZQ%3D%3D?line=68'>69</a>\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mSQUOjMB6zAgYpSJEMy46tKXJ\u001b[39m\u001b[39m\"\u001b[39m: pd\u001b[39m.\u001b[39mread_csv(\u001b[39m'\u001b[39m\u001b[39mdata/original/SQUOjMB6zAgYpSJEMy46tKXJ.csv\u001b[39m\u001b[39m'\u001b[39m),\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/ruimelo/Documents/GitHub/atc-smart-shower/frontend/app/dashboard.ipynb#W5sZmlsZQ%3D%3D?line=69'>70</a>\u001b[0m }\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/ruimelo/Documents/GitHub/atc-smart-shower/frontend/app/dashboard.ipynb#W5sZmlsZQ%3D%3D?line=70'>71</a>\u001b[0m dataset_water_consumption_dfs \u001b[39m=\u001b[39m {\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/ruimelo/Documents/GitHub/atc-smart-shower/frontend/app/dashboard.ipynb#W5sZmlsZQ%3D%3D?line=71'>72</a>\u001b[0m \u001b[39m\"\u001b[39m\u001b[39m16NSJNnjLK4MndjZYaKYGKEV\u001b[39m\u001b[39m\"\u001b[39m: pd\u001b[39m.\u001b[39mread_csv(\u001b[39m'\u001b[39m\u001b[39mdata/water_consumption/16NSJNnjLK4MndjZYaKYGKEV_water_consumption.csv\u001b[39m\u001b[39m'\u001b[39m),\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/ruimelo/Documents/GitHub/atc-smart-shower/frontend/app/dashboard.ipynb#W5sZmlsZQ%3D%3D?line=72'>73</a>\u001b[0m \u001b[39m\"\u001b[39m\u001b[39m7uLwefnSt8CgVlmIGY8emqJK\u001b[39m\u001b[39m\"\u001b[39m: pd\u001b[39m.\u001b[39mread_csv(\u001b[39m'\u001b[39m\u001b[39mdata/water_consumption/7uLwefnSt8CgVlmIGY8emqJK_water_consumption.csv\u001b[39m\u001b[39m'\u001b[39m),\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/ruimelo/Documents/GitHub/atc-smart-shower/frontend/app/dashboard.ipynb#W5sZmlsZQ%3D%3D?line=82'>83</a>\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mSQUOjMB6zAgYpSJEMy46tKXJ\u001b[39m\u001b[39m\"\u001b[39m: pd\u001b[39m.\u001b[39mread_csv(\u001b[39m'\u001b[39m\u001b[39mdata/water_consumption/SQUOjMB6zAgYpSJEMy46tKXJ_water_consumption.csv\u001b[39m\u001b[39m'\u001b[39m),\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/ruimelo/Documents/GitHub/atc-smart-shower/frontend/app/dashboard.ipynb#W5sZmlsZQ%3D%3D?line=83'>84</a>\u001b[0m }\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/ruimelo/Documents/GitHub/atc-smart-shower/frontend/app/dashboard.ipynb#W5sZmlsZQ%3D%3D?line=84'>85</a>\u001b[0m dataset_water_consumption_monthly_dfs \u001b[39m=\u001b[39m {\n\u001b[0;32m---> <a href='vscode-notebook-cell:/Users/ruimelo/Documents/GitHub/atc-smart-shower/frontend/app/dashboard.ipynb#W5sZmlsZQ%3D%3D?line=85'>86</a>\u001b[0m \u001b[39m\"\u001b[39m\u001b[39m16NSJNnjLK4MndjZYaKYGKEV\u001b[39m\u001b[39m\"\u001b[39m: pd\u001b[39m.\u001b[39;49mread_csv(\u001b[39m'\u001b[39;49m\u001b[39mdata/water_consumption/montly/16NSJNnjLK4MndjZYaKYGKEV_month.csv\u001b[39;49m\u001b[39m'\u001b[39;49m),\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/ruimelo/Documents/GitHub/atc-smart-shower/frontend/app/dashboard.ipynb#W5sZmlsZQ%3D%3D?line=86'>87</a>\u001b[0m \u001b[39m\"\u001b[39m\u001b[39m7uLwefnSt8CgVlmIGY8emqJK\u001b[39m\u001b[39m\"\u001b[39m: pd\u001b[39m.\u001b[39mread_csv(\u001b[39m'\u001b[39m\u001b[39mdata/water_consumption/montly/7uLwefnSt8CgVlmIGY8emqJK_month.csv\u001b[39m\u001b[39m'\u001b[39m),\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/ruimelo/Documents/GitHub/atc-smart-shower/frontend/app/dashboard.ipynb#W5sZmlsZQ%3D%3D?line=87'>88</a>\u001b[0m \u001b[39m\"\u001b[39m\u001b[39m8yS04Ddkk3pPL8e9Rku4LJtc\u001b[39m\u001b[39m\"\u001b[39m: pd\u001b[39m.\u001b[39mread_csv(\u001b[39m'\u001b[39m\u001b[39mdata/water_consumption/montly/8yS04Ddkk3pPL8e9Rku4LJtc_month.csv\u001b[39m\u001b[39m'\u001b[39m),\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/ruimelo/Documents/GitHub/atc-smart-shower/frontend/app/dashboard.ipynb#W5sZmlsZQ%3D%3D?line=88'>89</a>\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mCwp33jA19hp9VdoNJUlj6USf\u001b[39m\u001b[39m\"\u001b[39m: pd\u001b[39m.\u001b[39mread_csv(\u001b[39m'\u001b[39m\u001b[39mdata/water_consumption/montly/Cwp33jA19hp9VdoNJUlj6USf_month.csv\u001b[39m\u001b[39m'\u001b[39m),\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/ruimelo/Documents/GitHub/atc-smart-shower/frontend/app/dashboard.ipynb#W5sZmlsZQ%3D%3D?line=89'>90</a>\u001b[0m \u001b[39m\"\u001b[39m\u001b[39miBFIAuvh7bCNyOQDo0jkjhRV\u001b[39m\u001b[39m\"\u001b[39m: pd\u001b[39m.\u001b[39mread_csv(\u001b[39m'\u001b[39m\u001b[39mdata/water_consumption/montly/iBFIAuvh7bCNyOQDo0jkjhRV_month.csv\u001b[39m\u001b[39m'\u001b[39m),\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/ruimelo/Documents/GitHub/atc-smart-shower/frontend/app/dashboard.ipynb#W5sZmlsZQ%3D%3D?line=90'>91</a>\u001b[0m \u001b[39m\"\u001b[39m\u001b[39miNVKpGfGW6rU17eOtxpZSFWR\u001b[39m\u001b[39m\"\u001b[39m: pd\u001b[39m.\u001b[39mread_csv(\u001b[39m'\u001b[39m\u001b[39mdata/water_consumption/montly/iNVKpGfGW6rU17eOtxpZSFWR_month.csv\u001b[39m\u001b[39m'\u001b[39m),\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/ruimelo/Documents/GitHub/atc-smart-shower/frontend/app/dashboard.ipynb#W5sZmlsZQ%3D%3D?line=91'>92</a>\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mkaTMmHVh8gXUbHMppzdmdzpv\u001b[39m\u001b[39m\"\u001b[39m: pd\u001b[39m.\u001b[39mread_csv(\u001b[39m'\u001b[39m\u001b[39mdata/water_consumption/montly/kaTMmHVh8gXUbHMppzdmdzpv_monthcsv\u001b[39m\u001b[39m'\u001b[39m),\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/ruimelo/Documents/GitHub/atc-smart-shower/frontend/app/dashboard.ipynb#W5sZmlsZQ%3D%3D?line=92'>93</a>\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mKN9Z3gANLftDuUGvgs8O38dI\u001b[39m\u001b[39m\"\u001b[39m: pd\u001b[39m.\u001b[39mread_csv(\u001b[39m'\u001b[39m\u001b[39mdata/water_consumption/montly/KN9Z3gANLftDuUGvgs8O38dI_month.csv\u001b[39m\u001b[39m'\u001b[39m),\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/ruimelo/Documents/GitHub/atc-smart-shower/frontend/app/dashboard.ipynb#W5sZmlsZQ%3D%3D?line=93'>94</a>\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mLzbMafI31IosheUI7YGhj5at\u001b[39m\u001b[39m\"\u001b[39m: pd\u001b[39m.\u001b[39mread_csv(\u001b[39m'\u001b[39m\u001b[39mdata/water_consumption/montly/LzbMafI31IosheUI7YGhj5at_month.csv\u001b[39m\u001b[39m'\u001b[39m),\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/ruimelo/Documents/GitHub/atc-smart-shower/frontend/app/dashboard.ipynb#W5sZmlsZQ%3D%3D?line=94'>95</a>\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mPHqaZDuMTRvCZCvA259Z1vJu\u001b[39m\u001b[39m\"\u001b[39m: pd\u001b[39m.\u001b[39mread_csv(\u001b[39m'\u001b[39m\u001b[39mdata/water_consumption/montly/PHqaZDuMTRvCZCvA259Z1vJu_month.csv\u001b[39m\u001b[39m'\u001b[39m),\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/ruimelo/Documents/GitHub/atc-smart-shower/frontend/app/dashboard.ipynb#W5sZmlsZQ%3D%3D?line=95'>96</a>\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mRZngVU6axOdshmfma0yNAajE\u001b[39m\u001b[39m\"\u001b[39m: pd\u001b[39m.\u001b[39mread_csv(\u001b[39m'\u001b[39m\u001b[39mdata/water_consumption/montly/RZngVU6axOdshmfma0yNAajE_month.csv\u001b[39m\u001b[39m'\u001b[39m),\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/ruimelo/Documents/GitHub/atc-smart-shower/frontend/app/dashboard.ipynb#W5sZmlsZQ%3D%3D?line=96'>97</a>\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mSQUOjMB6zAgYpSJEMy46tKXJ\u001b[39m\u001b[39m\"\u001b[39m: pd\u001b[39m.\u001b[39mread_csv(\u001b[39m'\u001b[39m\u001b[39mdata/water_consumption/montly/SQUOjMB6zAgYpSJEMy46tKXJ_month.csv\u001b[39m\u001b[39m'\u001b[39m),\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/ruimelo/Documents/GitHub/atc-smart-shower/frontend/app/dashboard.ipynb#W5sZmlsZQ%3D%3D?line=97'>98</a>\u001b[0m }\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/ruimelo/Documents/GitHub/atc-smart-shower/frontend/app/dashboard.ipynb#W5sZmlsZQ%3D%3D?line=99'>100</a>\u001b[0m \u001b[39m# provide a scalar value to enable the slider to select ideal temperature\u001b[39;00m\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/ruimelo/Documents/GitHub/atc-smart-shower/frontend/app/dashboard.ipynb#W5sZmlsZQ%3D%3D?line=100'>101</a>\u001b[0m ideal_temperature \u001b[39m=\u001b[39m \u001b[39m50\u001b[39m\n",
"File \u001b[0;32m~/anaconda3/envs/atc/lib/python3.10/site-packages/pandas/io/parsers/readers.py:948\u001b[0m, in \u001b[0;36mread_csv\u001b[0;34m(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, skipfooter, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, date_format, dayfirst, cache_dates, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, doublequote, escapechar, comment, encoding, encoding_errors, dialect, on_bad_lines, delim_whitespace, low_memory, memory_map, float_precision, storage_options, dtype_backend)\u001b[0m\n\u001b[1;32m 935\u001b[0m kwds_defaults \u001b[39m=\u001b[39m _refine_defaults_read(\n\u001b[1;32m 936\u001b[0m dialect,\n\u001b[1;32m 937\u001b[0m delimiter,\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 944\u001b[0m dtype_backend\u001b[39m=\u001b[39mdtype_backend,\n\u001b[1;32m 945\u001b[0m )\n\u001b[1;32m 946\u001b[0m kwds\u001b[39m.\u001b[39mupdate(kwds_defaults)\n\u001b[0;32m--> 948\u001b[0m \u001b[39mreturn\u001b[39;00m _read(filepath_or_buffer, kwds)\n",
"File \u001b[0;32m~/anaconda3/envs/atc/lib/python3.10/site-packages/pandas/io/parsers/readers.py:611\u001b[0m, in \u001b[0;36m_read\u001b[0;34m(filepath_or_buffer, kwds)\u001b[0m\n\u001b[1;32m 608\u001b[0m _validate_names(kwds\u001b[39m.\u001b[39mget(\u001b[39m\"\u001b[39m\u001b[39mnames\u001b[39m\u001b[39m\"\u001b[39m, \u001b[39mNone\u001b[39;00m))\n\u001b[1;32m 610\u001b[0m \u001b[39m# Create the parser.\u001b[39;00m\n\u001b[0;32m--> 611\u001b[0m parser \u001b[39m=\u001b[39m TextFileReader(filepath_or_buffer, \u001b[39m*\u001b[39;49m\u001b[39m*\u001b[39;49mkwds)\n\u001b[1;32m 613\u001b[0m \u001b[39mif\u001b[39;00m chunksize \u001b[39mor\u001b[39;00m iterator:\n\u001b[1;32m 614\u001b[0m \u001b[39mreturn\u001b[39;00m parser\n",
"File \u001b[0;32m~/anaconda3/envs/atc/lib/python3.10/site-packages/pandas/io/parsers/readers.py:1448\u001b[0m, in \u001b[0;36mTextFileReader.__init__\u001b[0;34m(self, f, engine, **kwds)\u001b[0m\n\u001b[1;32m 1445\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39moptions[\u001b[39m\"\u001b[39m\u001b[39mhas_index_names\u001b[39m\u001b[39m\"\u001b[39m] \u001b[39m=\u001b[39m kwds[\u001b[39m\"\u001b[39m\u001b[39mhas_index_names\u001b[39m\u001b[39m\"\u001b[39m]\n\u001b[1;32m 1447\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mhandles: IOHandles \u001b[39m|\u001b[39m \u001b[39mNone\u001b[39;00m \u001b[39m=\u001b[39m \u001b[39mNone\u001b[39;00m\n\u001b[0;32m-> 1448\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_engine \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_make_engine(f, \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mengine)\n",
"File \u001b[0;32m~/anaconda3/envs/atc/lib/python3.10/site-packages/pandas/io/parsers/readers.py:1705\u001b[0m, in \u001b[0;36mTextFileReader._make_engine\u001b[0;34m(self, f, engine)\u001b[0m\n\u001b[1;32m 1703\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39m\"\u001b[39m\u001b[39mb\u001b[39m\u001b[39m\"\u001b[39m \u001b[39mnot\u001b[39;00m \u001b[39min\u001b[39;00m mode:\n\u001b[1;32m 1704\u001b[0m mode \u001b[39m+\u001b[39m\u001b[39m=\u001b[39m \u001b[39m\"\u001b[39m\u001b[39mb\u001b[39m\u001b[39m\"\u001b[39m\n\u001b[0;32m-> 1705\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mhandles \u001b[39m=\u001b[39m get_handle(\n\u001b[1;32m 1706\u001b[0m f,\n\u001b[1;32m 1707\u001b[0m mode,\n\u001b[1;32m 1708\u001b[0m encoding\u001b[39m=\u001b[39;49m\u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49moptions\u001b[39m.\u001b[39;49mget(\u001b[39m\"\u001b[39;49m\u001b[39mencoding\u001b[39;49m\u001b[39m\"\u001b[39;49m, \u001b[39mNone\u001b[39;49;00m),\n\u001b[1;32m 1709\u001b[0m compression\u001b[39m=\u001b[39;49m\u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49moptions\u001b[39m.\u001b[39;49mget(\u001b[39m\"\u001b[39;49m\u001b[39mcompression\u001b[39;49m\u001b[39m\"\u001b[39;49m, \u001b[39mNone\u001b[39;49;00m),\n\u001b[1;32m 1710\u001b[0m memory_map\u001b[39m=\u001b[39;49m\u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49moptions\u001b[39m.\u001b[39;49mget(\u001b[39m\"\u001b[39;49m\u001b[39mmemory_map\u001b[39;49m\u001b[39m\"\u001b[39;49m, \u001b[39mFalse\u001b[39;49;00m),\n\u001b[1;32m 1711\u001b[0m is_text\u001b[39m=\u001b[39;49mis_text,\n\u001b[1;32m 1712\u001b[0m errors\u001b[39m=\u001b[39;49m\u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49moptions\u001b[39m.\u001b[39;49mget(\u001b[39m\"\u001b[39;49m\u001b[39mencoding_errors\u001b[39;49m\u001b[39m\"\u001b[39;49m, \u001b[39m\"\u001b[39;49m\u001b[39mstrict\u001b[39;49m\u001b[39m\"\u001b[39;49m),\n\u001b[1;32m 1713\u001b[0m storage_options\u001b[39m=\u001b[39;49m\u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49moptions\u001b[39m.\u001b[39;49mget(\u001b[39m\"\u001b[39;49m\u001b[39mstorage_options\u001b[39;49m\u001b[39m\"\u001b[39;49m, \u001b[39mNone\u001b[39;49;00m),\n\u001b[1;32m 1714\u001b[0m )\n\u001b[1;32m 1715\u001b[0m \u001b[39massert\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mhandles \u001b[39mis\u001b[39;00m \u001b[39mnot\u001b[39;00m \u001b[39mNone\u001b[39;00m\n\u001b[1;32m 1716\u001b[0m f \u001b[39m=\u001b[39m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mhandles\u001b[39m.\u001b[39mhandle\n",
"File \u001b[0;32m~/anaconda3/envs/atc/lib/python3.10/site-packages/pandas/io/common.py:863\u001b[0m, in \u001b[0;36mget_handle\u001b[0;34m(path_or_buf, mode, encoding, compression, memory_map, is_text, errors, storage_options)\u001b[0m\n\u001b[1;32m 858\u001b[0m \u001b[39melif\u001b[39;00m \u001b[39misinstance\u001b[39m(handle, \u001b[39mstr\u001b[39m):\n\u001b[1;32m 859\u001b[0m \u001b[39m# Check whether the filename is to be opened in binary mode.\u001b[39;00m\n\u001b[1;32m 860\u001b[0m \u001b[39m# Binary mode does not support 'encoding' and 'newline'.\u001b[39;00m\n\u001b[1;32m 861\u001b[0m \u001b[39mif\u001b[39;00m ioargs\u001b[39m.\u001b[39mencoding \u001b[39mand\u001b[39;00m \u001b[39m\"\u001b[39m\u001b[39mb\u001b[39m\u001b[39m\"\u001b[39m \u001b[39mnot\u001b[39;00m \u001b[39min\u001b[39;00m ioargs\u001b[39m.\u001b[39mmode:\n\u001b[1;32m 862\u001b[0m \u001b[39m# Encoding\u001b[39;00m\n\u001b[0;32m--> 863\u001b[0m handle \u001b[39m=\u001b[39m \u001b[39mopen\u001b[39;49m(\n\u001b[1;32m 864\u001b[0m handle,\n\u001b[1;32m 865\u001b[0m ioargs\u001b[39m.\u001b[39;49mmode,\n\u001b[1;32m 866\u001b[0m encoding\u001b[39m=\u001b[39;49mioargs\u001b[39m.\u001b[39;49mencoding,\n\u001b[1;32m 867\u001b[0m errors\u001b[39m=\u001b[39;49merrors,\n\u001b[1;32m 868\u001b[0m newline\u001b[39m=\u001b[39;49m\u001b[39m\"\u001b[39;49m\u001b[39m\"\u001b[39;49m,\n\u001b[1;32m 869\u001b[0m )\n\u001b[1;32m 870\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[1;32m 871\u001b[0m \u001b[39m# Binary mode\u001b[39;00m\n\u001b[1;32m 872\u001b[0m handle \u001b[39m=\u001b[39m \u001b[39mopen\u001b[39m(handle, ioargs\u001b[39m.\u001b[39mmode)\n",
"\u001b[0;31mFileNotFoundError\u001b[0m: [Errno 2] No such file or directory: 'data/water_consumption/montly/16NSJNnjLK4MndjZYaKYGKEV_month.csv'"
]
}
],
"source": [
"import os\n",
"import plotly.express as px\n",
"import plotly.graph_objects as go\n",
"import pandas as pd\n",
"from dash import Dash, html, dcc, Input, Output, callback\n",
"import plotly.express as px\n",
"import numpy as np\n",
"import example_data\n",
"import core\n",
"from plotly.subplots import make_subplots\n",
"\n",
"outside_temp = example_data.ExampleDailyOutsideTemperature\n",
"energy_price = example_data.ExampleDailyEnergyCost\n",
"boiler_temperature = example_data.ExampleBoilerTemperature\n",
"\n",
"data = pd.DataFrame(columns=['hour', 'energy_consumption', 'comfort', 'policy_readable'])\n",
"data = pd.concat([data, pd.DataFrame({'hour': np.arange(0, 24), 'energy_consumption': energy_price.value, 'comfort': np.random.rand(24),\n",
" 'policy_readable': np.random.choice(['A', 'B', 'C', 'D', 'E'], 24)\n",
" })])\n",
"debug = False\n",
"\n",
"external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']\n",
"\n",
"app = Dash(__name__, external_stylesheets=external_stylesheets)\n",
"\n",
"app.layout = html.Div([\n",
" dcc.Location(id='url', refresh=False),\n",
" html.Div(id='page-content')\n",
"])\n",
"\n",
"server = app.server\n",
"\n",
"# Solution options\n",
"solution_options = [\n",
" \"Discrete Optimization\",\n",
" \"Continuous Optimization\",\n",
" \"Reinforcement Learning\"\n",
"]\n",
"solution_options_default_value = solution_options[0]\n",
"\n",
"# Datasets\n",
"dataset_options = [\n",
" \"16NSJNnjLK4MndjZYaKYGKEV\",\n",
" \"7uLwefnSt8CgVlmIGY8emqJK\",\n",
" \"8yS04Ddkk3pPL8e9Rku4LJtc\",\n",
" \"Cwp33jA19hp9VdoNJUlj6USf\",\n",
" \"iBFIAuvh7bCNyOQDo0jkjhRV\",\n",
" \"iNVKpGfGW6rU17eOtxpZSFWR\",\n",
" \"kaTMmHVh8gXUbHMppzdmdzpv\",\n",
" \"KN9Z3gANLftDuUGvgs8O38dI\",\n",
" \"LzbMafI31IosheUI7YGhj5at\",\n",
" \"PHqaZDuMTRvCZCvA259Z1vJu\",\n",
" \"RZngVU6axOdshmfma0yNAajE\",\n",
" \"SQUOjMB6zAgYpSJEMy46tKXJ\",\n",
"]\n",
"dataset_options_default_value = dataset_options[0]\n",
"dataset_original_dfs = {\n",
" \"16NSJNnjLK4MndjZYaKYGKEV\": pd.read_csv('data/original/16NSJNnjLK4MndjZYaKYGKEV.csv'),\n",
" \"7uLwefnSt8CgVlmIGY8emqJK\": pd.read_csv('data/original/7uLwefnSt8CgVlmIGY8emqJK.csv'),\n",
" \"8yS04Ddkk3pPL8e9Rku4LJtc\": pd.read_csv('data/original/8yS04Ddkk3pPL8e9Rku4LJtc.csv'),\n",
" \"Cwp33jA19hp9VdoNJUlj6USf\": pd.read_csv('data/original/Cwp33jA19hp9VdoNJUlj6USf.csv'),\n",
" \"iBFIAuvh7bCNyOQDo0jkjhRV\": pd.read_csv('data/original/iBFIAuvh7bCNyOQDo0jkjhRV.csv'),\n",
" \"iNVKpGfGW6rU17eOtxpZSFWR\": pd.read_csv('data/original/iNVKpGfGW6rU17eOtxpZSFWR.csv'),\n",
" \"kaTMmHVh8gXUbHMppzdmdzpv\": pd.read_csv('data/original/kaTMmHVh8gXUbHMppzdmdzpv.csv'),\n",
" \"KN9Z3gANLftDuUGvgs8O38dI\": pd.read_csv('data/original/KN9Z3gANLftDuUGvgs8O38dI.csv'),\n",
" \"LzbMafI31IosheUI7YGhj5at\": pd.read_csv('data/original/LzbMafI31IosheUI7YGhj5at.csv'),\n",
" \"PHqaZDuMTRvCZCvA259Z1vJu\": pd.read_csv('data/original/PHqaZDuMTRvCZCvA259Z1vJu.csv'),\n",
" \"RZngVU6axOdshmfma0yNAajE\": pd.read_csv('data/original/RZngVU6axOdshmfma0yNAajE.csv'),\n",
" \"SQUOjMB6zAgYpSJEMy46tKXJ\": pd.read_csv('data/original/SQUOjMB6zAgYpSJEMy46tKXJ.csv'),\n",
"}\n",
"dataset_water_consumption_dfs = {\n",
" \"16NSJNnjLK4MndjZYaKYGKEV\": pd.read_csv('data/water_consumption/16NSJNnjLK4MndjZYaKYGKEV_water_consumption.csv'),\n",
" \"7uLwefnSt8CgVlmIGY8emqJK\": pd.read_csv('data/water_consumption/7uLwefnSt8CgVlmIGY8emqJK_water_consumption.csv'),\n",
" \"8yS04Ddkk3pPL8e9Rku4LJtc\": pd.read_csv('data/water_consumption/8yS04Ddkk3pPL8e9Rku4LJtc_water_consumption.csv'),\n",
" \"Cwp33jA19hp9VdoNJUlj6USf\": pd.read_csv('data/water_consumption/Cwp33jA19hp9VdoNJUlj6USf_water_consumption.csv'),\n",
" \"iBFIAuvh7bCNyOQDo0jkjhRV\": pd.read_csv('data/water_consumption/iBFIAuvh7bCNyOQDo0jkjhRV_water_consumption.csv'),\n",
" \"iNVKpGfGW6rU17eOtxpZSFWR\": pd.read_csv('data/water_consumption/iNVKpGfGW6rU17eOtxpZSFWR_water_consumption.csv'),\n",
" \"kaTMmHVh8gXUbHMppzdmdzpv\": pd.read_csv('data/water_consumption/kaTMmHVh8gXUbHMppzdmdzpv_water_consumption.csv'),\n",
" \"KN9Z3gANLftDuUGvgs8O38dI\": pd.read_csv('data/water_consumption/KN9Z3gANLftDuUGvgs8O38dI_water_consumption.csv'),\n",
" \"LzbMafI31IosheUI7YGhj5at\": pd.read_csv('data/water_consumption/LzbMafI31IosheUI7YGhj5at_water_consumption.csv'),\n",
" \"PHqaZDuMTRvCZCvA259Z1vJu\": pd.read_csv('data/water_consumption/PHqaZDuMTRvCZCvA259Z1vJu_water_consumption.csv'),\n",
" \"RZngVU6axOdshmfma0yNAajE\": pd.read_csv('data/water_consumption/RZngVU6axOdshmfma0yNAajE_water_consumption.csv'),\n",
" \"SQUOjMB6zAgYpSJEMy46tKXJ\": pd.read_csv('data/water_consumption/SQUOjMB6zAgYpSJEMy46tKXJ_water_consumption.csv'),\n",
"}\n",
"dataset_water_consumption_monthly_dfs = {\n",
" \"16NSJNnjLK4MndjZYaKYGKEV\": pd.read_csv('data/water_consumption/monthly/16NSJNnjLK4MndjZYaKYGKEV_month.csv'),\n",
" \"7uLwefnSt8CgVlmIGY8emqJK\": pd.read_csv('data/water_consumption/monthly/7uLwefnSt8CgVlmIGY8emqJK_month.csv'),\n",
" \"8yS04Ddkk3pPL8e9Rku4LJtc\": pd.read_csv('data/water_consumption/monthly/8yS04Ddkk3pPL8e9Rku4LJtc_month.csv'),\n",
" \"Cwp33jA19hp9VdoNJUlj6USf\": pd.read_csv('data/water_consumption/monthly/Cwp33jA19hp9VdoNJUlj6USf_month.csv'),\n",
" \"iBFIAuvh7bCNyOQDo0jkjhRV\": pd.read_csv('data/water_consumption/monthly/iBFIAuvh7bCNyOQDo0jkjhRV_month.csv'),\n",
" \"iNVKpGfGW6rU17eOtxpZSFWR\": pd.read_csv('data/water_consumption/monthly/iNVKpGfGW6rU17eOtxpZSFWR_month.csv'),\n",
" \"kaTMmHVh8gXUbHMppzdmdzpv\": pd.read_csv('data/water_consumption/monthly/kaTMmHVh8gXUbHMppzdmdzpv_monthcsv'),\n",
" \"KN9Z3gANLftDuUGvgs8O38dI\": pd.read_csv('data/water_consumption/monthly/KN9Z3gANLftDuUGvgs8O38dI_month.csv'),\n",
" \"LzbMafI31IosheUI7YGhj5at\": pd.read_csv('data/water_consumption/monthly/LzbMafI31IosheUI7YGhj5at_month.csv'),\n",
" \"PHqaZDuMTRvCZCvA259Z1vJu\": pd.read_csv('data/water_consumption/monthly/PHqaZDuMTRvCZCvA259Z1vJu_month.csv'),\n",
" \"RZngVU6axOdshmfma0yNAajE\": pd.read_csv('data/water_consumption/monthly/RZngVU6axOdshmfma0yNAajE_month.csv'),\n",
" \"SQUOjMB6zAgYpSJEMy46tKXJ\": pd.read_csv('data/water_consumption/monthly/SQUOjMB6zAgYpSJEMy46tKXJ_month.csv'),\n",
"}\n",
"\n",
"# provide a scalar value to enable the slider to select ideal temperature\n",
"ideal_temperature = 50\n",
"\n",
"dashboard_layout = html.Div([\n",
" dcc.Link('About this project', href='/wiki'),\n",
"\n",
" html.H1('System Evaluation'),\n",
" #small subtitle that says of solution is possible or not\n",
" html.Div(id='solution-status', children='', style={'color': 'lighrgrey'}),\n",
" html.Div([\n",
" html.Div([\n",
" html.H3('Dataset'),\n",
" dcc.Dropdown(\n",
" id='dataset-dropdown',\n",
" options=dataset_options,\n",
" value=dataset_options_default_value,\n",
" )\n",
" ], className='three columns'),\n",
" html.Div([\n",
" html.H3('Solution'),\n",
" dcc.Dropdown(\n",
" id='solution-dropdown',\n",
" options=solution_options,\n",
" value=solution_options_default_value,\n",
" )\n",
" ], className='three columns'),\n",
" html.Div([\n",
" html.H3('Ideal Shower Temperature'),\n",
" dcc.Slider(\n",
" id='ideal-temperature-slider',\n",
" min=0,\n",
" max=100,\n",
" step=1,\n",
" value=ideal_temperature,\n",
" marks={\n",
" 0: '0°C',\n",
" 25: '25°C',\n",
" 50: '50°C',\n",
" 75: '75°C',\n",
" 100: '100°C'\n",
" },\n",
" )\n",
" ], className='three columns'),\n",
"\n",
"\n",
" ], className='row'),\n",
" html.Div(\n",
" [\n",
" html.Div(\n",
" [\n",
" html.H3('Dataset'),\n",
" dcc.Graph(id='dataset-graph')\n",
" ], className='twelve columns',\n",
" )\n",
" ], className='row'),\n",
" html.Div(\n",
" [\n",
" html.Div(\n",
" [\n",
" html.H3('Water Comsumption Patterns'),\n",
" dcc.Graph(id='water-consumption-graph')\n",
" ], className='twelve columns',\n",
" )\n",
" ], className='row'),\n",
" html.Div(\n",
" [\n",
" html.Div(\n",
" [\n",
" html.H4('Hourly'),\n",
" dcc.Graph(id='water_consumption_hourly_graph')\n",
" ], className='six columns',\n",
" ),\n",
" html.Div(\n",
" [\n",
" html.H4('Day of the Week'),\n",
" dcc.Graph(id='water_consumption_week_day_graph')\n",
" ], className='six columns',\n",
" )\n",
" ], className='row'),\n",
" html.Div(\n",
" [\n",
" html.Div(\n",
" [\n",
" html.H4('Monthly'),\n",
" dcc.Graph(id='water_consumption_monthly_graph')\n",
" ], className='six columns',\n",
" )\n",
" ], className='row'),\n",
" html.Div(\n",
" [\n",
" html.Div(\n",
" [\n",
" html.H3('Policy'),\n",
" dcc.Graph(id='policy_readable-graph')\n",
" ], className='six columns',\n",
" ),\n",
" html.Div(\n",
" [\n",
" html.H3('Energy Consumption'),\n",
" dcc.Graph(id='energy-consumption-graph')\n",
" ], className='six columns'\n",
" ),\n",
" ]\n",
" ),\n",
" html.Div(\n",
" [\n",
" html.Div(\n",
" [\n",
" html.H3('Comfort'),\n",
" dcc.Graph(id='comfort-graph')\n",
" ], className='six columns'\n",
" )\n",
" ], className='row'),\n",
"],\n",
"#add background image from local file and make it transparent\n",
"#, style={'background-image':'url(/assets/background_1.png)'}\n",
"style={'background-color': '#333', 'font-family': 'Fantasy', 'color': '#999', 'padding': '10px'}\n",
")\n",
"\n",
"\n",
"wiki_layout = html.Div([\n",
" dcc.Link('Dashboard', href='/'),\n",
"\n",
" html.H1('About this project'),\n",
"\n",
" html.Div([\n",
" html.Div([\n",
"\n",
" html.H3('What is this project about?'),\n",
"\n",
" html.P('This project is a simulation of a shower system. The goal is to find the best policy for the boiler to heat the water for the shower. The policy is a function that takes the current hour of the day and the current temperature of the water in the boiler and returns the temperature that the boiler should heat the water to.'),\n",
" html.P('The best policy is the one that maximizes the comfort of the shower and minimizes the energy consumption of the boiler.'),\n",
"\n",
" html.H3('How does it work?'),\n",
"\n",
" #Insert image of the system\n",
"\n",
" html.H3('\\'Bout us'),\n",
" html.Img(src='/assets/hackatos.png', style={'width': '40%', 'height': 'auto', 'display': 'block', 'margin-left': 'auto', 'margin-right': 'auto'}),\n",
" html.P('This project was developed by a team of 3, in the context of the Aveiro Tech City 2023 hackathon.'),\n",
" html.P('The team members are:'),\n",
" html.H4('Rui Melo'),\n",
" html.H4('André Catarino'),\n",
" html.H4('Francisco Petronilho'),\n",
" html.H4('André Tomás'),\n",
" html.H4('Zé Miguel'),\n",
"\n",
"\n",
" html.H3('References'),\n",
" html.P('The boiler model was based on the following paper:'),\n",
"\n",
"\n",
" ], className='six columns'),], className='row'),\n",
"],\n",
"style={'background-color': '#333', 'font-family': 'Fantasy', 'color': '#999', 'padding': '10px'}\n",
"\n",
")\n",
"\n",
"# Update the index\n",
"@callback(Output('page-content', 'children'), Input('url', 'pathname'))\n",
"def display_page(pathname):\n",
" if pathname == '/':\n",
" return dashboard_layout\n",
" elif pathname == '/wiki':\n",
" return wiki_layout\n",
" else:\n",
" return '404'\n",
" # You could also return a 404 \"URL not found\" page here\n",
"\n",
"\n",
"@app.callback(\n",
" Output('policy_readable-graph', 'figure'),\n",
" Output('energy-consumption-graph', 'figure'),\n",
" Output('comfort-graph', 'figure'),\n",
" Output('dataset-graph', 'figure'),\n",
" Output('water-consumption-graph', 'figure'),\n",
" Output('water_consumption_hourly_graph', 'figure'),\n",
" Output('water_consumption_week_day_graph', 'figure'),\n",
" Output('water_consumption_monthly_graph', 'figure'),\n",
" Output('solution-status', 'children'),\n",
" Input('dataset-dropdown', 'value'),\n",
" Input('solution-dropdown', 'value'),\n",
" Input('ideal-temperature-slider', 'value')\n",
")\n",
"def update_graph(dataset, solution, ideal_temperature):\n",
" energy_consumption = data['energy_consumption'].values\n",
" comfort_obtained = data['comfort'].values\n",
" \n",
" # Original Dataset Graph\n",
" original_df = dataset_original_dfs[dataset]\n",
"\n",
" dataset_graph = px.line()\n",
" dataset_graph.add_scatter(x=original_df['ts'], y=original_df['ActPow'], mode='lines', name='ActPow')\n",
" dataset_graph.add_scatter(x=original_df['ts'], y=original_df['HwActive'], mode='lines', name='HwActive')\n",
" dataset_graph.add_scatter(x=original_df['ts'], y=original_df['ChActive'], mode='lines', name='ChActive')\n",
" dataset_graph.add_scatter(x=original_df['ts'], y=original_df['HwTSet'], mode='lines', name='HwTSet')\n",
" dataset_graph.add_scatter(x=original_df['ts'], y=original_df['DHW_E21_T3_START_TEMP'], mode='lines', name='START_TEMP')\n",
" dataset_graph.add_scatter(x=original_df['ts'], y=original_df['HwTStor'], mode='lines', name='HwTStor')\n",
" dataset_graph.add_scatter(x=original_df['ts'], y=original_df['HwTAct'], mode='lines', name='HwTAct')\n",
" dataset_graph.add_scatter(x=original_df['ts'], y=original_df['OutTemp'], mode='lines', name='OutTemp')\n",
" start_time = pd.Timestamp(original_df['ts'][0])\n",
" dataset_graph.update_xaxes(range=[start_time, start_time+pd.Timedelta(days=2)])\n",
"\n",
"\n",
" # Water Consumption Graph\n",
" water_consumption_df = dataset_water_consumption_dfs[dataset]\n",
" if len(water_consumption_df) / 24 > 365:\n",
" water_consumption_df = water_consumption_df.head(365* 24)\n",
" water_consumption_df.index = pd.to_datetime(water_consumption_df[\"ts\"], errors='coerce')\n",
" water_consumption_graph = go.Figure()\n",
" water_consumption_graph = make_subplots(specs=[[{\"secondary_y\": True}]])\n",
" water_consumption_graph.add_trace(go.Scatter(x=water_consumption_df[:][\"ts\"], y=water_consumption_df[:]['water_consumption_bool'], mode='lines', name='Water consumption'),\n",
" secondary_y=False,)\n",
" water_consumption_graph.add_trace(go.Scatter(x=water_consumption_df[:][\"ts\"], y=water_consumption_df[:]['HwTStor'], mode='lines', name='Water temperature')\n",
" ,secondary_y=True,)\n",
" water_consumption_graph.update_layout(\n",
" title_text=\"Water consumption\"\n",
" )\n",
" water_consumption_graph.update_xaxes(title_text=\"time\")\n",
" water_consumption_graph.update_yaxes(title_text=\"water consumption\", secondary_y=False)\n",
" water_consumption_graph.update_yaxes(title_text=\"water temperature\", secondary_y=True)\n",
"\n",
" # Water Consumption Hourly Graph\n",
" water_consumption_df[\"ts_hour\"] = water_consumption_df[\"ts\"].apply(lambda x: x.split(\" \")[1].split(\":\")[0])\n",
" hour_series = water_consumption_df.groupby(\"ts_hour\")[\"water_consumption_bool\"].sum()\n",
" water_consumption_hourly_graph = go.Figure()\n",
" water_consumption_hourly_graph.add_trace(go.Bar(x=hour_series.index, y=hour_series.values, name='Water consumption per hour'))\n",
" water_consumption_hourly_graph.update_layout(\n",
" title_text=\"Water consumption per hour\"\n",
" )\n",
" water_consumption_hourly_graph.update_xaxes(title_text=\"Hour of day\")\n",
" water_consumption_hourly_graph.update_yaxes(title_text=\"Number of water usages\")\n",
"\n",
" # Water Consumption Week Day Graph\n",
" order = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']\n",
" water_consumption_df[\"datetime\"] = pd.to_datetime(water_consumption_df[\"ts\"], errors='coerce')\n",
" #create columns with day of week\n",
" water_consumption_df['day_of_week'] = water_consumption_df[\"datetime\"].apply(lambda x: x.day_name())\n",
" #turn day of week number into day of week name\n",
" #df['day_of_week'] = df['day_of_week'].apply(lambda x: calendar.day_name[x])\n",
" week_series = water_consumption_df.groupby(\"day_of_week\")[\"water_consumption_bool\"].sum().loc[order]\n",
"\n",
" # Water Consumption Week Day Graph\n",
" water_consumption_week_day_graph = go.Figure()\n",
" water_consumption_week_day_graph.add_trace(go.Bar(x=week_series.index, y=week_series.values, name='Water consumption per day of week'))\n",
" water_consumption_week_day_graph.update_layout(\n",
" title_text=\"Water consumption per day of week\"\n",
" )\n",
" water_consumption_week_day_graph.update_xaxes(title_text=\"Day of week\")\n",
" water_consumption_week_day_graph.update_yaxes(title_text=\"Number of water usages\")\n",
"\n",
" #dataset_water_consumption_monthly_dfs\n",
" #Water Consumption Monthly Graph\n",
" water_consumption_monthly_df = dataset_water_consumption_monthly_dfs[dataset]\n",
" water_consumption_monthly_graph = go.Figure()\n",
" water_consumption_monthly_graph.add_trace(go.Bar(x=water_consumption_monthly_df[\"month\"], y=water_consumption_monthly_df[\"water_consumption_bool\"], name='Water consumption per month'))\n",
" water_consumption_monthly_graph.update_layout(\n",
" title_text=\"Water consumption per month\"\n",
" )\n",
" water_consumption_monthly_graph.update_xaxes(title_text=\"Month\")\n",
" water_consumption_monthly_graph.update_yaxes(title_text=\"Number of water usages\")\n",
"\n",
"\n",
"\n",
"\n",
" # Policy Graph\n",
" policy_readable_graph = px.line(data, x='hour', y='policy_readable',\n",
" labels={'hour': 'Hour', 'policy_readable': 'Policy'},\n",
" color_discrete_sequence=['lightgreen'])\n",
" policy_readable_graph.update_layout(\n",
" xaxis_title=\"Hour\",\n",
" yaxis_title=\"Temperature (°C)\",\n",
" legend_title=\"Policy\"\n",
" )\n",
"\n",
"\n",
" # Energy Consumption Graph\n",
" energy_consumption_graph = px.line(data, x='hour',\n",
" y='energy_consumption',\n",
" labels={'hour': 'Hour', 'energy_consumption': 'Energy Consumption (kWh)'},\n",
" color_discrete_sequence=['lightgreen'])\n",
" energy_consumption_graph.update_layout(\n",
" xaxis_title=\"Hour\",\n",
" yaxis_title=\"Energy Consumption (kWh)\",\n",
" legend_title=\"Energy Consumption\",\n",
" )\n",
" #add accumulated energy consumption\n",
" energy_consumption = np.cumsum(energy_consumption)\n",
" energy_consumption_graph.add_trace(px.line(data, x='hour',\n",
" y=energy_consumption,\n",
" labels={'y': 'Acc. Energy Consumption (kWh)'},\n",
" color_discrete_sequence=['green']).data[0])\n",
"\n",
"\n",
" # Comfort Graph\n",
" comfort_graph = px.line(data, x='hour', y='comfort',\n",
" labels={'hour': 'Hour', 'comfort': 'comfort Score'},\n",
" color_discrete_sequence=['lightgreen'])\n",
"\n",
" comfort_graph.update_layout(\n",
" xaxis_title=\"Hour\",\n",
" yaxis_title=\"comfort Score\",\n",
" legend_title=\"comfort\"\n",
" )\n",
" #add accumulated comfort\n",
" comfort_obtained = np.cumsum(comfort_obtained)\n",
" comfort_graph.add_trace(px.line(data, x='hour', y=comfort_obtained,\n",
" labels={'y': 'Acc. comfort Score'},\n",
" color_discrete_sequence=['green']\n",
" ).data[0])\n",
" result = \"No solution found\"\n",
" return policy_readable_graph, energy_consumption_graph, comfort_graph, dataset_graph, water_consumption_graph, water_consumption_hourly_graph, water_consumption_week_day_graph,water_consumption_monthly_graph, result\n",
"\n",
"\n",
"if __name__ == \"__main__\":\n",
" app.run_server(host=\"0.0.0.0\", port=\"8050\", debug=debug)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "atc-smart-shower-YhjpRjjr-py3.10",
"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.11.2"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}
|