openstef 3.4.45__py3-none-any.whl → 3.4.46__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- openstef/data/NL_terrestrial_radiation.csv +25585 -0
- openstef/data/NL_terrestrial_radiation.csv.license +3 -0
- openstef/feature_engineering/apply_features.py +4 -0
- openstef/feature_engineering/cyclic_features.py +60 -1
- {openstef-3.4.45.dist-info → openstef-3.4.46.dist-info}/METADATA +1 -1
- {openstef-3.4.45.dist-info → openstef-3.4.46.dist-info}/RECORD +9 -7
- {openstef-3.4.45.dist-info → openstef-3.4.46.dist-info}/LICENSE +0 -0
- {openstef-3.4.45.dist-info → openstef-3.4.46.dist-info}/WHEEL +0 -0
- {openstef-3.4.45.dist-info → openstef-3.4.46.dist-info}/top_level.txt +0 -0
@@ -31,6 +31,7 @@ from openstef.feature_engineering.weather_features import (
|
|
31
31
|
from openstef.feature_engineering.cyclic_features import (
|
32
32
|
add_seasonal_cyclic_features,
|
33
33
|
add_time_cyclic_features,
|
34
|
+
add_daylight_terrestrial_feature,
|
34
35
|
)
|
35
36
|
|
36
37
|
|
@@ -124,5 +125,8 @@ def apply_features(
|
|
124
125
|
# Adds polar time features (sine and cosine) to capture periodic patterns based on the timestamp index.
|
125
126
|
data = add_time_cyclic_features(data)
|
126
127
|
|
128
|
+
# Adds daylight terrestrial feature
|
129
|
+
data = add_daylight_terrestrial_feature(data)
|
130
|
+
|
127
131
|
# Return dataframe including all requested features
|
128
132
|
return data
|
@@ -13,6 +13,8 @@ import structlog
|
|
13
13
|
import logging
|
14
14
|
|
15
15
|
from openstef.settings import Settings
|
16
|
+
from openstef import PROJECT_ROOT
|
17
|
+
|
16
18
|
|
17
19
|
structlog.configure(
|
18
20
|
wrapper_class=structlog.make_filtering_bound_logger(
|
@@ -21,10 +23,65 @@ structlog.configure(
|
|
21
23
|
)
|
22
24
|
logger = structlog.get_logger(__name__)
|
23
25
|
|
24
|
-
|
26
|
+
TERRESTRIAL_RADIATION_CSV_PATH: str = (
|
27
|
+
PROJECT_ROOT / "openstef" / "data" / "NL_terrestrial_radiation.csv"
|
28
|
+
)
|
25
29
|
NUM_SECONDS_IN_A_DAY = 24 * 60 * 60
|
26
30
|
|
27
31
|
|
32
|
+
def add_daylight_terrestrial_feature(
|
33
|
+
data: pd.DataFrame,
|
34
|
+
path_to_terrestrial_radiation_csv: str = TERRESTRIAL_RADIATION_CSV_PATH,
|
35
|
+
) -> pd.DataFrame:
|
36
|
+
"""Add daylight terrestrial radiation feature to the input dataset. This function processes terrestrial radiation
|
37
|
+
data and aligns it with the time indices of the input dataset. The terrestrial radiation data is normalized,
|
38
|
+
interpolated, and merged with the main dataset to provide a feature representing terrestrial radiation.
|
39
|
+
|
40
|
+
Args:
|
41
|
+
data (pd.DataFrame):
|
42
|
+
The input dataset containing a time-indexed DataFrame.
|
43
|
+
path_to_terrestrial_radiation_csv (str):
|
44
|
+
File path to the CSV file containing terrestrial radiation data. The CSV file
|
45
|
+
should have a time-based index.
|
46
|
+
|
47
|
+
Returns:
|
48
|
+
pd.DataFrame:
|
49
|
+
The input dataset with an added column for the terrestrial radiation feature.
|
50
|
+
|
51
|
+
Notes:
|
52
|
+
- The function assumes the input data and the terrestrial radiation data share
|
53
|
+
the same time zone and frequency alignment.
|
54
|
+
- The terrestrial radiation values are normalized using z-score normalization.
|
55
|
+
|
56
|
+
"""
|
57
|
+
# Load the terrestrial radiation data
|
58
|
+
terrestrial_radiation = pd.read_csv(path_to_terrestrial_radiation_csv, index_col=0)
|
59
|
+
terrestrial_radiation.index = pd.to_datetime(terrestrial_radiation.index)
|
60
|
+
|
61
|
+
# Align the index with the input data's year
|
62
|
+
year_diff = data.index.min().year - terrestrial_radiation.index.min().year
|
63
|
+
terrestrial_radiation.index += pd.DateOffset(years=year_diff)
|
64
|
+
|
65
|
+
# Resample to 15-minute intervals, and interpolate missing values
|
66
|
+
terrestrial_radiation = terrestrial_radiation.resample("15min").mean().interpolate()
|
67
|
+
|
68
|
+
# Normalize the terrestrial radiation values using z-score normalization
|
69
|
+
terrestrial_radiation = (
|
70
|
+
terrestrial_radiation - terrestrial_radiation.mean(axis=0)
|
71
|
+
) / terrestrial_radiation.std(axis=0)
|
72
|
+
terrestrial_radiation.columns = ["daylight_continuous"]
|
73
|
+
|
74
|
+
# Make a copy of the DataFrame to avoid modifying the original
|
75
|
+
data = data.copy()
|
76
|
+
|
77
|
+
# Merge the terrestrial radiation data with the input dataset
|
78
|
+
data = data.merge(
|
79
|
+
terrestrial_radiation, left_index=True, right_index=True, how="left"
|
80
|
+
)
|
81
|
+
|
82
|
+
return data
|
83
|
+
|
84
|
+
|
28
85
|
def add_time_cyclic_features(
|
29
86
|
data: pd.DataFrame,
|
30
87
|
) -> pd.DataFrame:
|
@@ -35,6 +92,7 @@ def add_time_cyclic_features(
|
|
35
92
|
|
36
93
|
Returns:
|
37
94
|
DataFrame that is the same as input dataframe with extra columns for the added time of the day features.
|
95
|
+
|
38
96
|
"""
|
39
97
|
# Ensure the index is a DatetimeIndex
|
40
98
|
if not isinstance(data.index, pd.DatetimeIndex):
|
@@ -71,6 +129,7 @@ def add_seasonal_cyclic_features(
|
|
71
129
|
>>> data = pd.DataFrame(index=pd.date_range(start='2023-01-01', periods=365, freq='D'))
|
72
130
|
>>> data_with_features = add_cyclical_features(data)
|
73
131
|
>>> print(data_with_features.head())
|
132
|
+
|
74
133
|
"""
|
75
134
|
# Ensure the index is a DatetimeIndex
|
76
135
|
if not isinstance(data.index, pd.DatetimeIndex):
|
@@ -4,6 +4,8 @@ openstef/app_settings.py,sha256=EJTDtimctFQQ-3f7ZcOQaRYohpZk3JD6aZBWPFYM2_A,582
|
|
4
4
|
openstef/enums.py,sha256=Wmoag2p7G2cvENA1qt8FcVbAgo-MswXKxmq7vkxHaxs,2680
|
5
5
|
openstef/exceptions.py,sha256=U4u2LTcdT6cmzpipT2Jh7kq9nCjT_-6gntn8yjuhGU0,1993
|
6
6
|
openstef/settings.py,sha256=nSgkBqFxuqB3w7Rwo60i8j37c5ngDbt6vpjHS6QtJXQ,354
|
7
|
+
openstef/data/NL_terrestrial_radiation.csv,sha256=A4kbW56GDzWi4tWUwY2C-4PiOvcKJCwkWQQtdg4ekPE,820246
|
8
|
+
openstef/data/NL_terrestrial_radiation.csv.license,sha256=AxxHusqwIXU5RHl5ZMU65LyXmgtbj6QlcnFaOEN4kEE,145
|
7
9
|
openstef/data/dutch_holidays.csv,sha256=Cg8EYjXp1O0lcFOkIOmrS5HaOArrxZwOXsZ9pVkIcKI,49847
|
8
10
|
openstef/data/dutch_holidays.csv.license,sha256=AxxHusqwIXU5RHl5ZMU65LyXmgtbj6QlcnFaOEN4kEE,145
|
9
11
|
openstef/data/pv_single_coefs.csv,sha256=jadIEYdHvl1lnV_06X_FASkJZ6C3Hecs5xZnH1gPMvI,24779
|
@@ -18,9 +20,9 @@ openstef/data_classes/model_specifications.py,sha256=Uod1W3QzhRqVLb6zvXwxh9wRL3E
|
|
18
20
|
openstef/data_classes/prediction_job.py,sha256=_o5_9HYv6ERTIWlcMpUE-mWwe7dRpaiP83dgNpqpa5Y,5657
|
19
21
|
openstef/data_classes/split_function.py,sha256=ljQIQQu1t1Y_CVWGAy25jrM6wG9odIVVQVimrT1n-1s,3358
|
20
22
|
openstef/feature_engineering/__init__.py,sha256=bIyGTSA4V5VoOLTwdaiJJAnozmpSzvQooVYlsf8H4eU,163
|
21
|
-
openstef/feature_engineering/apply_features.py,sha256=
|
23
|
+
openstef/feature_engineering/apply_features.py,sha256=S9HSsooDPcSSyEw9kixEhjjk3MAkAfyK1VhZKg5R0gA,4995
|
22
24
|
openstef/feature_engineering/bidding_zone_to_country_mapping.py,sha256=u9aabjFDImydkO6_cXiaQxBT4gb5zy0gGTg2EoIUO_Y,2106
|
23
|
-
openstef/feature_engineering/cyclic_features.py,sha256=
|
25
|
+
openstef/feature_engineering/cyclic_features.py,sha256=0Z3wZeF_qrkmEcOq91gtdSMZucAq99kUoBuFDV0SHqk,5962
|
24
26
|
openstef/feature_engineering/data_preparation.py,sha256=htca9LBO3ZN1D-iX4vXf0UN1fw_rRO7y6N3AuYVMpfk,5628
|
25
27
|
openstef/feature_engineering/feature_adder.py,sha256=aSqDl_gUrB3H2TD3cNvU5JniY_KOb4u4a2A6J7zB2BQ,6835
|
26
28
|
openstef/feature_engineering/feature_applicator.py,sha256=DR7jayrEMlra4BFL1Ps5WV2fxbkQ6VaOTa5RIKM-YNk,7447
|
@@ -90,8 +92,8 @@ openstef/tasks/utils/predictionjobloop.py,sha256=Ysy3zF5lzPMz_asYDKeF5m0qgVT3tCt
|
|
90
92
|
openstef/tasks/utils/taskcontext.py,sha256=L9K14ycwgVxbIVUjH2DIn_QWbnu-OfxcGtQ1K9T6sus,5630
|
91
93
|
openstef/validation/__init__.py,sha256=bIyGTSA4V5VoOLTwdaiJJAnozmpSzvQooVYlsf8H4eU,163
|
92
94
|
openstef/validation/validation.py,sha256=HVgreHvcZvPazfwC3NNE8_3lsMsZEd_42osCAg1_6W4,11128
|
93
|
-
openstef-3.4.
|
94
|
-
openstef-3.4.
|
95
|
-
openstef-3.4.
|
96
|
-
openstef-3.4.
|
97
|
-
openstef-3.4.
|
95
|
+
openstef-3.4.46.dist-info/LICENSE,sha256=7Pm2fWFFHHUG5lDHed1vl5CjzxObIXQglnYsEdtjo_k,14907
|
96
|
+
openstef-3.4.46.dist-info/METADATA,sha256=UJAm_jF1JSm4lcXL2tPkwR7XBaEleozpBF6iJnI8D4U,8068
|
97
|
+
openstef-3.4.46.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
98
|
+
openstef-3.4.46.dist-info/top_level.txt,sha256=kD0H4PqrQoncZ957FvqwfBxa89kTrun4Z_RAPs_HhLs,9
|
99
|
+
openstef-3.4.46.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|