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

@@ -8,17 +8,15 @@ logger = logging.getLogger(__name__)
8
8
 
9
9
 
10
10
 
11
- def stack_np_examples_into_sample(dict_list):
11
+ def stack_np_samples_into_batch(dict_list):
12
12
  # """
13
- # Stacks Numpy examples into a sample
14
-
15
- # See also: `unstack_np_sample_into_examples()` for opposite
13
+ # Stacks Numpy samples into a batch
16
14
 
17
15
  # Args:
18
- # dict_list: A list of dict-like Numpy examples to stack
16
+ # dict_list: A list of dict-like Numpy samples to stack
19
17
 
20
18
  # Returns:
21
- # The stacked NumpySample object
19
+ # The stacked NumpySample object, aka a batch
22
20
  # """
23
21
 
24
22
  if not dict_list:
@@ -21,7 +21,7 @@ def convert_gsp_to_numpy_sample(da: xr.DataArray, t0_idx: int | None = None) ->
21
21
  """Convert from Xarray to NumpySample"""
22
22
 
23
23
  # Extract values from the DataArray
24
- example = {
24
+ sample = {
25
25
  GSPSampleKey.gsp: da.values,
26
26
  GSPSampleKey.nominal_capacity_mwp: da.isel(time_utc=0)["nominal_capacity_mwp"].values,
27
27
  GSPSampleKey.effective_capacity_mwp: da.isel(time_utc=0)["effective_capacity_mwp"].values,
@@ -29,6 +29,6 @@ def convert_gsp_to_numpy_sample(da: xr.DataArray, t0_idx: int | None = None) ->
29
29
  }
30
30
 
31
31
  if t0_idx is not None:
32
- example[GSPSampleKey.t0_idx] = t0_idx
32
+ sample[GSPSampleKey.t0_idx] = t0_idx
33
33
 
34
- return example
34
+ return sample
@@ -21,7 +21,7 @@ def convert_nwp_to_numpy_sample(da: xr.DataArray, t0_idx: int | None = None) ->
21
21
  """Convert from Xarray to NWP NumpySample"""
22
22
 
23
23
  # Create example and add t if available
24
- example = {
24
+ sample = {
25
25
  NWPSampleKey.nwp: da.values,
26
26
  NWPSampleKey.channel_names: da.channel.values,
27
27
  NWPSampleKey.init_time_utc: da.init_time_utc.values.astype(float),
@@ -29,14 +29,14 @@ def convert_nwp_to_numpy_sample(da: xr.DataArray, t0_idx: int | None = None) ->
29
29
  }
30
30
 
31
31
  if "target_time_utc" in da.coords:
32
- example[NWPSampleKey.target_time_utc] = da.target_time_utc.values.astype(float)
32
+ sample[NWPSampleKey.target_time_utc] = da.target_time_utc.values.astype(float)
33
33
 
34
34
  # TODO: Do we need this at all? Especially since it is only present in UKV data
35
35
  for sample_key, dataset_key in ((NWPSampleKey.y_osgb, "y_osgb"),(NWPSampleKey.x_osgb, "x_osgb"),):
36
36
  if dataset_key in da.coords:
37
- example[sample_key] = da[dataset_key].values
37
+ sample[sample_key] = da[dataset_key].values
38
38
 
39
39
  if t0_idx is not None:
40
- example[NWPSampleKey.t0_idx] = t0_idx
40
+ sample[NWPSampleKey.t0_idx] = t0_idx
41
41
 
42
- return example
42
+ return sample
@@ -13,7 +13,7 @@ class SatelliteSampleKey:
13
13
 
14
14
  def convert_satellite_to_numpy_sample(da: xr.DataArray, t0_idx: int | None = None) -> dict:
15
15
  """Convert from Xarray to NumpySample"""
16
- example = {
16
+ sample = {
17
17
  SatelliteSampleKey.satellite_actual: da.values,
18
18
  SatelliteSampleKey.time_utc: da.time_utc.values.astype(float),
19
19
  }
@@ -22,9 +22,9 @@ def convert_satellite_to_numpy_sample(da: xr.DataArray, t0_idx: int | None = Non
22
22
  (SatelliteSampleKey.x_geostationary, "x_geostationary"),
23
23
  (SatelliteSampleKey.y_geostationary, "y_geostationary"),
24
24
  ):
25
- example[sample_key] = da[dataset_key].values
25
+ sample[sample_key] = da[dataset_key].values
26
26
 
27
27
  if t0_idx is not None:
28
- example[SatelliteSampleKey.t0_idx] = t0_idx
28
+ sample[SatelliteSampleKey.t0_idx] = t0_idx
29
29
 
30
- return example
30
+ return sample
@@ -18,13 +18,13 @@ def convert_site_to_numpy_sample(da: xr.DataArray, t0_idx: int | None = None) ->
18
18
  """Convert from Xarray to NumpySample"""
19
19
 
20
20
  # Extract values from the DataArray
21
- example = {
21
+ sample = {
22
22
  SiteSampleKey.generation: da.values,
23
23
  SiteSampleKey.capacity_kwp: da.isel(time_utc=0)["capacity_kwp"].values,
24
24
  SiteSampleKey.time_utc: da["time_utc"].values.astype(float),
25
25
  }
26
26
 
27
27
  if t0_idx is not None:
28
- example[SiteSampleKey.t0_idx] = t0_idx
28
+ sample[SiteSampleKey.t0_idx] = t0_idx
29
29
 
30
- return example
30
+ return sample
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: ocf_data_sampler
3
- Version: 0.0.42
3
+ Version: 0.0.44
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
@@ -56,7 +56,7 @@ Requires-Dist: mkdocs-material>=8.0; extra == "docs"
56
56
  # ocf-data-sampler
57
57
 
58
58
  <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
59
- [![All Contributors](https://img.shields.io/badge/all_contributors-9-orange.svg?style=flat-square)](#contributors-)
59
+ [![All Contributors](https://img.shields.io/badge/all_contributors-10-orange.svg?style=flat-square)](#contributors-)
60
60
  <!-- ALL-CONTRIBUTORS-BADGE:END -->
61
61
 
62
62
  [![tags badge](https://img.shields.io/github/v/tag/openclimatefix/ocf-data-sampler?include_prereleases&sort=semver&color=FFAC5F)](https://github.com/openclimatefix/ocf-data-sampler/tags)
@@ -134,6 +134,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
134
134
  <tr>
135
135
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/felix-e-h-p"><img src="https://avatars.githubusercontent.com/u/137530077?v=4?s=100" width="100px;" alt="Felix"/><br /><sub><b>Felix</b></sub></a><br /><a href="https://github.com/openclimatefix/ocf-data-sampler/commits?author=felix-e-h-p" title="Code">💻</a></td>
136
136
  <td align="center" valign="top" width="14.28%"><a href="https://timothyajaniportfolio-b6v3zq29k-timthegreat.vercel.app/"><img src="https://avatars.githubusercontent.com/u/60073728?v=4?s=100" width="100px;" alt="Ajani Timothy"/><br /><sub><b>Ajani Timothy</b></sub></a><br /><a href="https://github.com/openclimatefix/ocf-data-sampler/commits?author=Tim1119" title="Code">💻</a></td>
137
+ <td align="center" valign="top" width="14.28%"><a href="https://rupeshmangalam.vercel.app/"><img src="https://avatars.githubusercontent.com/u/91172425?v=4?s=100" width="100px;" alt="Rupesh Mangalam"/><br /><sub><b>Rupesh Mangalam</b></sub></a><br /><a href="https://github.com/openclimatefix/ocf-data-sampler/commits?author=RupeshMangalam21" title="Code">💻</a></td>
137
138
  </tr>
138
139
  </tbody>
139
140
  </table>
@@ -19,11 +19,11 @@ ocf_data_sampler/load/nwp/providers/ecmwf.py,sha256=2iR1Iy542lo51rC6XFLV-3pbUE68
19
19
  ocf_data_sampler/load/nwp/providers/ukv.py,sha256=79Bm7q-K_GJPYMy62SUIZbRWRF4-tIaB1dYPEgLD9vo,1207
20
20
  ocf_data_sampler/load/nwp/providers/utils.py,sha256=Sy2exG1wpXLLhMXYdsfR-DZMR3txG1_bBmBdchlc-yA,848
21
21
  ocf_data_sampler/numpy_sample/__init__.py,sha256=jWvN4BDYAgoFkdGBxjNrYioZdZNVbIcP4RsNGJCEGm0,345
22
- ocf_data_sampler/numpy_sample/collate.py,sha256=RSG6wedj31qMTO9I31fXRfcZd-PU8YSy1su4XHF0g10,2285
23
- ocf_data_sampler/numpy_sample/gsp.py,sha256=4ZckEN7S82UY36e9z6rp5DTp10SAn_cNISBNilpOADw,1008
24
- ocf_data_sampler/numpy_sample/nwp.py,sha256=eEIRXP09wY99Vq-ItnfQ6U9AY1vJPLYKfUOc83V6ICo,1302
25
- ocf_data_sampler/numpy_sample/satellite.py,sha256=WYG9_ryOk3RWHWjgcMjIaU-YahEhTXz2xN0rQm-_TTQ,914
26
- ocf_data_sampler/numpy_sample/site.py,sha256=E2MQKkgUXikbIlKYU4ueNCPoBYJC-vnkbrQ_IwP2hqw,792
22
+ ocf_data_sampler/numpy_sample/collate.py,sha256=y8QFUhskaAfOMP22aVkexwyGAwLHbNE-q1pOZ6txWKA,2227
23
+ ocf_data_sampler/numpy_sample/gsp.py,sha256=5UaWO_aGRRVQo82wnDaT4zBKHihOnIsXiwgPjM8vGFM,1005
24
+ ocf_data_sampler/numpy_sample/nwp.py,sha256=_seQNWsut3IzPsrpipqImjnaM3XNHZCy5_5be6syivk,1297
25
+ ocf_data_sampler/numpy_sample/satellite.py,sha256=8OaTvkPjzSjotcdKsa6BKmmlBKDBunbhDN4Pjo0Grxs,910
26
+ ocf_data_sampler/numpy_sample/site.py,sha256=PIfmCtPA37dqpC8GArkryVqFrNAwqacj0iW2ikBOdSk,789
27
27
  ocf_data_sampler/numpy_sample/sun_position.py,sha256=UklhucCxCT6GMlAhCWL6c4cfWrdc1cWgegrYaqUoHOY,1611
28
28
  ocf_data_sampler/select/__init__.py,sha256=E4AJulEbO2K-o0UlG1fgaEteuf_1ZFjHTvrotXSb4YU,332
29
29
  ocf_data_sampler/select/dropout.py,sha256=HCx5Wzk8Oh2Z9vV94Jy-ALJsHtGduwvMaQOleQXp5z0,1142
@@ -49,7 +49,7 @@ tests/load/test_load_gsp.py,sha256=aT_nqaSXmUTcdHzuTT7AmXJr3R31k4OEN-Fv3eLxlQE,4
49
49
  tests/load/test_load_nwp.py,sha256=3qyyDkB1q9t3tyAwogfotNrxqUOpXXimco1CImoEWGg,753
50
50
  tests/load/test_load_satellite.py,sha256=STX5AqqmOAgUgE9R1xyq_sM3P1b8NKdGjO-hDhayfxM,524
51
51
  tests/load/test_load_sites.py,sha256=T9lSEnGPI8FQISudVYHHNTHeplNS62Vrx48jaZ6J_Jo,364
52
- tests/numpy_sample/test_collate.py,sha256=Oks9YxLBRX1Abz9wwGO36VT4-ftYxlDKVIQ9ra7xrhY,851
52
+ tests/numpy_sample/test_collate.py,sha256=oWVNRR0LyF0iqaxjsq6hPMmkSGIyvGVlAM6q2rqvXqQ,840
53
53
  tests/numpy_sample/test_gsp.py,sha256=FLlq4SlJ-9cSRAepf4_ksA6PsUVKegnKEAc5pUojCJ0,1458
54
54
  tests/numpy_sample/test_nwp.py,sha256=yf4u7mAU0E3FQ4xAH6YjuHuHBzzFoXjHSFNkOVJUdSM,1455
55
55
  tests/numpy_sample/test_satellite.py,sha256=cCqtn5See-uSNfh89COGTUQNuFm6sIZ8QmBVHsuUeRI,1189
@@ -64,8 +64,8 @@ tests/torch_datasets/conftest.py,sha256=eRCzHE7cxS4AoskExkCGFDBeqItktAYNAdkfpMoF
64
64
  tests/torch_datasets/test_process_and_combine.py,sha256=mbjQdqzLhox-U2sc1Ec68xLz95b3XOyPa7WchgxUM88,4256
65
65
  tests/torch_datasets/test_pvnet_uk_regional.py,sha256=dLY861PMyQ_buTksP8d0UXzfKsZ_CFNgceSYVGXRIRs,2134
66
66
  tests/torch_datasets/test_site.py,sha256=TSmdpD0OFid6e8eRgeB5FGxglUN1L2t4cIuMTfjA7jE,4539
67
- ocf_data_sampler-0.0.42.dist-info/LICENSE,sha256=F-Q3UFCR-BECSocV55BFDpn4YKxve9PKrm-lTt6o_Tg,1073
68
- ocf_data_sampler-0.0.42.dist-info/METADATA,sha256=tLh8ajGI3CLruw5ZEasx7beUa3FiKs_fXSg9cRexgdQ,11055
69
- ocf_data_sampler-0.0.42.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
70
- ocf_data_sampler-0.0.42.dist-info/top_level.txt,sha256=Faob6N6cFdPc5eUpCTYcXgCaNhi4XLLteUL5W5ayYmg,31
71
- ocf_data_sampler-0.0.42.dist-info/RECORD,,
67
+ ocf_data_sampler-0.0.44.dist-info/LICENSE,sha256=F-Q3UFCR-BECSocV55BFDpn4YKxve9PKrm-lTt6o_Tg,1073
68
+ ocf_data_sampler-0.0.44.dist-info/METADATA,sha256=DXdwieKe_o3sJ5BSZ8-zN8xawG3_1YDLQRHqgWV89xM,11431
69
+ ocf_data_sampler-0.0.44.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
70
+ ocf_data_sampler-0.0.44.dist-info/top_level.txt,sha256=Faob6N6cFdPc5eUpCTYcXgCaNhi4XLLteUL5W5ayYmg,31
71
+ ocf_data_sampler-0.0.44.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  from ocf_data_sampler.numpy_sample import GSPSampleKey, SatelliteSampleKey
2
- from ocf_data_sampler.numpy_sample.collate import stack_np_examples_into_sample
2
+ from ocf_data_sampler.numpy_sample.collate import stack_np_samples_into_batch
3
3
  from ocf_data_sampler.torch_datasets import PVNetUKRegionalDataset
4
4
 
5
5
 
@@ -16,11 +16,11 @@ def test_pvnet(pvnet_config_filename):
16
16
  sample1 = dataset[0]
17
17
  sample2 = dataset[1]
18
18
 
19
- sample = stack_np_examples_into_sample([sample1, sample2])
19
+ batch = stack_np_samples_into_batch([sample1, sample2])
20
20
 
21
- assert isinstance(sample, dict)
22
- assert "nwp" in sample
23
- assert isinstance(sample["nwp"], dict)
24
- assert "ukv" in sample["nwp"]
25
- assert GSPSampleKey.gsp in sample
26
- assert SatelliteSampleKey.satellite_actual in sample
21
+ assert isinstance(batch, dict)
22
+ assert "nwp" in batch
23
+ assert isinstance(batch["nwp"], dict)
24
+ assert "ukv" in batch["nwp"]
25
+ assert GSPSampleKey.gsp in batch
26
+ assert SatelliteSampleKey.satellite_actual in batch