Quarter embedding using trigonometry + more thesis writing
This commit is contained in:
@@ -46,7 +46,7 @@ class NrvDataset(Dataset):
|
||||
if self.data_config.LOAD_HISTORY:
|
||||
self.history_features.append("total_load")
|
||||
if self.data_config.PV_HISTORY:
|
||||
self.history_features.append("pv_gen_forecast")
|
||||
self.history_features.append("pv_history")
|
||||
if self.data_config.WIND_HISTORY:
|
||||
self.history_features.append("wind_history")
|
||||
if self.data_config.NOMINAL_NET_POSITION:
|
||||
@@ -56,7 +56,7 @@ class NrvDataset(Dataset):
|
||||
if self.data_config.LOAD_FORECAST:
|
||||
self.forecast_features.append("load_forecast")
|
||||
if self.data_config.PV_FORECAST:
|
||||
self.forecast_features.append("pv_gen_forecast")
|
||||
self.forecast_features.append("pv_forecast")
|
||||
if self.data_config.WIND_FORECAST:
|
||||
self.forecast_features.append("wind_forecast")
|
||||
if self.data_config.NOMINAL_NET_POSITION:
|
||||
|
||||
@@ -40,7 +40,7 @@ class DataConfig:
|
||||
|
||||
|
||||
class DataProcessor:
|
||||
def __init__(self, data_config: DataConfig, lstm: bool = False, path:str="./"):
|
||||
def __init__(self, data_config: DataConfig, lstm: bool = False, path: str = "./"):
|
||||
self.batch_size = 2048
|
||||
self.path = path
|
||||
self.lstm = lstm
|
||||
@@ -55,20 +55,21 @@ class DataProcessor:
|
||||
|
||||
self.history_features = self.get_nrv_history()
|
||||
self.future_features = self.get_load_forecast()
|
||||
# self.pv_forecast = self.get_pv_forecast()
|
||||
self.pv_forecast = self.get_pv_forecast()
|
||||
self.wind_forecast = self.get_wind_forecast()
|
||||
|
||||
self.all_features = self.history_features.merge(
|
||||
self.future_features, on="datetime", how="left"
|
||||
)
|
||||
# self.all_features = self.all_features.merge(
|
||||
# self.pv_forecast, on="datetime", how="left"
|
||||
# )
|
||||
|
||||
self.all_features = self.all_features.merge(
|
||||
self.pv_forecast, on="datetime", how="left"
|
||||
)
|
||||
|
||||
self.all_features = self.all_features.merge(
|
||||
self.wind_forecast, on="datetime", how="left"
|
||||
)
|
||||
|
||||
|
||||
self.all_features = self.all_features.merge(
|
||||
self.get_nominal_net_position(), on="datetime", how="left"
|
||||
)
|
||||
@@ -86,6 +87,7 @@ class DataProcessor:
|
||||
|
||||
self.nrv_scaler = MinMaxScaler(feature_range=(-1, 1))
|
||||
self.load_forecast_scaler = MinMaxScaler(feature_range=(-1, 1))
|
||||
self.pv_forecast_scaler = MinMaxScaler(feature_range=(-1, 1))
|
||||
self.wind_forecast_scaler = MinMaxScaler(feature_range=(-1, 1))
|
||||
self.nominal_net_position_scaler = MinMaxScaler(feature_range=(-1, 1))
|
||||
|
||||
@@ -151,10 +153,19 @@ class DataProcessor:
|
||||
def get_pv_forecast(self):
|
||||
df = pd.read_csv(self.path + pv_forecast_data_path, delimiter=";")
|
||||
|
||||
df = df[df["region"] == "Belgium"]
|
||||
|
||||
df = df.rename(
|
||||
columns={"dayahead11hforecast": "pv_forecast", "Datetime": "datetime"}
|
||||
columns={
|
||||
"dayahead11hforecast": "pv_forecast",
|
||||
"Datetime": "datetime",
|
||||
"measured": "pv_history",
|
||||
}
|
||||
)
|
||||
df = df[["datetime", "pv_forecast"]]
|
||||
df = df[["datetime", "pv_forecast", "pv_history"]]
|
||||
|
||||
# replace nan by zero
|
||||
df = df.fillna(0)
|
||||
|
||||
df = df.groupby("datetime").mean().reset_index()
|
||||
df["datetime"] = pd.to_datetime(df["datetime"], utc=True)
|
||||
@@ -165,7 +176,11 @@ class DataProcessor:
|
||||
df = pd.read_csv(self.path + wind_forecast_data_path, delimiter=";")
|
||||
|
||||
df = df.rename(
|
||||
columns={"measured": "wind_history", "dayaheadforecast": "wind_forecast", "datetime": "datetime"}
|
||||
columns={
|
||||
"measured": "wind_history",
|
||||
"dayaheadforecast": "wind_forecast",
|
||||
"datetime": "datetime",
|
||||
}
|
||||
)
|
||||
df = df[["datetime", "wind_forecast", "wind_history"]]
|
||||
|
||||
@@ -198,8 +213,6 @@ class DataProcessor:
|
||||
df = df.set_index("datetime").resample("15min").ffill().reset_index()
|
||||
return df
|
||||
|
||||
|
||||
|
||||
def set_batch_size(self, batch_size: int):
|
||||
self.batch_size = batch_size
|
||||
|
||||
@@ -233,15 +246,26 @@ class DataProcessor:
|
||||
train_df["total_load"] = self.load_forecast_scaler.transform(
|
||||
train_df["total_load"].values.reshape(-1, 1)
|
||||
).reshape(-1)
|
||||
|
||||
train_df["pv_forecast"] = self.pv_forecast_scaler.fit_transform(
|
||||
train_df["pv_forecast"].values.reshape(-1, 1)
|
||||
).reshape(-1)
|
||||
|
||||
train_df["pv_history"] = self.pv_forecast_scaler.transform(
|
||||
train_df["pv_history"].values.reshape(-1, 1)
|
||||
).reshape(-1)
|
||||
|
||||
train_df["wind_forecast"] = self.wind_forecast_scaler.fit_transform(
|
||||
train_df["wind_forecast"].values.reshape(-1, 1)
|
||||
).reshape(-1)
|
||||
train_df["wind_history"] = self.wind_forecast_scaler.transform(
|
||||
train_df["wind_history"].values.reshape(-1, 1)
|
||||
).reshape(-1)
|
||||
train_df["nominal_net_position"] = self.nominal_net_position_scaler.fit_transform(
|
||||
train_df["nominal_net_position"].values.reshape(-1, 1)
|
||||
).reshape(-1)
|
||||
train_df["nominal_net_position"] = (
|
||||
self.nominal_net_position_scaler.fit_transform(
|
||||
train_df["nominal_net_position"].values.reshape(-1, 1)
|
||||
).reshape(-1)
|
||||
)
|
||||
|
||||
train_dataset = NrvDataset(
|
||||
train_df,
|
||||
@@ -253,7 +277,10 @@ class DataProcessor:
|
||||
return self.get_dataloader(train_dataset, shuffle=shuffle)
|
||||
|
||||
def get_test_dataloader(
|
||||
self, transform: bool = True, predict_sequence_length: int = 96, full_day_skip: bool = False
|
||||
self,
|
||||
transform: bool = True,
|
||||
predict_sequence_length: int = 96,
|
||||
full_day_skip: bool = False,
|
||||
):
|
||||
test_df = self.all_features.copy()
|
||||
|
||||
@@ -273,16 +300,26 @@ class DataProcessor:
|
||||
test_df["total_load"] = self.load_forecast_scaler.transform(
|
||||
test_df["total_load"].values.reshape(-1, 1)
|
||||
).reshape(-1)
|
||||
|
||||
test_df["pv_forecast"] = self.pv_forecast_scaler.transform(
|
||||
test_df["pv_forecast"].values.reshape(-1, 1)
|
||||
).reshape(-1)
|
||||
|
||||
test_df["pv_history"] = self.pv_forecast_scaler.transform(
|
||||
test_df["pv_history"].values.reshape(-1, 1)
|
||||
).reshape(-1)
|
||||
|
||||
test_df["wind_forecast"] = self.wind_forecast_scaler.transform(
|
||||
test_df["wind_forecast"].values.reshape(-1, 1)
|
||||
).reshape(-1)
|
||||
test_df["wind_history"] = self.wind_forecast_scaler.transform(
|
||||
test_df["wind_history"].values.reshape(-1, 1)
|
||||
).reshape(-1)
|
||||
test_df["nominal_net_position"] = self.nominal_net_position_scaler.transform(
|
||||
test_df["nominal_net_position"].values.reshape(-1, 1)
|
||||
).reshape(-1)
|
||||
|
||||
test_df["nominal_net_position"] = (
|
||||
self.nominal_net_position_scaler.transform(
|
||||
test_df["nominal_net_position"].values.reshape(-1, 1)
|
||||
).reshape(-1)
|
||||
)
|
||||
|
||||
test_dataset = NrvDataset(
|
||||
test_df,
|
||||
@@ -294,12 +331,17 @@ class DataProcessor:
|
||||
return self.get_dataloader(test_dataset, shuffle=False)
|
||||
|
||||
def get_dataloaders(
|
||||
self, transform: bool = True, predict_sequence_length: int = 96, full_day_skip: bool = False
|
||||
self,
|
||||
transform: bool = True,
|
||||
predict_sequence_length: int = 96,
|
||||
full_day_skip: bool = False,
|
||||
):
|
||||
return self.get_train_dataloader(
|
||||
transform=transform, predict_sequence_length=predict_sequence_length
|
||||
), self.get_test_dataloader(
|
||||
transform=transform, predict_sequence_length=predict_sequence_length, full_day_skip=full_day_skip
|
||||
transform=transform,
|
||||
predict_sequence_length=predict_sequence_length,
|
||||
full_day_skip=full_day_skip,
|
||||
)
|
||||
|
||||
def inverse_transform(self, input_data):
|
||||
@@ -338,7 +380,7 @@ class DataProcessor:
|
||||
time_feature_size *= 96
|
||||
if self.data_config.DAY_OF_WEEK:
|
||||
time_feature_size *= 7
|
||||
|
||||
|
||||
if time_feature_size == 1:
|
||||
return 0
|
||||
return time_feature_size
|
||||
|
||||
Reference in New Issue
Block a user