Spaces:
Sleeping
Sleeping
Daniel Varga commited on
Commit ·
a714bca
1
Parent(s): 961a934
does not crash
Browse files- v2/app.py +10 -6
- v2/visualization.py +1 -2
v2/app.py
CHANGED
|
@@ -21,6 +21,9 @@ from bess import BatteryModel
|
|
| 21 |
met_2021_data, cons_2021_data = read_datasets()
|
| 22 |
|
| 23 |
|
|
|
|
|
|
|
|
|
|
| 24 |
def recalculate(**uiParameters):
|
| 25 |
fixed_consumption = uiParameters['fixed_consumption']
|
| 26 |
del uiParameters['fixed_consumption']
|
|
@@ -50,11 +53,14 @@ def recalculate(**uiParameters):
|
|
| 50 |
time_interval_h = time_interval_min / 60
|
| 51 |
|
| 52 |
# for faster testing:
|
| 53 |
-
DATASET_TRUNCATED_SIZE =
|
| 54 |
if DATASET_TRUNCATED_SIZE is not None:
|
| 55 |
print("Truncating dataset to", DATASET_TRUNCATED_SIZE, "datapoints, that is", DATASET_TRUNCATED_SIZE * time_interval_h / 24, "days")
|
| 56 |
all_data = all_data.iloc[:DATASET_TRUNCATED_SIZE]
|
| 57 |
|
|
|
|
|
|
|
|
|
|
| 58 |
print("Working with", solar_parameters.solar_cell_num, "solar cells, that's a maximum production of", all_data['Production'].max(), "kW.")
|
| 59 |
|
| 60 |
all_data_with_predictions = all_data.copy()
|
|
@@ -66,16 +72,14 @@ def recalculate(**uiParameters):
|
|
| 66 |
|
| 67 |
all_data_with_predictions['Consumption_fees'] = precalculated_supplier.consumption_fees # [HUF / kWh]
|
| 68 |
|
| 69 |
-
battery_model = BatteryModel(capacity_Ah=
|
| 70 |
|
| 71 |
# param_1 is prob of choosing PASSIVE
|
| 72 |
# param_2 is prob of choosing NETWORK_CHARGE
|
| 73 |
decider = RandomDecider(np.array([0.0, 0.0]), precalculated_supplier)
|
| 74 |
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
results = simulator(battery_model, all_data, decider)
|
| 79 |
return results
|
| 80 |
|
| 81 |
|
|
|
|
| 21 |
met_2021_data, cons_2021_data = read_datasets()
|
| 22 |
|
| 23 |
|
| 24 |
+
# TODO move out everything that should not be recalculated.
|
| 25 |
+
# TODO actually use uiParameters.
|
| 26 |
+
# TODO ui_refresh spawns its own Supplier, which is just dumb.
|
| 27 |
def recalculate(**uiParameters):
|
| 28 |
fixed_consumption = uiParameters['fixed_consumption']
|
| 29 |
del uiParameters['fixed_consumption']
|
|
|
|
| 53 |
time_interval_h = time_interval_min / 60
|
| 54 |
|
| 55 |
# for faster testing:
|
| 56 |
+
DATASET_TRUNCATED_SIZE = None
|
| 57 |
if DATASET_TRUNCATED_SIZE is not None:
|
| 58 |
print("Truncating dataset to", DATASET_TRUNCATED_SIZE, "datapoints, that is", DATASET_TRUNCATED_SIZE * time_interval_h / 24, "days")
|
| 59 |
all_data = all_data.iloc[:DATASET_TRUNCATED_SIZE]
|
| 60 |
|
| 61 |
+
if fixed_consumption:
|
| 62 |
+
all_data['Consumption'] = 10
|
| 63 |
+
|
| 64 |
print("Working with", solar_parameters.solar_cell_num, "solar cells, that's a maximum production of", all_data['Production'].max(), "kW.")
|
| 65 |
|
| 66 |
all_data_with_predictions = all_data.copy()
|
|
|
|
| 72 |
|
| 73 |
all_data_with_predictions['Consumption_fees'] = precalculated_supplier.consumption_fees # [HUF / kWh]
|
| 74 |
|
| 75 |
+
battery_model = BatteryModel(capacity_Ah=600, time_interval_h=time_interval_h)
|
| 76 |
|
| 77 |
# param_1 is prob of choosing PASSIVE
|
| 78 |
# param_2 is prob of choosing NETWORK_CHARGE
|
| 79 |
decider = RandomDecider(np.array([0.0, 0.0]), precalculated_supplier)
|
| 80 |
|
| 81 |
+
results, total_network_fee = simulator(battery_model, all_data_with_predictions, decider)
|
| 82 |
+
print(f"{total_network_fee=}")
|
|
|
|
|
|
|
| 83 |
return results
|
| 84 |
|
| 85 |
|
v2/visualization.py
CHANGED
|
@@ -86,8 +86,7 @@ def plotly_visualize_simulation(results, date_range):
|
|
| 86 |
return fig
|
| 87 |
|
| 88 |
|
| 89 |
-
def plotly_visualize_monthly(
|
| 90 |
-
consumption = data_processing.monthly_analysis(result)
|
| 91 |
# months = monthly_results.index
|
| 92 |
months = list(range(1, 13))
|
| 93 |
fig = go.Figure()
|
|
|
|
| 86 |
return fig
|
| 87 |
|
| 88 |
|
| 89 |
+
def plotly_visualize_monthly(consumption):
|
|
|
|
| 90 |
# months = monthly_results.index
|
| 91 |
months = list(range(1, 13))
|
| 92 |
fig = go.Figure()
|