Update app.py
Browse files
app.py
CHANGED
@@ -11,13 +11,25 @@ from plotting import (
|
|
11 |
create_iv_plot_with_temperature_curves,
|
12 |
)
|
13 |
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
chunks = []
|
17 |
-
for chunk in pd.read_csv(file_path,
|
|
|
|
|
|
|
|
|
18 |
if start_date and end_date:
|
19 |
-
chunk = chunk[(chunk['datetime'] >= start_date) & (chunk['datetime'] <= end_date)]
|
|
|
20 |
chunks.append(chunk)
|
|
|
21 |
return pd.concat(chunks)
|
22 |
|
23 |
# Initialize Panel extension
|
@@ -54,41 +66,46 @@ loading_spinner = pn.indicators.LoadingSpinner(width=50, height=50)
|
|
54 |
plot_power_curves.param.value,
|
55 |
plot_temperature_curves.param.value,
|
56 |
)
|
|
|
|
|
|
|
|
|
|
|
57 |
def update_iv_plot(inverter_ids, plot_power_curves, plot_temperature_curves):
|
58 |
if not inverter_ids:
|
59 |
return pn.pane.Markdown("No Inverters selected for Plotting.")
|
60 |
else:
|
61 |
-
|
62 |
if plot_power_curves:
|
63 |
-
|
64 |
if plot_temperature_curves:
|
65 |
-
|
66 |
if not plot_power_curves and not plot_temperature_curves:
|
67 |
-
|
68 |
|
69 |
-
|
70 |
-
|
71 |
|
72 |
# Plot IV + Power + Temperature Curves
|
73 |
if plot_power_curves and plot_temperature_curves:
|
74 |
print("Plotting IV + Power + Temperature Curves")
|
75 |
return create_iv_plot_with_power_and_temperature_curves(
|
76 |
-
|
77 |
)
|
78 |
# Plot IV + Temperature Curves
|
79 |
elif (not plot_power_curves) and plot_temperature_curves:
|
80 |
print("Plot IV + Temperature Curves")
|
81 |
return create_iv_plot_with_temperature_curves(
|
82 |
-
|
83 |
)
|
84 |
# Plot IV + Power Curves
|
85 |
elif plot_power_curves and (not plot_temperature_curves):
|
86 |
print("Plot IV + Power Curves")
|
87 |
-
return create_iv_plot_with_power_curves(
|
88 |
# Plot only IV Curves
|
89 |
else:
|
90 |
print("Plot only IV Curves")
|
91 |
-
return create_iv_plot(
|
92 |
|
93 |
@pn.depends(heatmap_pr.param.value)
|
94 |
def update_heatmap_pr(heatmap_pr):
|
|
|
11 |
create_iv_plot_with_temperature_curves,
|
12 |
)
|
13 |
|
14 |
+
def load_data_in_chunks(file_path, selected_columns, start_date=None, end_date=None, chunksize=10000):
|
15 |
+
# Load the entire header
|
16 |
+
header = pd.read_csv(file_path, nrows=0, header=[0, 1, 2])
|
17 |
+
|
18 |
+
# Filter the required columns
|
19 |
+
columns = [col for col in header.columns if col[2] in selected_columns]
|
20 |
+
columns = [('datetime', '', '')] + columns
|
21 |
+
|
22 |
chunks = []
|
23 |
+
for chunk in pd.read_csv(file_path, chunksize=chunksize, parse_dates=['datetime'], header=[0, 1, 2]):
|
24 |
+
# Filter the necessary columns
|
25 |
+
chunk.columns = header.columns
|
26 |
+
chunk = chunk[columns]
|
27 |
+
|
28 |
if start_date and end_date:
|
29 |
+
chunk = chunk[(chunk[('datetime', '', '')] >= start_date) & (chunk[('datetime', '', '')] <= end_date)]
|
30 |
+
|
31 |
chunks.append(chunk)
|
32 |
+
|
33 |
return pd.concat(chunks)
|
34 |
|
35 |
# Initialize Panel extension
|
|
|
66 |
plot_power_curves.param.value,
|
67 |
plot_temperature_curves.param.value,
|
68 |
)
|
69 |
+
@pn.depends(
|
70 |
+
inverter_ids.param.value,
|
71 |
+
plot_power_curves.param.value,
|
72 |
+
plot_temperature_curves.param.value,
|
73 |
+
)
|
74 |
def update_iv_plot(inverter_ids, plot_power_curves, plot_temperature_curves):
|
75 |
if not inverter_ids:
|
76 |
return pn.pane.Markdown("No Inverters selected for Plotting.")
|
77 |
else:
|
78 |
+
selected_columns = []
|
79 |
if plot_power_curves:
|
80 |
+
selected_columns += [CURRENT, IRRADIANCE, VOLTAGE, POWER_DC, POWER_AC]
|
81 |
if plot_temperature_curves:
|
82 |
+
selected_columns += [T_AMBIENT, T_MODULE, T_HEATSINK, T_CPU, T_BOARD]
|
83 |
if not plot_power_curves and not plot_temperature_curves:
|
84 |
+
selected_columns += [CURRENT, IRRADIANCE, VOLTAGE]
|
85 |
|
86 |
+
timeseries_data = load_data_in_chunks('multi_index_timeseries_data.csv', selected_columns)
|
87 |
+
other_features_data = load_data_in_chunks('other_features_data.csv', TEMPERATURE_COLUMNS_TO_USE)
|
88 |
|
89 |
# Plot IV + Power + Temperature Curves
|
90 |
if plot_power_curves and plot_temperature_curves:
|
91 |
print("Plotting IV + Power + Temperature Curves")
|
92 |
return create_iv_plot_with_power_and_temperature_curves(
|
93 |
+
timeseries_data, other_features_data, inverter_ids
|
94 |
)
|
95 |
# Plot IV + Temperature Curves
|
96 |
elif (not plot_power_curves) and plot_temperature_curves:
|
97 |
print("Plot IV + Temperature Curves")
|
98 |
return create_iv_plot_with_temperature_curves(
|
99 |
+
timeseries_data, other_features_data, inverter_ids
|
100 |
)
|
101 |
# Plot IV + Power Curves
|
102 |
elif plot_power_curves and (not plot_temperature_curves):
|
103 |
print("Plot IV + Power Curves")
|
104 |
+
return create_iv_plot_with_power_curves(timeseries_data, inverter_ids)
|
105 |
# Plot only IV Curves
|
106 |
else:
|
107 |
print("Plot only IV Curves")
|
108 |
+
return create_iv_plot(timeseries_data, inverter_ids)
|
109 |
|
110 |
@pn.depends(heatmap_pr.param.value)
|
111 |
def update_heatmap_pr(heatmap_pr):
|