Update plotting.py
Browse files- plotting.py +430 -427
plotting.py
CHANGED
@@ -1,427 +1,430 @@
|
|
1 |
-
import panel as pn
|
2 |
-
import plotly.graph_objs as go
|
3 |
-
import plotly.express as px
|
4 |
-
from plotly.subplots import make_subplots
|
5 |
-
|
6 |
-
from consts import (
|
7 |
-
INVERTER_ID_MAPPING,
|
8 |
-
CURRENT,
|
9 |
-
IRRADIANCE,
|
10 |
-
VOLTAGE,
|
11 |
-
POWER_DC,
|
12 |
-
POWER_AC,
|
13 |
-
T_AMBIENT,
|
14 |
-
T_MODULE,
|
15 |
-
T_HEATSINK,
|
16 |
-
T_CPU,
|
17 |
-
T_BOARD,
|
18 |
-
)
|
19 |
-
|
20 |
-
|
21 |
-
def create_iv_plot(df, inverter_ids):
|
22 |
-
"""# Helper function to create a line plot with secondary y-axis"""
|
23 |
-
|
24 |
-
print("Selected Inverter Ids: {}".format(inverter_ids))
|
25 |
-
fig = make_subplots(
|
26 |
-
rows=2,
|
27 |
-
cols=1,
|
28 |
-
shared_xaxes=True,
|
29 |
-
vertical_spacing=0.01,
|
30 |
-
specs=[[{"secondary_y": True}], [{}]],
|
31 |
-
)
|
32 |
-
|
33 |
-
for inverter in inverter_ids:
|
34 |
-
inv_id = INVERTER_ID_MAPPING[inverter]
|
35 |
-
print("Creating plot for inv_id: {}".format(inv_id))
|
36 |
-
inv_data = df[str(inv_id)]
|
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 |
-
fig.
|
79 |
-
|
80 |
-
|
81 |
-
fig.
|
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 |
-
fig.update_yaxes(title_text="
|
167 |
-
fig.
|
168 |
-
|
169 |
-
|
170 |
-
fig.
|
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 |
-
fig.update_yaxes(title_text="
|
301 |
-
fig.
|
302 |
-
fig.update_yaxes(title_text="
|
303 |
-
|
304 |
-
|
305 |
-
fig.
|
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 |
-
fig.
|
416 |
-
fig.update_yaxes(title_text="
|
417 |
-
|
418 |
-
|
419 |
-
fig.
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
|
|
|
|
|
|
|
1 |
+
import panel as pn
|
2 |
+
import plotly.graph_objs as go
|
3 |
+
import plotly.express as px
|
4 |
+
from plotly.subplots import make_subplots
|
5 |
+
|
6 |
+
from consts import (
|
7 |
+
INVERTER_ID_MAPPING,
|
8 |
+
CURRENT,
|
9 |
+
IRRADIANCE,
|
10 |
+
VOLTAGE,
|
11 |
+
POWER_DC,
|
12 |
+
POWER_AC,
|
13 |
+
T_AMBIENT,
|
14 |
+
T_MODULE,
|
15 |
+
T_HEATSINK,
|
16 |
+
T_CPU,
|
17 |
+
T_BOARD,
|
18 |
+
)
|
19 |
+
|
20 |
+
|
21 |
+
def create_iv_plot(df, inverter_ids):
|
22 |
+
"""# Helper function to create a line plot with secondary y-axis"""
|
23 |
+
|
24 |
+
print("Selected Inverter Ids: {}".format(inverter_ids))
|
25 |
+
fig = make_subplots(
|
26 |
+
rows=2,
|
27 |
+
cols=1,
|
28 |
+
shared_xaxes=True,
|
29 |
+
vertical_spacing=0.01,
|
30 |
+
specs=[[{"secondary_y": True}], [{}]],
|
31 |
+
)
|
32 |
+
|
33 |
+
for inverter in inverter_ids:
|
34 |
+
inv_id = INVERTER_ID_MAPPING[inverter]
|
35 |
+
print("Creating plot for inv_id: {}".format(inv_id))
|
36 |
+
inv_data = df[str(inv_id)]
|
37 |
+
print(inv_data.head())
|
38 |
+
print(inv_data.columns)
|
39 |
+
print(f"df columns {df.columns}")
|
40 |
+
|
41 |
+
# Graph 1: DC current and G-POA (Twin Y-Axis)
|
42 |
+
fig.add_trace(
|
43 |
+
go.Scatter(
|
44 |
+
x=inv_data.index,
|
45 |
+
y=inv_data[CURRENT],
|
46 |
+
mode="lines",
|
47 |
+
name=f"{CURRENT}-{inv_id}",
|
48 |
+
),
|
49 |
+
row=1,
|
50 |
+
col=1,
|
51 |
+
secondary_y=False,
|
52 |
+
)
|
53 |
+
|
54 |
+
fig.add_trace(
|
55 |
+
go.Scatter(
|
56 |
+
x=inv_data.index,
|
57 |
+
y=inv_data[IRRADIANCE],
|
58 |
+
mode="lines",
|
59 |
+
name=f"{IRRADIANCE}-{inv_id}",
|
60 |
+
),
|
61 |
+
row=1,
|
62 |
+
col=1,
|
63 |
+
secondary_y=True,
|
64 |
+
)
|
65 |
+
|
66 |
+
# Graph 2: Voltage
|
67 |
+
fig.add_trace(
|
68 |
+
go.Scatter(
|
69 |
+
x=inv_data.index,
|
70 |
+
y=inv_data[VOLTAGE],
|
71 |
+
mode="lines",
|
72 |
+
name=f"{VOLTAGE}-{inv_id}",
|
73 |
+
),
|
74 |
+
row=2,
|
75 |
+
col=1,
|
76 |
+
)
|
77 |
+
# Update axis labels
|
78 |
+
fig.update_yaxes(title_text="Current (A)", row=1, col=1)
|
79 |
+
fig.update_yaxes(title_text="Irradiance (W/m2)", row=1, col=1, secondary_y=True)
|
80 |
+
fig.update_yaxes(title_text="Voltage (V)", row=2, col=1)
|
81 |
+
fig.update_xaxes(title_text="Datetime", row=2, col=1)
|
82 |
+
|
83 |
+
# Update layout to add titles and adjust axis labels
|
84 |
+
fig.update_layout(title_text="IV Plots", height=800, width=1000)
|
85 |
+
|
86 |
+
return fig
|
87 |
+
|
88 |
+
|
89 |
+
def create_iv_plot_with_power_curves(df, inverter_ids):
|
90 |
+
"""# Helper function to create a line plot with secondary y-axis"""
|
91 |
+
|
92 |
+
print("Selected Inverter Ids: {}".format(inverter_ids))
|
93 |
+
fig = make_subplots(
|
94 |
+
rows=3,
|
95 |
+
cols=1,
|
96 |
+
shared_xaxes=True,
|
97 |
+
vertical_spacing=0.01,
|
98 |
+
specs=[[{"secondary_y": True}], [{}], [{}]],
|
99 |
+
)
|
100 |
+
|
101 |
+
for inverter in inverter_ids:
|
102 |
+
inv_id = INVERTER_ID_MAPPING[inverter]
|
103 |
+
print("Creating plot for inv_id: {}".format(inv_id))
|
104 |
+
inv_data = df[str(inv_id)]
|
105 |
+
|
106 |
+
# Graph 1: DC current and G-POA (Twin Y-Axis)
|
107 |
+
fig.add_trace(
|
108 |
+
go.Scatter(
|
109 |
+
x=inv_data.index,
|
110 |
+
y=inv_data[CURRENT],
|
111 |
+
mode="lines",
|
112 |
+
name=f"{CURRENT}-{inv_id}",
|
113 |
+
),
|
114 |
+
row=1,
|
115 |
+
col=1,
|
116 |
+
secondary_y=False,
|
117 |
+
)
|
118 |
+
|
119 |
+
fig.add_trace(
|
120 |
+
go.Scatter(
|
121 |
+
x=inv_data.index,
|
122 |
+
y=inv_data[IRRADIANCE],
|
123 |
+
mode="lines",
|
124 |
+
name=f"{IRRADIANCE}-{inv_id}",
|
125 |
+
),
|
126 |
+
row=1,
|
127 |
+
col=1,
|
128 |
+
secondary_y=True,
|
129 |
+
)
|
130 |
+
|
131 |
+
# Graph 2: Voltage
|
132 |
+
fig.add_trace(
|
133 |
+
go.Scatter(
|
134 |
+
x=inv_data.index,
|
135 |
+
y=inv_data[VOLTAGE],
|
136 |
+
mode="lines",
|
137 |
+
name=f"{VOLTAGE}-{inv_id}",
|
138 |
+
),
|
139 |
+
row=2,
|
140 |
+
col=1,
|
141 |
+
)
|
142 |
+
|
143 |
+
# Graph 3: P-dc and P-ac
|
144 |
+
fig.add_trace(
|
145 |
+
go.Scatter(
|
146 |
+
x=inv_data.index,
|
147 |
+
y=inv_data[POWER_DC],
|
148 |
+
mode="lines",
|
149 |
+
name=f"{POWER_DC}-{inv_id}",
|
150 |
+
),
|
151 |
+
row=3,
|
152 |
+
col=1,
|
153 |
+
)
|
154 |
+
fig.add_trace(
|
155 |
+
go.Scatter(
|
156 |
+
x=inv_data.index,
|
157 |
+
y=inv_data[POWER_AC],
|
158 |
+
mode="lines",
|
159 |
+
name=f"{POWER_AC}-{inv_id}",
|
160 |
+
),
|
161 |
+
row=3,
|
162 |
+
col=1,
|
163 |
+
)
|
164 |
+
|
165 |
+
# Update axis labels
|
166 |
+
fig.update_yaxes(title_text="Current (A)", row=1, col=1)
|
167 |
+
fig.update_yaxes(title_text="Irradiance (W/m2)", row=1, col=1, secondary_y=True)
|
168 |
+
fig.update_yaxes(title_text="Voltage (V)", row=2, col=1)
|
169 |
+
fig.update_yaxes(title_text="P-dc & P-ac (W)", row=3, col=1)
|
170 |
+
fig.update_xaxes(title_text="Datetime", row=3, col=1)
|
171 |
+
|
172 |
+
# Update layout to add titles
|
173 |
+
fig.update_layout(title_text="IV Plot with Power Curves", height=800, width=1000)
|
174 |
+
|
175 |
+
return fig
|
176 |
+
|
177 |
+
|
178 |
+
def create_iv_plot_with_power_and_temperature_curves(df, df2, inverter_ids):
|
179 |
+
# Create the specs for subplots
|
180 |
+
print("Selected Inverter Ids: {}".format(inverter_ids))
|
181 |
+
fig = make_subplots(
|
182 |
+
rows=4,
|
183 |
+
cols=1,
|
184 |
+
shared_xaxes=True,
|
185 |
+
vertical_spacing=0.01,
|
186 |
+
specs=[[{"secondary_y": True}], [{}], [{}], [{}]],
|
187 |
+
)
|
188 |
+
|
189 |
+
for inverter in inverter_ids:
|
190 |
+
inv_id = INVERTER_ID_MAPPING[inverter]
|
191 |
+
print("Creating plot for inv_id: {}".format(inv_id))
|
192 |
+
inv_data = df[str(inv_id)]
|
193 |
+
temperature_data = df2[df2["Inv"] == inv_id]
|
194 |
+
|
195 |
+
# Graph 1: DC current and G-POA (Twin Y-Axis)
|
196 |
+
fig.add_trace(
|
197 |
+
go.Scatter(
|
198 |
+
x=inv_data.index,
|
199 |
+
y=inv_data[CURRENT],
|
200 |
+
mode="lines",
|
201 |
+
name=f"{CURRENT}-{inv_id}",
|
202 |
+
),
|
203 |
+
row=1,
|
204 |
+
col=1,
|
205 |
+
secondary_y=False,
|
206 |
+
)
|
207 |
+
|
208 |
+
fig.add_trace(
|
209 |
+
go.Scatter(
|
210 |
+
x=inv_data.index,
|
211 |
+
y=inv_data[IRRADIANCE],
|
212 |
+
mode="lines",
|
213 |
+
name=f"{IRRADIANCE}-{inv_id}",
|
214 |
+
),
|
215 |
+
row=1,
|
216 |
+
col=1,
|
217 |
+
secondary_y=True,
|
218 |
+
)
|
219 |
+
|
220 |
+
# Graph 2: Voltage
|
221 |
+
fig.add_trace(
|
222 |
+
go.Scatter(
|
223 |
+
x=inv_data.index,
|
224 |
+
y=inv_data[VOLTAGE],
|
225 |
+
mode="lines",
|
226 |
+
name=f"{VOLTAGE}-{inv_id}",
|
227 |
+
),
|
228 |
+
row=2,
|
229 |
+
col=1,
|
230 |
+
)
|
231 |
+
|
232 |
+
# Graph 3: P-dc and P-ac
|
233 |
+
fig.add_trace(
|
234 |
+
go.Scatter(
|
235 |
+
x=inv_data.index,
|
236 |
+
y=inv_data[POWER_DC],
|
237 |
+
mode="lines",
|
238 |
+
name=f"{POWER_DC}-{inv_id}",
|
239 |
+
),
|
240 |
+
row=3,
|
241 |
+
col=1,
|
242 |
+
)
|
243 |
+
fig.add_trace(
|
244 |
+
go.Scatter(
|
245 |
+
x=inv_data.index,
|
246 |
+
y=inv_data[POWER_AC],
|
247 |
+
mode="lines",
|
248 |
+
name=f"{POWER_AC}-{inv_id}",
|
249 |
+
),
|
250 |
+
row=3,
|
251 |
+
col=1,
|
252 |
+
)
|
253 |
+
|
254 |
+
# Graph 4: T-amb, T-mod, T-heatsink, T-CPU and T-board
|
255 |
+
fig.add_trace(
|
256 |
+
go.Scatter(
|
257 |
+
x=temperature_data.index,
|
258 |
+
y=temperature_data[T_AMBIENT],
|
259 |
+
name=f"{T_AMBIENT}-{inv_id}",
|
260 |
+
),
|
261 |
+
row=4,
|
262 |
+
col=1,
|
263 |
+
)
|
264 |
+
fig.add_trace(
|
265 |
+
go.Scatter(
|
266 |
+
x=inv_data.index, y=inv_data[T_MODULE], name=f"{T_MODULE}-{inv_id}"
|
267 |
+
),
|
268 |
+
row=4,
|
269 |
+
col=1,
|
270 |
+
)
|
271 |
+
fig.add_trace(
|
272 |
+
go.Scatter(
|
273 |
+
x=temperature_data.index,
|
274 |
+
y=temperature_data[T_HEATSINK],
|
275 |
+
name=f"{T_HEATSINK}-{inv_id}",
|
276 |
+
),
|
277 |
+
row=4,
|
278 |
+
col=1,
|
279 |
+
)
|
280 |
+
fig.add_trace(
|
281 |
+
go.Scatter(
|
282 |
+
x=temperature_data.index,
|
283 |
+
y=temperature_data[T_CPU],
|
284 |
+
name=f"{T_CPU}-{inv_id}",
|
285 |
+
),
|
286 |
+
row=4,
|
287 |
+
col=1,
|
288 |
+
)
|
289 |
+
fig.add_trace(
|
290 |
+
go.Scatter(
|
291 |
+
x=temperature_data.index,
|
292 |
+
y=temperature_data[T_BOARD],
|
293 |
+
name=f"{T_BOARD}-{inv_id}",
|
294 |
+
),
|
295 |
+
row=4,
|
296 |
+
col=1,
|
297 |
+
)
|
298 |
+
|
299 |
+
# Update axis labels
|
300 |
+
fig.update_yaxes(title_text="Current (A)", row=1, col=1)
|
301 |
+
fig.update_yaxes(title_text="Irradiance (W/m2)", row=1, col=1, secondary_y=True)
|
302 |
+
fig.update_yaxes(title_text="Voltage (V)", row=2, col=1)
|
303 |
+
fig.update_yaxes(title_text="P-dc & P-ac (W)", row=3, col=1)
|
304 |
+
fig.update_xaxes(title_text="Datetime", row=4, col=1)
|
305 |
+
fig.update_yaxes(title_text="Temperature (°C)", row=4, col=1)
|
306 |
+
|
307 |
+
# Update layout to add titles
|
308 |
+
fig.update_layout(
|
309 |
+
title_text="IV Plots with Power and Temperature", height=800, width=1000
|
310 |
+
)
|
311 |
+
|
312 |
+
return pn.pane.Plotly(fig)
|
313 |
+
|
314 |
+
|
315 |
+
def create_iv_plot_with_temperature_curves(df, df2, inverter_ids):
|
316 |
+
# Create the specs for subplots
|
317 |
+
print("Selected Inverter Ids: {}".format(inverter_ids))
|
318 |
+
fig = make_subplots(
|
319 |
+
rows=3,
|
320 |
+
cols=1,
|
321 |
+
shared_xaxes=True,
|
322 |
+
vertical_spacing=0.01,
|
323 |
+
specs=[[{"secondary_y": True}], [{}], [{}]],
|
324 |
+
)
|
325 |
+
|
326 |
+
for inverter in inverter_ids:
|
327 |
+
inv_id = INVERTER_ID_MAPPING[inverter]
|
328 |
+
print("Creating plot for inv_id: {}".format(inv_id))
|
329 |
+
inv_data = df[str(inv_id)]
|
330 |
+
temperature_data = df2[df2["Inv"] == inv_id]
|
331 |
+
|
332 |
+
# Graph 1: DC current and G-POA (Twin Y-Axis)
|
333 |
+
fig.add_trace(
|
334 |
+
go.Scatter(
|
335 |
+
x=inv_data.index,
|
336 |
+
y=inv_data[CURRENT],
|
337 |
+
mode="lines",
|
338 |
+
name=f"{CURRENT}-{inv_id}",
|
339 |
+
),
|
340 |
+
row=1,
|
341 |
+
col=1,
|
342 |
+
secondary_y=False,
|
343 |
+
)
|
344 |
+
|
345 |
+
fig.add_trace(
|
346 |
+
go.Scatter(
|
347 |
+
x=inv_data.index,
|
348 |
+
y=inv_data[IRRADIANCE],
|
349 |
+
mode="lines",
|
350 |
+
name=f"{IRRADIANCE}-{inv_id}",
|
351 |
+
),
|
352 |
+
row=1,
|
353 |
+
col=1,
|
354 |
+
secondary_y=True,
|
355 |
+
)
|
356 |
+
|
357 |
+
# Graph 2: Voltage
|
358 |
+
fig.add_trace(
|
359 |
+
go.Scatter(
|
360 |
+
x=inv_data.index,
|
361 |
+
y=inv_data[VOLTAGE],
|
362 |
+
mode="lines",
|
363 |
+
name=f"{VOLTAGE}-{inv_id}",
|
364 |
+
),
|
365 |
+
row=2,
|
366 |
+
col=1,
|
367 |
+
)
|
368 |
+
|
369 |
+
# Graph 4: T-amb, T-mod, T-heatsink, T-CPU and T-board
|
370 |
+
fig.add_trace(
|
371 |
+
go.Scatter(
|
372 |
+
x=temperature_data.index,
|
373 |
+
y=temperature_data[T_AMBIENT],
|
374 |
+
name=f"{T_AMBIENT}-{inv_id}",
|
375 |
+
),
|
376 |
+
row=3,
|
377 |
+
col=1,
|
378 |
+
)
|
379 |
+
fig.add_trace(
|
380 |
+
go.Scatter(
|
381 |
+
x=inv_data.index, y=inv_data[T_MODULE], name=f"{T_MODULE}-{inv_id}"
|
382 |
+
),
|
383 |
+
row=3,
|
384 |
+
col=1,
|
385 |
+
)
|
386 |
+
fig.add_trace(
|
387 |
+
go.Scatter(
|
388 |
+
x=temperature_data.index,
|
389 |
+
y=temperature_data[T_HEATSINK],
|
390 |
+
name=f"{T_HEATSINK}-{inv_id}",
|
391 |
+
),
|
392 |
+
row=3,
|
393 |
+
col=1,
|
394 |
+
)
|
395 |
+
fig.add_trace(
|
396 |
+
go.Scatter(
|
397 |
+
x=temperature_data.index,
|
398 |
+
y=temperature_data[T_CPU],
|
399 |
+
name=f"{T_CPU}-{inv_id}",
|
400 |
+
),
|
401 |
+
row=3,
|
402 |
+
col=1,
|
403 |
+
)
|
404 |
+
fig.add_trace(
|
405 |
+
go.Scatter(
|
406 |
+
x=temperature_data.index,
|
407 |
+
y=temperature_data[T_BOARD],
|
408 |
+
name=f"{T_BOARD}-{inv_id}",
|
409 |
+
),
|
410 |
+
row=3,
|
411 |
+
col=1,
|
412 |
+
)
|
413 |
+
|
414 |
+
# Update axis labels
|
415 |
+
fig.update_yaxes(title_text="Current (A)", row=1, col=1)
|
416 |
+
fig.update_yaxes(title_text="Irradiance (W/m2)", row=1, col=1, secondary_y=True)
|
417 |
+
fig.update_yaxes(title_text="Voltage (V)", row=2, col=1)
|
418 |
+
fig.update_xaxes(title_text="Datetime", row=3, col=1)
|
419 |
+
fig.update_yaxes(title_text="Temperature (°C)", row=3, col=1)
|
420 |
+
|
421 |
+
# Update layout to add titles
|
422 |
+
fig.update_layout(title_text="IV Plots with Temperature", height=800, width=1000)
|
423 |
+
|
424 |
+
return pn.pane.Plotly(fig)
|
425 |
+
|
426 |
+
|
427 |
+
def create_heatmap(df, title):
|
428 |
+
fig = px.imshow(df.transpose(), aspect="auto", title=title)
|
429 |
+
fig.update_layout(height=400, width=1200)
|
430 |
+
return pn.pane.Plotly(fig)
|