jerin commited on
Commit
830ab0c
1 Parent(s): e93e440

add mqtt and streamlit dashboard

Browse files
Files changed (3) hide show
  1. mqttclient.ipynb +1093 -0
  2. mqttpublisher.ipynb +89 -0
  3. streamlit.py +65 -0
mqttclient.ipynb ADDED
@@ -0,0 +1,1093 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 2,
6
+ "metadata": {},
7
+ "outputs": [
8
+ {
9
+ "name": "stderr",
10
+ "output_type": "stream",
11
+ "text": [
12
+ "C:\\Users\\jerin\\AppData\\Local\\Temp\\ipykernel_6272\\1211754903.py:21: DeprecationWarning: Callback API version 1 is deprecated, update to latest version\n",
13
+ " client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION1)\n"
14
+ ]
15
+ },
16
+ {
17
+ "name": "stdout",
18
+ "output_type": "stream",
19
+ "text": [
20
+ "{'sa_temp': 68.6, 'ma_temp': 70.0}\n"
21
+ ]
22
+ },
23
+ {
24
+ "ename": "KeyboardInterrupt",
25
+ "evalue": "",
26
+ "output_type": "error",
27
+ "traceback": [
28
+ "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
29
+ "\u001b[1;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)",
30
+ "Cell \u001b[1;32mIn[2], line 25\u001b[0m\n\u001b[0;32m 23\u001b[0m client\u001b[38;5;241m.\u001b[39mconnect(broker_address, broker_port)\n\u001b[0;32m 24\u001b[0m client\u001b[38;5;241m.\u001b[39msubscribe(topic)\n\u001b[1;32m---> 25\u001b[0m \u001b[43mclient\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mloop_forever\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n",
31
+ "File \u001b[1;32mc:\\Users\\jerin\\anaconda3\\envs\\smartbuilding\\Lib\\site-packages\\paho\\mqtt\\client.py:2291\u001b[0m, in \u001b[0;36mClient.loop_forever\u001b[1;34m(self, timeout, retry_first_connection)\u001b[0m\n\u001b[0;32m 2289\u001b[0m rc \u001b[38;5;241m=\u001b[39m MQTTErrorCode\u001b[38;5;241m.\u001b[39mMQTT_ERR_SUCCESS\n\u001b[0;32m 2290\u001b[0m \u001b[38;5;28;01mwhile\u001b[39;00m rc \u001b[38;5;241m==\u001b[39m MQTTErrorCode\u001b[38;5;241m.\u001b[39mMQTT_ERR_SUCCESS:\n\u001b[1;32m-> 2291\u001b[0m rc \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_loop\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtimeout\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 2292\u001b[0m \u001b[38;5;66;03m# We don't need to worry about locking here, because we've\u001b[39;00m\n\u001b[0;32m 2293\u001b[0m \u001b[38;5;66;03m# either called loop_forever() when in single threaded mode, or\u001b[39;00m\n\u001b[0;32m 2294\u001b[0m \u001b[38;5;66;03m# in multi threaded mode when loop_stop() has been called and\u001b[39;00m\n\u001b[0;32m 2295\u001b[0m \u001b[38;5;66;03m# so no other threads can access _out_packet or _messages.\u001b[39;00m\n\u001b[0;32m 2296\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m (\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_thread_terminate \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mTrue\u001b[39;00m\n\u001b[0;32m 2297\u001b[0m \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;28mlen\u001b[39m(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_out_packet) \u001b[38;5;241m==\u001b[39m \u001b[38;5;241m0\u001b[39m\n\u001b[0;32m 2298\u001b[0m \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;28mlen\u001b[39m(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_out_messages) \u001b[38;5;241m==\u001b[39m \u001b[38;5;241m0\u001b[39m):\n",
32
+ "File \u001b[1;32mc:\\Users\\jerin\\anaconda3\\envs\\smartbuilding\\Lib\\site-packages\\paho\\mqtt\\client.py:1657\u001b[0m, in \u001b[0;36mClient._loop\u001b[1;34m(self, timeout)\u001b[0m\n\u001b[0;32m 1654\u001b[0m rlist \u001b[38;5;241m=\u001b[39m [\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_sock, \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_sockpairR]\n\u001b[0;32m 1656\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m-> 1657\u001b[0m socklist \u001b[38;5;241m=\u001b[39m select\u001b[38;5;241m.\u001b[39mselect(rlist, wlist, [], timeout)\n\u001b[0;32m 1658\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mTypeError\u001b[39;00m:\n\u001b[0;32m 1659\u001b[0m \u001b[38;5;66;03m# Socket isn't correct type, in likelihood connection is lost\u001b[39;00m\n\u001b[0;32m 1660\u001b[0m \u001b[38;5;66;03m# ... or we called disconnect(). In that case the socket will\u001b[39;00m\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 1663\u001b[0m \u001b[38;5;66;03m# rc != MQTT_ERR_SUCCESS and we don't want state to change from\u001b[39;00m\n\u001b[0;32m 1664\u001b[0m \u001b[38;5;66;03m# mqtt_cs_disconnecting.\u001b[39;00m\n\u001b[0;32m 1665\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_state \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;129;01min\u001b[39;00m (_ConnectionState\u001b[38;5;241m.\u001b[39mMQTT_CS_DISCONNECTING, _ConnectionState\u001b[38;5;241m.\u001b[39mMQTT_CS_DISCONNECTED):\n",
33
+ "\u001b[1;31mKeyboardInterrupt\u001b[0m: "
34
+ ]
35
+ }
36
+ ],
37
+ "source": [
38
+ "import paho.mqtt.client as mqtt\n",
39
+ "import json\n",
40
+ "import pandas as pd\n",
41
+ "\n",
42
+ "broker_address = \"localhost\"\n",
43
+ "broker_port = 1883\n",
44
+ "topic = \"sensor_data\"\n",
45
+ "\n",
46
+ "df = pd.DataFrame(columns=[\"sa_temp\", \"ma_temp\"])\n",
47
+ "\n",
48
+ "def on_message(client, userdata, message):\n",
49
+ " global df\n",
50
+ " payload = json.loads(message.payload.decode())\n",
51
+ " sa_temp = payload[\"sa_temp\"]\n",
52
+ " ma_temp = payload[\"ma_temp\"]\n",
53
+ " print(payload)\n",
54
+ " # df.loc[len(df)] = {\"sa_temp\": sa_temp, \"ma_temp\": ma_temp}\n",
55
+ " \n",
56
+ "\n",
57
+ "\n",
58
+ "client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION1)\n",
59
+ "client.on_message = on_message\n",
60
+ "client.connect(broker_address, broker_port)\n",
61
+ "client.subscribe(topic)\n",
62
+ "client.loop_forever()\n",
63
+ "\n",
64
+ "\n"
65
+ ]
66
+ },
67
+ {
68
+ "cell_type": "code",
69
+ "execution_count": 25,
70
+ "metadata": {},
71
+ "outputs": [
72
+ {
73
+ "data": {
74
+ "text/html": [
75
+ "<div>\n",
76
+ "<style scoped>\n",
77
+ " .dataframe tbody tr th:only-of-type {\n",
78
+ " vertical-align: middle;\n",
79
+ " }\n",
80
+ "\n",
81
+ " .dataframe tbody tr th {\n",
82
+ " vertical-align: top;\n",
83
+ " }\n",
84
+ "\n",
85
+ " .dataframe thead th {\n",
86
+ " text-align: right;\n",
87
+ " }\n",
88
+ "</style>\n",
89
+ "<table border=\"1\" class=\"dataframe\">\n",
90
+ " <thead>\n",
91
+ " <tr style=\"text-align: right;\">\n",
92
+ " <th></th>\n",
93
+ " <th>sa_temp</th>\n",
94
+ " <th>ma_temp</th>\n",
95
+ " </tr>\n",
96
+ " </thead>\n",
97
+ " <tbody>\n",
98
+ " <tr>\n",
99
+ " <th>0</th>\n",
100
+ " <td>68.6</td>\n",
101
+ " <td>70.0</td>\n",
102
+ " </tr>\n",
103
+ " <tr>\n",
104
+ " <th>1</th>\n",
105
+ " <td>68.6</td>\n",
106
+ " <td>70.0</td>\n",
107
+ " </tr>\n",
108
+ " <tr>\n",
109
+ " <th>2</th>\n",
110
+ " <td>68.6</td>\n",
111
+ " <td>70.0</td>\n",
112
+ " </tr>\n",
113
+ " <tr>\n",
114
+ " <th>3</th>\n",
115
+ " <td>68.6</td>\n",
116
+ " <td>70.0</td>\n",
117
+ " </tr>\n",
118
+ " </tbody>\n",
119
+ "</table>\n",
120
+ "</div>"
121
+ ],
122
+ "text/plain": [
123
+ " sa_temp ma_temp\n",
124
+ "0 68.6 70.0\n",
125
+ "1 68.6 70.0\n",
126
+ "2 68.6 70.0\n",
127
+ "3 68.6 70.0"
128
+ ]
129
+ },
130
+ "execution_count": 25,
131
+ "metadata": {},
132
+ "output_type": "execute_result"
133
+ }
134
+ ],
135
+ "source": [
136
+ "df"
137
+ ]
138
+ },
139
+ {
140
+ "cell_type": "code",
141
+ "execution_count": 4,
142
+ "metadata": {},
143
+ "outputs": [
144
+ {
145
+ "ename": "ValueError",
146
+ "evalue": "Mime type rendering requires nbformat>=4.2.0 but it is not installed",
147
+ "output_type": "error",
148
+ "traceback": [
149
+ "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
150
+ "\u001b[1;31mValueError\u001b[0m Traceback (most recent call last)",
151
+ "File \u001b[1;32mc:\\Users\\jerin\\anaconda3\\envs\\smartbuilding\\Lib\\site-packages\\IPython\\core\\formatters.py:925\u001b[0m, in \u001b[0;36mIPythonDisplayFormatter.__call__\u001b[1;34m(self, obj)\u001b[0m\n\u001b[0;32m 923\u001b[0m method \u001b[38;5;241m=\u001b[39m get_real_method(obj, \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mprint_method)\n\u001b[0;32m 924\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m method \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m--> 925\u001b[0m \u001b[43mmethod\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 926\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;01mTrue\u001b[39;00m\n",
152
+ "File \u001b[1;32mc:\\Users\\jerin\\anaconda3\\envs\\smartbuilding\\Lib\\site-packages\\plotly\\basedatatypes.py:832\u001b[0m, in \u001b[0;36mBaseFigure._ipython_display_\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 829\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mplotly\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mio\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m \u001b[38;5;21;01mpio\u001b[39;00m\n\u001b[0;32m 831\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m pio\u001b[38;5;241m.\u001b[39mrenderers\u001b[38;5;241m.\u001b[39mrender_on_display \u001b[38;5;129;01mand\u001b[39;00m pio\u001b[38;5;241m.\u001b[39mrenderers\u001b[38;5;241m.\u001b[39mdefault:\n\u001b[1;32m--> 832\u001b[0m \u001b[43mpio\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mshow\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[0;32m 833\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m 834\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;28mrepr\u001b[39m(\u001b[38;5;28mself\u001b[39m))\n",
153
+ "File \u001b[1;32mc:\\Users\\jerin\\anaconda3\\envs\\smartbuilding\\Lib\\site-packages\\plotly\\io\\_renderers.py:394\u001b[0m, in \u001b[0;36mshow\u001b[1;34m(fig, renderer, validate, **kwargs)\u001b[0m\n\u001b[0;32m 389\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\n\u001b[0;32m 390\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mMime type rendering requires ipython but it is not installed\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 391\u001b[0m )\n\u001b[0;32m 393\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m nbformat \u001b[38;5;129;01mor\u001b[39;00m Version(nbformat\u001b[38;5;241m.\u001b[39m__version__) \u001b[38;5;241m<\u001b[39m Version(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m4.2.0\u001b[39m\u001b[38;5;124m\"\u001b[39m):\n\u001b[1;32m--> 394\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\n\u001b[0;32m 395\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mMime type rendering requires nbformat>=4.2.0 but it is not installed\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 396\u001b[0m )\n\u001b[0;32m 398\u001b[0m ipython_display\u001b[38;5;241m.\u001b[39mdisplay(bundle, raw\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m)\n\u001b[0;32m 400\u001b[0m \u001b[38;5;66;03m# external renderers\u001b[39;00m\n",
154
+ "\u001b[1;31mValueError\u001b[0m: Mime type rendering requires nbformat>=4.2.0 but it is not installed"
155
+ ]
156
+ },
157
+ {
158
+ "data": {
159
+ "application/vnd.plotly.v1+json": {
160
+ "config": {
161
+ "plotlyServerURL": "https://plot.ly"
162
+ },
163
+ "data": [
164
+ {
165
+ "hovertemplate": "index=%{x}<br>sa_temp=%{y}<extra></extra>",
166
+ "legendgroup": "",
167
+ "line": {
168
+ "color": "#636efa",
169
+ "dash": "solid"
170
+ },
171
+ "marker": {
172
+ "symbol": "circle"
173
+ },
174
+ "mode": "lines",
175
+ "name": "",
176
+ "orientation": "v",
177
+ "showlegend": false,
178
+ "type": "scatter",
179
+ "x": [],
180
+ "xaxis": "x",
181
+ "y": [],
182
+ "yaxis": "y"
183
+ }
184
+ ],
185
+ "layout": {
186
+ "legend": {
187
+ "tracegroupgap": 0
188
+ },
189
+ "margin": {
190
+ "t": 60
191
+ },
192
+ "template": {
193
+ "data": {
194
+ "bar": [
195
+ {
196
+ "error_x": {
197
+ "color": "#2a3f5f"
198
+ },
199
+ "error_y": {
200
+ "color": "#2a3f5f"
201
+ },
202
+ "marker": {
203
+ "line": {
204
+ "color": "#E5ECF6",
205
+ "width": 0.5
206
+ },
207
+ "pattern": {
208
+ "fillmode": "overlay",
209
+ "size": 10,
210
+ "solidity": 0.2
211
+ }
212
+ },
213
+ "type": "bar"
214
+ }
215
+ ],
216
+ "barpolar": [
217
+ {
218
+ "marker": {
219
+ "line": {
220
+ "color": "#E5ECF6",
221
+ "width": 0.5
222
+ },
223
+ "pattern": {
224
+ "fillmode": "overlay",
225
+ "size": 10,
226
+ "solidity": 0.2
227
+ }
228
+ },
229
+ "type": "barpolar"
230
+ }
231
+ ],
232
+ "carpet": [
233
+ {
234
+ "aaxis": {
235
+ "endlinecolor": "#2a3f5f",
236
+ "gridcolor": "white",
237
+ "linecolor": "white",
238
+ "minorgridcolor": "white",
239
+ "startlinecolor": "#2a3f5f"
240
+ },
241
+ "baxis": {
242
+ "endlinecolor": "#2a3f5f",
243
+ "gridcolor": "white",
244
+ "linecolor": "white",
245
+ "minorgridcolor": "white",
246
+ "startlinecolor": "#2a3f5f"
247
+ },
248
+ "type": "carpet"
249
+ }
250
+ ],
251
+ "choropleth": [
252
+ {
253
+ "colorbar": {
254
+ "outlinewidth": 0,
255
+ "ticks": ""
256
+ },
257
+ "type": "choropleth"
258
+ }
259
+ ],
260
+ "contour": [
261
+ {
262
+ "colorbar": {
263
+ "outlinewidth": 0,
264
+ "ticks": ""
265
+ },
266
+ "colorscale": [
267
+ [
268
+ 0,
269
+ "#0d0887"
270
+ ],
271
+ [
272
+ 0.1111111111111111,
273
+ "#46039f"
274
+ ],
275
+ [
276
+ 0.2222222222222222,
277
+ "#7201a8"
278
+ ],
279
+ [
280
+ 0.3333333333333333,
281
+ "#9c179e"
282
+ ],
283
+ [
284
+ 0.4444444444444444,
285
+ "#bd3786"
286
+ ],
287
+ [
288
+ 0.5555555555555556,
289
+ "#d8576b"
290
+ ],
291
+ [
292
+ 0.6666666666666666,
293
+ "#ed7953"
294
+ ],
295
+ [
296
+ 0.7777777777777778,
297
+ "#fb9f3a"
298
+ ],
299
+ [
300
+ 0.8888888888888888,
301
+ "#fdca26"
302
+ ],
303
+ [
304
+ 1,
305
+ "#f0f921"
306
+ ]
307
+ ],
308
+ "type": "contour"
309
+ }
310
+ ],
311
+ "contourcarpet": [
312
+ {
313
+ "colorbar": {
314
+ "outlinewidth": 0,
315
+ "ticks": ""
316
+ },
317
+ "type": "contourcarpet"
318
+ }
319
+ ],
320
+ "heatmap": [
321
+ {
322
+ "colorbar": {
323
+ "outlinewidth": 0,
324
+ "ticks": ""
325
+ },
326
+ "colorscale": [
327
+ [
328
+ 0,
329
+ "#0d0887"
330
+ ],
331
+ [
332
+ 0.1111111111111111,
333
+ "#46039f"
334
+ ],
335
+ [
336
+ 0.2222222222222222,
337
+ "#7201a8"
338
+ ],
339
+ [
340
+ 0.3333333333333333,
341
+ "#9c179e"
342
+ ],
343
+ [
344
+ 0.4444444444444444,
345
+ "#bd3786"
346
+ ],
347
+ [
348
+ 0.5555555555555556,
349
+ "#d8576b"
350
+ ],
351
+ [
352
+ 0.6666666666666666,
353
+ "#ed7953"
354
+ ],
355
+ [
356
+ 0.7777777777777778,
357
+ "#fb9f3a"
358
+ ],
359
+ [
360
+ 0.8888888888888888,
361
+ "#fdca26"
362
+ ],
363
+ [
364
+ 1,
365
+ "#f0f921"
366
+ ]
367
+ ],
368
+ "type": "heatmap"
369
+ }
370
+ ],
371
+ "heatmapgl": [
372
+ {
373
+ "colorbar": {
374
+ "outlinewidth": 0,
375
+ "ticks": ""
376
+ },
377
+ "colorscale": [
378
+ [
379
+ 0,
380
+ "#0d0887"
381
+ ],
382
+ [
383
+ 0.1111111111111111,
384
+ "#46039f"
385
+ ],
386
+ [
387
+ 0.2222222222222222,
388
+ "#7201a8"
389
+ ],
390
+ [
391
+ 0.3333333333333333,
392
+ "#9c179e"
393
+ ],
394
+ [
395
+ 0.4444444444444444,
396
+ "#bd3786"
397
+ ],
398
+ [
399
+ 0.5555555555555556,
400
+ "#d8576b"
401
+ ],
402
+ [
403
+ 0.6666666666666666,
404
+ "#ed7953"
405
+ ],
406
+ [
407
+ 0.7777777777777778,
408
+ "#fb9f3a"
409
+ ],
410
+ [
411
+ 0.8888888888888888,
412
+ "#fdca26"
413
+ ],
414
+ [
415
+ 1,
416
+ "#f0f921"
417
+ ]
418
+ ],
419
+ "type": "heatmapgl"
420
+ }
421
+ ],
422
+ "histogram": [
423
+ {
424
+ "marker": {
425
+ "pattern": {
426
+ "fillmode": "overlay",
427
+ "size": 10,
428
+ "solidity": 0.2
429
+ }
430
+ },
431
+ "type": "histogram"
432
+ }
433
+ ],
434
+ "histogram2d": [
435
+ {
436
+ "colorbar": {
437
+ "outlinewidth": 0,
438
+ "ticks": ""
439
+ },
440
+ "colorscale": [
441
+ [
442
+ 0,
443
+ "#0d0887"
444
+ ],
445
+ [
446
+ 0.1111111111111111,
447
+ "#46039f"
448
+ ],
449
+ [
450
+ 0.2222222222222222,
451
+ "#7201a8"
452
+ ],
453
+ [
454
+ 0.3333333333333333,
455
+ "#9c179e"
456
+ ],
457
+ [
458
+ 0.4444444444444444,
459
+ "#bd3786"
460
+ ],
461
+ [
462
+ 0.5555555555555556,
463
+ "#d8576b"
464
+ ],
465
+ [
466
+ 0.6666666666666666,
467
+ "#ed7953"
468
+ ],
469
+ [
470
+ 0.7777777777777778,
471
+ "#fb9f3a"
472
+ ],
473
+ [
474
+ 0.8888888888888888,
475
+ "#fdca26"
476
+ ],
477
+ [
478
+ 1,
479
+ "#f0f921"
480
+ ]
481
+ ],
482
+ "type": "histogram2d"
483
+ }
484
+ ],
485
+ "histogram2dcontour": [
486
+ {
487
+ "colorbar": {
488
+ "outlinewidth": 0,
489
+ "ticks": ""
490
+ },
491
+ "colorscale": [
492
+ [
493
+ 0,
494
+ "#0d0887"
495
+ ],
496
+ [
497
+ 0.1111111111111111,
498
+ "#46039f"
499
+ ],
500
+ [
501
+ 0.2222222222222222,
502
+ "#7201a8"
503
+ ],
504
+ [
505
+ 0.3333333333333333,
506
+ "#9c179e"
507
+ ],
508
+ [
509
+ 0.4444444444444444,
510
+ "#bd3786"
511
+ ],
512
+ [
513
+ 0.5555555555555556,
514
+ "#d8576b"
515
+ ],
516
+ [
517
+ 0.6666666666666666,
518
+ "#ed7953"
519
+ ],
520
+ [
521
+ 0.7777777777777778,
522
+ "#fb9f3a"
523
+ ],
524
+ [
525
+ 0.8888888888888888,
526
+ "#fdca26"
527
+ ],
528
+ [
529
+ 1,
530
+ "#f0f921"
531
+ ]
532
+ ],
533
+ "type": "histogram2dcontour"
534
+ }
535
+ ],
536
+ "mesh3d": [
537
+ {
538
+ "colorbar": {
539
+ "outlinewidth": 0,
540
+ "ticks": ""
541
+ },
542
+ "type": "mesh3d"
543
+ }
544
+ ],
545
+ "parcoords": [
546
+ {
547
+ "line": {
548
+ "colorbar": {
549
+ "outlinewidth": 0,
550
+ "ticks": ""
551
+ }
552
+ },
553
+ "type": "parcoords"
554
+ }
555
+ ],
556
+ "pie": [
557
+ {
558
+ "automargin": true,
559
+ "type": "pie"
560
+ }
561
+ ],
562
+ "scatter": [
563
+ {
564
+ "fillpattern": {
565
+ "fillmode": "overlay",
566
+ "size": 10,
567
+ "solidity": 0.2
568
+ },
569
+ "type": "scatter"
570
+ }
571
+ ],
572
+ "scatter3d": [
573
+ {
574
+ "line": {
575
+ "colorbar": {
576
+ "outlinewidth": 0,
577
+ "ticks": ""
578
+ }
579
+ },
580
+ "marker": {
581
+ "colorbar": {
582
+ "outlinewidth": 0,
583
+ "ticks": ""
584
+ }
585
+ },
586
+ "type": "scatter3d"
587
+ }
588
+ ],
589
+ "scattercarpet": [
590
+ {
591
+ "marker": {
592
+ "colorbar": {
593
+ "outlinewidth": 0,
594
+ "ticks": ""
595
+ }
596
+ },
597
+ "type": "scattercarpet"
598
+ }
599
+ ],
600
+ "scattergeo": [
601
+ {
602
+ "marker": {
603
+ "colorbar": {
604
+ "outlinewidth": 0,
605
+ "ticks": ""
606
+ }
607
+ },
608
+ "type": "scattergeo"
609
+ }
610
+ ],
611
+ "scattergl": [
612
+ {
613
+ "marker": {
614
+ "colorbar": {
615
+ "outlinewidth": 0,
616
+ "ticks": ""
617
+ }
618
+ },
619
+ "type": "scattergl"
620
+ }
621
+ ],
622
+ "scattermapbox": [
623
+ {
624
+ "marker": {
625
+ "colorbar": {
626
+ "outlinewidth": 0,
627
+ "ticks": ""
628
+ }
629
+ },
630
+ "type": "scattermapbox"
631
+ }
632
+ ],
633
+ "scatterpolar": [
634
+ {
635
+ "marker": {
636
+ "colorbar": {
637
+ "outlinewidth": 0,
638
+ "ticks": ""
639
+ }
640
+ },
641
+ "type": "scatterpolar"
642
+ }
643
+ ],
644
+ "scatterpolargl": [
645
+ {
646
+ "marker": {
647
+ "colorbar": {
648
+ "outlinewidth": 0,
649
+ "ticks": ""
650
+ }
651
+ },
652
+ "type": "scatterpolargl"
653
+ }
654
+ ],
655
+ "scatterternary": [
656
+ {
657
+ "marker": {
658
+ "colorbar": {
659
+ "outlinewidth": 0,
660
+ "ticks": ""
661
+ }
662
+ },
663
+ "type": "scatterternary"
664
+ }
665
+ ],
666
+ "surface": [
667
+ {
668
+ "colorbar": {
669
+ "outlinewidth": 0,
670
+ "ticks": ""
671
+ },
672
+ "colorscale": [
673
+ [
674
+ 0,
675
+ "#0d0887"
676
+ ],
677
+ [
678
+ 0.1111111111111111,
679
+ "#46039f"
680
+ ],
681
+ [
682
+ 0.2222222222222222,
683
+ "#7201a8"
684
+ ],
685
+ [
686
+ 0.3333333333333333,
687
+ "#9c179e"
688
+ ],
689
+ [
690
+ 0.4444444444444444,
691
+ "#bd3786"
692
+ ],
693
+ [
694
+ 0.5555555555555556,
695
+ "#d8576b"
696
+ ],
697
+ [
698
+ 0.6666666666666666,
699
+ "#ed7953"
700
+ ],
701
+ [
702
+ 0.7777777777777778,
703
+ "#fb9f3a"
704
+ ],
705
+ [
706
+ 0.8888888888888888,
707
+ "#fdca26"
708
+ ],
709
+ [
710
+ 1,
711
+ "#f0f921"
712
+ ]
713
+ ],
714
+ "type": "surface"
715
+ }
716
+ ],
717
+ "table": [
718
+ {
719
+ "cells": {
720
+ "fill": {
721
+ "color": "#EBF0F8"
722
+ },
723
+ "line": {
724
+ "color": "white"
725
+ }
726
+ },
727
+ "header": {
728
+ "fill": {
729
+ "color": "#C8D4E3"
730
+ },
731
+ "line": {
732
+ "color": "white"
733
+ }
734
+ },
735
+ "type": "table"
736
+ }
737
+ ]
738
+ },
739
+ "layout": {
740
+ "annotationdefaults": {
741
+ "arrowcolor": "#2a3f5f",
742
+ "arrowhead": 0,
743
+ "arrowwidth": 1
744
+ },
745
+ "autotypenumbers": "strict",
746
+ "coloraxis": {
747
+ "colorbar": {
748
+ "outlinewidth": 0,
749
+ "ticks": ""
750
+ }
751
+ },
752
+ "colorscale": {
753
+ "diverging": [
754
+ [
755
+ 0,
756
+ "#8e0152"
757
+ ],
758
+ [
759
+ 0.1,
760
+ "#c51b7d"
761
+ ],
762
+ [
763
+ 0.2,
764
+ "#de77ae"
765
+ ],
766
+ [
767
+ 0.3,
768
+ "#f1b6da"
769
+ ],
770
+ [
771
+ 0.4,
772
+ "#fde0ef"
773
+ ],
774
+ [
775
+ 0.5,
776
+ "#f7f7f7"
777
+ ],
778
+ [
779
+ 0.6,
780
+ "#e6f5d0"
781
+ ],
782
+ [
783
+ 0.7,
784
+ "#b8e186"
785
+ ],
786
+ [
787
+ 0.8,
788
+ "#7fbc41"
789
+ ],
790
+ [
791
+ 0.9,
792
+ "#4d9221"
793
+ ],
794
+ [
795
+ 1,
796
+ "#276419"
797
+ ]
798
+ ],
799
+ "sequential": [
800
+ [
801
+ 0,
802
+ "#0d0887"
803
+ ],
804
+ [
805
+ 0.1111111111111111,
806
+ "#46039f"
807
+ ],
808
+ [
809
+ 0.2222222222222222,
810
+ "#7201a8"
811
+ ],
812
+ [
813
+ 0.3333333333333333,
814
+ "#9c179e"
815
+ ],
816
+ [
817
+ 0.4444444444444444,
818
+ "#bd3786"
819
+ ],
820
+ [
821
+ 0.5555555555555556,
822
+ "#d8576b"
823
+ ],
824
+ [
825
+ 0.6666666666666666,
826
+ "#ed7953"
827
+ ],
828
+ [
829
+ 0.7777777777777778,
830
+ "#fb9f3a"
831
+ ],
832
+ [
833
+ 0.8888888888888888,
834
+ "#fdca26"
835
+ ],
836
+ [
837
+ 1,
838
+ "#f0f921"
839
+ ]
840
+ ],
841
+ "sequentialminus": [
842
+ [
843
+ 0,
844
+ "#0d0887"
845
+ ],
846
+ [
847
+ 0.1111111111111111,
848
+ "#46039f"
849
+ ],
850
+ [
851
+ 0.2222222222222222,
852
+ "#7201a8"
853
+ ],
854
+ [
855
+ 0.3333333333333333,
856
+ "#9c179e"
857
+ ],
858
+ [
859
+ 0.4444444444444444,
860
+ "#bd3786"
861
+ ],
862
+ [
863
+ 0.5555555555555556,
864
+ "#d8576b"
865
+ ],
866
+ [
867
+ 0.6666666666666666,
868
+ "#ed7953"
869
+ ],
870
+ [
871
+ 0.7777777777777778,
872
+ "#fb9f3a"
873
+ ],
874
+ [
875
+ 0.8888888888888888,
876
+ "#fdca26"
877
+ ],
878
+ [
879
+ 1,
880
+ "#f0f921"
881
+ ]
882
+ ]
883
+ },
884
+ "colorway": [
885
+ "#636efa",
886
+ "#EF553B",
887
+ "#00cc96",
888
+ "#ab63fa",
889
+ "#FFA15A",
890
+ "#19d3f3",
891
+ "#FF6692",
892
+ "#B6E880",
893
+ "#FF97FF",
894
+ "#FECB52"
895
+ ],
896
+ "font": {
897
+ "color": "#2a3f5f"
898
+ },
899
+ "geo": {
900
+ "bgcolor": "white",
901
+ "lakecolor": "white",
902
+ "landcolor": "#E5ECF6",
903
+ "showlakes": true,
904
+ "showland": true,
905
+ "subunitcolor": "white"
906
+ },
907
+ "hoverlabel": {
908
+ "align": "left"
909
+ },
910
+ "hovermode": "closest",
911
+ "mapbox": {
912
+ "style": "light"
913
+ },
914
+ "paper_bgcolor": "white",
915
+ "plot_bgcolor": "#E5ECF6",
916
+ "polar": {
917
+ "angularaxis": {
918
+ "gridcolor": "white",
919
+ "linecolor": "white",
920
+ "ticks": ""
921
+ },
922
+ "bgcolor": "#E5ECF6",
923
+ "radialaxis": {
924
+ "gridcolor": "white",
925
+ "linecolor": "white",
926
+ "ticks": ""
927
+ }
928
+ },
929
+ "scene": {
930
+ "xaxis": {
931
+ "backgroundcolor": "#E5ECF6",
932
+ "gridcolor": "white",
933
+ "gridwidth": 2,
934
+ "linecolor": "white",
935
+ "showbackground": true,
936
+ "ticks": "",
937
+ "zerolinecolor": "white"
938
+ },
939
+ "yaxis": {
940
+ "backgroundcolor": "#E5ECF6",
941
+ "gridcolor": "white",
942
+ "gridwidth": 2,
943
+ "linecolor": "white",
944
+ "showbackground": true,
945
+ "ticks": "",
946
+ "zerolinecolor": "white"
947
+ },
948
+ "zaxis": {
949
+ "backgroundcolor": "#E5ECF6",
950
+ "gridcolor": "white",
951
+ "gridwidth": 2,
952
+ "linecolor": "white",
953
+ "showbackground": true,
954
+ "ticks": "",
955
+ "zerolinecolor": "white"
956
+ }
957
+ },
958
+ "shapedefaults": {
959
+ "line": {
960
+ "color": "#2a3f5f"
961
+ }
962
+ },
963
+ "ternary": {
964
+ "aaxis": {
965
+ "gridcolor": "white",
966
+ "linecolor": "white",
967
+ "ticks": ""
968
+ },
969
+ "baxis": {
970
+ "gridcolor": "white",
971
+ "linecolor": "white",
972
+ "ticks": ""
973
+ },
974
+ "bgcolor": "#E5ECF6",
975
+ "caxis": {
976
+ "gridcolor": "white",
977
+ "linecolor": "white",
978
+ "ticks": ""
979
+ }
980
+ },
981
+ "title": {
982
+ "x": 0.05
983
+ },
984
+ "xaxis": {
985
+ "automargin": true,
986
+ "gridcolor": "white",
987
+ "linecolor": "white",
988
+ "ticks": "",
989
+ "title": {
990
+ "standoff": 15
991
+ },
992
+ "zerolinecolor": "white",
993
+ "zerolinewidth": 2
994
+ },
995
+ "yaxis": {
996
+ "automargin": true,
997
+ "gridcolor": "white",
998
+ "linecolor": "white",
999
+ "ticks": "",
1000
+ "title": {
1001
+ "standoff": 15
1002
+ },
1003
+ "zerolinecolor": "white",
1004
+ "zerolinewidth": 2
1005
+ }
1006
+ }
1007
+ },
1008
+ "xaxis": {
1009
+ "anchor": "y",
1010
+ "domain": [
1011
+ 0,
1012
+ 1
1013
+ ],
1014
+ "title": {
1015
+ "text": "index"
1016
+ }
1017
+ },
1018
+ "yaxis": {
1019
+ "anchor": "x",
1020
+ "domain": [
1021
+ 0,
1022
+ 1
1023
+ ],
1024
+ "title": {
1025
+ "text": "sa_temp"
1026
+ }
1027
+ }
1028
+ }
1029
+ },
1030
+ "text/html": [
1031
+ "<div> <script type=\"text/javascript\">window.PlotlyConfig = {MathJaxConfig: 'local'};</script>\n",
1032
+ " <script charset=\"utf-8\" src=\"https://cdn.plot.ly/plotly-2.30.0.min.js\"></script> <div id=\"c95365dc-5cdc-4348-87ed-a350f4465ed0\" class=\"plotly-graph-div\" style=\"height:100%; width:100%;\"></div> <script type=\"text/javascript\"> window.PLOTLYENV=window.PLOTLYENV || {}; if (document.getElementById(\"c95365dc-5cdc-4348-87ed-a350f4465ed0\")) { Plotly.newPlot( \"c95365dc-5cdc-4348-87ed-a350f4465ed0\", [{\"hovertemplate\":\"index=%{x}\\u003cbr\\u003esa_temp=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"\",\"line\":{\"color\":\"#636efa\",\"dash\":\"solid\"},\"marker\":{\"symbol\":\"circle\"},\"mode\":\"lines\",\"name\":\"\",\"orientation\":\"v\",\"showlegend\":false,\"x\":[],\"xaxis\":\"x\",\"y\":[],\"yaxis\":\"y\",\"type\":\"scatter\"}], {\"template\":{\"data\":{\"histogram2dcontour\":[{\"type\":\"histogram2dcontour\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"choropleth\":[{\"type\":\"choropleth\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"histogram2d\":[{\"type\":\"histogram2d\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"heatmap\":[{\"type\":\"heatmap\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"heatmapgl\":[{\"type\":\"heatmapgl\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"contourcarpet\":[{\"type\":\"contourcarpet\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"contour\":[{\"type\":\"contour\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"surface\":[{\"type\":\"surface\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"mesh3d\":[{\"type\":\"mesh3d\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"scatter\":[{\"fillpattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2},\"type\":\"scatter\"}],\"parcoords\":[{\"type\":\"parcoords\",\"line\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterpolargl\":[{\"type\":\"scatterpolargl\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"bar\":[{\"error_x\":{\"color\":\"#2a3f5f\"},\"error_y\":{\"color\":\"#2a3f5f\"},\"marker\":{\"line\":{\"color\":\"#E5ECF6\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"bar\"}],\"scattergeo\":[{\"type\":\"scattergeo\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterpolar\":[{\"type\":\"scatterpolar\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"histogram\":[{\"marker\":{\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"histogram\"}],\"scattergl\":[{\"type\":\"scattergl\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatter3d\":[{\"type\":\"scatter3d\",\"line\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scattermapbox\":[{\"type\":\"scattermapbox\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterternary\":[{\"type\":\"scatterternary\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scattercarpet\":[{\"type\":\"scattercarpet\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"carpet\":[{\"aaxis\":{\"endlinecolor\":\"#2a3f5f\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"#2a3f5f\"},\"baxis\":{\"endlinecolor\":\"#2a3f5f\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"#2a3f5f\"},\"type\":\"carpet\"}],\"table\":[{\"cells\":{\"fill\":{\"color\":\"#EBF0F8\"},\"line\":{\"color\":\"white\"}},\"header\":{\"fill\":{\"color\":\"#C8D4E3\"},\"line\":{\"color\":\"white\"}},\"type\":\"table\"}],\"barpolar\":[{\"marker\":{\"line\":{\"color\":\"#E5ECF6\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"barpolar\"}],\"pie\":[{\"automargin\":true,\"type\":\"pie\"}]},\"layout\":{\"autotypenumbers\":\"strict\",\"colorway\":[\"#636efa\",\"#EF553B\",\"#00cc96\",\"#ab63fa\",\"#FFA15A\",\"#19d3f3\",\"#FF6692\",\"#B6E880\",\"#FF97FF\",\"#FECB52\"],\"font\":{\"color\":\"#2a3f5f\"},\"hovermode\":\"closest\",\"hoverlabel\":{\"align\":\"left\"},\"paper_bgcolor\":\"white\",\"plot_bgcolor\":\"#E5ECF6\",\"polar\":{\"bgcolor\":\"#E5ECF6\",\"angularaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"radialaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"}},\"ternary\":{\"bgcolor\":\"#E5ECF6\",\"aaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"baxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"caxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"}},\"coloraxis\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"colorscale\":{\"sequential\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"sequentialminus\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"diverging\":[[0,\"#8e0152\"],[0.1,\"#c51b7d\"],[0.2,\"#de77ae\"],[0.3,\"#f1b6da\"],[0.4,\"#fde0ef\"],[0.5,\"#f7f7f7\"],[0.6,\"#e6f5d0\"],[0.7,\"#b8e186\"],[0.8,\"#7fbc41\"],[0.9,\"#4d9221\"],[1,\"#276419\"]]},\"xaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\",\"automargin\":true,\"zerolinewidth\":2},\"yaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\",\"automargin\":true,\"zerolinewidth\":2},\"scene\":{\"xaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2},\"yaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2},\"zaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2}},\"shapedefaults\":{\"line\":{\"color\":\"#2a3f5f\"}},\"annotationdefaults\":{\"arrowcolor\":\"#2a3f5f\",\"arrowhead\":0,\"arrowwidth\":1},\"geo\":{\"bgcolor\":\"white\",\"landcolor\":\"#E5ECF6\",\"subunitcolor\":\"white\",\"showland\":true,\"showlakes\":true,\"lakecolor\":\"white\"},\"title\":{\"x\":0.05},\"mapbox\":{\"style\":\"light\"}}},\"xaxis\":{\"anchor\":\"y\",\"domain\":[0.0,1.0],\"title\":{\"text\":\"index\"}},\"yaxis\":{\"anchor\":\"x\",\"domain\":[0.0,1.0],\"title\":{\"text\":\"sa_temp\"}},\"legend\":{\"tracegroupgap\":0},\"margin\":{\"t\":60}}, {\"responsive\": true} ) }; </script> </div>"
1033
+ ],
1034
+ "text/plain": [
1035
+ "Figure({\n",
1036
+ " 'data': [{'hovertemplate': 'index=%{x}<br>sa_temp=%{y}<extra></extra>',\n",
1037
+ " 'legendgroup': '',\n",
1038
+ " 'line': {'color': '#636efa', 'dash': 'solid'},\n",
1039
+ " 'marker': {'symbol': 'circle'},\n",
1040
+ " 'mode': 'lines',\n",
1041
+ " 'name': '',\n",
1042
+ " 'orientation': 'v',\n",
1043
+ " 'showlegend': False,\n",
1044
+ " 'type': 'scatter',\n",
1045
+ " 'x': array([], dtype=int64),\n",
1046
+ " 'xaxis': 'x',\n",
1047
+ " 'y': array([], dtype=object),\n",
1048
+ " 'yaxis': 'y'}],\n",
1049
+ " 'layout': {'legend': {'tracegroupgap': 0},\n",
1050
+ " 'margin': {'t': 60},\n",
1051
+ " 'template': '...',\n",
1052
+ " 'xaxis': {'anchor': 'y', 'domain': [0.0, 1.0], 'title': {'text': 'index'}},\n",
1053
+ " 'yaxis': {'anchor': 'x', 'domain': [0.0, 1.0], 'title': {'text': 'sa_temp'}}}\n",
1054
+ "})"
1055
+ ]
1056
+ },
1057
+ "execution_count": 4,
1058
+ "metadata": {},
1059
+ "output_type": "execute_result"
1060
+ }
1061
+ ],
1062
+ "source": []
1063
+ },
1064
+ {
1065
+ "cell_type": "code",
1066
+ "execution_count": null,
1067
+ "metadata": {},
1068
+ "outputs": [],
1069
+ "source": []
1070
+ }
1071
+ ],
1072
+ "metadata": {
1073
+ "kernelspec": {
1074
+ "display_name": "smartbuilding",
1075
+ "language": "python",
1076
+ "name": "python3"
1077
+ },
1078
+ "language_info": {
1079
+ "codemirror_mode": {
1080
+ "name": "ipython",
1081
+ "version": 3
1082
+ },
1083
+ "file_extension": ".py",
1084
+ "mimetype": "text/x-python",
1085
+ "name": "python",
1086
+ "nbconvert_exporter": "python",
1087
+ "pygments_lexer": "ipython3",
1088
+ "version": "3.11.8"
1089
+ }
1090
+ },
1091
+ "nbformat": 4,
1092
+ "nbformat_minor": 2
1093
+ }
mqttpublisher.ipynb ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 1,
6
+ "metadata": {},
7
+ "outputs": [
8
+ {
9
+ "name": "stderr",
10
+ "output_type": "stream",
11
+ "text": [
12
+ "C:\\Users\\jerin\\AppData\\Local\\Temp\\ipykernel_18680\\2251714346.py:13: DeprecationWarning: Callback API version 1 is deprecated, update to latest version\n",
13
+ " client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION1, clientId)\n"
14
+ ]
15
+ },
16
+ {
17
+ "ename": "KeyboardInterrupt",
18
+ "evalue": "",
19
+ "output_type": "error",
20
+ "traceback": [
21
+ "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
22
+ "\u001b[1;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)",
23
+ "Cell \u001b[1;32mIn[1], line 28\u001b[0m\n\u001b[0;32m 26\u001b[0m \u001b[38;5;28;01mwhile\u001b[39;00m \u001b[38;5;28;01mTrue\u001b[39;00m:\n\u001b[0;32m 27\u001b[0m publish_sensor_data()\n\u001b[1;32m---> 28\u001b[0m time\u001b[38;5;241m.\u001b[39msleep(\u001b[38;5;241m5\u001b[39m)\n\u001b[0;32m 29\u001b[0m client\u001b[38;5;241m.\u001b[39mdisconnect()\n",
24
+ "\u001b[1;31mKeyboardInterrupt\u001b[0m: "
25
+ ]
26
+ }
27
+ ],
28
+ "source": [
29
+ "import paho.mqtt.client as mqtt\n",
30
+ "import time\n",
31
+ "import random\n",
32
+ "import pandas as pd\n",
33
+ "import json\n",
34
+ "\n",
35
+ "clientId = \"smartbuilding\"\n",
36
+ "broker_address = \"localhost\"\n",
37
+ "broker_port = 1883\n",
38
+ "\n",
39
+ "df = pd.read_csv(\"buildingdata.csv\")\n",
40
+ "\n",
41
+ "client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION1, clientId)\n",
42
+ "client.connect(broker_address, broker_port)\n",
43
+ "topic = \"sensor_data\"\n",
44
+ "\n",
45
+ "def publish_sensor_data():\n",
46
+ " # temp = round(random.uniform(20, 30), 2) \n",
47
+ " # pressure = round(random.uniform(900, 1100), 2) \n",
48
+ " for index, row in df.iterrows():\n",
49
+ " sa_temp = row['rtu_004_sa_temp']\n",
50
+ " ma_temp = row['rtu_004_ma_temp']\n",
51
+ " client.publish(topic, payload=json.dumps({\"sa_temp\": sa_temp, \"ma_temp\": ma_temp}))\n",
52
+ "\n",
53
+ "\n",
54
+ "while True:\n",
55
+ " publish_sensor_data()\n",
56
+ " time.sleep(5)\n",
57
+ "client.disconnect()"
58
+ ]
59
+ },
60
+ {
61
+ "cell_type": "code",
62
+ "execution_count": null,
63
+ "metadata": {},
64
+ "outputs": [],
65
+ "source": []
66
+ }
67
+ ],
68
+ "metadata": {
69
+ "kernelspec": {
70
+ "display_name": "smartbuilding",
71
+ "language": "python",
72
+ "name": "python3"
73
+ },
74
+ "language_info": {
75
+ "codemirror_mode": {
76
+ "name": "ipython",
77
+ "version": 3
78
+ },
79
+ "file_extension": ".py",
80
+ "mimetype": "text/x-python",
81
+ "name": "python",
82
+ "nbconvert_exporter": "python",
83
+ "pygments_lexer": "ipython3",
84
+ "version": "3.11.8"
85
+ }
86
+ },
87
+ "nbformat": 4,
88
+ "nbformat_minor": 2
89
+ }
streamlit.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st # web development
2
+ import numpy as np # np mean, np random
3
+ import pandas as pd # read csv, df manipulation
4
+ import time # to simulate a real time data, time loop
5
+ import plotly.express as px # interactive charts
6
+ import paho.mqtt.client as mqtt
7
+ import json
8
+ import warnings
9
+ warnings.filterwarnings('ignore')
10
+
11
+ # df = pd.read_csv('buildingdata.csv')
12
+ st.set_page_config(
13
+ page_title = 'Real-Time Data Buliding 59',
14
+ page_icon = '✅',
15
+ layout = 'wide'
16
+ )
17
+
18
+ st.title("Buliding 59 Dashboard")
19
+ placeholder = st.empty()
20
+
21
+ broker_address = "localhost"
22
+ broker_port = 1883
23
+ topic = "sensor_data"
24
+
25
+ df = pd.DataFrame({"sa_temp":[60, 56, 66,69,70],"ma_temp":[30,40,50,60,65]})
26
+
27
+ def on_message(client, userdata, message):
28
+ global df
29
+ payload = json.loads(message.payload.decode())
30
+ sa_temp = payload["sa_temp"]
31
+ ma_temp = payload["ma_temp"]
32
+ len_df = len(df)
33
+ df.loc[len_df] = {"sa_temp": sa_temp, "ma_temp": ma_temp}
34
+ if len_df>5:
35
+ with placeholder.container():
36
+ fig_col1, fig_col2 = st.columns(2)
37
+ with fig_col1:
38
+ st.markdown("### Supply Air temperature")
39
+ fig1 = px.line(data_frame=df[len_df-5:len_df], y = 'sa_temp', x = df[len_df-5:len_df].index)
40
+ st.write(fig1)
41
+ with fig_col2:
42
+ st.markdown("### Mixed Air temperature")
43
+ fig2 = px.line(data_frame=df[len_df-5:len_df], y = 'ma_temp', x = df[len_df-5:len_df].index)
44
+ st.write(fig2)
45
+ st.markdown("### Detailed Data View")
46
+ st.dataframe(df[len_df-5:len_df])
47
+ # time.sleep(1)
48
+
49
+
50
+
51
+ client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION1)
52
+ client.on_message = on_message
53
+ client.connect(broker_address, broker_port)
54
+ client.subscribe(topic)
55
+ client.loop_forever()
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+
64
+
65
+