ocf-data-sampler 0.0.1__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.0.1/LICENSE +21 -0
- ocf_data_sampler-0.0.1/MANIFEST.in +1 -0
- ocf_data_sampler-0.0.1/PKG-INFO +20 -0
- ocf_data_sampler-0.0.1/README.md +2 -0
- ocf_data_sampler-0.0.1/ocf_data_sampler.egg-info/PKG-INFO +20 -0
- ocf_data_sampler-0.0.1/ocf_data_sampler.egg-info/SOURCES.txt +12 -0
- ocf_data_sampler-0.0.1/ocf_data_sampler.egg-info/dependency_links.txt +1 -0
- ocf_data_sampler-0.0.1/ocf_data_sampler.egg-info/requires.txt +8 -0
- ocf_data_sampler-0.0.1/ocf_data_sampler.egg-info/top_level.txt +1 -0
- ocf_data_sampler-0.0.1/requirements.txt +8 -0
- ocf_data_sampler-0.0.1/setup.cfg +4 -0
- ocf_data_sampler-0.0.1/setup.py +24 -0
- ocf_data_sampler-0.0.1/tests/__init__.py +0 -0
- ocf_data_sampler-0.0.1/tests/conftest.py +202 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Open Climate Fix
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
include *.txt
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: ocf_data_sampler
|
|
3
|
+
Version: 0.0.1
|
|
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
|
+
A repo for sampling from weather data for renewable energy prediction
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: ocf_data_sampler
|
|
3
|
+
Version: 0.0.1
|
|
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
|
+
A repo for sampling from weather data for renewable energy prediction
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
MANIFEST.in
|
|
3
|
+
README.md
|
|
4
|
+
requirements.txt
|
|
5
|
+
setup.py
|
|
6
|
+
ocf_data_sampler.egg-info/PKG-INFO
|
|
7
|
+
ocf_data_sampler.egg-info/SOURCES.txt
|
|
8
|
+
ocf_data_sampler.egg-info/dependency_links.txt
|
|
9
|
+
ocf_data_sampler.egg-info/requires.txt
|
|
10
|
+
ocf_data_sampler.egg-info/top_level.txt
|
|
11
|
+
tests/__init__.py
|
|
12
|
+
tests/conftest.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
tests
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
""" Usual setup file for package """
|
|
2
|
+
# read the contents of your README file
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
from setuptools import find_packages, setup
|
|
6
|
+
|
|
7
|
+
this_directory = Path(__file__).parent
|
|
8
|
+
long_description = (this_directory / "README.md").read_text()
|
|
9
|
+
install_requires = (this_directory / "requirements.txt").read_text().splitlines()
|
|
10
|
+
|
|
11
|
+
setup(
|
|
12
|
+
name="ocf_data_sampler",
|
|
13
|
+
version="0.0.1",
|
|
14
|
+
license="MIT",
|
|
15
|
+
description="Sample from weather data for renewable energy prediction",
|
|
16
|
+
author="James Fulton, Peter Dudfield, and the Open Climate Fix team",
|
|
17
|
+
author_email="info@openclimatefix.org",
|
|
18
|
+
company="Open Climate Fix Ltd",
|
|
19
|
+
install_requires=install_requires,
|
|
20
|
+
long_description=long_description,
|
|
21
|
+
long_description_content_type="text/markdown",
|
|
22
|
+
include_package_data=True,
|
|
23
|
+
packages=find_packages(),
|
|
24
|
+
)
|
|
File without changes
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
import numpy as np
|
|
4
|
+
import pandas as pd
|
|
5
|
+
import pytest
|
|
6
|
+
import xarray as xr
|
|
7
|
+
import tempfile
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@pytest.fixture(scope="session")
|
|
12
|
+
def config_filename():
|
|
13
|
+
return f"{os.path.dirname(os.path.abspath(__file__))}/test_data/pvnet_test_config.yaml"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@pytest.fixture(scope="session")
|
|
17
|
+
def sat_zarr_path():
|
|
18
|
+
|
|
19
|
+
# Load dataset which only contains coordinates, but no data
|
|
20
|
+
ds = xr.open_zarr(
|
|
21
|
+
f"{os.path.dirname(os.path.abspath(__file__))}/test_data/non_hrv_shell.zarr.zip"
|
|
22
|
+
).compute()
|
|
23
|
+
|
|
24
|
+
# Add time coord
|
|
25
|
+
ds = ds.assign_coords(time=pd.date_range("2023-01-01 00:00", "2023-01-02 23:55", freq="5min"))
|
|
26
|
+
|
|
27
|
+
# Add data to dataset
|
|
28
|
+
ds["data"] = xr.DataArray(
|
|
29
|
+
np.zeros([len(ds[c]) for c in ds.coords], dtype=np.float32),
|
|
30
|
+
coords=ds.coords,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
# Transpose to variables, time, y, x (just in case)
|
|
34
|
+
ds = ds.transpose("variable", "time", "y_geostationary", "x_geostationary")
|
|
35
|
+
|
|
36
|
+
# add 100,000 to x_geostationary, this to make sure the fix index is within the satellite image
|
|
37
|
+
ds["x_geostationary"] = ds["x_geostationary"] - 200_000
|
|
38
|
+
|
|
39
|
+
# Add some NaNs
|
|
40
|
+
ds["data"].values[:, :, 0, 0] = np.nan
|
|
41
|
+
|
|
42
|
+
# make sure channel values are strings
|
|
43
|
+
ds["variable"] = ds["variable"].astype(str)
|
|
44
|
+
|
|
45
|
+
# add data attrs area
|
|
46
|
+
ds["data"].attrs["area"] = (
|
|
47
|
+
"""msg_seviri_rss_3km:
|
|
48
|
+
description: MSG SEVIRI Rapid Scanning Service area definition with 3 km resolution
|
|
49
|
+
projection:
|
|
50
|
+
proj: geos
|
|
51
|
+
lon_0: 9.5
|
|
52
|
+
h: 35785831
|
|
53
|
+
x_0: 0
|
|
54
|
+
y_0: 0
|
|
55
|
+
a: 6378169
|
|
56
|
+
rf: 295.488065897014
|
|
57
|
+
no_defs: null
|
|
58
|
+
type: crs
|
|
59
|
+
shape:
|
|
60
|
+
height: 298
|
|
61
|
+
width: 615
|
|
62
|
+
area_extent:
|
|
63
|
+
lower_left_xy: [28503.830075263977, 5090183.970808983]
|
|
64
|
+
upper_right_xy: [-1816744.1169023514, 4196063.827395439]
|
|
65
|
+
units: m
|
|
66
|
+
"""
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
# Specifiy chunking
|
|
70
|
+
ds = ds.chunk({"time": 10, "variable": -1, "y_geostationary": -1, "x_geostationary": -1})
|
|
71
|
+
|
|
72
|
+
# Save temporarily as a zarr
|
|
73
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
74
|
+
zarr_path = f"{tmpdir}/test_sat.zarr"
|
|
75
|
+
ds.to_zarr(zarr_path)
|
|
76
|
+
|
|
77
|
+
yield zarr_path
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
@pytest.fixture(scope="session")
|
|
81
|
+
def ds_nwp_ukv():
|
|
82
|
+
init_times = pd.date_range(start="2023-01-01 00:00", freq="180min", periods=24 * 7)
|
|
83
|
+
steps = pd.timedelta_range("0h", "10h", freq="1h")
|
|
84
|
+
|
|
85
|
+
x = np.linspace(-239_000, 857_000, 50)
|
|
86
|
+
y = np.linspace(-183_000, 1225_000, 100)
|
|
87
|
+
variables = ["si10", "dswrf", "t", "prate"]
|
|
88
|
+
|
|
89
|
+
coords = (
|
|
90
|
+
("init_time", init_times),
|
|
91
|
+
("variable", variables),
|
|
92
|
+
("step", steps),
|
|
93
|
+
("x", x),
|
|
94
|
+
("y", y),
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
nwp_array_shape = tuple(len(coord_values) for _, coord_values in coords)
|
|
98
|
+
|
|
99
|
+
nwp_data = xr.DataArray(
|
|
100
|
+
np.random.uniform(0, 200, size=nwp_array_shape).astype(np.float32),
|
|
101
|
+
coords=coords,
|
|
102
|
+
)
|
|
103
|
+
return nwp_data.to_dataset(name="UKV")
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
@pytest.fixture(scope="session")
|
|
107
|
+
def nwp_ukv_zarr_path(ds_nwp_ukv):
|
|
108
|
+
ds = ds_nwp_ukv.chunk(
|
|
109
|
+
{
|
|
110
|
+
"init_time": 1,
|
|
111
|
+
"step": -1,
|
|
112
|
+
"variable": -1,
|
|
113
|
+
"x": 50,
|
|
114
|
+
"y": 50,
|
|
115
|
+
}
|
|
116
|
+
)
|
|
117
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
118
|
+
filename = tmpdir + "/ukv_nwp.zarr"
|
|
119
|
+
ds.to_zarr(filename)
|
|
120
|
+
yield filename
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
@pytest.fixture(scope="session")
|
|
124
|
+
def ds_nwp_ecmwf():
|
|
125
|
+
init_times = pd.date_range(start="2023-01-01 00:00", freq="6h", periods=24 * 7)
|
|
126
|
+
steps = pd.timedelta_range("0h", "14h", freq="1h")
|
|
127
|
+
|
|
128
|
+
lons = np.arange(-12, 3)
|
|
129
|
+
lats = np.arange(48, 60)
|
|
130
|
+
variables = ["t2m","dswrf", "mcc"]
|
|
131
|
+
|
|
132
|
+
coords = (
|
|
133
|
+
("init_time", init_times),
|
|
134
|
+
("variable", variables),
|
|
135
|
+
("step", steps),
|
|
136
|
+
("longitude", lons),
|
|
137
|
+
("latitude", lats),
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
nwp_array_shape = tuple(len(coord_values) for _, coord_values in coords)
|
|
141
|
+
|
|
142
|
+
nwp_data = xr.DataArray(
|
|
143
|
+
np.random.uniform(0, 200, size=nwp_array_shape).astype(np.float32),
|
|
144
|
+
coords=coords,
|
|
145
|
+
)
|
|
146
|
+
return nwp_data.to_dataset(name="ECMWF_UK")
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
@pytest.fixture(scope="session")
|
|
150
|
+
def nwp_ecmwf_zarr_path(ds_nwp_ecmwf):
|
|
151
|
+
ds = ds_nwp_ecmwf.chunk(
|
|
152
|
+
{
|
|
153
|
+
"init_time": 1,
|
|
154
|
+
"step": -1,
|
|
155
|
+
"variable": -1,
|
|
156
|
+
"longitude": 50,
|
|
157
|
+
"latitude": 50,
|
|
158
|
+
}
|
|
159
|
+
)
|
|
160
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
161
|
+
filename = tmpdir + "/ukv_ecmwf.zarr"
|
|
162
|
+
ds.to_zarr(filename)
|
|
163
|
+
yield filename
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
@pytest.fixture(scope="session")
|
|
167
|
+
def ds_uk_gsp():
|
|
168
|
+
times = pd.date_range("2023-01-01 00:00", "2023-01-02 00:00", freq="30min")
|
|
169
|
+
gsp_ids = np.arange(0, 318)
|
|
170
|
+
capacity = np.ones((len(times), len(gsp_ids)))
|
|
171
|
+
generation = np.random.uniform(0, 200, size=(len(times), len(gsp_ids))).astype(np.float32)
|
|
172
|
+
|
|
173
|
+
coords = (
|
|
174
|
+
("datetime_gmt", times),
|
|
175
|
+
("gsp_id", gsp_ids),
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
da_cap = xr.DataArray(
|
|
179
|
+
capacity,
|
|
180
|
+
coords=coords,
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
da_gen = xr.DataArray(
|
|
184
|
+
generation,
|
|
185
|
+
coords=coords,
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
return xr.Dataset({
|
|
189
|
+
"capacity_mwp": da_cap,
|
|
190
|
+
"installedcapacity_mwp": da_cap,
|
|
191
|
+
"generation_mw":da_gen
|
|
192
|
+
})
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
@pytest.fixture(scope="session")
|
|
196
|
+
def uk_gsp_zarr_path(ds_uk_gsp):
|
|
197
|
+
|
|
198
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
199
|
+
filename = tmpdir + "/uk_gsp.zarr"
|
|
200
|
+
ds_uk_gsp.to_zarr(filename)
|
|
201
|
+
yield filename
|
|
202
|
+
|