ocf-data-sampler 0.1.8__tar.gz → 0.1.10__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.1.8/ocf_data_sampler.egg-info → ocf_data_sampler-0.1.10}/PKG-INFO +1 -1
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/sample/base.py +23 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/torch_datasets/datasets/pvnet_uk.py +2 -3
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/torch_datasets/datasets/site.py +9 -5
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10/ocf_data_sampler.egg-info}/PKG-INFO +1 -1
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/pyproject.toml +1 -1
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/scripts/refactor_site.py +1 -1
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/tests/test_sample/test_base.py +18 -1
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/LICENSE +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/MANIFEST.in +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/README.md +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/__init__.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/config/__init__.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/config/load.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/config/model.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/config/save.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/constants.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/data/uk_gsp_locations.csv +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/load/__init__.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/load/gsp.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/load/load_dataset.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/load/nwp/__init__.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/load/nwp/nwp.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/load/nwp/providers/__init__.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/load/nwp/providers/ecmwf.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/load/nwp/providers/ukv.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/load/nwp/providers/utils.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/load/satellite.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/load/site.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/load/utils.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/numpy_sample/__init__.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/numpy_sample/collate.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/numpy_sample/datetime_features.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/numpy_sample/gsp.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/numpy_sample/nwp.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/numpy_sample/satellite.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/numpy_sample/site.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/numpy_sample/sun_position.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/sample/__init__.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/sample/site.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/sample/uk_regional.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/select/__init__.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/select/dropout.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/select/fill_time_periods.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/select/find_contiguous_time_periods.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/select/geospatial.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/select/location.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/select/select_spatial_slice.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/select/select_time_slice.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/select/spatial_slice_for_dataset.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/select/time_slice_for_dataset.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/torch_datasets/datasets/__init__.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/torch_datasets/utils/merge_and_fill_utils.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/torch_datasets/utils/valid_time_periods.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/torch_datasets/utils/validate_channels.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/utils.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler.egg-info/SOURCES.txt +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler.egg-info/dependency_links.txt +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler.egg-info/requires.txt +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler.egg-info/top_level.txt +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/setup.cfg +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/tests/__init__.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/tests/config/test_config.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/tests/config/test_load.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/tests/config/test_save.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/tests/conftest.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/tests/load/test_load_gsp.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/tests/load/test_load_nwp.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/tests/load/test_load_satellite.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/tests/load/test_load_sites.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/tests/numpy_sample/test_collate.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/tests/numpy_sample/test_datetime_features.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/tests/numpy_sample/test_gsp.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/tests/numpy_sample/test_nwp.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/tests/numpy_sample/test_satellite.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/tests/numpy_sample/test_sun_position.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/tests/select/test_dropout.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/tests/select/test_fill_time_periods.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/tests/select/test_find_contiguous_time_periods.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/tests/select/test_location.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/tests/select/test_select_spatial_slice.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/tests/select/test_select_time_slice.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/tests/test_sample/test_site_sample.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/tests/test_sample/test_uk_regional_sample.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/tests/torch_datasets/test_merge_and_fill_utils.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/tests/torch_datasets/test_pvnet_uk.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/tests/torch_datasets/test_site.py +0 -0
- {ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/tests/torch_datasets/test_validate_channels_utils.py +0 -0
|
@@ -73,3 +73,26 @@ def batch_to_tensor(batch: NumpyBatch) -> TensorBatch:
|
|
|
73
73
|
elif np.issubdtype(v.dtype, np.number):
|
|
74
74
|
batch[k] = torch.as_tensor(v)
|
|
75
75
|
return batch
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def copy_batch_to_device(batch: dict, device: torch.device) -> dict:
|
|
79
|
+
"""
|
|
80
|
+
Moves tensor leaves in a nested dict to a new device.
|
|
81
|
+
|
|
82
|
+
Args:
|
|
83
|
+
batch: Nested dict with tensors to move.
|
|
84
|
+
device: Device to move tensors to.
|
|
85
|
+
|
|
86
|
+
Returns:
|
|
87
|
+
A dict with tensors moved to the new device.
|
|
88
|
+
"""
|
|
89
|
+
batch_copy = {}
|
|
90
|
+
|
|
91
|
+
for k, v in batch.items():
|
|
92
|
+
if isinstance(v, dict):
|
|
93
|
+
batch_copy[k] = copy_batch_to_device(v, device)
|
|
94
|
+
elif isinstance(v, torch.Tensor):
|
|
95
|
+
batch_copy[k] = v.to(device)
|
|
96
|
+
else:
|
|
97
|
+
batch_copy[k] = v
|
|
98
|
+
return batch_copy
|
|
@@ -186,9 +186,8 @@ class PVNetUKRegionalDataset(Dataset):
|
|
|
186
186
|
gsp_ids: List of GSP IDs to create samples for. Defaults to all
|
|
187
187
|
"""
|
|
188
188
|
|
|
189
|
-
config = load_yaml_configuration(config_filename)
|
|
190
|
-
|
|
191
|
-
# Validate channels for NWP and satellite data
|
|
189
|
+
# config = load_yaml_configuration(config_filename)
|
|
190
|
+
config: Configuration = load_yaml_configuration(config_filename)
|
|
192
191
|
validate_nwp_channels(config)
|
|
193
192
|
validate_satellite_channels(config)
|
|
194
193
|
|
{ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/torch_datasets/datasets/site.py
RENAMED
|
@@ -20,7 +20,6 @@ from ocf_data_sampler.select import (
|
|
|
20
20
|
from ocf_data_sampler.utils import minutes
|
|
21
21
|
from ocf_data_sampler.torch_datasets.utils.valid_time_periods import find_valid_time_periods
|
|
22
22
|
from ocf_data_sampler.torch_datasets.utils.merge_and_fill_utils import merge_dicts, fill_nans_in_arrays
|
|
23
|
-
from ocf_data_sampler.torch_datasets.utils.validate_channels import validate_nwp_channels
|
|
24
23
|
|
|
25
24
|
from ocf_data_sampler.numpy_sample import (
|
|
26
25
|
convert_site_to_numpy_sample,
|
|
@@ -30,8 +29,12 @@ from ocf_data_sampler.numpy_sample import (
|
|
|
30
29
|
make_sun_position_numpy_sample,
|
|
31
30
|
)
|
|
32
31
|
from ocf_data_sampler.numpy_sample import NWPSampleKey
|
|
33
|
-
from ocf_data_sampler.constants import NWP_MEANS, NWP_STDS
|
|
32
|
+
from ocf_data_sampler.constants import NWP_MEANS, NWP_STDS, RSS_MEAN, RSS_STD
|
|
34
33
|
|
|
34
|
+
from ocf_data_sampler.torch_datasets.utils.validate_channels import (
|
|
35
|
+
validate_nwp_channels,
|
|
36
|
+
validate_satellite_channels,
|
|
37
|
+
)
|
|
35
38
|
|
|
36
39
|
xr.set_options(keep_attrs=True)
|
|
37
40
|
|
|
@@ -52,9 +55,8 @@ class SitesDataset(Dataset):
|
|
|
52
55
|
"""
|
|
53
56
|
|
|
54
57
|
config: Configuration = load_yaml_configuration(config_filename)
|
|
55
|
-
|
|
56
|
-
# Validate NWP channels
|
|
57
58
|
validate_nwp_channels(config)
|
|
59
|
+
validate_satellite_channels(config)
|
|
58
60
|
|
|
59
61
|
datasets_dict = get_dataset_dict(config.input_data)
|
|
60
62
|
|
|
@@ -237,8 +239,10 @@ class SitesDataset(Dataset):
|
|
|
237
239
|
data_arrays.append((f"nwp-{provider}", da_nwp))
|
|
238
240
|
|
|
239
241
|
if "sat" in dataset_dict:
|
|
240
|
-
# TODO add some satellite normalisation
|
|
241
242
|
da_sat = dataset_dict["sat"]
|
|
243
|
+
|
|
244
|
+
# Standardise
|
|
245
|
+
da_sat = (da_sat - RSS_MEAN) / RSS_STD
|
|
242
246
|
data_arrays.append(("satellite", da_sat))
|
|
243
247
|
|
|
244
248
|
if "site" in dataset_dict:
|
|
@@ -9,7 +9,8 @@ import numpy as np
|
|
|
9
9
|
from pathlib import Path
|
|
10
10
|
from ocf_data_sampler.sample.base import (
|
|
11
11
|
SampleBase,
|
|
12
|
-
batch_to_tensor
|
|
12
|
+
batch_to_tensor,
|
|
13
|
+
copy_batch_to_device
|
|
13
14
|
)
|
|
14
15
|
|
|
15
16
|
class TestSample(SampleBase):
|
|
@@ -145,3 +146,19 @@ def test_batch_to_tensor_multidimensional():
|
|
|
145
146
|
assert tensor_batch['matrix'].shape == (2, 2)
|
|
146
147
|
assert tensor_batch['tensor'].shape == (2, 2, 2)
|
|
147
148
|
assert torch.equal(tensor_batch['matrix'], torch.tensor([[1, 2], [3, 4]]))
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
def test_copy_batch_to_device():
|
|
152
|
+
""" Test moving tensors to a different device """
|
|
153
|
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
|
154
|
+
batch = {
|
|
155
|
+
'tensor_data': torch.tensor([1, 2, 3]),
|
|
156
|
+
'nested': {
|
|
157
|
+
'matrix': torch.tensor([[1, 2], [3, 4]])
|
|
158
|
+
},
|
|
159
|
+
'non_tensor': 'unchanged'
|
|
160
|
+
}
|
|
161
|
+
moved_batch = copy_batch_to_device(batch, device)
|
|
162
|
+
assert moved_batch['tensor_data'].device == device
|
|
163
|
+
assert moved_batch['nested']['matrix'].device == device
|
|
164
|
+
assert moved_batch['non_tensor'] == 'unchanged' # Non-tensors should remain unchanged
|
|
File without changes
|
|
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.1.8 → ocf_data_sampler-0.1.10}/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.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/load/nwp/providers/__init__.py
RENAMED
|
File without changes
|
{ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/load/nwp/providers/ecmwf.py
RENAMED
|
File without changes
|
{ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/load/nwp/providers/ukv.py
RENAMED
|
File without changes
|
{ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/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.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/numpy_sample/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/numpy_sample/satellite.py
RENAMED
|
File without changes
|
|
File without changes
|
{ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/numpy_sample/sun_position.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/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.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/select/select_spatial_slice.py
RENAMED
|
File without changes
|
{ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/select/select_time_slice.py
RENAMED
|
File without changes
|
|
File without changes
|
{ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/ocf_data_sampler/select/time_slice_for_dataset.py
RENAMED
|
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.1.8 → ocf_data_sampler-0.1.10}/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
|
|
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.1.8 → ocf_data_sampler-0.1.10}/tests/numpy_sample/test_datetime_features.py
RENAMED
|
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.1.8 → ocf_data_sampler-0.1.10}/tests/select/test_find_contiguous_time_periods.py
RENAMED
|
File without changes
|
|
File without changes
|
{ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/tests/select/test_select_spatial_slice.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/tests/test_sample/test_uk_regional_sample.py
RENAMED
|
File without changes
|
{ocf_data_sampler-0.1.8 → ocf_data_sampler-0.1.10}/tests/torch_datasets/test_merge_and_fill_utils.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|