ocf-data-sampler 0.0.23__py3-none-any.whl → 0.0.24__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.

@@ -1,7 +1,7 @@
1
1
  """Conversion from Xarray to NumpyBatch"""
2
2
 
3
- from .gsp import convert_gsp_to_numpy_batch
4
- from .nwp import convert_nwp_to_numpy_batch
5
- from .satellite import convert_satellite_to_numpy_batch
3
+ from .gsp import convert_gsp_to_numpy_batch, GSPBatchKey
4
+ from .nwp import convert_nwp_to_numpy_batch, NWPBatchKey
5
+ from .satellite import convert_satellite_to_numpy_batch, SatelliteBatchKey
6
6
  from .sun_position import make_sun_position_numpy_batch
7
7
 
@@ -6,15 +6,15 @@ import xarray as xr
6
6
  class GSPBatchKey:
7
7
 
8
8
  gsp = 'gsp'
9
- gsp_nominal_capacity_mwp = 'gsp_nominal_capacity_mwp'
10
- gsp_effective_capacity_mwp = 'gsp_effective_capacity_mwp'
11
- gsp_time_utc = 'gsp_time_utc'
12
- gsp_t0_idx = 'gsp_t0_idx'
13
- gsp_solar_azimuth = 'gsp_solar_azimuth'
14
- gsp_solar_elevation = 'gsp_solar_elevation'
9
+ nominal_capacity_mwp = 'gsp_nominal_capacity_mwp'
10
+ effective_capacity_mwp = 'gsp_effective_capacity_mwp'
11
+ time_utc = 'gsp_time_utc'
12
+ t0_idx = 'gsp_t0_idx'
13
+ solar_azimuth = 'gsp_solar_azimuth'
14
+ solar_elevation = 'gsp_solar_elevation'
15
15
  gsp_id = 'gsp_id'
16
- gsp_x_osgb = 'gsp_x_osgb'
17
- gsp_y_osgb = 'gsp_y_osgb'
16
+ x_osgb = 'gsp_x_osgb'
17
+ y_osgb = 'gsp_y_osgb'
18
18
 
19
19
 
20
20
  def convert_gsp_to_numpy_batch(da: xr.DataArray, t0_idx: int | None = None) -> dict:
@@ -22,12 +22,12 @@ def convert_gsp_to_numpy_batch(da: xr.DataArray, t0_idx: int | None = None) -> d
22
22
 
23
23
  example = {
24
24
  GSPBatchKey.gsp: da.values,
25
- GSPBatchKey.gsp_nominal_capacity_mwp: da.isel(time_utc=0)["nominal_capacity_mwp"].values,
26
- GSPBatchKey.gsp_effective_capacity_mwp: da.isel(time_utc=0)["effective_capacity_mwp"].values,
27
- GSPBatchKey.gsp_time_utc: da["time_utc"].values.astype(float),
25
+ GSPBatchKey.nominal_capacity_mwp: da.isel(time_utc=0)["nominal_capacity_mwp"].values,
26
+ GSPBatchKey.effective_capacity_mwp: da.isel(time_utc=0)["effective_capacity_mwp"].values,
27
+ GSPBatchKey.time_utc: da["time_utc"].values.astype(float),
28
28
  }
29
29
 
30
30
  if t0_idx is not None:
31
- example[GSPBatchKey.gsp_t0_idx] = t0_idx
31
+ example[GSPBatchKey.t0_idx] = t0_idx
32
32
 
33
33
  return example
@@ -7,13 +7,13 @@ import xarray as xr
7
7
  class NWPBatchKey:
8
8
 
9
9
  nwp = 'nwp'
10
- nwp_channel_names = 'nwp_channel_names'
11
- nwp_init_time_utc = 'nwp_init_time_utc'
12
- nwp_step = 'nwp_step'
13
- nwp_target_time_utc = 'nwp_target_time_utc'
14
- nwp_t0_idx = 'nwp_t0_idx'
15
- nwp_y_osgb = 'nwp_y_osgb'
16
- nwp_x_osgb = 'nwp_x_osgb'
10
+ channel_names = 'nwp_channel_names'
11
+ init_time_utc = 'nwp_init_time_utc'
12
+ step = 'nwp_step'
13
+ target_time_utc = 'nwp_target_time_utc'
14
+ t0_idx = 'nwp_t0_idx'
15
+ y_osgb = 'nwp_y_osgb'
16
+ x_osgb = 'nwp_x_osgb'
17
17
 
18
18
 
19
19
  def convert_nwp_to_numpy_batch(da: xr.DataArray, t0_idx: int | None = None) -> dict:
@@ -21,23 +21,23 @@ def convert_nwp_to_numpy_batch(da: xr.DataArray, t0_idx: int | None = None) -> d
21
21
 
22
22
  example = {
23
23
  NWPBatchKey.nwp: da.values,
24
- NWPBatchKey.nwp_channel_names: da.channel.values,
25
- NWPBatchKey.nwp_init_time_utc: da.init_time_utc.values.astype(float),
26
- NWPBatchKey.nwp_step: (da.step.values / pd.Timedelta("1h")).astype(int),
24
+ NWPBatchKey.channel_names: da.channel.values,
25
+ NWPBatchKey.init_time_utc: da.init_time_utc.values.astype(float),
26
+ NWPBatchKey.step: (da.step.values / pd.Timedelta("1h")).astype(int),
27
27
  }
28
28
 
29
29
  if "target_time_utc" in da.coords:
30
- example[NWPBatchKey.nwp_target_time_utc] = da.target_time_utc.values.astype(float)
30
+ example[NWPBatchKey.target_time_utc] = da.target_time_utc.values.astype(float)
31
31
 
32
32
  # TODO: Do we need this at all? Especially since it is only present in UKV data
33
33
  for batch_key, dataset_key in (
34
- (NWPBatchKey.nwp_y_osgb, "y_osgb"),
35
- (NWPBatchKey.nwp_x_osgb, "x_osgb"),
34
+ (NWPBatchKey.y_osgb, "y_osgb"),
35
+ (NWPBatchKey.x_osgb, "x_osgb"),
36
36
  ):
37
37
  if dataset_key in da.coords:
38
38
  example[batch_key] = da[dataset_key].values
39
39
 
40
40
  if t0_idx is not None:
41
- example[NWPBatchKey.nwp_t0_idx] = t0_idx
41
+ example[NWPBatchKey.t0_idx] = t0_idx
42
42
 
43
43
  return example
@@ -5,26 +5,26 @@ import xarray as xr
5
5
  class SatelliteBatchKey:
6
6
 
7
7
  satellite_actual = 'satellite_actual'
8
- satellite_time_utc = 'satellite_time_utc'
9
- satellite_x_geostationary = 'satellite_x_geostationary'
10
- satellite_y_geostationary = 'satellite_y_geostationary'
11
- satellite_t0_idx = 'satellite_t0_idx'
8
+ time_utc = 'satellite_time_utc'
9
+ x_geostationary = 'satellite_x_geostationary'
10
+ y_geostationary = 'satellite_y_geostationary'
11
+ t0_idx = 'satellite_t0_idx'
12
12
 
13
13
 
14
14
  def convert_satellite_to_numpy_batch(da: xr.DataArray, t0_idx: int | None = None) -> dict:
15
15
  """Convert from Xarray to NumpyBatch"""
16
16
  example = {
17
17
  SatelliteBatchKey.satellite_actual: da.values,
18
- SatelliteBatchKey.satellite_time_utc: da.time_utc.values.astype(float),
18
+ SatelliteBatchKey.time_utc: da.time_utc.values.astype(float),
19
19
  }
20
20
 
21
21
  for batch_key, dataset_key in (
22
- (SatelliteBatchKey.satellite_x_geostationary, "x_geostationary"),
23
- (SatelliteBatchKey.satellite_y_geostationary, "y_geostationary"),
22
+ (SatelliteBatchKey.x_geostationary, "x_geostationary"),
23
+ (SatelliteBatchKey.y_geostationary, "y_geostationary"),
24
24
  ):
25
25
  example[batch_key] = da[dataset_key].values
26
26
 
27
27
  if t0_idx is not None:
28
- example[SatelliteBatchKey.satellite_t0_idx] = t0_idx
28
+ example[SatelliteBatchKey.t0_idx] = t0_idx
29
29
 
30
30
  return example
@@ -24,12 +24,12 @@ from ocf_data_sampler.numpy_batch import (
24
24
  convert_nwp_to_numpy_batch,
25
25
  convert_satellite_to_numpy_batch,
26
26
  make_sun_position_numpy_batch,
27
+ NWPBatchKey,
28
+ GSPBatchKey,
27
29
  )
28
30
 
29
31
 
30
32
  from ocf_data_sampler.config import Configuration, load_yaml_configuration
31
- from ocf_data_sampler.numpy_batch.nwp import NWPBatchKey
32
- from ocf_data_sampler.numpy_batch.gsp import GSPBatchKey
33
33
 
34
34
  from ocf_data_sampler.select.location import Location
35
35
  from ocf_data_sampler.select.geospatial import osgb_to_lon_lat
@@ -426,8 +426,8 @@ def process_and_combine_datasets(
426
426
  # TODO: Do we need all of these?
427
427
  numpy_modalities.append({
428
428
  GSPBatchKey.gsp_id: location.id,
429
- GSPBatchKey.gsp_x_osgb: location.x,
430
- GSPBatchKey.gsp_y_osgb: location.y,
429
+ GSPBatchKey.x_osgb: location.x,
430
+ GSPBatchKey.y_osgb: location.y,
431
431
  })
432
432
 
433
433
  # Combine all the modalities and fill NaNs
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ocf_data_sampler
3
- Version: 0.0.23
3
+ Version: 0.0.24
4
4
  Summary: Sample from weather data for renewable energy prediction
5
5
  Author: James Fulton, Peter Dudfield, and the Open Climate Fix team
6
6
  Author-email: info@openclimatefix.org
@@ -15,10 +15,10 @@ ocf_data_sampler/load/nwp/providers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQ
15
15
  ocf_data_sampler/load/nwp/providers/ecmwf.py,sha256=vW-p3vCyQ-CofKo555-gE7VDi5hlpjtjTLfHqWF0HEE,1175
16
16
  ocf_data_sampler/load/nwp/providers/ukv.py,sha256=79Bm7q-K_GJPYMy62SUIZbRWRF4-tIaB1dYPEgLD9vo,1207
17
17
  ocf_data_sampler/load/nwp/providers/utils.py,sha256=Sy2exG1wpXLLhMXYdsfR-DZMR3txG1_bBmBdchlc-yA,848
18
- ocf_data_sampler/numpy_batch/__init__.py,sha256=mrtqwbGik5Zc9MYP5byfCTBm08wMtS2XnTsypC4fPMo,245
19
- ocf_data_sampler/numpy_batch/gsp.py,sha256=FQg5infqOZ8QAsRCXq00HPplN8XnsbKoWUeV3N7TGK8,1008
20
- ocf_data_sampler/numpy_batch/nwp.py,sha256=dt4gXZonrdkyoVmMnwkKyJ_xFnJ4M5xscr-pdNoRsc4,1311
21
- ocf_data_sampler/numpy_batch/satellite.py,sha256=yWYmq6hEvX4LTJ95K_e0BRJJkBmRurQT2mI2KibmwCI,983
18
+ ocf_data_sampler/numpy_batch/__init__.py,sha256=M9b7L7kSgoZt2FKENDe-uFI_Qzs-fDecw-5qyrhnTm4,290
19
+ ocf_data_sampler/numpy_batch/gsp.py,sha256=QjQ25JmtufvdiSsxUkBTPhxouYGWPnnWze8pXr_aBno,960
20
+ ocf_data_sampler/numpy_batch/nwp.py,sha256=dAehfRo5DL2Yb20ifHHl5cU1QOrm3ZOpQmN39fSUOw8,1255
21
+ ocf_data_sampler/numpy_batch/satellite.py,sha256=3NoE_ElzMHwO60apqJeFAwI6J7eIxD0OWTyAVl-uJi8,903
22
22
  ocf_data_sampler/numpy_batch/sun_position.py,sha256=zw2bjtcjsm_tvKk0r_MZmgfYUJLHuLjLly2sMjwP3XI,1606
23
23
  ocf_data_sampler/select/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
24
24
  ocf_data_sampler/select/dropout.py,sha256=zDpVLMjGb70RRyYKN-WI2Kp3x9SznstT4cMcZ4dsvJg,1066
@@ -29,26 +29,26 @@ ocf_data_sampler/select/location.py,sha256=26Y5ZjfFngShBwXieuWSoOA-RLaRzci4TTmcD
29
29
  ocf_data_sampler/select/select_spatial_slice.py,sha256=hWIJe4_VzuQ2iiiQh7V17AXwTILT5kIkUvzG458J_Gw,11220
30
30
  ocf_data_sampler/select/select_time_slice.py,sha256=41cch1fQr59fZgv7UHsNGc3OvoynrixT3bmr3_1d7cU,6628
31
31
  ocf_data_sampler/torch_datasets/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
32
- ocf_data_sampler/torch_datasets/pvnet_uk_regional.py,sha256=5AV_eFtQ842-E7kNeQPLvEvcmV4LDkJKYbV2rvU_wkE,19113
32
+ ocf_data_sampler/torch_datasets/pvnet_uk_regional.py,sha256=Mlz_uyt8c8-uN0uaEiJV2DgF5WAqtWlsINFgA925CZI,19025
33
33
  tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
34
34
  tests/conftest.py,sha256=O77dmow8mGpGPbZ6Pz7ma7cLaiV1k8mxW1eYg37Avrw,5585
35
35
  tests/config/test_config.py,sha256=G_PD_pXib0zdRBPUIn0jjwJ9VyoKaO_TanLN1Mh5Ca4,5055
36
36
  tests/load/test_load_gsp.py,sha256=aT_nqaSXmUTcdHzuTT7AmXJr3R31k4OEN-Fv3eLxlQE,424
37
37
  tests/load/test_load_nwp.py,sha256=3qyyDkB1q9t3tyAwogfotNrxqUOpXXimco1CImoEWGg,753
38
38
  tests/load/test_load_satellite.py,sha256=STX5AqqmOAgUgE9R1xyq_sM3P1b8NKdGjO-hDhayfxM,524
39
- tests/numpy_batch/test_gsp.py,sha256=ke4CsFn9ZKRgrciT5-OHS8jmd8nu9gGKKr0T2WzZK6M,592
40
- tests/numpy_batch/test_nwp.py,sha256=7ELnpQc6kAWPTQoPejTnXIxCPgjFVmzmdsa8E0ZEBGY,1490
41
- tests/numpy_batch/test_satellite.py,sha256=DIVnVq7JYgoC6Y6xMtLCNUnk3ADzakCi0bZ44QTdPgQ,1230
42
- tests/numpy_batch/test_sun_position.py,sha256=zw7ErTKARkW8NrpXJ9MeGp-dkNBJsCscxQx0dnZHg2c,2513
39
+ tests/numpy_batch/test_gsp.py,sha256=VANXV32K8aLX4dCdhCUnDorJmyNN-Bjc7Wc1N-RzWEk,548
40
+ tests/numpy_batch/test_nwp.py,sha256=Fnj7cR-VR2Z0kMu8SrgnIayjxWnPWrYFjWSjMmnrh4Y,1445
41
+ tests/numpy_batch/test_satellite.py,sha256=8a4ZwMLpsOmYKmwI1oW_su_hwkCNYMEJAEfa0dbsx1k,1179
42
+ tests/numpy_batch/test_sun_position.py,sha256=FYQ7KtlN0V5LlEjgI-cKjTMtGHUCxiMvxkRYTdMAgEE,2485
43
43
  tests/select/test_dropout.py,sha256=kiycl7RxAQYMCZJlokmx6Da5h_oBpSs8Is8pmSW4gOU,2413
44
44
  tests/select/test_fill_time_periods.py,sha256=o59f2YRe5b0vJrG3B0aYZkYeHnpNk4s6EJxdXZluNQg,907
45
45
  tests/select/test_find_contiguous_time_periods.py,sha256=G6tJRJd0DMfH9EdfzlKWsmfTbtMwOf3w-2filjJzuIQ,5998
46
46
  tests/select/test_location.py,sha256=_WZk2FPYeJ-nIfCJS6Sp_yaVEEo7m31DmMFoZzgyCts,2712
47
47
  tests/select/test_select_spatial_slice.py,sha256=7EX9b6g-pMdACQx3yefjs5do2s-Rho2UmKevV4oglsU,5147
48
48
  tests/select/test_select_time_slice.py,sha256=XC1J3DBBDnt81jcba5u-Hnd0yKv8GIQErLm-OECV6rs,10147
49
- tests/torch_datasets/test_pvnet_uk_regional.py,sha256=r1SHtwaXQrOYU3EOH1OEp_Bamo338IMv-9Q_gKsUOa4,2789
50
- ocf_data_sampler-0.0.23.dist-info/LICENSE,sha256=F-Q3UFCR-BECSocV55BFDpn4YKxve9PKrm-lTt6o_Tg,1073
51
- ocf_data_sampler-0.0.23.dist-info/METADATA,sha256=mQrWfafPPHVh3Bq40lCEq2_qNcmCj2_8piukA2yqLAg,5269
52
- ocf_data_sampler-0.0.23.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
53
- ocf_data_sampler-0.0.23.dist-info/top_level.txt,sha256=KaQn5qzkJGJP6hKWqsVAc9t0cMLjVvSTk8-kTrW79SA,23
54
- ocf_data_sampler-0.0.23.dist-info/RECORD,,
49
+ tests/torch_datasets/test_pvnet_uk_regional.py,sha256=u3taw6p3oozM0_7cEEhCYbImAQPRldRhpruqSyV08Vg,2675
50
+ ocf_data_sampler-0.0.24.dist-info/LICENSE,sha256=F-Q3UFCR-BECSocV55BFDpn4YKxve9PKrm-lTt6o_Tg,1073
51
+ ocf_data_sampler-0.0.24.dist-info/METADATA,sha256=wwIltvHOvOd-L2KaOF3jsLOMx-QuY6yP6sNR0QddCdk,5269
52
+ ocf_data_sampler-0.0.24.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
53
+ ocf_data_sampler-0.0.24.dist-info/top_level.txt,sha256=KaQn5qzkJGJP6hKWqsVAc9t0cMLjVvSTk8-kTrW79SA,23
54
+ ocf_data_sampler-0.0.24.dist-info/RECORD,,
@@ -1,7 +1,6 @@
1
1
  from ocf_data_sampler.load.gsp import open_gsp
2
2
 
3
- from ocf_data_sampler.numpy_batch import convert_gsp_to_numpy_batch
4
- from ocf_data_sampler.numpy_batch.gsp import GSPBatchKey
3
+ from ocf_data_sampler.numpy_batch import convert_gsp_to_numpy_batch, GSPBatchKey
5
4
 
6
5
  def test_convert_gsp_to_numpy_batch(uk_gsp_zarr_path):
7
6
 
@@ -4,9 +4,7 @@ import xarray as xr
4
4
 
5
5
  import pytest
6
6
 
7
- from ocf_data_sampler.numpy_batch import convert_nwp_to_numpy_batch
8
-
9
- from ocf_data_sampler.numpy_batch.nwp import NWPBatchKey
7
+ from ocf_data_sampler.numpy_batch import convert_nwp_to_numpy_batch, NWPBatchKey
10
8
 
11
9
  @pytest.fixture(scope="module")
12
10
  def da_nwp_like():
@@ -5,9 +5,7 @@ import xarray as xr
5
5
 
6
6
  import pytest
7
7
 
8
- from ocf_data_sampler.numpy_batch import convert_satellite_to_numpy_batch
9
-
10
- from ocf_data_sampler.numpy_batch.satellite import SatelliteBatchKey
8
+ from ocf_data_sampler.numpy_batch import convert_satellite_to_numpy_batch, SatelliteBatchKey
11
9
 
12
10
 
13
11
  @pytest.fixture(scope="module")
@@ -6,7 +6,7 @@ from ocf_data_sampler.numpy_batch.sun_position import (
6
6
  calculate_azimuth_and_elevation, make_sun_position_numpy_batch
7
7
  )
8
8
 
9
- from ocf_data_sampler.numpy_batch.gsp import GSPBatchKey
9
+ from ocf_data_sampler.numpy_batch import GSPBatchKey
10
10
 
11
11
 
12
12
  @pytest.mark.parametrize("lat", [0, 5, 10, 23.5])
@@ -71,11 +71,11 @@ def test_make_sun_position_numpy_batch():
71
71
 
72
72
  batch = make_sun_position_numpy_batch(datetimes, lon, lat, key_prefix="gsp")
73
73
 
74
- assert GSPBatchKey.gsp_solar_elevation in batch
75
- assert GSPBatchKey.gsp_solar_azimuth in batch
74
+ assert GSPBatchKey.solar_elevation in batch
75
+ assert GSPBatchKey.solar_azimuth in batch
76
76
 
77
77
  # The solar coords are normalised in the function
78
- assert (batch[GSPBatchKey.gsp_solar_elevation]>=0).all()
79
- assert (batch[GSPBatchKey.gsp_solar_elevation]<=1).all()
80
- assert (batch[GSPBatchKey.gsp_solar_azimuth]>=0).all()
81
- assert (batch[GSPBatchKey.gsp_solar_azimuth]<=1).all()
78
+ assert (batch[GSPBatchKey.solar_elevation]>=0).all()
79
+ assert (batch[GSPBatchKey.solar_elevation]<=1).all()
80
+ assert (batch[GSPBatchKey.solar_azimuth]>=0).all()
81
+ assert (batch[GSPBatchKey.solar_azimuth]<=1).all()
@@ -3,9 +3,7 @@ import tempfile
3
3
 
4
4
  from ocf_data_sampler.torch_datasets.pvnet_uk_regional import PVNetUKRegionalDataset
5
5
  from ocf_data_sampler.config import load_yaml_configuration, save_yaml_configuration
6
- from ocf_data_sampler.numpy_batch.nwp import NWPBatchKey
7
- from ocf_data_sampler.numpy_batch.gsp import GSPBatchKey
8
- from ocf_data_sampler.numpy_batch.satellite import SatelliteBatchKey
6
+ from ocf_data_sampler.numpy_batch import NWPBatchKey, GSPBatchKey, SatelliteBatchKey
9
7
 
10
8
 
11
9
  @pytest.fixture()
@@ -39,7 +37,7 @@ def test_pvnet(pvnet_config_filename):
39
37
 
40
38
  for key in [
41
39
  NWPBatchKey.nwp, SatelliteBatchKey.satellite_actual, GSPBatchKey.gsp,
42
- GSPBatchKey.gsp_solar_azimuth, GSPBatchKey.gsp_solar_elevation,
40
+ GSPBatchKey.solar_azimuth, GSPBatchKey.solar_elevation,
43
41
  ]:
44
42
  assert key in sample
45
43
 
@@ -54,8 +52,8 @@ def test_pvnet(pvnet_config_filename):
54
52
  # 3 hours of 30 minute data (inclusive)
55
53
  assert sample[GSPBatchKey.gsp].shape == (7,)
56
54
  # Solar angles have same shape as GSP data
57
- assert sample[GSPBatchKey.gsp_solar_azimuth].shape == (7,)
58
- assert sample[GSPBatchKey.gsp_solar_elevation].shape == (7,)
55
+ assert sample[GSPBatchKey.solar_azimuth].shape == (7,)
56
+ assert sample[GSPBatchKey.solar_elevation].shape == (7,)
59
57
 
60
58
  def test_pvnet_no_gsp(pvnet_config_filename):
61
59