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

@@ -24,20 +24,21 @@ def _get_pixel_index_location(da: xr.DataArray, location: Location) -> tuple[int
24
24
 
25
25
  x, y = location.in_coord_system(target_coords)
26
26
 
27
+ x_vals = da[x_dim].values
28
+ y_vals = da[y_dim].values
29
+
27
30
  # Check that requested point lies within the data
28
- if not (da[x_dim].values[0] < x < da[x_dim].values[-1]):
31
+ if not (x_vals[0] < x < x_vals[-1]):
29
32
  raise ValueError(
30
- f"{x} is not in the interval {da[x_dim].values[0]}: {da[x_dim].values[-1]}",
33
+ f"{x} is not in the interval {x_vals[0]}: {x_vals[-1]}",
31
34
  )
32
- if not (da[y_dim].values[0] < y < da[y_dim].values[-1]):
35
+ if not (y_vals[0] < y < y_vals[-1]):
33
36
  raise ValueError(
34
- f"{y} is not in the interval {da[y_dim].values[0]}: {da[y_dim].values[-1]}",
37
+ f"{y} is not in the interval {y_vals[0]}: {y_vals[-1]}",
35
38
  )
36
39
 
37
- x_index = da.get_index(x_dim)
38
- y_index = da.get_index(y_dim)
39
- closest_x = x_index.get_indexer([x], method="nearest")[0]
40
- closest_y = y_index.get_indexer([y], method="nearest")[0]
40
+ closest_x = np.argmin(np.abs(x_vals - x))
41
+ closest_y = np.argmin(np.abs(y_vals - y))
41
42
 
42
43
  return closest_x, closest_y
43
44
 
ocf_data_sampler/utils.py CHANGED
@@ -15,7 +15,16 @@ def minutes(minutes: int | list[float]) -> pd.Timedelta | pd.TimedeltaIndex:
15
15
 
16
16
  def compute(xarray_dict: dict) -> dict:
17
17
  """Eagerly load a nested dictionary of xarray DataArrays."""
18
- for k, v in xarray_dict.items():
18
+ # Load these keys first because they don't use tensorstore
19
+ priority_keys = ["gsp", "site"]
20
+ for key in priority_keys:
21
+ if key in xarray_dict:
22
+ xarray_dict[key] = xarray_dict[key].compute()
23
+
24
+ # Load the rest
25
+ keys = [k for k in xarray_dict if k not in priority_keys]
26
+ for k in keys:
27
+ v = xarray_dict[k]
19
28
  if isinstance(v, dict):
20
29
  xarray_dict[k] = compute(v)
21
30
  else:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ocf-data-sampler
3
- Version: 0.5.16
3
+ Version: 0.5.18
4
4
  Author: James Fulton, Peter Dudfield
5
5
  Author-email: Open Climate Fix team <info@openclimatefix.org>
6
6
  License: MIT License
@@ -1,5 +1,5 @@
1
1
  ocf_data_sampler/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
2
- ocf_data_sampler/utils.py,sha256=CTJf9bjHjO8vOJebUtXiMpvgwUpF7gEOjjaoE77fhTk,1177
2
+ ocf_data_sampler/utils.py,sha256=WfmyBacjFGsv_IlUHRezNGc4ixi4wBvom_JF76iJYbY,1487
3
3
  ocf_data_sampler/config/__init__.py,sha256=O29mbH0XG2gIY1g3BaveGCnpBO2SFqdu-qzJ7a6evl0,223
4
4
  ocf_data_sampler/config/load.py,sha256=LL-7wemI8o4KPkx35j-wQ3HjsMvDgqXr7G46IcASfnU,632
5
5
  ocf_data_sampler/config/model.py,sha256=5ou8BZgQ9h-xyJEqHdspPKZgZO9Vr6opjSphUys7yE8,11505
@@ -38,7 +38,7 @@ ocf_data_sampler/select/fill_time_periods.py,sha256=TlGxp1xiAqnhdWfLy0pv3FuZc00d
38
38
  ocf_data_sampler/select/find_contiguous_time_periods.py,sha256=etkr6LuB7zxkfzWJ6SgHiULdRuFzFlq5bOUNd257Qx4,11545
39
39
  ocf_data_sampler/select/geospatial.py,sha256=rvMy_e--3tm-KAy9pU6b9-UMBQqH2sXykr3N_4SHYy4,6528
40
40
  ocf_data_sampler/select/location.py,sha256=Qp0di-Pgq8WLjN9IBcTVTaRM3lckhr4ZVzaDRcgVXHw,2352
41
- ocf_data_sampler/select/select_spatial_slice.py,sha256=Ym_YJjZqeMPC5Bw_xMi7Re2-uCbUagm2KXhnAnstTHo,7200
41
+ ocf_data_sampler/select/select_spatial_slice.py,sha256=NB6NtZBc_Mb5zPCItzBIEa_Nroj2kEsjUIsa_kdWoj0,7081
42
42
  ocf_data_sampler/select/select_time_slice.py,sha256=cpkdovJMvcjxSGfq9G0OJK5aDAeCXg7exWYrJnR4N2w,4116
43
43
  ocf_data_sampler/torch_datasets/datasets/__init__.py,sha256=o0SsEXXZ6k9iL__5_RN1Sf60lw_eqK91P3UFEHAD2k0,102
44
44
  ocf_data_sampler/torch_datasets/datasets/pvnet_uk.py,sha256=wUsIZ0Fhq5bbE8v02C0UPcFWIhWI7kfSka9UrWP0_m4,12240
@@ -58,7 +58,7 @@ ocf_data_sampler/torch_datasets/utils/valid_time_periods.py,sha256=xcy75cVxl0Wrg
58
58
  ocf_data_sampler/torch_datasets/utils/validation_utils.py,sha256=YqmT-lExWlI8_ul3l0EP73Ik002fStr_bhsZh9mQqEU,4735
59
59
  scripts/download_gsp_location_data.py,sha256=rRDXMoqX-RYY4jPdxhdlxJGhWdl6r245F5UARgKV6P4,3121
60
60
  scripts/refactor_site.py,sha256=skzvsPP0Cn9yTKndzkilyNcGz4DZ88ctvCJ0XrBdc2A,3135
61
- ocf_data_sampler-0.5.16.dist-info/METADATA,sha256=82UiAraNLrkhOMwZcLeK7Ckg3zgArx5BuzvfBOhy9m8,12817
62
- ocf_data_sampler-0.5.16.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
63
- ocf_data_sampler-0.5.16.dist-info/top_level.txt,sha256=deUxqmsONNAGZDNbsntbXH7BRA1MqWaUeAJrCo6q_xA,25
64
- ocf_data_sampler-0.5.16.dist-info/RECORD,,
61
+ ocf_data_sampler-0.5.18.dist-info/METADATA,sha256=X8GB_jGQyev3yFEAmGCW1NvDnKiIw5hVWPyzNTGteLE,12817
62
+ ocf_data_sampler-0.5.18.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
63
+ ocf_data_sampler-0.5.18.dist-info/top_level.txt,sha256=deUxqmsONNAGZDNbsntbXH7BRA1MqWaUeAJrCo6q_xA,25
64
+ ocf_data_sampler-0.5.18.dist-info/RECORD,,