ocf-data-sampler 0.5.12__py3-none-any.whl → 0.5.14__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.
Potentially problematic release.
This version of ocf-data-sampler might be problematic. Click here for more details.
- ocf_data_sampler/config/model.py +0 -17
- ocf_data_sampler/select/select_spatial_slice.py +4 -4
- ocf_data_sampler/torch_datasets/datasets/pvnet_uk.py +7 -7
- ocf_data_sampler/torch_datasets/datasets/site.py +7 -7
- ocf_data_sampler/torch_datasets/utils/config_normalization_values_to_dicts.py +29 -27
- {ocf_data_sampler-0.5.12.dist-info → ocf_data_sampler-0.5.14.dist-info}/METADATA +1 -1
- {ocf_data_sampler-0.5.12.dist-info → ocf_data_sampler-0.5.14.dist-info}/RECORD +9 -9
- {ocf_data_sampler-0.5.12.dist-info → ocf_data_sampler-0.5.14.dist-info}/WHEEL +0 -0
- {ocf_data_sampler-0.5.12.dist-info → ocf_data_sampler-0.5.14.dist-info}/top_level.txt +0 -0
ocf_data_sampler/config/model.py
CHANGED
|
@@ -172,23 +172,6 @@ class NormalisationConstantsMixin(Base):
|
|
|
172
172
|
"""Normalisation constants for multiple channels."""
|
|
173
173
|
normalisation_constants: dict[str, NormalisationValues]
|
|
174
174
|
|
|
175
|
-
@property
|
|
176
|
-
def channel_means(self) -> dict[str, float]:
|
|
177
|
-
"""Return the channel means."""
|
|
178
|
-
return {
|
|
179
|
-
channel: norm_values.mean
|
|
180
|
-
for channel, norm_values in self.normalisation_constants.items()
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
@property
|
|
185
|
-
def channel_stds(self) -> dict[str, float]:
|
|
186
|
-
"""Return the channel standard deviations."""
|
|
187
|
-
return {
|
|
188
|
-
channel: norm_values.std
|
|
189
|
-
for channel, norm_values in self.normalisation_constants.items()
|
|
190
|
-
}
|
|
191
|
-
|
|
192
175
|
|
|
193
176
|
class Satellite(TimeWindowMixin, DropoutMixin, SpatialWindowMixin, NormalisationConstantsMixin):
|
|
194
177
|
"""Satellite configuration model."""
|
|
@@ -25,13 +25,13 @@ def _get_pixel_index_location(da: xr.DataArray, location: Location) -> tuple[int
|
|
|
25
25
|
x, y = location.in_coord_system(target_coords)
|
|
26
26
|
|
|
27
27
|
# Check that requested point lies within the data
|
|
28
|
-
if not (da[x_dim].
|
|
28
|
+
if not (da[x_dim].values[0] < x < da[x_dim].values[-1]):
|
|
29
29
|
raise ValueError(
|
|
30
|
-
f"{x} is not in the interval {da[x_dim].
|
|
30
|
+
f"{x} is not in the interval {da[x_dim].values[0]}: {da[x_dim].values[-1]}",
|
|
31
31
|
)
|
|
32
|
-
if not (da[y_dim].
|
|
32
|
+
if not (da[y_dim].values[0] < y < da[y_dim].values[-1]):
|
|
33
33
|
raise ValueError(
|
|
34
|
-
f"{y} is not in the interval {da[y_dim].
|
|
34
|
+
f"{y} is not in the interval {da[y_dim].values[0]}: {da[y_dim].values[-1]}",
|
|
35
35
|
)
|
|
36
36
|
|
|
37
37
|
x_index = da.get_index(x_dim)
|
|
@@ -137,10 +137,10 @@ class AbstractPVNetUKDataset(Dataset):
|
|
|
137
137
|
for nwp_key, da_nwp in dataset_dict["nwp"].items():
|
|
138
138
|
|
|
139
139
|
# Standardise and convert to NumpyBatch
|
|
140
|
-
|
|
141
|
-
|
|
140
|
+
channel_means = self.means_dict["nwp"][nwp_key]
|
|
141
|
+
channel_stds = self.stds_dict["nwp"][nwp_key]
|
|
142
142
|
|
|
143
|
-
da_nwp = (da_nwp -
|
|
143
|
+
da_nwp = (da_nwp - channel_means) / channel_stds
|
|
144
144
|
|
|
145
145
|
nwp_numpy_modalities[nwp_key] = convert_nwp_to_numpy_sample(da_nwp)
|
|
146
146
|
|
|
@@ -151,17 +151,17 @@ class AbstractPVNetUKDataset(Dataset):
|
|
|
151
151
|
da_sat = dataset_dict["sat"]
|
|
152
152
|
|
|
153
153
|
# Standardise and convert to NumpyBatch
|
|
154
|
-
|
|
155
|
-
|
|
154
|
+
channel_means = self.means_dict["sat"]
|
|
155
|
+
channel_stds = self.stds_dict["sat"]
|
|
156
156
|
|
|
157
|
-
da_sat = (da_sat -
|
|
157
|
+
da_sat = (da_sat - channel_means) / channel_stds
|
|
158
158
|
|
|
159
159
|
numpy_modalities.append(convert_satellite_to_numpy_sample(da_sat))
|
|
160
160
|
|
|
161
161
|
if "gsp" in dataset_dict:
|
|
162
162
|
gsp_config = self.config.input_data.gsp
|
|
163
163
|
da_gsp = dataset_dict["gsp"]
|
|
164
|
-
da_gsp = da_gsp / da_gsp.effective_capacity_mwp
|
|
164
|
+
da_gsp = da_gsp / da_gsp.effective_capacity_mwp.values
|
|
165
165
|
|
|
166
166
|
# Convert to NumpyBatch
|
|
167
167
|
numpy_modalities.append(
|
|
@@ -82,10 +82,10 @@ def process_and_combine_datasets(
|
|
|
82
82
|
|
|
83
83
|
# Standardise and convert to NumpyBatch
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
channel_means = means_dict["nwp"][nwp_key]
|
|
86
|
+
channel_stds = stds_dict["nwp"][nwp_key]
|
|
87
87
|
|
|
88
|
-
da_nwp = (da_nwp -
|
|
88
|
+
da_nwp = (da_nwp - channel_means) / channel_stds
|
|
89
89
|
|
|
90
90
|
nwp_numpy_modalities[nwp_key] = convert_nwp_to_numpy_sample(da_nwp)
|
|
91
91
|
|
|
@@ -96,16 +96,16 @@ def process_and_combine_datasets(
|
|
|
96
96
|
da_sat = dataset_dict["sat"]
|
|
97
97
|
|
|
98
98
|
# Standardise and convert to NumpyBatch
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
channel_means = means_dict["sat"]
|
|
100
|
+
channel_stds = stds_dict["sat"]
|
|
101
101
|
|
|
102
|
-
da_sat = (da_sat -
|
|
102
|
+
da_sat = (da_sat - channel_means) / channel_stds
|
|
103
103
|
|
|
104
104
|
numpy_modalities.append(convert_satellite_to_numpy_sample(da_sat))
|
|
105
105
|
|
|
106
106
|
if "site" in dataset_dict:
|
|
107
107
|
da_sites = dataset_dict["site"]
|
|
108
|
-
da_sites = da_sites / da_sites.capacity_kwp
|
|
108
|
+
da_sites = da_sites / da_sites.capacity_kwp.values
|
|
109
109
|
|
|
110
110
|
# Convert to NumpyBatch
|
|
111
111
|
numpy_modalities.append(convert_site_to_numpy_sample(da_sites))
|
|
@@ -1,28 +1,14 @@
|
|
|
1
|
-
"""Utility function for converting
|
|
1
|
+
"""Utility function for converting normalisation constants in the config to arrays."""
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import numpy as np
|
|
4
4
|
|
|
5
5
|
from ocf_data_sampler.config import Configuration
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
def channel_dict_to_dataarray(channel_dict: dict[str, float]) -> xr.DataArray:
|
|
9
|
-
"""Converts a dictionary of channel values to a DataArray.
|
|
10
|
-
|
|
11
|
-
Args:
|
|
12
|
-
channel_dict: Dictionary mapping channel names (str) to their values (float).
|
|
13
|
-
|
|
14
|
-
Returns:
|
|
15
|
-
xr.DataArray: A 1D DataArray with channels as coordinates.
|
|
16
|
-
"""
|
|
17
|
-
return xr.DataArray(
|
|
18
|
-
list(channel_dict.values()),
|
|
19
|
-
coords={"channel": list(channel_dict.keys())},
|
|
20
|
-
)
|
|
21
|
-
|
|
22
8
|
def config_normalization_values_to_dicts(
|
|
23
9
|
config: Configuration,
|
|
24
|
-
) -> tuple[dict[str,
|
|
25
|
-
"""Construct
|
|
10
|
+
) -> tuple[dict[str, np.ndarray | dict[str, np.ndarray]]]:
|
|
11
|
+
"""Construct numpy arrays of mean and std values from the config normalisation constants.
|
|
26
12
|
|
|
27
13
|
Args:
|
|
28
14
|
config: Data configuration.
|
|
@@ -40,18 +26,34 @@ def config_normalization_values_to_dicts(
|
|
|
40
26
|
stds_dict["nwp"] = {}
|
|
41
27
|
|
|
42
28
|
for nwp_key in config.input_data.nwp:
|
|
43
|
-
|
|
29
|
+
nwp_config = config.input_data.nwp[nwp_key]
|
|
44
30
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
31
|
+
means_list = []
|
|
32
|
+
stds_list = []
|
|
33
|
+
|
|
34
|
+
for channel in list(nwp_config.channels):
|
|
35
|
+
# These accumulated channels are diffed and renamed
|
|
36
|
+
if channel in nwp_config.accum_channels:
|
|
37
|
+
channel =f"diff_{channel}"
|
|
38
|
+
|
|
39
|
+
means_list.append(nwp_config.normalisation_constants[channel].mean)
|
|
40
|
+
stds_list.append(nwp_config.normalisation_constants[channel].std)
|
|
41
|
+
|
|
42
|
+
means_dict["nwp"][nwp_key] = np.array(means_list)[None, :, None, None]
|
|
43
|
+
stds_dict["nwp"][nwp_key] = np.array(stds_list)[None, :, None, None]
|
|
51
44
|
|
|
52
45
|
if config.input_data.satellite is not None:
|
|
46
|
+
sat_config = config.input_data.satellite
|
|
47
|
+
|
|
48
|
+
means_list = []
|
|
49
|
+
stds_list = []
|
|
50
|
+
|
|
51
|
+
for channel in list(config.input_data.satellite.channels):
|
|
52
|
+
means_list.append(sat_config.normalisation_constants[channel].mean)
|
|
53
|
+
stds_list.append(sat_config.normalisation_constants[channel].std)
|
|
53
54
|
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
# Convert to array and expand dimensions so we can normalise the 4D sat and NWP sources
|
|
56
|
+
means_dict["sat"] = np.array(means_list)[None, :, None, None]
|
|
57
|
+
stds_dict["sat"] = np.array(stds_list)[None, :, None, None]
|
|
56
58
|
|
|
57
59
|
return means_dict, stds_dict
|
|
@@ -2,7 +2,7 @@ ocf_data_sampler/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,
|
|
|
2
2
|
ocf_data_sampler/utils.py,sha256=CTJf9bjHjO8vOJebUtXiMpvgwUpF7gEOjjaoE77fhTk,1177
|
|
3
3
|
ocf_data_sampler/config/__init__.py,sha256=O29mbH0XG2gIY1g3BaveGCnpBO2SFqdu-qzJ7a6evl0,223
|
|
4
4
|
ocf_data_sampler/config/load.py,sha256=LL-7wemI8o4KPkx35j-wQ3HjsMvDgqXr7G46IcASfnU,632
|
|
5
|
-
ocf_data_sampler/config/model.py,sha256=
|
|
5
|
+
ocf_data_sampler/config/model.py,sha256=ucddp09yM4HGZKVuW-0N8vLGqLVAo_S4mPT89N_iG-0,11881
|
|
6
6
|
ocf_data_sampler/config/save.py,sha256=m8SPw5rXjkMm1rByjh3pK5StdBi4e8ysnn3jQopdRaI,1064
|
|
7
7
|
ocf_data_sampler/data/uk_gsp_locations_20220314.csv,sha256=RSh7DRh55E3n8lVAaWXGTaXXHevZZtI58td4d4DhGos,10415772
|
|
8
8
|
ocf_data_sampler/data/uk_gsp_locations_20250109.csv,sha256=XZISFatnbpO9j8LwaxNKFzQSjs6hcHFsV8a9uDDpy2E,9055334
|
|
@@ -37,18 +37,18 @@ ocf_data_sampler/select/fill_time_periods.py,sha256=TlGxp1xiAqnhdWfLy0pv3FuZc00d
|
|
|
37
37
|
ocf_data_sampler/select/find_contiguous_time_periods.py,sha256=etkr6LuB7zxkfzWJ6SgHiULdRuFzFlq5bOUNd257Qx4,11545
|
|
38
38
|
ocf_data_sampler/select/geospatial.py,sha256=rvMy_e--3tm-KAy9pU6b9-UMBQqH2sXykr3N_4SHYy4,6528
|
|
39
39
|
ocf_data_sampler/select/location.py,sha256=Qp0di-Pgq8WLjN9IBcTVTaRM3lckhr4ZVzaDRcgVXHw,2352
|
|
40
|
-
ocf_data_sampler/select/select_spatial_slice.py,sha256=
|
|
40
|
+
ocf_data_sampler/select/select_spatial_slice.py,sha256=Ym_YJjZqeMPC5Bw_xMi7Re2-uCbUagm2KXhnAnstTHo,7200
|
|
41
41
|
ocf_data_sampler/select/select_time_slice.py,sha256=HeHbwZ0CP03x0-LaJtpbSdtpLufwVTR73p6wH6O_PS8,5513
|
|
42
42
|
ocf_data_sampler/torch_datasets/datasets/__init__.py,sha256=o0SsEXXZ6k9iL__5_RN1Sf60lw_eqK91P3UFEHAD2k0,102
|
|
43
|
-
ocf_data_sampler/torch_datasets/datasets/pvnet_uk.py,sha256=
|
|
44
|
-
ocf_data_sampler/torch_datasets/datasets/site.py,sha256=
|
|
43
|
+
ocf_data_sampler/torch_datasets/datasets/pvnet_uk.py,sha256=wVx4QKHqak2FbxtryAxsVe6wpYM2n_YKgIKpiVs6gpE,12098
|
|
44
|
+
ocf_data_sampler/torch_datasets/datasets/site.py,sha256=ivdSB_YpAqL8-Q1m_uKTGU2YlNQ1bZXdwialT_UpGuo,15590
|
|
45
45
|
ocf_data_sampler/torch_datasets/sample/__init__.py,sha256=GL84vdZl_SjHDGVyh9Uekx2XhPYuZ0dnO3l6f6KXnHI,100
|
|
46
46
|
ocf_data_sampler/torch_datasets/sample/base.py,sha256=cQ1oIyhdmlotejZK8B3Cw6MNvpdnBPD8G_o2h7Ye4Vc,2206
|
|
47
47
|
ocf_data_sampler/torch_datasets/sample/site.py,sha256=40NwNTqjL1WVhPdwe02zDHHfDLG2u_bvCfRCtGAtFc0,1466
|
|
48
48
|
ocf_data_sampler/torch_datasets/sample/uk_regional.py,sha256=Xx5cBYUyaM6PGUWQ76MHT9hwj6IJ7WAOxbpmYFbJGhc,10483
|
|
49
49
|
ocf_data_sampler/torch_datasets/utils/__init__.py,sha256=TNSYuSSmFgjsvvJxtoDrH645Z64CHsNUUQ0iayTccP4,416
|
|
50
50
|
ocf_data_sampler/torch_datasets/utils/add_alterate_coordinate_projections.py,sha256=w6Q4TyxNyl7PKAbhqiXvqOpnqIjwmOUcGREIvPNGYlQ,2666
|
|
51
|
-
ocf_data_sampler/torch_datasets/utils/config_normalization_values_to_dicts.py,sha256=
|
|
51
|
+
ocf_data_sampler/torch_datasets/utils/config_normalization_values_to_dicts.py,sha256=SGt1H2nXcaj44ND14-gHzvA7dkLfgjTacCq7rOkRGwg,1991
|
|
52
52
|
ocf_data_sampler/torch_datasets/utils/merge_and_fill_utils.py,sha256=we7BTxRH7B7jKayDT7YfNyfI3zZClz2Bk-HXKQIokgU,956
|
|
53
53
|
ocf_data_sampler/torch_datasets/utils/spatial_slice_for_dataset.py,sha256=Hvz0wHSWMYYamf2oHNiGlzJcM4cAH6pL_7ZEvIBL2dE,1882
|
|
54
54
|
ocf_data_sampler/torch_datasets/utils/time_slice_for_dataset.py,sha256=8E4a5v9dqr-sZOyBruuO-tjLPBbjtpYtdFY5z23aqnU,4365
|
|
@@ -56,7 +56,7 @@ ocf_data_sampler/torch_datasets/utils/valid_time_periods.py,sha256=xcy75cVxl0Wrg
|
|
|
56
56
|
ocf_data_sampler/torch_datasets/utils/validation_utils.py,sha256=YqmT-lExWlI8_ul3l0EP73Ik002fStr_bhsZh9mQqEU,4735
|
|
57
57
|
scripts/download_gsp_location_data.py,sha256=rRDXMoqX-RYY4jPdxhdlxJGhWdl6r245F5UARgKV6P4,3121
|
|
58
58
|
scripts/refactor_site.py,sha256=skzvsPP0Cn9yTKndzkilyNcGz4DZ88ctvCJ0XrBdc2A,3135
|
|
59
|
-
ocf_data_sampler-0.5.
|
|
60
|
-
ocf_data_sampler-0.5.
|
|
61
|
-
ocf_data_sampler-0.5.
|
|
62
|
-
ocf_data_sampler-0.5.
|
|
59
|
+
ocf_data_sampler-0.5.14.dist-info/METADATA,sha256=OgS9xvqBfhmlWym0DYBBbT-IwZ3tRz_EKo2wEdErmCA,12817
|
|
60
|
+
ocf_data_sampler-0.5.14.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
61
|
+
ocf_data_sampler-0.5.14.dist-info/top_level.txt,sha256=deUxqmsONNAGZDNbsntbXH7BRA1MqWaUeAJrCo6q_xA,25
|
|
62
|
+
ocf_data_sampler-0.5.14.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|