Skip to content

Commit e0b95b2

Browse files
committed
Add tutorial scripts
1 parent d38137b commit e0b95b2

File tree

2 files changed

+59
-49
lines changed

2 files changed

+59
-49
lines changed

scripts/run_quickstart.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
""" This script provides an example of how to run PowNet 2.0.
2+
"""
3+
4+
import os
5+
from pownet.core import Simulator
6+
7+
8+
def main():
9+
10+
# --------- User inputs
11+
12+
input_folder = "..//model_library"
13+
output_folder = "..//temptemp"
14+
15+
model_name = "dummy"
16+
model_year = 2016
17+
18+
# Simulation parameters
19+
sim_horizon = 24
20+
steps_to_run = 2
21+
solver = "gurobi" # or highs
22+
23+
# --------- End of user inputs
24+
25+
# Run the simulation
26+
simulator = Simulator(
27+
input_folder=input_folder,
28+
model_name=model_name,
29+
model_year=model_year,
30+
)
31+
32+
simulator.run(
33+
sim_horizon=sim_horizon,
34+
steps_to_run=steps_to_run,
35+
solver=solver,
36+
)
37+
38+
# Write the simulation results
39+
if not os.path.exists(output_folder):
40+
os.makedirs(output_folder)
41+
simulator.write_results(output_folder)
42+
43+
# Plot the results
44+
simulator.plot_fuelmix("bar", output_folder)
45+
simulator.plot_unit_status(output_folder)
46+
47+
48+
if __name__ == "__main__":
49+
main()

scripts/test_arima.py

Lines changed: 10 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import os
21
from pownet.stochastic.solar import SolarTSModel
3-
from pownet.stochastic.demand import DemandTSModel
42
import pandas as pd
53
import matplotlib.pyplot as plt
64

@@ -9,62 +7,25 @@
97
# Show info
108
logging.basicConfig(level=logging.INFO)
119

12-
# %% Demand
13-
14-
data = pd.read_csv("../temp/hourly_demand_2023.csv")
15-
16-
demand_model = DemandTSModel()
17-
demand_model.load_data(data)
18-
exog_vars = ["temp", "rhum", "prcp", "weekend"]
19-
20-
# arima_order, seasonal_order = demand_model.find_best_model(
21-
# target_column="demand",
22-
# exog_vars=exog_vars,
23-
# )
10+
# %% Solar
11+
data = pd.read_csv("../temp/merra_2019.csv")
2412

13+
solar_model = SolarTSModel()
14+
solar_model.load_data(data)
2515

26-
demand_model.fit(
27-
target_column="demand",
28-
exog_vars=exog_vars,
29-
arima_order=(1, 0, 1),
30-
seasonal_order=(0, 0, 0, 0),
31-
)
32-
predictions = demand_model.predict()
16+
solar_model.fit(target_column="ground_irradiance", arima_order=(2, 1, 2))
17+
predictions = solar_model.predict()
3318

34-
data.index = pd.to_datetime(data["datetime"])
35-
exog_data = data[exog_vars].astype(float)
36-
synthetic = demand_model.get_synthetic(exog_data=exog_data)
19+
resids = solar_model.pred_residuals
3720

21+
synthetic = solar_model.get_synthetic()
3822

39-
duration = 10
23+
duration = 30
4024
# plt.plot(predictions[: 24 * 3], label="Predictions")
4125
plt.plot(synthetic[: 24 * duration], label="Synthetic")
4226
plt.plot(
43-
data.set_index("datetime")["demand"].iloc[: 24 * duration],
27+
data.set_index("datetime")["ground_irradiance"].iloc[: 24 * duration],
4428
label="Actual",
4529
)
4630
plt.legend()
4731
plt.show()
48-
49-
"""# %% Solar
50-
data = pd.read_csv("../temp/merra_2019.csv")
51-
52-
solar_model = SolarTSModel()
53-
solar_model.load_data(data)
54-
55-
solar_model.fit(target_column="ground_irradiance", arima_order=(2, 1, 2))
56-
predictions = solar_model.predict()
57-
58-
resids = solar_model.pred_residuals"""
59-
60-
# synthetic = solar_model.get_synthetic()
61-
62-
# duration = 30
63-
# # plt.plot(predictions[: 24 * 3], label="Predictions")
64-
# plt.plot(synthetic[: 24 * duration], label="Synthetic")
65-
# plt.plot(
66-
# data.set_index("datetime")["ground_irradiance"].iloc[: 24 * duration],
67-
# label="Actual",
68-
# )
69-
# plt.legend()
70-
# plt.show()

0 commit comments

Comments
 (0)