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

File without changes
@@ -0,0 +1,37 @@
1
+ """ECMWF provider loaders"""
2
+ from pathlib import Path
3
+ import xarray as xr
4
+ from ocf_data_sampler.load.nwp.providers.utils import open_zarr_paths
5
+ from ocf_data_sampler.load.utils import check_time_unique_increasing, make_spatial_coords_increasing
6
+
7
+ def open_ifs(zarr_path: Path | str | list[Path] | list[str]) -> xr.DataArray:
8
+ """
9
+ Opens the ECMWF IFS NWP data
10
+
11
+ Args:
12
+ zarr_path: Path to the zarr to open
13
+
14
+ Returns:
15
+ Xarray DataArray of the NWP data
16
+ """
17
+ # Open the data
18
+ ds = open_zarr_paths(zarr_path)
19
+
20
+ # Rename
21
+ ds = ds.rename(
22
+ {
23
+ "init_time": "init_time_utc",
24
+ "variable": "channel",
25
+ }
26
+ )
27
+
28
+ # Check the timestmps are unique and increasing
29
+ check_time_unique_increasing(ds.init_time_utc)
30
+
31
+ # Make sure the spatial coords are in increasing order
32
+ ds = make_spatial_coords_increasing(ds, x_coord="longitude", y_coord="latitude")
33
+
34
+ ds = ds.transpose("init_time_utc", "step", "channel", "longitude", "latitude")
35
+
36
+ # TODO: should we control the dtype of the DataArray?
37
+ return ds.ECMWF_UK
@@ -0,0 +1,45 @@
1
+ """UKV provider loaders"""
2
+
3
+ import xarray as xr
4
+
5
+ from pathlib import Path
6
+
7
+ from ocf_data_sampler.load.nwp.providers.utils import open_zarr_paths
8
+ from ocf_data_sampler.load.utils import check_time_unique_increasing, make_spatial_coords_increasing
9
+
10
+
11
+ def open_ukv(zarr_path: Path | str | list[Path] | list[str]) -> xr.DataArray:
12
+ """
13
+ Opens the NWP data
14
+
15
+ Args:
16
+ zarr_path: Path to the zarr to open
17
+
18
+ Returns:
19
+ Xarray DataArray of the NWP data
20
+ """
21
+ # Open the data
22
+ ds = open_zarr_paths(zarr_path)
23
+
24
+ # Rename
25
+ ds = ds.rename(
26
+ {
27
+ "init_time": "init_time_utc",
28
+ "variable": "channel",
29
+ "x": "x_osgb",
30
+ "y": "y_osgb",
31
+ }
32
+ )
33
+
34
+ # Check the timestmps are unique and increasing
35
+ check_time_unique_increasing(ds.init_time_utc)
36
+
37
+ # Make sure the spatial coords are in increasing order
38
+ ds = make_spatial_coords_increasing(ds, x_coord="x_osgb", y_coord="y_osgb")
39
+
40
+ ds = ds.transpose("init_time_utc", "step", "channel", "x_osgb", "y_osgb")
41
+
42
+ # TODO: should we control the dtype of the DataArray?
43
+ return ds.UKV
44
+
45
+
@@ -0,0 +1,34 @@
1
+ from pathlib import Path
2
+ import xarray as xr
3
+
4
+
5
+ def open_zarr_paths(
6
+ zarr_path: Path | str | list[Path] | list[str],
7
+ time_dim: str = "init_time"
8
+ ) -> xr.Dataset:
9
+ """Opens the NWP data
10
+
11
+ Args:
12
+ zarr_path: Path to the zarr(s) to open
13
+ time_dim: Name of the time dimension
14
+
15
+ Returns:
16
+ The opened Xarray Dataset
17
+ """
18
+ if type(zarr_path) in [list, tuple] or "*" in str(zarr_path): # Multi-file dataset
19
+ ds = xr.open_mfdataset(
20
+ zarr_path,
21
+ engine="zarr",
22
+ concat_dim=time_dim,
23
+ combine="nested",
24
+ chunks="auto",
25
+ ).sortby(time_dim)
26
+ else:
27
+ ds = xr.open_dataset(
28
+ zarr_path,
29
+ engine="zarr",
30
+ consolidated=True,
31
+ mode="r",
32
+ chunks="auto",
33
+ )
34
+ return ds
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ocf_data_sampler
3
- Version: 0.0.10
3
+ Version: 0.0.11
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
@@ -6,6 +6,10 @@ ocf_data_sampler/load/satellite.py,sha256=RcF0HmpV2PKedOdqcTc6dDk4qdQZAdTLYwmMuN
6
6
  ocf_data_sampler/load/utils.py,sha256=tkhuhL3YzJucAtaCH572OxBkYvcEDpSed83yg02O8jg,966
7
7
  ocf_data_sampler/load/nwp/__init__.py,sha256=SmcrnbygO5xtCKmGR4wtHrj-HI7nOAvnAtfuvRufBGQ,25
8
8
  ocf_data_sampler/load/nwp/nwp.py,sha256=O4QnajEZem8BvBgTcYYDBhRhgqPYuJkolHmpMRmrXEA,610
9
+ ocf_data_sampler/load/nwp/providers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
+ ocf_data_sampler/load/nwp/providers/ecmwf.py,sha256=1AFfdhReLjVZIfoA6N1fnKuBS-c8s_6W660A4k5KfA8,1095
11
+ ocf_data_sampler/load/nwp/providers/ukv.py,sha256=IyZ9F9W9exfm08z1ndKsDN6BG2iir5bYf6RI4pOlGb4,1124
12
+ ocf_data_sampler/load/nwp/providers/utils.py,sha256=Sy2exG1wpXLLhMXYdsfR-DZMR3txG1_bBmBdchlc-yA,848
9
13
  ocf_data_sampler/numpy_batch/__init__.py,sha256=mrtqwbGik5Zc9MYP5byfCTBm08wMtS2XnTsypC4fPMo,245
10
14
  ocf_data_sampler/numpy_batch/gsp.py,sha256=EL0_cJJNyvkQQcOat9vFA61pF4lema3BP_vB4ZS788U,805
11
15
  ocf_data_sampler/numpy_batch/nwp.py,sha256=Rv0yfDj902Z2oCwdlRjOs3Kh-F5Fgxjjylh99-lQ9ws,1105
@@ -21,8 +25,8 @@ ocf_data_sampler/torch_datasets/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOC
21
25
  ocf_data_sampler/torch_datasets/pvnet_uk_regional.py,sha256=rVKFfoHqSfm4C-eOXiqi5GwBJdMewRMIikvpjEJXi1s,17477
22
26
  tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
27
  tests/conftest.py,sha256=OcArgF60paroZQqoP7xExRBF34nEyMuXd7dS7hD6p3w,5393
24
- ocf_data_sampler-0.0.10.dist-info/LICENSE,sha256=F-Q3UFCR-BECSocV55BFDpn4YKxve9PKrm-lTt6o_Tg,1073
25
- ocf_data_sampler-0.0.10.dist-info/METADATA,sha256=eXXMZ7ogKXx0j3Krj508liDesXTjUzM2c0NlzOz1P6Q,588
26
- ocf_data_sampler-0.0.10.dist-info/WHEEL,sha256=HiCZjzuy6Dw0hdX5R3LCFPDmFS4BWl8H-8W39XfmgX4,91
27
- ocf_data_sampler-0.0.10.dist-info/top_level.txt,sha256=KaQn5qzkJGJP6hKWqsVAc9t0cMLjVvSTk8-kTrW79SA,23
28
- ocf_data_sampler-0.0.10.dist-info/RECORD,,
28
+ ocf_data_sampler-0.0.11.dist-info/LICENSE,sha256=F-Q3UFCR-BECSocV55BFDpn4YKxve9PKrm-lTt6o_Tg,1073
29
+ ocf_data_sampler-0.0.11.dist-info/METADATA,sha256=UygNspgLmps-YBxZwJd9wWq1ATU9mPtvRZ4b3-Qbr24,588
30
+ ocf_data_sampler-0.0.11.dist-info/WHEEL,sha256=HiCZjzuy6Dw0hdX5R3LCFPDmFS4BWl8H-8W39XfmgX4,91
31
+ ocf_data_sampler-0.0.11.dist-info/top_level.txt,sha256=KaQn5qzkJGJP6hKWqsVAc9t0cMLjVvSTk8-kTrW79SA,23
32
+ ocf_data_sampler-0.0.11.dist-info/RECORD,,