ocf-data-sampler 0.2.13__tar.gz → 0.2.14__tar.gz
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-0.2.13 → ocf_data_sampler-0.2.14}/PKG-INFO +1 -1
- ocf_data_sampler-0.2.14/ocf_data_sampler/torch_datasets/sample/uk_regional.py +176 -0
- ocf_data_sampler-0.2.14/ocf_data_sampler/torch_datasets/utils/validation_utils.py +108 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler.egg-info/PKG-INFO +1 -1
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler.egg-info/SOURCES.txt +1 -0
- ocf_data_sampler-0.2.13/ocf_data_sampler/torch_datasets/sample/uk_regional.py +0 -71
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/LICENSE +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/README.md +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/__init__.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/config/__init__.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/config/load.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/config/model.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/config/save.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/data/uk_gsp_locations.csv +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/load/__init__.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/load/gsp.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/load/load_dataset.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/load/nwp/__init__.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/load/nwp/nwp.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/load/nwp/providers/__init__.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/load/nwp/providers/cloudcasting.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/load/nwp/providers/ecmwf.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/load/nwp/providers/gfs.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/load/nwp/providers/icon.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/load/nwp/providers/ukv.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/load/nwp/providers/utils.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/load/satellite.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/load/site.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/load/utils.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/numpy_sample/__init__.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/numpy_sample/collate.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/numpy_sample/common_types.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/numpy_sample/datetime_features.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/numpy_sample/gsp.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/numpy_sample/nwp.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/numpy_sample/satellite.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/numpy_sample/site.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/numpy_sample/sun_position.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/select/__init__.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/select/dropout.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/select/fill_time_periods.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/select/find_contiguous_time_periods.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/select/geospatial.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/select/location.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/select/select_spatial_slice.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/select/select_time_slice.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/torch_datasets/datasets/__init__.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/torch_datasets/datasets/pvnet_uk.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/torch_datasets/datasets/site.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/torch_datasets/sample/__init__.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/torch_datasets/sample/base.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/torch_datasets/sample/site.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/torch_datasets/utils/__init__.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/torch_datasets/utils/channel_dict_to_dataarray.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/torch_datasets/utils/merge_and_fill_utils.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/torch_datasets/utils/spatial_slice_for_dataset.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/torch_datasets/utils/time_slice_for_dataset.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/torch_datasets/utils/valid_time_periods.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/utils.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler.egg-info/dependency_links.txt +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler.egg-info/requires.txt +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler.egg-info/top_level.txt +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/pyproject.toml +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/scripts/refactor_site.py +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/setup.cfg +0 -0
- {ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/utils/compute_icon_mean_stddev.py +0 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"""PVNet UK Regional sample implementation for dataset handling and visualisation."""
|
|
2
|
+
|
|
3
|
+
import torch
|
|
4
|
+
from typing_extensions import override
|
|
5
|
+
|
|
6
|
+
from ocf_data_sampler.config import Configuration
|
|
7
|
+
from ocf_data_sampler.numpy_sample import (
|
|
8
|
+
GSPSampleKey,
|
|
9
|
+
NWPSampleKey,
|
|
10
|
+
SatelliteSampleKey,
|
|
11
|
+
)
|
|
12
|
+
from ocf_data_sampler.numpy_sample.common_types import NumpySample
|
|
13
|
+
from ocf_data_sampler.torch_datasets.sample.base import SampleBase
|
|
14
|
+
from ocf_data_sampler.torch_datasets.utils.validation_utils import (
|
|
15
|
+
calculate_expected_shapes,
|
|
16
|
+
check_dimensions,
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class UKRegionalSample(SampleBase):
|
|
21
|
+
"""Handles UK Regional PVNet data operations."""
|
|
22
|
+
|
|
23
|
+
def __init__(self, data: NumpySample) -> None:
|
|
24
|
+
"""Initialises UK Regional sample with data."""
|
|
25
|
+
self._data = data
|
|
26
|
+
|
|
27
|
+
@override
|
|
28
|
+
def to_numpy(self) -> NumpySample:
|
|
29
|
+
"""Returns the data as a NumPy sample."""
|
|
30
|
+
return self._data
|
|
31
|
+
|
|
32
|
+
@override
|
|
33
|
+
def save(self, path: str) -> None:
|
|
34
|
+
"""Saves sample to the specified path in pickle format."""
|
|
35
|
+
# Saves to pickle format
|
|
36
|
+
torch.save(self._data, path)
|
|
37
|
+
|
|
38
|
+
@classmethod
|
|
39
|
+
@override
|
|
40
|
+
def load(cls, path: str) -> "UKRegionalSample":
|
|
41
|
+
"""Loads sample from the specified path.
|
|
42
|
+
|
|
43
|
+
Args:
|
|
44
|
+
path: Path to the saved sample file.
|
|
45
|
+
|
|
46
|
+
Returns:
|
|
47
|
+
A UKRegionalSample instance with the loaded data.
|
|
48
|
+
"""
|
|
49
|
+
# Loads from .pt format
|
|
50
|
+
# TODO: We should move away from using torch.load(..., weights_only=False)
|
|
51
|
+
return cls(torch.load(path, weights_only=False))
|
|
52
|
+
|
|
53
|
+
def validate_sample(self, config: Configuration) -> bool:
|
|
54
|
+
"""Validates that the sample has the expected structure and data shapes.
|
|
55
|
+
|
|
56
|
+
Args:
|
|
57
|
+
config: Configuration dict with expected shapes and required fields.
|
|
58
|
+
|
|
59
|
+
Returns:
|
|
60
|
+
bool: True if validation passes, otherwise raises an exception.
|
|
61
|
+
"""
|
|
62
|
+
if not isinstance(config, Configuration):
|
|
63
|
+
raise TypeError("config must be Configuration object")
|
|
64
|
+
|
|
65
|
+
# Calculate expected shapes from configuration
|
|
66
|
+
expected_shapes = calculate_expected_shapes(config)
|
|
67
|
+
|
|
68
|
+
# Check GSP shape if specified
|
|
69
|
+
gsp_key = GSPSampleKey.gsp
|
|
70
|
+
# Check if GSP data is expected but missing
|
|
71
|
+
if gsp_key in expected_shapes and gsp_key not in self._data:
|
|
72
|
+
raise ValueError(f"Configuration expects GSP data ('{gsp_key}') but is missing.")
|
|
73
|
+
|
|
74
|
+
# Check GSP shape if data exists and is expected
|
|
75
|
+
if gsp_key in self._data and gsp_key in expected_shapes:
|
|
76
|
+
gsp_data = self._data[gsp_key]
|
|
77
|
+
check_dimensions(
|
|
78
|
+
actual_shape=gsp_data.shape,
|
|
79
|
+
expected_shape=expected_shapes[gsp_key],
|
|
80
|
+
name="GSP",
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
# Checks for NWP data - nested structure
|
|
84
|
+
nwp_key = NWPSampleKey.nwp
|
|
85
|
+
if nwp_key in expected_shapes and nwp_key not in self._data:
|
|
86
|
+
raise ValueError(f"Configuration expects NWP data ('{nwp_key}') but is missing.")
|
|
87
|
+
|
|
88
|
+
# Check NWP structure and shapes if data exists
|
|
89
|
+
if nwp_key in self._data:
|
|
90
|
+
nwp_data_all_providers = self._data[nwp_key]
|
|
91
|
+
if not isinstance(nwp_data_all_providers, dict):
|
|
92
|
+
raise ValueError(f"NWP data ('{nwp_key}') should be a dictionary.")
|
|
93
|
+
|
|
94
|
+
# Loop through providers present in actual data
|
|
95
|
+
for provider, provider_data in nwp_data_all_providers.items():
|
|
96
|
+
if "nwp" not in provider_data:
|
|
97
|
+
raise ValueError(f"Missing array key in NWP data for provider '{provider}'.")
|
|
98
|
+
|
|
99
|
+
if nwp_key in expected_shapes and provider in expected_shapes[nwp_key]:
|
|
100
|
+
nwp_array = provider_data["nwp"]
|
|
101
|
+
actual_shape = nwp_array.shape
|
|
102
|
+
expected_shape = expected_shapes[nwp_key][provider]
|
|
103
|
+
|
|
104
|
+
check_dimensions(
|
|
105
|
+
actual_shape=actual_shape,
|
|
106
|
+
expected_shape=expected_shape,
|
|
107
|
+
name=f"NWP data ({provider})",
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
# Validate satellite data
|
|
111
|
+
sat_key = SatelliteSampleKey.satellite_actual
|
|
112
|
+
# Check if Satellite data is expected but missing
|
|
113
|
+
if sat_key in expected_shapes and sat_key not in self._data:
|
|
114
|
+
raise ValueError(f"Configuration expects Satellite data ('{sat_key}') but is missing.")
|
|
115
|
+
|
|
116
|
+
# Check satellite shape if data exists and is expected
|
|
117
|
+
if sat_key in self._data and sat_key in expected_shapes:
|
|
118
|
+
sat_data = self._data[sat_key]
|
|
119
|
+
check_dimensions(
|
|
120
|
+
actual_shape=sat_data.shape,
|
|
121
|
+
expected_shape=expected_shapes[sat_key],
|
|
122
|
+
name="Satellite data",
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
# Validate solar coordinates data
|
|
126
|
+
solar_keys = ["solar_azimuth", "solar_elevation"]
|
|
127
|
+
# Check if solar coordinate is expected but missing
|
|
128
|
+
for solar_key in solar_keys:
|
|
129
|
+
if solar_key in expected_shapes and solar_key not in self._data:
|
|
130
|
+
raise ValueError(f"Configuration expects {solar_key} data but is missing.")
|
|
131
|
+
|
|
132
|
+
# Check solar coordinate shape if data exists and is expected
|
|
133
|
+
if solar_key in self._data and solar_key in expected_shapes:
|
|
134
|
+
solar_data = self._data[solar_key]
|
|
135
|
+
check_dimensions(
|
|
136
|
+
actual_shape=solar_data.shape,
|
|
137
|
+
expected_shape=expected_shapes[solar_key],
|
|
138
|
+
name=f"{solar_key.replace('_', ' ').title()} data",
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
return True
|
|
142
|
+
|
|
143
|
+
@override
|
|
144
|
+
def plot(self) -> None:
|
|
145
|
+
"""Plots the sample data for visualization."""
|
|
146
|
+
from matplotlib import pyplot as plt
|
|
147
|
+
|
|
148
|
+
fig, axes = plt.subplots(2, 2, figsize=(12, 8))
|
|
149
|
+
|
|
150
|
+
if NWPSampleKey.nwp in self._data:
|
|
151
|
+
first_nwp = next(iter(self._data[NWPSampleKey.nwp].values()))
|
|
152
|
+
if "nwp" in first_nwp:
|
|
153
|
+
axes[0, 1].imshow(first_nwp["nwp"][0])
|
|
154
|
+
title = "NWP (First Channel)"
|
|
155
|
+
if NWPSampleKey.channel_names in first_nwp:
|
|
156
|
+
channel_names = first_nwp[NWPSampleKey.channel_names]
|
|
157
|
+
if channel_names:
|
|
158
|
+
title = f"NWP: {channel_names[0]}"
|
|
159
|
+
axes[0, 1].set_title(title)
|
|
160
|
+
|
|
161
|
+
if GSPSampleKey.gsp in self._data:
|
|
162
|
+
axes[0, 0].plot(self._data[GSPSampleKey.gsp])
|
|
163
|
+
axes[0, 0].set_title("GSP Generation")
|
|
164
|
+
|
|
165
|
+
if "solar_azimuth" in self._data and "solar_elevation" in self._data:
|
|
166
|
+
axes[1, 1].plot(self._data["solar_azimuth"], label="Azimuth")
|
|
167
|
+
axes[1, 1].plot(self._data["solar_elevation"], label="Elevation")
|
|
168
|
+
axes[1, 1].set_title("Solar Position")
|
|
169
|
+
axes[1, 1].legend()
|
|
170
|
+
|
|
171
|
+
if SatelliteSampleKey.satellite_actual in self._data:
|
|
172
|
+
axes[1, 0].imshow(self._data[SatelliteSampleKey.satellite_actual])
|
|
173
|
+
axes[1, 0].set_title("Satellite Data")
|
|
174
|
+
|
|
175
|
+
plt.tight_layout()
|
|
176
|
+
plt.show()
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"""Validate sample shape against expected shape - utility function."""
|
|
2
|
+
|
|
3
|
+
from ocf_data_sampler.config import Configuration
|
|
4
|
+
from ocf_data_sampler.numpy_sample import GSPSampleKey, NWPSampleKey, SatelliteSampleKey
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def check_dimensions(
|
|
8
|
+
actual_shape: tuple[int, ...],
|
|
9
|
+
expected_shape: tuple[int, ...],
|
|
10
|
+
name: str,
|
|
11
|
+
) -> None:
|
|
12
|
+
"""Check if dimensions match between actual and expected shapes.
|
|
13
|
+
|
|
14
|
+
Args:
|
|
15
|
+
actual_shape: The actual shape of the data (e.g., array.shape).
|
|
16
|
+
expected_shape: The expected shape.
|
|
17
|
+
name: Name of the data component for clear error messages.
|
|
18
|
+
|
|
19
|
+
Raises:
|
|
20
|
+
ValueError: If dimensions don't match.
|
|
21
|
+
"""
|
|
22
|
+
if actual_shape != expected_shape:
|
|
23
|
+
raise ValueError(
|
|
24
|
+
f"'{name}' shape mismatch: "
|
|
25
|
+
f"Actual shape: {actual_shape}, Expected shape: {expected_shape}",
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def calculate_expected_shapes(
|
|
30
|
+
config: Configuration,
|
|
31
|
+
) -> dict[str, tuple[int, ...]]:
|
|
32
|
+
"""Calculate expected shapes from configuration.
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
config: Configuration object with shape information.
|
|
36
|
+
|
|
37
|
+
Returns:
|
|
38
|
+
Dictionary mapping data keys to their expected shapes.
|
|
39
|
+
"""
|
|
40
|
+
expected_shapes = {}
|
|
41
|
+
input_data = config.input_data
|
|
42
|
+
|
|
43
|
+
# Calculate GSP shape
|
|
44
|
+
gsp_config = input_data.gsp
|
|
45
|
+
expected_shapes[GSPSampleKey.gsp] = (
|
|
46
|
+
_calculate_time_steps(
|
|
47
|
+
gsp_config.interval_start_minutes,
|
|
48
|
+
gsp_config.interval_end_minutes,
|
|
49
|
+
gsp_config.time_resolution_minutes,
|
|
50
|
+
),
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
# Calculate NWP shape for multiple providers
|
|
54
|
+
expected_shapes[NWPSampleKey.nwp] = {}
|
|
55
|
+
for provider_key, provider_config in input_data.nwp.items():
|
|
56
|
+
expected_shapes[NWPSampleKey.nwp][provider_key] = (
|
|
57
|
+
_calculate_time_steps(
|
|
58
|
+
provider_config.interval_start_minutes,
|
|
59
|
+
provider_config.interval_end_minutes,
|
|
60
|
+
provider_config.time_resolution_minutes,
|
|
61
|
+
),
|
|
62
|
+
len(provider_config.channels),
|
|
63
|
+
provider_config.image_size_pixels_height,
|
|
64
|
+
provider_config.image_size_pixels_width,
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
# Calculate satellite shape
|
|
68
|
+
sat_config = input_data.satellite
|
|
69
|
+
expected_shapes[SatelliteSampleKey.satellite_actual] = (
|
|
70
|
+
_calculate_time_steps(
|
|
71
|
+
sat_config.interval_start_minutes,
|
|
72
|
+
sat_config.interval_end_minutes,
|
|
73
|
+
sat_config.time_resolution_minutes,
|
|
74
|
+
),
|
|
75
|
+
len(sat_config.channels),
|
|
76
|
+
sat_config.image_size_pixels_height,
|
|
77
|
+
sat_config.image_size_pixels_width,
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
# Calculate solar coordinates shapes
|
|
81
|
+
solar_config = input_data.solar_position
|
|
82
|
+
# For solar azimuth
|
|
83
|
+
expected_shapes["solar_azimuth"] = (
|
|
84
|
+
_calculate_time_steps(
|
|
85
|
+
solar_config.interval_start_minutes,
|
|
86
|
+
solar_config.interval_end_minutes,
|
|
87
|
+
solar_config.time_resolution_minutes,
|
|
88
|
+
),
|
|
89
|
+
)
|
|
90
|
+
# For solar elevation
|
|
91
|
+
expected_shapes["solar_elevation"] = expected_shapes["solar_azimuth"]
|
|
92
|
+
|
|
93
|
+
return expected_shapes
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def _calculate_time_steps(start_minutes: int, end_minutes: int, resolution_minutes: int) -> int:
|
|
97
|
+
"""Calculate number of time steps based on interval and resolution.
|
|
98
|
+
|
|
99
|
+
Args:
|
|
100
|
+
start_minutes: Start of interval in minutes
|
|
101
|
+
end_minutes: End of interval in minutes
|
|
102
|
+
resolution_minutes: Time resolution in minutes
|
|
103
|
+
|
|
104
|
+
Returns:
|
|
105
|
+
Number of time steps
|
|
106
|
+
"""
|
|
107
|
+
time_span = end_minutes - start_minutes
|
|
108
|
+
return (time_span // resolution_minutes) + 1
|
|
@@ -58,5 +58,6 @@ ocf_data_sampler/torch_datasets/utils/merge_and_fill_utils.py
|
|
|
58
58
|
ocf_data_sampler/torch_datasets/utils/spatial_slice_for_dataset.py
|
|
59
59
|
ocf_data_sampler/torch_datasets/utils/time_slice_for_dataset.py
|
|
60
60
|
ocf_data_sampler/torch_datasets/utils/valid_time_periods.py
|
|
61
|
+
ocf_data_sampler/torch_datasets/utils/validation_utils.py
|
|
61
62
|
scripts/refactor_site.py
|
|
62
63
|
utils/compute_icon_mean_stddev.py
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
"""PVNet UK Regional sample implementation for dataset handling and visualisation."""
|
|
2
|
-
|
|
3
|
-
import torch
|
|
4
|
-
from typing_extensions import override
|
|
5
|
-
|
|
6
|
-
from ocf_data_sampler.numpy_sample import (
|
|
7
|
-
GSPSampleKey,
|
|
8
|
-
NWPSampleKey,
|
|
9
|
-
SatelliteSampleKey,
|
|
10
|
-
)
|
|
11
|
-
from ocf_data_sampler.numpy_sample.common_types import NumpySample
|
|
12
|
-
|
|
13
|
-
from .base import SampleBase
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
class UKRegionalSample(SampleBase):
|
|
17
|
-
"""Handles UK Regional PVNet data operations."""
|
|
18
|
-
|
|
19
|
-
def __init__(self, data: NumpySample) -> None:
|
|
20
|
-
"""Initialises UK Regional sample with data."""
|
|
21
|
-
self._data = data
|
|
22
|
-
|
|
23
|
-
@override
|
|
24
|
-
def to_numpy(self) -> NumpySample:
|
|
25
|
-
return self._data
|
|
26
|
-
|
|
27
|
-
@override
|
|
28
|
-
def save(self, path: str) -> None:
|
|
29
|
-
# Saves to pickle format
|
|
30
|
-
torch.save(self._data, path)
|
|
31
|
-
|
|
32
|
-
@classmethod
|
|
33
|
-
@override
|
|
34
|
-
def load(cls, path: str) -> "UKRegionalSample":
|
|
35
|
-
# Loads from .pt format
|
|
36
|
-
# TODO: We should move away from using torch.load(..., weights_only=False)
|
|
37
|
-
return cls(torch.load(path, weights_only=False))
|
|
38
|
-
|
|
39
|
-
@override
|
|
40
|
-
def plot(self) -> None:
|
|
41
|
-
from matplotlib import pyplot as plt
|
|
42
|
-
|
|
43
|
-
fig, axes = plt.subplots(2, 2, figsize=(12, 8))
|
|
44
|
-
|
|
45
|
-
if NWPSampleKey.nwp in self._data:
|
|
46
|
-
first_nwp = next(iter(self._data[NWPSampleKey.nwp].values()))
|
|
47
|
-
if "nwp" in first_nwp:
|
|
48
|
-
axes[0, 1].imshow(first_nwp["nwp"][0])
|
|
49
|
-
title = "NWP (First Channel)"
|
|
50
|
-
if NWPSampleKey.channel_names in first_nwp:
|
|
51
|
-
channel_names = first_nwp[NWPSampleKey.channel_names]
|
|
52
|
-
if channel_names:
|
|
53
|
-
title = f"NWP: {channel_names[0]}"
|
|
54
|
-
axes[0, 1].set_title(title)
|
|
55
|
-
|
|
56
|
-
if GSPSampleKey.gsp in self._data:
|
|
57
|
-
axes[0, 0].plot(self._data[GSPSampleKey.gsp])
|
|
58
|
-
axes[0, 0].set_title("GSP Generation")
|
|
59
|
-
|
|
60
|
-
if "solar_azimuth" in self._data and "solar_elevation" in self._data:
|
|
61
|
-
axes[1, 1].plot(self._data["solar_azimuth"], label="Azimuth")
|
|
62
|
-
axes[1, 1].plot(self._data["solar_elevation"], label="Elevation")
|
|
63
|
-
axes[1, 1].set_title("Solar Position")
|
|
64
|
-
axes[1, 1].legend()
|
|
65
|
-
|
|
66
|
-
if SatelliteSampleKey.satellite_actual in self._data:
|
|
67
|
-
axes[1, 0].imshow(self._data[SatelliteSampleKey.satellite_actual])
|
|
68
|
-
axes[1, 0].set_title("Satellite Data")
|
|
69
|
-
|
|
70
|
-
plt.tight_layout()
|
|
71
|
-
plt.show()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/data/uk_gsp_locations.csv
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/load/nwp/providers/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/load/nwp/providers/ecmwf.py
RENAMED
|
File without changes
|
{ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/load/nwp/providers/gfs.py
RENAMED
|
File without changes
|
{ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/load/nwp/providers/icon.py
RENAMED
|
File without changes
|
{ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/load/nwp/providers/ukv.py
RENAMED
|
File without changes
|
{ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/load/nwp/providers/utils.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/numpy_sample/__init__.py
RENAMED
|
File without changes
|
{ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/numpy_sample/collate.py
RENAMED
|
File without changes
|
{ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/numpy_sample/common_types.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/numpy_sample/satellite.py
RENAMED
|
File without changes
|
|
File without changes
|
{ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/numpy_sample/sun_position.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/select/fill_time_periods.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/select/select_spatial_slice.py
RENAMED
|
File without changes
|
{ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/select/select_time_slice.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/torch_datasets/datasets/site.py
RENAMED
|
File without changes
|
|
File without changes
|
{ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/torch_datasets/sample/base.py
RENAMED
|
File without changes
|
{ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler/torch_datasets/sample/site.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ocf_data_sampler-0.2.13 → ocf_data_sampler-0.2.14}/ocf_data_sampler.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|