ocf-data-sampler 0.2.20__py3-none-any.whl → 0.2.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.

@@ -1,6 +1,5 @@
1
1
  """Torch dataset for UK PVNet."""
2
2
 
3
- import numpy as np
4
3
  import pandas as pd
5
4
  import xarray as xr
6
5
  from torch.utils.data import Dataset
@@ -257,22 +256,12 @@ class PVNetUKRegionalDataset(AbstractPVNetUKDataset):
257
256
  # Construct a lookup for locations - useful for users to construct sample by GSP ID
258
257
  location_lookup = {loc.id: loc for loc in self.locations}
259
258
 
260
- # Construct indices for sampling
261
- t_index, loc_index = np.meshgrid(
262
- np.arange(len(self.valid_t0_times)),
263
- np.arange(len(self.locations)),
264
- )
265
-
266
- # Make array of all possible (t0, location) coordinates. Each row is a single coordinate
267
- index_pairs = np.stack((t_index.ravel(), loc_index.ravel())).T
268
-
269
259
  # Assign coords and indices to self
270
260
  self.location_lookup = location_lookup
271
- self.index_pairs = index_pairs
272
261
 
273
262
  @override
274
263
  def __len__(self) -> int:
275
- return len(self.index_pairs)
264
+ return len(self.locations)*len(self.valid_t0_times)
276
265
 
277
266
  def _get_sample(self, t0: pd.Timestamp, location: Location) -> NumpySample:
278
267
  """Generate the PVNet sample for given coordinates.
@@ -290,7 +279,16 @@ class PVNetUKRegionalDataset(AbstractPVNetUKDataset):
290
279
  @override
291
280
  def __getitem__(self, idx: int) -> NumpySample:
292
281
  # Get the coordinates of the sample
293
- t_index, loc_index = self.index_pairs[idx]
282
+
283
+ if idx >= len(self):
284
+ raise ValueError(f"Index {idx} out of range for dataset of length {len(self)}")
285
+
286
+ # t_index will be between 0 and len(self.valid_t0_times)-1
287
+ t_index = idx % len(self.valid_t0_times)
288
+
289
+ # For each location, there are len(self.valid_t0_times) possible samples
290
+ loc_index = idx // len(self.valid_t0_times)
291
+
294
292
  location = self.locations[loc_index]
295
293
  t0 = self.valid_t0_times[t_index]
296
294
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ocf-data-sampler
3
- Version: 0.2.20
3
+ Version: 0.2.21
4
4
  Author: James Fulton, Peter Dudfield
5
5
  Author-email: Open Climate Fix team <info@openclimatefix.org>
6
6
  License: MIT License
@@ -39,7 +39,7 @@ ocf_data_sampler/select/location.py,sha256=AZvGR8y62opiW7zACGXjoOtBEWRfSLOZIA73O
39
39
  ocf_data_sampler/select/select_spatial_slice.py,sha256=liAqIa-Amj58pOqx5r16i99HURj9oQ41j7gnPgRDQP4,8201
40
40
  ocf_data_sampler/select/select_time_slice.py,sha256=HeHbwZ0CP03x0-LaJtpbSdtpLufwVTR73p6wH6O_PS8,5513
41
41
  ocf_data_sampler/torch_datasets/datasets/__init__.py,sha256=jfJSFcR0eO1AqeH7S3KnGjsBqVZT5w3oyi784PUR6Q0,146
42
- ocf_data_sampler/torch_datasets/datasets/pvnet_uk.py,sha256=ZV2FoMPxFU2aPTWipj9HhJhGfrEg9MYOJRNR8aFcmvs,12613
42
+ ocf_data_sampler/torch_datasets/datasets/pvnet_uk.py,sha256=cd4IyzYu8rMFgLHRXqYpnOIAZe4Yl21YdLmDQw45F7o,12545
43
43
  ocf_data_sampler/torch_datasets/datasets/site.py,sha256=nRUlhXQQGVrTuBmE1QnwXAUsPTXz0dsezlQjwK71jIQ,17641
44
44
  ocf_data_sampler/torch_datasets/sample/__init__.py,sha256=GL84vdZl_SjHDGVyh9Uekx2XhPYuZ0dnO3l6f6KXnHI,100
45
45
  ocf_data_sampler/torch_datasets/sample/base.py,sha256=cQ1oIyhdmlotejZK8B3Cw6MNvpdnBPD8G_o2h7Ye4Vc,2206
@@ -55,7 +55,7 @@ ocf_data_sampler/torch_datasets/utils/validation_utils.py,sha256=YqmT-lExWlI8_ul
55
55
  scripts/download_gsp_location_data.py,sha256=rRDXMoqX-RYY4jPdxhdlxJGhWdl6r245F5UARgKV6P4,3121
56
56
  scripts/refactor_site.py,sha256=skzvsPP0Cn9yTKndzkilyNcGz4DZ88ctvCJ0XrBdc2A,3135
57
57
  utils/compute_icon_mean_stddev.py,sha256=a1oWMRMnny39rV-dvu8rcx85sb4bXzPFrR1gkUr4Jpg,2296
58
- ocf_data_sampler-0.2.20.dist-info/METADATA,sha256=r0mN9CoHXY_Vj44DxMbrCe2fd00RWYE2vxID5SQ-6RM,11581
59
- ocf_data_sampler-0.2.20.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
60
- ocf_data_sampler-0.2.20.dist-info/top_level.txt,sha256=LEFU4Uk-PEo72QGLAfnVZIUEm37Q8mKuMeg_Xk-p33g,31
61
- ocf_data_sampler-0.2.20.dist-info/RECORD,,
58
+ ocf_data_sampler-0.2.21.dist-info/METADATA,sha256=PKoq-iYwiK9VGZLHgAQCQJm-U97WMkb7HToAsrPNzlw,11581
59
+ ocf_data_sampler-0.2.21.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
60
+ ocf_data_sampler-0.2.21.dist-info/top_level.txt,sha256=LEFU4Uk-PEo72QGLAfnVZIUEm37Q8mKuMeg_Xk-p33g,31
61
+ ocf_data_sampler-0.2.21.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.4.0)
2
+ Generator: setuptools (80.7.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5