Skip to content

Commit 85643e2

Browse files
committed
Create test_arima.py
1 parent abc5c67 commit 85643e2

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

scripts/test_arima.py

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import os
2+
from pownet.stochastic.solar import SolarTSModel
3+
from pownet.stochastic.demand import DemandTSModel
4+
import pandas as pd
5+
import matplotlib.pyplot as plt
6+
7+
import logging
8+
9+
# Show info
10+
logging.basicConfig(level=logging.INFO)
11+
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+
# )
24+
25+
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()
33+
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)
37+
38+
39+
duration = 10
40+
# plt.plot(predictions[: 24 * 3], label="Predictions")
41+
plt.plot(synthetic[: 24 * duration], label="Synthetic")
42+
plt.plot(
43+
data.set_index("datetime")["demand"].iloc[: 24 * duration],
44+
label="Actual",
45+
)
46+
plt.legend()
47+
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)