ocf-data-sampler 0.0.51__tar.gz → 0.0.53__tar.gz

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.

Files changed (79) hide show
  1. {ocf_data_sampler-0.0.51/ocf_data_sampler.egg-info → ocf_data_sampler-0.0.53}/PKG-INFO +3 -2
  2. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/README.md +2 -1
  3. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/ocf_data_sampler/constants.py +48 -0
  4. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/ocf_data_sampler/load/utils.py +1 -1
  5. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/ocf_data_sampler/torch_datasets/datasets/site.py +25 -1
  6. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53/ocf_data_sampler.egg-info}/PKG-INFO +3 -2
  7. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/pyproject.toml +1 -1
  8. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/tests/torch_datasets/test_site.py +17 -2
  9. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/LICENSE +0 -0
  10. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/MANIFEST.in +0 -0
  11. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/ocf_data_sampler/__init__.py +0 -0
  12. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/ocf_data_sampler/config/__init__.py +0 -0
  13. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/ocf_data_sampler/config/load.py +0 -0
  14. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/ocf_data_sampler/config/model.py +0 -0
  15. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/ocf_data_sampler/config/save.py +0 -0
  16. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/ocf_data_sampler/data/uk_gsp_locations.csv +0 -0
  17. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/ocf_data_sampler/load/__init__.py +0 -0
  18. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/ocf_data_sampler/load/gsp.py +0 -0
  19. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/ocf_data_sampler/load/load_dataset.py +0 -0
  20. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/ocf_data_sampler/load/nwp/__init__.py +0 -0
  21. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/ocf_data_sampler/load/nwp/nwp.py +0 -0
  22. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/ocf_data_sampler/load/nwp/providers/__init__.py +0 -0
  23. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/ocf_data_sampler/load/nwp/providers/ecmwf.py +0 -0
  24. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/ocf_data_sampler/load/nwp/providers/ukv.py +0 -0
  25. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/ocf_data_sampler/load/nwp/providers/utils.py +0 -0
  26. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/ocf_data_sampler/load/satellite.py +0 -0
  27. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/ocf_data_sampler/load/site.py +0 -0
  28. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/ocf_data_sampler/numpy_sample/__init__.py +0 -0
  29. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/ocf_data_sampler/numpy_sample/collate.py +0 -0
  30. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/ocf_data_sampler/numpy_sample/datetime_features.py +0 -0
  31. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/ocf_data_sampler/numpy_sample/gsp.py +0 -0
  32. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/ocf_data_sampler/numpy_sample/nwp.py +0 -0
  33. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/ocf_data_sampler/numpy_sample/satellite.py +0 -0
  34. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/ocf_data_sampler/numpy_sample/site.py +0 -0
  35. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/ocf_data_sampler/numpy_sample/sun_position.py +0 -0
  36. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/ocf_data_sampler/select/__init__.py +0 -0
  37. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/ocf_data_sampler/select/dropout.py +0 -0
  38. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/ocf_data_sampler/select/fill_time_periods.py +0 -0
  39. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/ocf_data_sampler/select/find_contiguous_time_periods.py +0 -0
  40. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/ocf_data_sampler/select/geospatial.py +0 -0
  41. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/ocf_data_sampler/select/location.py +0 -0
  42. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/ocf_data_sampler/select/select_spatial_slice.py +0 -0
  43. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/ocf_data_sampler/select/select_time_slice.py +0 -0
  44. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/ocf_data_sampler/select/spatial_slice_for_dataset.py +0 -0
  45. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/ocf_data_sampler/select/time_slice_for_dataset.py +0 -0
  46. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/ocf_data_sampler/torch_datasets/datasets/__init__.py +0 -0
  47. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/ocf_data_sampler/torch_datasets/datasets/pvnet_uk_regional.py +0 -0
  48. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/ocf_data_sampler/torch_datasets/utils/merge_and_fill_utils.py +0 -0
  49. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/ocf_data_sampler/torch_datasets/utils/valid_time_periods.py +0 -0
  50. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/ocf_data_sampler/utils.py +0 -0
  51. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/ocf_data_sampler.egg-info/SOURCES.txt +0 -0
  52. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/ocf_data_sampler.egg-info/dependency_links.txt +0 -0
  53. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/ocf_data_sampler.egg-info/requires.txt +0 -0
  54. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/ocf_data_sampler.egg-info/top_level.txt +0 -0
  55. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/scripts/refactor_site.py +0 -0
  56. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/setup.cfg +0 -0
  57. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/tests/__init__.py +0 -0
  58. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/tests/config/test_config.py +0 -0
  59. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/tests/config/test_save.py +0 -0
  60. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/tests/conftest.py +0 -0
  61. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/tests/load/test_load_gsp.py +0 -0
  62. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/tests/load/test_load_nwp.py +0 -0
  63. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/tests/load/test_load_satellite.py +0 -0
  64. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/tests/load/test_load_sites.py +0 -0
  65. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/tests/numpy_sample/test_collate.py +0 -0
  66. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/tests/numpy_sample/test_datetime_features.py +0 -0
  67. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/tests/numpy_sample/test_gsp.py +0 -0
  68. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/tests/numpy_sample/test_nwp.py +0 -0
  69. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/tests/numpy_sample/test_satellite.py +0 -0
  70. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/tests/numpy_sample/test_sun_position.py +0 -0
  71. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/tests/select/test_dropout.py +0 -0
  72. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/tests/select/test_fill_time_periods.py +0 -0
  73. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/tests/select/test_find_contiguous_time_periods.py +0 -0
  74. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/tests/select/test_location.py +0 -0
  75. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/tests/select/test_select_spatial_slice.py +0 -0
  76. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/tests/select/test_select_time_slice.py +0 -0
  77. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/tests/torch_datasets/conftest.py +0 -0
  78. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/tests/torch_datasets/test_merge_and_fill_utils.py +0 -0
  79. {ocf_data_sampler-0.0.51 → ocf_data_sampler-0.0.53}/tests/torch_datasets/test_pvnet_uk_regional.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: ocf_data_sampler
3
- Version: 0.0.51
3
+ Version: 0.0.53
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
@@ -56,7 +56,7 @@ Requires-Dist: mkdocs-material>=8.0; extra == "docs"
56
56
  # ocf-data-sampler
57
57
 
58
58
  <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
59
- [![All Contributors](https://img.shields.io/badge/all_contributors-11-orange.svg?style=flat-square)](#contributors-)
59
+ [![All Contributors](https://img.shields.io/badge/all_contributors-12-orange.svg?style=flat-square)](#contributors-)
60
60
  <!-- ALL-CONTRIBUTORS-BADGE:END -->
61
61
 
62
62
  [![tags badge](https://img.shields.io/github/v/tag/openclimatefix/ocf-data-sampler?include_prereleases&sort=semver&color=FFAC5F)](https://github.com/openclimatefix/ocf-data-sampler/tags)
@@ -136,6 +136,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
136
136
  <td align="center" valign="top" width="14.28%"><a href="https://timothyajaniportfolio-b6v3zq29k-timthegreat.vercel.app/"><img src="https://avatars.githubusercontent.com/u/60073728?v=4?s=100" width="100px;" alt="Ajani Timothy"/><br /><sub><b>Ajani Timothy</b></sub></a><br /><a href="https://github.com/openclimatefix/ocf-data-sampler/commits?author=Tim1119" title="Code">💻</a></td>
137
137
  <td align="center" valign="top" width="14.28%"><a href="https://rupeshmangalam.vercel.app/"><img src="https://avatars.githubusercontent.com/u/91172425?v=4?s=100" width="100px;" alt="Rupesh Mangalam"/><br /><sub><b>Rupesh Mangalam</b></sub></a><br /><a href="https://github.com/openclimatefix/ocf-data-sampler/commits?author=RupeshMangalam21" title="Code">💻</a></td>
138
138
  <td align="center" valign="top" width="14.28%"><a href="http://siddharth7113.github.io"><img src="https://avatars.githubusercontent.com/u/114160268?v=4?s=100" width="100px;" alt="Siddharth"/><br /><sub><b>Siddharth</b></sub></a><br /><a href="https://github.com/openclimatefix/ocf-data-sampler/commits?author=siddharth7113" title="Code">💻</a></td>
139
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/Sachin-G13"><img src="https://avatars.githubusercontent.com/u/190184500?v=4?s=100" width="100px;" alt="Sachin-G13"/><br /><sub><b>Sachin-G13</b></sub></a><br /><a href="https://github.com/openclimatefix/ocf-data-sampler/commits?author=Sachin-G13" title="Code">💻</a></td>
139
140
  </tr>
140
141
  </tbody>
141
142
  </table>
@@ -1,7 +1,7 @@
1
1
  # ocf-data-sampler
2
2
 
3
3
  <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
4
- [![All Contributors](https://img.shields.io/badge/all_contributors-11-orange.svg?style=flat-square)](#contributors-)
4
+ [![All Contributors](https://img.shields.io/badge/all_contributors-12-orange.svg?style=flat-square)](#contributors-)
5
5
  <!-- ALL-CONTRIBUTORS-BADGE:END -->
6
6
 
7
7
  [![tags badge](https://img.shields.io/github/v/tag/openclimatefix/ocf-data-sampler?include_prereleases&sort=semver&color=FFAC5F)](https://github.com/openclimatefix/ocf-data-sampler/tags)
@@ -81,6 +81,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
81
81
  <td align="center" valign="top" width="14.28%"><a href="https://timothyajaniportfolio-b6v3zq29k-timthegreat.vercel.app/"><img src="https://avatars.githubusercontent.com/u/60073728?v=4?s=100" width="100px;" alt="Ajani Timothy"/><br /><sub><b>Ajani Timothy</b></sub></a><br /><a href="https://github.com/openclimatefix/ocf-data-sampler/commits?author=Tim1119" title="Code">💻</a></td>
82
82
  <td align="center" valign="top" width="14.28%"><a href="https://rupeshmangalam.vercel.app/"><img src="https://avatars.githubusercontent.com/u/91172425?v=4?s=100" width="100px;" alt="Rupesh Mangalam"/><br /><sub><b>Rupesh Mangalam</b></sub></a><br /><a href="https://github.com/openclimatefix/ocf-data-sampler/commits?author=RupeshMangalam21" title="Code">💻</a></td>
83
83
  <td align="center" valign="top" width="14.28%"><a href="http://siddharth7113.github.io"><img src="https://avatars.githubusercontent.com/u/114160268?v=4?s=100" width="100px;" alt="Siddharth"/><br /><sub><b>Siddharth</b></sub></a><br /><a href="https://github.com/openclimatefix/ocf-data-sampler/commits?author=siddharth7113" title="Code">💻</a></td>
84
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/Sachin-G13"><img src="https://avatars.githubusercontent.com/u/190184500?v=4?s=100" width="100px;" alt="Sachin-G13"/><br /><sub><b>Sachin-G13</b></sub></a><br /><a href="https://github.com/openclimatefix/ocf-data-sampler/commits?author=Sachin-G13" title="Code">💻</a></td>
84
85
  </tr>
85
86
  </tbody>
86
87
  </table>
@@ -5,6 +5,7 @@ import numpy as np
5
5
  NWP_PROVIDERS = [
6
6
  "ukv",
7
7
  "ecmwf",
8
+ "gfs"
8
9
  ]
9
10
 
10
11
 
@@ -127,13 +128,60 @@ ECMWF_MEAN = {
127
128
  ECMWF_STD = _to_data_array(ECMWF_STD)
128
129
  ECMWF_MEAN = _to_data_array(ECMWF_MEAN)
129
130
 
131
+ # ------ GFS
132
+ GFS_STD = {
133
+ "dlwrf": 96.305916,
134
+ "dswrf": 246.18533,
135
+ "hcc": 42.525383,
136
+ "lcc": 44.3732,
137
+ "mcc": 43.150745,
138
+ "prate": 0.00010159573,
139
+ "r": 25.440672,
140
+ "sde": 0.43345627,
141
+ "t": 22.825893,
142
+ "tcc": 41.030598,
143
+ "u10": 5.470838,
144
+ "u100": 6.8899174,
145
+ "v10": 4.7401133,
146
+ "v100": 6.076132,
147
+ "vis": 8294.022,
148
+ "u": 10.614556,
149
+ "v": 7.176398,
150
+ }
151
+
152
+ GFS_MEAN = {
153
+ "dlwrf": 298.342,
154
+ "dswrf": 168.12321,
155
+ "hcc": 35.272,
156
+ "lcc": 43.578342,
157
+ "mcc": 33.738823,
158
+ "prate": 2.8190969e-05,
159
+ "r": 18.359747,
160
+ "sde": 0.36937004,
161
+ "t": 278.5223,
162
+ "tcc": 66.841606,
163
+ "u10": -0.0022310058,
164
+ "u100": 0.0823025,
165
+ "v10": 0.06219831,
166
+ "v100": 0.0797807,
167
+ "vis": 19628.32,
168
+ "u": 11.645444,
169
+ "v": 0.12330122,
170
+ }
171
+
172
+ GFS_STD = _to_data_array(GFS_STD)
173
+ GFS_MEAN = _to_data_array(GFS_MEAN)
174
+
175
+
130
176
  NWP_STDS = NWPStatDict(
131
177
  ukv=UKV_STD,
132
178
  ecmwf=ECMWF_STD,
179
+ gfs=GFS_STD
133
180
  )
134
181
  NWP_MEANS = NWPStatDict(
135
182
  ukv=UKV_MEAN,
136
183
  ecmwf=ECMWF_MEAN,
184
+ gfs=GFS_MEAN
137
185
  )
138
186
 
139
187
  # ------ Satellite
@@ -40,4 +40,4 @@ def get_xr_data_array_from_xr_dataset(ds: xr.Dataset) -> xr.DataArray:
40
40
 
41
41
  datavars = list(ds.var())
42
42
  assert len(datavars) == 1, "Cannot open as xr.DataArray: dataset contains multiple variables"
43
- return ds[datavars[0]]
43
+ return ds[datavars[0]]
@@ -1,6 +1,6 @@
1
1
  """Torch dataset for sites"""
2
2
  import logging
3
-
3
+ import numpy as np
4
4
  import pandas as pd
5
5
  import xarray as xr
6
6
  from typing import Tuple
@@ -421,3 +421,27 @@ def convert_to_numpy_and_combine(
421
421
  combined_sample = fill_nans_in_arrays(combined_sample)
422
422
 
423
423
  return combined_sample
424
+
425
+
426
+ def coarsen_data(xr_data: xr.Dataset, coarsen_to_deg: float=0.1):
427
+ """
428
+ Coarsen the data to a specified resolution in degrees.
429
+
430
+ Args:
431
+ xr_data: xarray dataset to coarsen
432
+ coarsen_to_deg: resolution to coarsen to in degrees
433
+ """
434
+
435
+ if "latitude" in xr_data.coords and "longitude" in xr_data.coords:
436
+ step = np.abs(xr_data.latitude.values[1]-xr_data.latitude.values[0])
437
+ step = np.round(step,4)
438
+ coarsen_factor = int(coarsen_to_deg/step)
439
+ if coarsen_factor > 1:
440
+ xr_data = xr_data.coarsen(
441
+ latitude=coarsen_factor,
442
+ longitude=coarsen_factor,
443
+ boundary="pad",
444
+ coord_func="min"
445
+ ).mean()
446
+
447
+ return xr_data
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: ocf_data_sampler
3
- Version: 0.0.51
3
+ Version: 0.0.53
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
@@ -56,7 +56,7 @@ Requires-Dist: mkdocs-material>=8.0; extra == "docs"
56
56
  # ocf-data-sampler
57
57
 
58
58
  <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
59
- [![All Contributors](https://img.shields.io/badge/all_contributors-11-orange.svg?style=flat-square)](#contributors-)
59
+ [![All Contributors](https://img.shields.io/badge/all_contributors-12-orange.svg?style=flat-square)](#contributors-)
60
60
  <!-- ALL-CONTRIBUTORS-BADGE:END -->
61
61
 
62
62
  [![tags badge](https://img.shields.io/github/v/tag/openclimatefix/ocf-data-sampler?include_prereleases&sort=semver&color=FFAC5F)](https://github.com/openclimatefix/ocf-data-sampler/tags)
@@ -136,6 +136,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
136
136
  <td align="center" valign="top" width="14.28%"><a href="https://timothyajaniportfolio-b6v3zq29k-timthegreat.vercel.app/"><img src="https://avatars.githubusercontent.com/u/60073728?v=4?s=100" width="100px;" alt="Ajani Timothy"/><br /><sub><b>Ajani Timothy</b></sub></a><br /><a href="https://github.com/openclimatefix/ocf-data-sampler/commits?author=Tim1119" title="Code">💻</a></td>
137
137
  <td align="center" valign="top" width="14.28%"><a href="https://rupeshmangalam.vercel.app/"><img src="https://avatars.githubusercontent.com/u/91172425?v=4?s=100" width="100px;" alt="Rupesh Mangalam"/><br /><sub><b>Rupesh Mangalam</b></sub></a><br /><a href="https://github.com/openclimatefix/ocf-data-sampler/commits?author=RupeshMangalam21" title="Code">💻</a></td>
138
138
  <td align="center" valign="top" width="14.28%"><a href="http://siddharth7113.github.io"><img src="https://avatars.githubusercontent.com/u/114160268?v=4?s=100" width="100px;" alt="Siddharth"/><br /><sub><b>Siddharth</b></sub></a><br /><a href="https://github.com/openclimatefix/ocf-data-sampler/commits?author=siddharth7113" title="Code">💻</a></td>
139
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/Sachin-G13"><img src="https://avatars.githubusercontent.com/u/190184500?v=4?s=100" width="100px;" alt="Sachin-G13"/><br /><sub><b>Sachin-G13</b></sub></a><br /><a href="https://github.com/openclimatefix/ocf-data-sampler/commits?author=Sachin-G13" title="Code">💻</a></td>
139
140
  </tr>
140
141
  </tbody>
141
142
  </table>
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "ocf_data_sampler"
7
- version = "0.0.51"
7
+ version = "0.0.53"
8
8
  license = { file = "LICENSE" }
9
9
  readme = "README.md"
10
10
  description = "Sample from weather data for renewable energy prediction"
@@ -1,7 +1,8 @@
1
1
  import pandas as pd
2
2
  import numpy as np
3
- from ocf_data_sampler.torch_datasets.datasets.site import SitesDataset, convert_from_dataset_to_dict_datasets
3
+ from ocf_data_sampler.torch_datasets.datasets.site import SitesDataset, convert_from_dataset_to_dict_datasets, coarsen_data
4
4
  from xarray import Dataset, DataArray
5
+ import xarray as xr
5
6
 
6
7
  from torch.utils.data import DataLoader
7
8
 
@@ -43,7 +44,6 @@ def test_site(site_config_filename):
43
44
 
44
45
  expected_data_vars = {"nwp-ukv", "satellite", "site"}
45
46
 
46
- import xarray as xr
47
47
 
48
48
  sample.to_netcdf("sample.nc")
49
49
  sample = xr.open_dataset("sample.nc")
@@ -198,3 +198,18 @@ def test_process_and_combine_site_sample_dict(site_config_filename):
198
198
  assert nwp_result.shape == (4, 1, 2, 2), f"Unexpected shape for nwp-ukv : {nwp_result.shape}"
199
199
  site_result = result["site"]
200
200
  assert site_result.shape == (197,), f"Unexpected shape for site: {site_result.shape}"
201
+
202
+
203
+ def test_potentially_coarsen(ds_nwp_ecmwf):
204
+ """Test potentially_coarsen function with ECMWF_UK data."""
205
+ nwp_data = ds_nwp_ecmwf
206
+ assert nwp_data.ECMWF_UK.shape[3:] == (15, 12) # Check initial shape (lon, lat)
207
+
208
+ data = coarsen_data(xr_data=nwp_data, coarsen_to_deg=2)
209
+ assert data.ECMWF_UK.shape[3:] == (8, 6) # Coarsen to every 2 degrees
210
+
211
+ data = coarsen_data(xr_data=nwp_data, coarsen_to_deg=3)
212
+ assert data.ECMWF_UK.shape[3:] == (5, 4) # Coarsen to every 3 degrees
213
+
214
+ data = coarsen_data(xr_data=nwp_data, coarsen_to_deg=1)
215
+ assert data.ECMWF_UK.shape[3:] == (15, 12) # No coarsening (same shape)