ocf-data-sampler 0.2.0__py3-none-any.whl → 0.2.2__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.
@@ -2,8 +2,10 @@
2
2
 
3
3
  import numpy as np
4
4
 
5
+ from ocf_data_sampler.numpy_sample.common_types import NumpyBatch
5
6
 
6
- def stack_np_samples_into_batch(dict_list: list[dict]) -> dict:
7
+
8
+ def stack_np_samples_into_batch(dict_list: list[dict]) -> NumpyBatch:
7
9
  """Stacks list of dict samples into a dict where all samples are joined along a new axis.
8
10
 
9
11
  Args:
@@ -0,0 +1,11 @@
1
+ """This module defines type aliases for numpy and torch data structures used in the project."""
2
+
3
+
4
+ from typing import TypeAlias
5
+
6
+ import numpy as np
7
+ import torch
8
+
9
+ NumpySample: TypeAlias = dict[str, np.ndarray | dict[str, np.ndarray]]
10
+ NumpyBatch: TypeAlias = dict[str, np.ndarray | dict[str, np.ndarray]]
11
+ TensorBatch: TypeAlias = dict[str, torch.Tensor | dict[str, torch.Tensor]]
@@ -3,6 +3,8 @@
3
3
  import numpy as np
4
4
  import pandas as pd
5
5
 
6
+ from ocf_data_sampler.numpy_sample.common_types import NumpySample
7
+
6
8
 
7
9
  def _get_date_time_in_pi(dt: pd.DatetimeIndex) -> tuple[np.ndarray, np.ndarray]:
8
10
  """Create positional embeddings for the datetimes in radians.
@@ -22,7 +24,7 @@ def _get_date_time_in_pi(dt: pd.DatetimeIndex) -> tuple[np.ndarray, np.ndarray]:
22
24
  return date_in_pi, time_in_pi
23
25
 
24
26
 
25
- def make_datetime_numpy_dict(datetimes: pd.DatetimeIndex, key_prefix: str = "wind") -> dict:
27
+ def make_datetime_numpy_dict(datetimes: pd.DatetimeIndex, key_prefix: str = "wind") -> NumpySample:
26
28
  """Creates dictionary of cyclical datetime features - encoded."""
27
29
  date_in_pi, time_in_pi = _get_date_time_in_pi(datetimes)
28
30
 
@@ -2,6 +2,8 @@
2
2
 
3
3
  import xarray as xr
4
4
 
5
+ from ocf_data_sampler.numpy_sample.common_types import NumpySample
6
+
5
7
 
6
8
  class GSPSampleKey:
7
9
  """Keys for the GSP sample dictionary."""
@@ -16,7 +18,7 @@ class GSPSampleKey:
16
18
  y_osgb = "gsp_y_osgb"
17
19
 
18
20
 
19
- def convert_gsp_to_numpy_sample(da: xr.DataArray, t0_idx: int | None = None) -> dict:
21
+ def convert_gsp_to_numpy_sample(da: xr.DataArray, t0_idx: int | None = None) -> NumpySample:
20
22
  """Convert from Xarray to NumpySample.
21
23
 
22
24
  Args:
@@ -3,6 +3,8 @@
3
3
  import pandas as pd
4
4
  import xarray as xr
5
5
 
6
+ from ocf_data_sampler.numpy_sample.common_types import NumpySample
7
+
6
8
 
7
9
  class NWPSampleKey:
8
10
  """Keys for NWP NumpySample."""
@@ -15,7 +17,7 @@ class NWPSampleKey:
15
17
  t0_idx = "nwp_t0_idx"
16
18
 
17
19
 
18
- def convert_nwp_to_numpy_sample(da: xr.DataArray, t0_idx: int | None = None) -> dict:
20
+ def convert_nwp_to_numpy_sample(da: xr.DataArray, t0_idx: int | None = None) -> NumpySample:
19
21
  """Convert from Xarray to NWP NumpySample.
20
22
 
21
23
  Args:
@@ -2,6 +2,8 @@
2
2
 
3
3
  import xarray as xr
4
4
 
5
+ from ocf_data_sampler.numpy_sample.common_types import NumpySample
6
+
5
7
 
6
8
  class SatelliteSampleKey:
7
9
  """Keys for the SatelliteSample dictionary."""
@@ -13,7 +15,7 @@ class SatelliteSampleKey:
13
15
  t0_idx = "satellite_t0_idx"
14
16
 
15
17
 
16
- def convert_satellite_to_numpy_sample(da: xr.DataArray, t0_idx: int | None = None) -> dict:
18
+ def convert_satellite_to_numpy_sample(da: xr.DataArray, t0_idx: int | None = None) -> NumpySample:
17
19
  """Convert from Xarray to NumpySample.
18
20
 
19
21
  Args:
@@ -2,6 +2,8 @@
2
2
 
3
3
  import xarray as xr
4
4
 
5
+ from ocf_data_sampler.numpy_sample.common_types import NumpySample
6
+
5
7
 
6
8
  class SiteSampleKey:
7
9
  """Keys for the site sample dictionary."""
@@ -17,7 +19,7 @@ class SiteSampleKey:
17
19
  time_cos = "site_time_cos"
18
20
 
19
21
 
20
- def convert_site_to_numpy_sample(da: xr.DataArray, t0_idx: int | None = None) -> dict:
22
+ def convert_site_to_numpy_sample(da: xr.DataArray, t0_idx: int | None = None) -> NumpySample:
21
23
  """Convert from Xarray to NumpySample.
22
24
 
23
25
  Args:
@@ -4,6 +4,8 @@ import numpy as np
4
4
  import pandas as pd
5
5
  import pvlib
6
6
 
7
+ from ocf_data_sampler.numpy_sample.common_types import NumpySample
8
+
7
9
 
8
10
  def calculate_azimuth_and_elevation(
9
11
  datetimes: pd.DatetimeIndex,
@@ -35,7 +37,7 @@ def make_sun_position_numpy_sample(
35
37
  datetimes: pd.DatetimeIndex,
36
38
  lon: float,
37
39
  lat: float,
38
- ) -> dict:
40
+ ) -> NumpySample:
39
41
  """Creates NumpySample with standardized solar coordinates.
40
42
 
41
43
  Args:
@@ -1,14 +1,11 @@
1
1
  """Base class for handling flat/nested data structures with NWP consideration."""
2
2
 
3
3
  from abc import ABC, abstractmethod
4
- from typing import TypeAlias
5
4
 
6
5
  import numpy as np
7
6
  import torch
8
7
 
9
- NumpySample: TypeAlias = dict[str, np.ndarray | dict[str, np.ndarray]]
10
- NumpyBatch: TypeAlias = dict[str, np.ndarray | dict[str, np.ndarray]]
11
- TensorBatch: TypeAlias = dict[str, torch.Tensor | dict[str, torch.Tensor]]
8
+ from ocf_data_sampler.numpy_sample.common_types import NumpyBatch, NumpySample, TensorBatch
12
9
 
13
10
 
14
11
  class SampleBase(ABC):
@@ -3,7 +3,8 @@
3
3
  import xarray as xr
4
4
  from typing_extensions import override
5
5
 
6
- from ocf_data_sampler.sample.base import NumpySample, SampleBase
6
+ from ocf_data_sampler.numpy_sample.common_types import NumpySample
7
+ from ocf_data_sampler.sample.base import SampleBase
7
8
  from ocf_data_sampler.torch_datasets.datasets.site import convert_netcdf_to_numpy_sample
8
9
 
9
10
 
@@ -8,7 +8,8 @@ from ocf_data_sampler.numpy_sample import (
8
8
  NWPSampleKey,
9
9
  SatelliteSampleKey,
10
10
  )
11
- from ocf_data_sampler.sample.base import NumpySample, SampleBase
11
+ from ocf_data_sampler.numpy_sample.common_types import NumpySample
12
+ from ocf_data_sampler.sample.base import SampleBase
12
13
 
13
14
 
14
15
  class UKRegionalSample(SampleBase):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: ocf-data-sampler
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Author: James Fulton, Peter Dudfield
5
5
  Author-email: Open Climate Fix team <info@openclimatefix.org>
6
6
  License: MIT License
@@ -20,17 +20,18 @@ ocf_data_sampler/load/nwp/providers/icon.py,sha256=yYUrs5HgjU0C5pMHBB6FGn3tLjswi
20
20
  ocf_data_sampler/load/nwp/providers/ukv.py,sha256=-0v8JCLH8ypz8GMXZ6Rrx-I0LoHuHO8sXFupbC1RpM0,1013
21
21
  ocf_data_sampler/load/nwp/providers/utils.py,sha256=cJZ9JA4W_ZeTcLQ5z71w46_DJaPcW_2JMmBdjP9r3qs,835
22
22
  ocf_data_sampler/numpy_sample/__init__.py,sha256=nY5C6CcuxiWZ_jrXRzWtN7WyKXhJImSiVTIG6Rz4B_4,401
23
- ocf_data_sampler/numpy_sample/collate.py,sha256=I9YPcbxOwHYaDGKbzxqdV-3DFEHkzqdhAwnW7_tZH2w,1966
24
- ocf_data_sampler/numpy_sample/datetime_features.py,sha256=INudxHcoB_c-GvYXe08S4Up_8TU5zOJ39PWRrTKfLp8,1203
25
- ocf_data_sampler/numpy_sample/gsp.py,sha256=EDaQdOVEDBJGrXsq54UNBfpXTzi0ky_WpgBbmlyxOXM,1074
26
- ocf_data_sampler/numpy_sample/nwp.py,sha256=iBGOdLMn-F5yR3juX3l4G2oXDpvGNuUdcR6ZCZkCqZk,1037
27
- ocf_data_sampler/numpy_sample/satellite.py,sha256=oBlyNpO-syoyK4SSghoHqIDNyhcBqyd1L6eXSSw0k3w,1036
28
- ocf_data_sampler/numpy_sample/site.py,sha256=tpX7j6dTOz2YmOFIzVYqTfWvIduKlOnBcLITsuPMgxU,1250
29
- ocf_data_sampler/numpy_sample/sun_position.py,sha256=nkfgN6NmiLGoLSuJZrDsM-6nsIzJN75tWfN20Z7n8xo,1480
23
+ ocf_data_sampler/numpy_sample/collate.py,sha256=hoxIc5SoHoIs3Nx37aRZzWChpswjy9lHUgaKgHIoo80,2039
24
+ ocf_data_sampler/numpy_sample/common_types.py,sha256=9CjYHkUTx0ObduWh43fhsybZCTXvexql7qC2ptMDoek,377
25
+ ocf_data_sampler/numpy_sample/datetime_features.py,sha256=qoUOQzHZebnc5JiXCwm258kPLwNRNJgE5JcVHKI9b70,1278
26
+ ocf_data_sampler/numpy_sample/gsp.py,sha256=aUHDIUSu2LMsVmR7TsTriZxVfv495QNL-scaxyJFHgQ,1149
27
+ ocf_data_sampler/numpy_sample/nwp.py,sha256=X9T5XZLVucXX8QAUhdeTnomNBPrsfvsO8I4SXaQHDxE,1112
28
+ ocf_data_sampler/numpy_sample/satellite.py,sha256=RaYzYIcB1AmDrKeiqSpn4QVfBH-QMe26F1P5t1az2Jg,1111
29
+ ocf_data_sampler/numpy_sample/site.py,sha256=zfYBjK3CJrIaKH1QdKXU7gwOxTqONt527y3nJ9TRnwc,1325
30
+ ocf_data_sampler/numpy_sample/sun_position.py,sha256=5tt-zNm6aRuZMsxZPaAxyg7HeikswfZCeHWXTHuO2K0,1555
30
31
  ocf_data_sampler/sample/__init__.py,sha256=zdS73NTnxFX_j8uh9tT-IXiURB6635wbneM1koWYV1o,169
31
- ocf_data_sampler/sample/base.py,sha256=lnr-MNRpAxjVFJHCEvCZL86NrYy9LWnNOsLWBGDL8kc,2359
32
- ocf_data_sampler/sample/site.py,sha256=4aJys40CQ-2CRKo_dgvm3rINTdfyTGWQGEaXGbh58qQ,1236
33
- ocf_data_sampler/sample/uk_regional.py,sha256=uMtLdqZCsKttjFmhIC6JITzu2JDZh-VQdYUfbpyhgFM,2409
32
+ ocf_data_sampler/sample/base.py,sha256=cQ1oIyhdmlotejZK8B3Cw6MNvpdnBPD8G_o2h7Ye4Vc,2206
33
+ ocf_data_sampler/sample/site.py,sha256=BhQPygeLUncXJGN_Yd2CL050kN6ktZlobaJw0O0RagI,1290
34
+ ocf_data_sampler/sample/uk_regional.py,sha256=VOby07RnZYvzszExwqoZRVwZ1EbCclRpXq1e9CL16CE,2463
34
35
  ocf_data_sampler/select/__init__.py,sha256=E4AJulEbO2K-o0UlG1fgaEteuf_1ZFjHTvrotXSb4YU,332
35
36
  ocf_data_sampler/select/dropout.py,sha256=_rzXl8_4VHTY_JMjbaoWopaFCJmLdaBpqfYF4vr24tk,1638
36
37
  ocf_data_sampler/select/fill_time_periods.py,sha256=TlGxp1xiAqnhdWfLy0pv3FuZc00dtimjWdLzr4JoTGA,865
@@ -50,7 +51,7 @@ ocf_data_sampler/torch_datasets/utils/merge_and_fill_utils.py,sha256=we7BTxRH7B7
50
51
  ocf_data_sampler/torch_datasets/utils/valid_time_periods.py,sha256=LdHgLPAYUVoCRMk2nnFdsMpygGS2kbps3h-7_bZnETw,4718
51
52
  scripts/refactor_site.py,sha256=skzvsPP0Cn9yTKndzkilyNcGz4DZ88ctvCJ0XrBdc2A,3135
52
53
  utils/compute_icon_mean_stddev.py,sha256=a1oWMRMnny39rV-dvu8rcx85sb4bXzPFrR1gkUr4Jpg,2296
53
- ocf_data_sampler-0.2.0.dist-info/METADATA,sha256=rh1lluAp3u6zh1uORcL9zieq1tGPWRsdFV4Hp2O4XM8,11594
54
- ocf_data_sampler-0.2.0.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
55
- ocf_data_sampler-0.2.0.dist-info/top_level.txt,sha256=LEFU4Uk-PEo72QGLAfnVZIUEm37Q8mKuMeg_Xk-p33g,31
56
- ocf_data_sampler-0.2.0.dist-info/RECORD,,
54
+ ocf_data_sampler-0.2.2.dist-info/METADATA,sha256=NEsKFB-wcbnffDXMEBNpFhxfM7dH2pgfEbiRferBfLE,11594
55
+ ocf_data_sampler-0.2.2.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
56
+ ocf_data_sampler-0.2.2.dist-info/top_level.txt,sha256=LEFU4Uk-PEo72QGLAfnVZIUEm37Q8mKuMeg_Xk-p33g,31
57
+ ocf_data_sampler-0.2.2.dist-info/RECORD,,