Spaces:
Sleeping
Sleeping
Daniel Varga commited on
Commit ·
6ae2b2a
1
Parent(s): a714bca
no repeated data load. switched to gr.Blocks
Browse files
v2/app.py
CHANGED
|
@@ -45,7 +45,6 @@ def recalculate(**uiParameters):
|
|
| 45 |
|
| 46 |
solar_parameters = SolarParameters()
|
| 47 |
|
| 48 |
-
met_2021_data, cons_2021_data = read_datasets()
|
| 49 |
add_production_field(met_2021_data, solar_parameters)
|
| 50 |
all_data = interpolate_and_join(met_2021_data, cons_2021_data)
|
| 51 |
|
|
@@ -83,7 +82,7 @@ def recalculate(**uiParameters):
|
|
| 83 |
return results
|
| 84 |
|
| 85 |
|
| 86 |
-
def ui_refresh(solar_cell_num, bess_nominal_capacity, fixed_consumption):
|
| 87 |
results = recalculate(solar_cell_num=solar_cell_num, bess_nominal_capacity=bess_nominal_capacity, fixed_consumption=fixed_consumption)
|
| 88 |
|
| 89 |
fig1 = plotly_visualize_simulation(results, date_range=("2021-02-01", "2021-02-07"))
|
|
@@ -113,14 +112,27 @@ def ui_refresh(solar_cell_num, bess_nominal_capacity, fixed_consumption):
|
|
| 113 |
return (html, fig_monthly, fig1, fig2)
|
| 114 |
|
| 115 |
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
gr.Slider(0, 2000,
|
| 120 |
-
gr.
|
| 121 |
-
gr.Checkbox(value=False, label="Use fixed consumption (10 kW)")],
|
| 122 |
-
outputs = ["html", "plot", "plot", "plot"],
|
| 123 |
-
live=True,
|
| 124 |
-
)
|
| 125 |
|
| 126 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
solar_parameters = SolarParameters()
|
| 47 |
|
|
|
|
| 48 |
add_production_field(met_2021_data, solar_parameters)
|
| 49 |
all_data = interpolate_and_join(met_2021_data, cons_2021_data)
|
| 50 |
|
|
|
|
| 82 |
return results
|
| 83 |
|
| 84 |
|
| 85 |
+
def ui_refresh(solar_cell_num, bess_nominal_capacity, fixed_consumption, base_price, peak_price):
|
| 86 |
results = recalculate(solar_cell_num=solar_cell_num, bess_nominal_capacity=bess_nominal_capacity, fixed_consumption=fixed_consumption)
|
| 87 |
|
| 88 |
fig1 = plotly_visualize_simulation(results, date_range=("2021-02-01", "2021-02-07"))
|
|
|
|
| 112 |
return (html, fig_monthly, fig1, fig2)
|
| 113 |
|
| 114 |
|
| 115 |
+
with gr.Blocks() as ui:
|
| 116 |
+
with gr.Row():
|
| 117 |
+
solar_slider = gr.Slider(0, 2000, 114, label="Solar cell number")
|
| 118 |
+
bess_slider = gr.Slider(0, 2000, 330, label="BESS nominal capacity in [Ah]")
|
| 119 |
+
fixed_consumption = gr.Checkbox(value=False, label="Use fixed consumption (10 kW)")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
|
| 121 |
+
with gr.Accordion("Advanced Pricing Settings", open=False):
|
| 122 |
+
base_price = gr.Number(value=0.1, label="Base energy price [€/kWh]")
|
| 123 |
+
peak_price = gr.Number(value=0.3, label="Peak energy price [€/kWh]")
|
| 124 |
+
|
| 125 |
+
run_btn = gr.Button("Run Simulation")
|
| 126 |
+
|
| 127 |
+
html_out = gr.HTML()
|
| 128 |
+
plot1 = gr.Plot()
|
| 129 |
+
plot2 = gr.Plot()
|
| 130 |
+
plot3 = gr.Plot()
|
| 131 |
+
|
| 132 |
+
run_btn.click(
|
| 133 |
+
ui_refresh,
|
| 134 |
+
inputs=[solar_slider, bess_slider, fixed_consumption, base_price, peak_price],
|
| 135 |
+
outputs=[html_out, plot1, plot2, plot3],
|
| 136 |
+
)
|
| 137 |
+
|
| 138 |
+
ui.launch()
|