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

@@ -14,6 +14,7 @@ NWP_PROVIDERS = [
14
14
  "ecmwf",
15
15
  "gfs",
16
16
  "icon_eu",
17
+ "cloudcasting",
17
18
  ]
18
19
 
19
20
 
@@ -2,6 +2,7 @@
2
2
 
3
3
  import xarray as xr
4
4
 
5
+ from ocf_data_sampler.load.nwp.providers.cloudcasting import open_cloudcasting
5
6
  from ocf_data_sampler.load.nwp.providers.ecmwf import open_ifs
6
7
  from ocf_data_sampler.load.nwp.providers.gfs import open_gfs
7
8
  from ocf_data_sampler.load.nwp.providers.icon import open_icon_eu
@@ -28,6 +29,8 @@ def open_nwp(zarr_path: str | list[str], provider: str) -> xr.DataArray:
28
29
  _open_nwp = open_icon_eu
29
30
  elif provider == "gfs":
30
31
  _open_nwp = open_gfs
32
+ elif provider == "cloudcasting":
33
+ _open_nwp = open_cloudcasting
31
34
  else:
32
35
  raise ValueError(f"Unknown provider: {provider}")
33
36
 
@@ -0,0 +1,51 @@
1
+ """Cloudcasting provider loader."""
2
+
3
+ from pathlib import Path
4
+
5
+ import xarray as xr
6
+
7
+ from ocf_data_sampler.load.nwp.providers.utils import open_zarr_paths
8
+ from ocf_data_sampler.load.utils import (
9
+ check_time_unique_increasing,
10
+ get_xr_data_array_from_xr_dataset,
11
+ make_spatial_coords_increasing,
12
+ )
13
+
14
+
15
+ def open_cloudcasting(zarr_path: Path | str | list[Path] | list[str]) -> xr.DataArray:
16
+ """Opens the satellite predictions from cloudcasting.
17
+
18
+ Cloudcasting is a OCF forecast product. We forecast future satellite images from recent
19
+ satellite images. More information can be found in the references below.
20
+
21
+ Args:
22
+ zarr_path: Path to the zarr to open
23
+
24
+ Returns:
25
+ Xarray DataArray of the cloudcasting data
26
+
27
+ References:
28
+ [1] https://www.openclimatefix.org/projects/cloud-forecasting
29
+ [2] https://github.com/ClimeTrend/cloudcasting
30
+ [3] https://github.com/openclimatefix/sat_pred
31
+ """
32
+ # Open the data
33
+ ds = open_zarr_paths(zarr_path)
34
+
35
+ # Rename
36
+ ds = ds.rename(
37
+ {
38
+ "init_time": "init_time_utc",
39
+ "variable": "channel",
40
+ },
41
+ )
42
+
43
+ # Check the timestamps are unique and increasing
44
+ check_time_unique_increasing(ds.init_time_utc)
45
+
46
+ # Make sure the spatial coords are in increasing order
47
+ ds = make_spatial_coords_increasing(ds, x_coord="x_geostationary", y_coord="y_geostationary")
48
+
49
+ ds = ds.transpose("init_time_utc", "step", "channel", "x_geostationary", "y_geostationary")
50
+
51
+ return get_xr_data_array_from_xr_dataset(ds)
@@ -55,7 +55,10 @@ def select_time_slice_nwp(
55
55
  if accum_channels is None:
56
56
  accum_channels = []
57
57
 
58
- if dropout_timedeltas is not None:
58
+ if dropout_timedeltas is None:
59
+ dropout_timedeltas = []
60
+
61
+ if len(dropout_timedeltas)>0:
59
62
  if not all(t < pd.Timedelta(0) for t in dropout_timedeltas):
60
63
  raise ValueError("dropout timedeltas must be negative")
61
64
  if len(dropout_timedeltas) < 1:
@@ -64,7 +67,7 @@ def select_time_slice_nwp(
64
67
  if not (0 <= dropout_frac <= 1):
65
68
  raise ValueError("dropout_frac must be between 0 and 1")
66
69
 
67
- consider_dropout = (dropout_timedeltas is not None) and dropout_frac > 0
70
+ consider_dropout = len(dropout_timedeltas) > 0 and dropout_frac > 0
68
71
 
69
72
  # The accumatated and non-accumulated channels
70
73
  accum_channels = np.intersect1d(da.channel.values, accum_channels)
@@ -28,7 +28,7 @@ def find_valid_time_periods(datasets_dict: dict, config: Configuration) -> pd.Da
28
28
  for nwp_key, nwp_config in config.input_data.nwp.items():
29
29
  da = datasets_dict["nwp"][nwp_key]
30
30
 
31
- if nwp_config.dropout_timedeltas_minutes is None:
31
+ if nwp_config.dropout_timedeltas_minutes==[]:
32
32
  max_dropout = minutes(0)
33
33
  else:
34
34
  max_dropout = minutes(np.max(np.abs(nwp_config.dropout_timedeltas_minutes)))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: ocf-data-sampler
3
- Version: 0.2.2
3
+ Version: 0.2.4
4
4
  Author: James Fulton, Peter Dudfield
5
5
  Author-email: Open Climate Fix team <info@openclimatefix.org>
6
6
  License: MIT License
@@ -2,7 +2,7 @@ ocf_data_sampler/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,
2
2
  ocf_data_sampler/utils.py,sha256=DjuneGGisl08ENvPZV_lrcX4b2NCKJC1ZpXgIpxuQi4,290
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
- ocf_data_sampler/config/model.py,sha256=y8maV_1z0LL_m0J607ka_yJ0KI-0ssYDn5Ghk8aNgR0,10189
5
+ ocf_data_sampler/config/model.py,sha256=pb02qtCmWhJhrU3_T_gUzC7i2_JcO8xGwwhKGd8yMuk,10209
6
6
  ocf_data_sampler/config/save.py,sha256=m8SPw5rXjkMm1rByjh3pK5StdBi4e8ysnn3jQopdRaI,1064
7
7
  ocf_data_sampler/data/uk_gsp_locations.csv,sha256=RSh7DRh55E3n8lVAaWXGTaXXHevZZtI58td4d4DhGos,10415772
8
8
  ocf_data_sampler/load/__init__.py,sha256=T5Zj1PGt0aiiNEN7Ra1Ac-cBsNKhphmmHy_8g7XU_w0,219
@@ -12,8 +12,9 @@ ocf_data_sampler/load/satellite.py,sha256=E7Ln7Y60Qr1RTV-_R71YoxXQM-Ca7Y1faIo3oK
12
12
  ocf_data_sampler/load/site.py,sha256=zOzlWk6pYZBB5daqG8URGksmDXWKrkutUvN8uALAIh8,1468
13
13
  ocf_data_sampler/load/utils.py,sha256=Jwbr1rpEa3cefjw-OTVRaxnIHyGixYB3TlTlta0BOdU,1727
14
14
  ocf_data_sampler/load/nwp/__init__.py,sha256=SmcrnbygO5xtCKmGR4wtHrj-HI7nOAvnAtfuvRufBGQ,25
15
- ocf_data_sampler/load/nwp/nwp.py,sha256=0AIHQTJLUtwP2Toz_PskOTYFJXfMvGhk8faAcNvI9jk,922
15
+ ocf_data_sampler/load/nwp/nwp.py,sha256=OUK6thsKfEcqGUj4WoxDiyqGcVwwoujePdmQRis8H8I,1076
16
16
  ocf_data_sampler/load/nwp/providers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
+ ocf_data_sampler/load/nwp/providers/cloudcasting.py,sha256=mGsEqo5nVGQhfIK1KC-ywLsaFKU18-UFKqQVtB8gpnw,1564
17
18
  ocf_data_sampler/load/nwp/providers/ecmwf.py,sha256=5AzktPJgertCx6oij6aePRosPuZHGFznMxTgtkk_mgc,994
18
19
  ocf_data_sampler/load/nwp/providers/gfs.py,sha256=JSDeh4YG1wibV8--P3X-zTO8LP0dsJcpFvIyglBbhi0,979
19
20
  ocf_data_sampler/load/nwp/providers/icon.py,sha256=yYUrs5HgjU0C5pMHBB6FGn3tLjswi990IY6QCXS1Zmw,1569
@@ -39,7 +40,7 @@ ocf_data_sampler/select/find_contiguous_time_periods.py,sha256=cEXrQDzk8pXknxB0q
39
40
  ocf_data_sampler/select/geospatial.py,sha256=CDExkl36eZOKmdJPzUr_K0Wn3axHqv5nYo-EkSiINcc,5032
40
41
  ocf_data_sampler/select/location.py,sha256=AZvGR8y62opiW7zACGXjoOtBEWRfSLOZIA73O5Deu0c,1037
41
42
  ocf_data_sampler/select/select_spatial_slice.py,sha256=qY2Ll00EPA80oBtzwMoR5nk0UIpoWZF9oXl22YwWr0Q,12341
42
- ocf_data_sampler/select/select_time_slice.py,sha256=q5QdgHPIXQb49uT5NwbOguY1GhjWc_o3c-2cDb5kLAo,5455
43
+ ocf_data_sampler/select/select_time_slice.py,sha256=HeHbwZ0CP03x0-LaJtpbSdtpLufwVTR73p6wH6O_PS8,5513
43
44
  ocf_data_sampler/select/spatial_slice_for_dataset.py,sha256=Hvz0wHSWMYYamf2oHNiGlzJcM4cAH6pL_7ZEvIBL2dE,1882
44
45
  ocf_data_sampler/select/time_slice_for_dataset.py,sha256=1DN6VsWWdLvkpJxodZtBRDUgC4vJE2td_RP5J3ZqPNw,4268
45
46
  ocf_data_sampler/torch_datasets/datasets/__init__.py,sha256=jfJSFcR0eO1AqeH7S3KnGjsBqVZT5w3oyi784PUR6Q0,146
@@ -48,10 +49,10 @@ ocf_data_sampler/torch_datasets/datasets/site.py,sha256=j29cWPIcksRbge014MxR0_Og
48
49
  ocf_data_sampler/torch_datasets/utils/__init__.py,sha256=7Yt4anQVU9y27nj4Wx1tRLqbAQLbzW0ED71UL65LvxA,187
49
50
  ocf_data_sampler/torch_datasets/utils/channel_dict_to_dataarray.py,sha256=MGylKhXxXLQC2fYv-8L_GVoYhov3LcEwC0Q21xItDSk,353
50
51
  ocf_data_sampler/torch_datasets/utils/merge_and_fill_utils.py,sha256=we7BTxRH7B7jKayDT7YfNyfI3zZClz2Bk-HXKQIokgU,956
51
- ocf_data_sampler/torch_datasets/utils/valid_time_periods.py,sha256=LdHgLPAYUVoCRMk2nnFdsMpygGS2kbps3h-7_bZnETw,4718
52
+ ocf_data_sampler/torch_datasets/utils/valid_time_periods.py,sha256=xcy75cVxl0WrglnX5YUAFjXXlO2GwEBHWyqo8TDuiOA,4714
52
53
  scripts/refactor_site.py,sha256=skzvsPP0Cn9yTKndzkilyNcGz4DZ88ctvCJ0XrBdc2A,3135
53
54
  utils/compute_icon_mean_stddev.py,sha256=a1oWMRMnny39rV-dvu8rcx85sb4bXzPFrR1gkUr4Jpg,2296
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,,
55
+ ocf_data_sampler-0.2.4.dist-info/METADATA,sha256=FC4sEcGWlkOdXRxqoiln0f-aYqXa5c9bRt7nVeNVuBI,11594
56
+ ocf_data_sampler-0.2.4.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
57
+ ocf_data_sampler-0.2.4.dist-info/top_level.txt,sha256=LEFU4Uk-PEo72QGLAfnVZIUEm37Q8mKuMeg_Xk-p33g,31
58
+ ocf_data_sampler-0.2.4.dist-info/RECORD,,