ocf-data-sampler 0.0.19__py3-none-any.whl → 0.0.21__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/__init__.py +5 -0
- ocf_data_sampler/config/load.py +33 -0
- ocf_data_sampler/config/model.py +249 -0
- ocf_data_sampler/config/save.py +36 -0
- ocf_data_sampler/select/dropout.py +2 -2
- ocf_data_sampler/select/geospatial.py +118 -0
- ocf_data_sampler/select/location.py +62 -0
- ocf_data_sampler/select/select_spatial_slice.py +5 -14
- ocf_data_sampler/torch_datasets/pvnet_uk_regional.py +1 -2
- ocf_data_sampler-0.0.21.dist-info/METADATA +83 -0
- ocf_data_sampler-0.0.21.dist-info/RECORD +53 -0
- tests/config/test_config.py +152 -0
- tests/conftest.py +6 -1
- tests/load/test_load_gsp.py +15 -0
- tests/load/test_load_nwp.py +21 -0
- tests/load/test_load_satellite.py +17 -0
- tests/numpy_batch/test_gsp.py +23 -0
- tests/numpy_batch/test_nwp.py +54 -0
- tests/numpy_batch/test_satellite.py +42 -0
- tests/numpy_batch/test_sun_position.py +81 -0
- tests/select/test_dropout.py +75 -0
- tests/select/test_fill_time_periods.py +28 -0
- tests/select/test_find_contiguous_time_periods.py +202 -0
- tests/select/test_location.py +67 -0
- tests/select/test_select_spatial_slice.py +154 -0
- tests/select/test_select_time_slice.py +284 -0
- tests/torch_datasets/test_pvnet_uk_regional.py +72 -0
- ocf_data_sampler-0.0.19.dist-info/METADATA +0 -22
- ocf_data_sampler-0.0.19.dist-info/RECORD +0 -32
- {ocf_data_sampler-0.0.19.dist-info → ocf_data_sampler-0.0.21.dist-info}/LICENSE +0 -0
- {ocf_data_sampler-0.0.19.dist-info → ocf_data_sampler-0.0.21.dist-info}/WHEEL +0 -0
- {ocf_data_sampler-0.0.19.dist-info → ocf_data_sampler-0.0.21.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
import tempfile
|
|
3
|
+
|
|
4
|
+
from ocf_data_sampler.torch_datasets.pvnet_uk_regional import PVNetUKRegionalDataset
|
|
5
|
+
from ocf_data_sampler.config import load_yaml_configuration, save_yaml_configuration
|
|
6
|
+
from ocf_datapipes.batch import BatchKey, NWPBatchKey
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@pytest.fixture()
|
|
10
|
+
def pvnet_config_filename(tmp_path, config_filename, nwp_ukv_zarr_path, uk_gsp_zarr_path, sat_zarr_path):
|
|
11
|
+
|
|
12
|
+
# adjust config to point to the zarr file
|
|
13
|
+
config = load_yaml_configuration(config_filename)
|
|
14
|
+
config.input_data.nwp['ukv'].nwp_zarr_path = nwp_ukv_zarr_path
|
|
15
|
+
config.input_data.satellite.satellite_zarr_path = sat_zarr_path
|
|
16
|
+
config.input_data.gsp.gsp_zarr_path = uk_gsp_zarr_path
|
|
17
|
+
|
|
18
|
+
filename = f"{tmp_path}/configuration.yaml"
|
|
19
|
+
save_yaml_configuration(config, filename)
|
|
20
|
+
return filename
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def test_pvnet(pvnet_config_filename):
|
|
24
|
+
|
|
25
|
+
# Create dataset object
|
|
26
|
+
dataset = PVNetUKRegionalDataset(pvnet_config_filename)
|
|
27
|
+
|
|
28
|
+
assert len(dataset.locations) == 317 # no of GSPs not including the National level
|
|
29
|
+
# NB. I have not checked this value is in fact correct, but it does seem to stay constant
|
|
30
|
+
assert len(dataset.valid_t0_times) == 39
|
|
31
|
+
assert len(dataset) == 317*39
|
|
32
|
+
|
|
33
|
+
# Generate a sample
|
|
34
|
+
sample = dataset[0]
|
|
35
|
+
|
|
36
|
+
assert isinstance(sample, dict)
|
|
37
|
+
|
|
38
|
+
for key in [
|
|
39
|
+
BatchKey.nwp, BatchKey.satellite_actual, BatchKey.gsp,
|
|
40
|
+
BatchKey.gsp_solar_azimuth, BatchKey.gsp_solar_elevation,
|
|
41
|
+
]:
|
|
42
|
+
assert key in sample
|
|
43
|
+
|
|
44
|
+
for nwp_source in ["ukv"]:
|
|
45
|
+
assert nwp_source in sample[BatchKey.nwp]
|
|
46
|
+
|
|
47
|
+
# check the shape of the data is correct
|
|
48
|
+
# 30 minutes of 5 minute data (inclusive), one channel, 2x2 pixels
|
|
49
|
+
assert sample[BatchKey.satellite_actual].shape == (7, 1, 2, 2)
|
|
50
|
+
# 3 hours of 60 minute data (inclusive), one channel, 2x2 pixels
|
|
51
|
+
assert sample[BatchKey.nwp]["ukv"][NWPBatchKey.nwp].shape == (4, 1, 2, 2)
|
|
52
|
+
# 3 hours of 30 minute data (inclusive)
|
|
53
|
+
assert sample[BatchKey.gsp].shape == (7,)
|
|
54
|
+
# Solar angles have same shape as GSP data
|
|
55
|
+
assert sample[BatchKey.gsp_solar_azimuth].shape == (7,)
|
|
56
|
+
assert sample[BatchKey.gsp_solar_elevation].shape == (7,)
|
|
57
|
+
|
|
58
|
+
def test_pvnet_no_gsp(pvnet_config_filename):
|
|
59
|
+
|
|
60
|
+
# load config
|
|
61
|
+
config = load_yaml_configuration(pvnet_config_filename)
|
|
62
|
+
# remove gsp
|
|
63
|
+
config.input_data.gsp.gsp_zarr_path = ''
|
|
64
|
+
|
|
65
|
+
# save temp config file
|
|
66
|
+
with tempfile.NamedTemporaryFile() as temp_config_file:
|
|
67
|
+
save_yaml_configuration(config, temp_config_file.name)
|
|
68
|
+
# Create dataset object
|
|
69
|
+
dataset = PVNetUKRegionalDataset(temp_config_file.name)
|
|
70
|
+
|
|
71
|
+
# Generate a sample
|
|
72
|
+
_ = dataset[0]
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: ocf_data_sampler
|
|
3
|
-
Version: 0.0.19
|
|
4
|
-
Summary: Sample from weather data for renewable energy prediction
|
|
5
|
-
Author: James Fulton, Peter Dudfield, and the Open Climate Fix team
|
|
6
|
-
Author-email: info@openclimatefix.org
|
|
7
|
-
License: MIT
|
|
8
|
-
Description-Content-Type: text/markdown
|
|
9
|
-
License-File: LICENSE
|
|
10
|
-
Requires-Dist: numpy
|
|
11
|
-
Requires-Dist: pandas
|
|
12
|
-
Requires-Dist: xarray
|
|
13
|
-
Requires-Dist: zarr
|
|
14
|
-
Requires-Dist: dask
|
|
15
|
-
Requires-Dist: ocf-blosc2
|
|
16
|
-
Requires-Dist: ocf-datapipes ==3.3.39
|
|
17
|
-
Requires-Dist: pvlib
|
|
18
|
-
|
|
19
|
-
# OCF Data Sampler
|
|
20
|
-
[](https://github.com/openclimatefix/ocf-meta-repo?tab=readme-ov-file#overview-of-ocfs-nowcasting-repositories)
|
|
21
|
-
|
|
22
|
-
A repo for sampling from weather data for renewable energy prediction
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
ocf_data_sampler/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
2
|
-
ocf_data_sampler/data/uk_gsp_locations.csv,sha256=RSh7DRh55E3n8lVAaWXGTaXXHevZZtI58td4d4DhGos,10415772
|
|
3
|
-
ocf_data_sampler/load/__init__.py,sha256=MjgfxilTzyz1RYFoBEeAXmE9hyjknLvdmlHPmlAoiQY,44
|
|
4
|
-
ocf_data_sampler/load/gsp.py,sha256=Gcr1JVUOPKhFRDCSHtfPDjxx0BtyyEhXrZvGEKLPJ5I,759
|
|
5
|
-
ocf_data_sampler/load/satellite.py,sha256=3KlA1fx4SwxdzM-jC1WRaONXO0D6m0WxORnEnwUnZrA,2967
|
|
6
|
-
ocf_data_sampler/load/utils.py,sha256=EQGvVWlGMoSOdbDYuMfVAa0v6wmAOPmHIAemdrTB5v4,1406
|
|
7
|
-
ocf_data_sampler/load/nwp/__init__.py,sha256=SmcrnbygO5xtCKmGR4wtHrj-HI7nOAvnAtfuvRufBGQ,25
|
|
8
|
-
ocf_data_sampler/load/nwp/nwp.py,sha256=O4QnajEZem8BvBgTcYYDBhRhgqPYuJkolHmpMRmrXEA,610
|
|
9
|
-
ocf_data_sampler/load/nwp/providers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
|
-
ocf_data_sampler/load/nwp/providers/ecmwf.py,sha256=vW-p3vCyQ-CofKo555-gE7VDi5hlpjtjTLfHqWF0HEE,1175
|
|
11
|
-
ocf_data_sampler/load/nwp/providers/ukv.py,sha256=79Bm7q-K_GJPYMy62SUIZbRWRF4-tIaB1dYPEgLD9vo,1207
|
|
12
|
-
ocf_data_sampler/load/nwp/providers/utils.py,sha256=Sy2exG1wpXLLhMXYdsfR-DZMR3txG1_bBmBdchlc-yA,848
|
|
13
|
-
ocf_data_sampler/numpy_batch/__init__.py,sha256=mrtqwbGik5Zc9MYP5byfCTBm08wMtS2XnTsypC4fPMo,245
|
|
14
|
-
ocf_data_sampler/numpy_batch/gsp.py,sha256=3gwSj0k29JyA8_09zovB8f8Pr-dVhCuMSO1-k4QKAOg,668
|
|
15
|
-
ocf_data_sampler/numpy_batch/nwp.py,sha256=Rv0yfDj902Z2oCwdlRjOs3Kh-F5Fgxjjylh99-lQ9ws,1105
|
|
16
|
-
ocf_data_sampler/numpy_batch/satellite.py,sha256=e6eoNmiiHtzZbDVtBolFzDuE3qwhHN6bL9H86emAUsk,732
|
|
17
|
-
ocf_data_sampler/numpy_batch/sun_position.py,sha256=UW6-WtjrKdCkcguolHUDSLhYFfarknQzzjlCX8YdEOM,1700
|
|
18
|
-
ocf_data_sampler/select/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
19
|
-
ocf_data_sampler/select/dropout.py,sha256=3aDqlL3U9kzzIkIHV44h5_ZbfOUSg1iChHKingXk7-s,1064
|
|
20
|
-
ocf_data_sampler/select/fill_time_periods.py,sha256=iTtMjIPFYG5xtUYYedAFBLjTWWUa7t7WQ0-yksWf0-E,440
|
|
21
|
-
ocf_data_sampler/select/find_contiguous_time_periods.py,sha256=6ioB8LeFpFNBMgKDxrgG3zqzNjkBF_jlV9yye2ZYT2E,11925
|
|
22
|
-
ocf_data_sampler/select/select_spatial_slice.py,sha256=7BSzOFPMSBWpBWXSajWTfI8luUVsSgh4zN-rkr-AuUs,11470
|
|
23
|
-
ocf_data_sampler/select/select_time_slice.py,sha256=41cch1fQr59fZgv7UHsNGc3OvoynrixT3bmr3_1d7cU,6628
|
|
24
|
-
ocf_data_sampler/torch_datasets/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
25
|
-
ocf_data_sampler/torch_datasets/pvnet_uk_regional.py,sha256=NGrq5e6NOX8npz_45io7gVlx6eYfI-AW0rxcQjSOBQE,19167
|
|
26
|
-
tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
27
|
-
tests/conftest.py,sha256=OcArgF60paroZQqoP7xExRBF34nEyMuXd7dS7hD6p3w,5393
|
|
28
|
-
ocf_data_sampler-0.0.19.dist-info/LICENSE,sha256=F-Q3UFCR-BECSocV55BFDpn4YKxve9PKrm-lTt6o_Tg,1073
|
|
29
|
-
ocf_data_sampler-0.0.19.dist-info/METADATA,sha256=rmnF4WJbPaLoeBFmJ-ZWgwY4FpoxcND8ZvQHMrnv8b8,801
|
|
30
|
-
ocf_data_sampler-0.0.19.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
|
31
|
-
ocf_data_sampler-0.0.19.dist-info/top_level.txt,sha256=KaQn5qzkJGJP6hKWqsVAc9t0cMLjVvSTk8-kTrW79SA,23
|
|
32
|
-
ocf_data_sampler-0.0.19.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|