PVNet 3.0.36__tar.gz → 3.0.38__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.
Files changed (49) hide show
  1. {pvnet-3.0.36 → pvnet-3.0.38}/PKG-INFO +17 -7
  2. {pvnet-3.0.36 → pvnet-3.0.38}/PVNet.egg-info/PKG-INFO +17 -7
  3. {pvnet-3.0.36 → pvnet-3.0.38}/PVNet.egg-info/SOURCES.txt +2 -1
  4. {pvnet-3.0.36 → pvnet-3.0.38}/README.md +16 -6
  5. pvnet-3.0.38/pvnet/__init__.py +2 -0
  6. {pvnet-3.0.36 → pvnet-3.0.38}/pvnet/data/pv_site_datamodule.py +1 -1
  7. {pvnet-3.0.36 → pvnet-3.0.38}/pvnet/utils.py +28 -0
  8. pvnet-3.0.38/tests/test_utils.py +38 -0
  9. pvnet-3.0.36/pvnet/__init__.py +0 -2
  10. {pvnet-3.0.36 → pvnet-3.0.38}/LICENSE +0 -0
  11. {pvnet-3.0.36 → pvnet-3.0.38}/MANIFEST.in +0 -0
  12. {pvnet-3.0.36 → pvnet-3.0.38}/PVNet.egg-info/dependency_links.txt +0 -0
  13. {pvnet-3.0.36 → pvnet-3.0.38}/PVNet.egg-info/requires.txt +0 -0
  14. {pvnet-3.0.36 → pvnet-3.0.38}/PVNet.egg-info/top_level.txt +0 -0
  15. {pvnet-3.0.36 → pvnet-3.0.38}/pvnet/callbacks.py +0 -0
  16. {pvnet-3.0.36 → pvnet-3.0.38}/pvnet/data/__init__.py +0 -0
  17. {pvnet-3.0.36 → pvnet-3.0.38}/pvnet/data/base.py +0 -0
  18. {pvnet-3.0.36 → pvnet-3.0.38}/pvnet/data/datamodule.py +0 -0
  19. {pvnet-3.0.36 → pvnet-3.0.38}/pvnet/data/utils.py +0 -0
  20. {pvnet-3.0.36 → pvnet-3.0.38}/pvnet/data/wind_datamodule.py +0 -0
  21. {pvnet-3.0.36 → pvnet-3.0.38}/pvnet/load_model.py +0 -0
  22. {pvnet-3.0.36 → pvnet-3.0.38}/pvnet/models/__init__.py +0 -0
  23. {pvnet-3.0.36 → pvnet-3.0.38}/pvnet/models/base_model.py +0 -0
  24. {pvnet-3.0.36 → pvnet-3.0.38}/pvnet/models/baseline/__init__.py +0 -0
  25. {pvnet-3.0.36 → pvnet-3.0.38}/pvnet/models/baseline/last_value.py +0 -0
  26. {pvnet-3.0.36 → pvnet-3.0.38}/pvnet/models/baseline/single_value.py +0 -0
  27. {pvnet-3.0.36 → pvnet-3.0.38}/pvnet/models/ensemble.py +0 -0
  28. {pvnet-3.0.36 → pvnet-3.0.38}/pvnet/models/multimodal/__init__.py +0 -0
  29. {pvnet-3.0.36 → pvnet-3.0.38}/pvnet/models/multimodal/basic_blocks.py +0 -0
  30. {pvnet-3.0.36 → pvnet-3.0.38}/pvnet/models/multimodal/encoders/__init__.py +0 -0
  31. {pvnet-3.0.36 → pvnet-3.0.38}/pvnet/models/multimodal/encoders/basic_blocks.py +0 -0
  32. {pvnet-3.0.36 → pvnet-3.0.38}/pvnet/models/multimodal/encoders/encoders2d.py +0 -0
  33. {pvnet-3.0.36 → pvnet-3.0.38}/pvnet/models/multimodal/encoders/encoders3d.py +0 -0
  34. {pvnet-3.0.36 → pvnet-3.0.38}/pvnet/models/multimodal/encoders/encodersRNN.py +0 -0
  35. {pvnet-3.0.36 → pvnet-3.0.38}/pvnet/models/multimodal/linear_networks/__init__.py +0 -0
  36. {pvnet-3.0.36 → pvnet-3.0.38}/pvnet/models/multimodal/linear_networks/basic_blocks.py +0 -0
  37. {pvnet-3.0.36 → pvnet-3.0.38}/pvnet/models/multimodal/linear_networks/networks.py +0 -0
  38. {pvnet-3.0.36 → pvnet-3.0.38}/pvnet/models/multimodal/multimodal.py +0 -0
  39. {pvnet-3.0.36 → pvnet-3.0.38}/pvnet/models/multimodal/multimodal_base.py +0 -0
  40. {pvnet-3.0.36 → pvnet-3.0.38}/pvnet/models/multimodal/site_encoders/__init__.py +0 -0
  41. {pvnet-3.0.36 → pvnet-3.0.38}/pvnet/models/multimodal/site_encoders/basic_blocks.py +0 -0
  42. {pvnet-3.0.36 → pvnet-3.0.38}/pvnet/models/multimodal/site_encoders/encoders.py +0 -0
  43. {pvnet-3.0.36 → pvnet-3.0.38}/pvnet/models/multimodal/unimodal_teacher.py +0 -0
  44. {pvnet-3.0.36 → pvnet-3.0.38}/pvnet/models/utils.py +0 -0
  45. {pvnet-3.0.36 → pvnet-3.0.38}/pvnet/optimizers.py +0 -0
  46. {pvnet-3.0.36 → pvnet-3.0.38}/pvnet/training.py +0 -0
  47. {pvnet-3.0.36 → pvnet-3.0.38}/pyproject.toml +0 -0
  48. {pvnet-3.0.36 → pvnet-3.0.38}/setup.cfg +0 -0
  49. {pvnet-3.0.36 → pvnet-3.0.38}/tests/test_end2end.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PVNet
3
- Version: 3.0.36
3
+ Version: 3.0.38
4
4
  Summary: PVNet
5
5
  Author-email: Peter Dudfield <info@openclimatefix.org>
6
6
  Description-Content-Type: text/markdown
@@ -65,12 +65,12 @@ together.
65
65
 
66
66
  ## Experiments
67
67
 
68
- **Link to our workshop paper coming soon**
68
+ Our paper based on this repo was accepted into the Tackling Climate Change with Machine Learning workshop at ICLR 2024 and can be viewed [here](https://www.climatechange.ai/papers/iclr2024/46).
69
69
 
70
- Some very rough working notes on this model are
71
- [here](https://docs.google.com/document/d/1fbkfkBzp16WbnCg7RDuRDvgzInA6XQu3xh4NCjV-WDA/edit?usp=sharing).
70
+ Some slightly more structured notes on deliberate experiments we have performed with PVNet are [here](https://docs.google.com/document/d/1VumDwWd8YAfvXbOtJEv3ZJm_FHQDzrKXR0jU9vnvGQg).
72
71
 
73
- Some slightly more structured notes on deliberate experiments we have performed with PVNet are [here](https://docs.google.com/document/d/1VumDwWd8YAfvXbOtJEv3ZJm_FHQDzrKXR0jU9vnvGQg/edit?usp=sharing)
72
+ Some very rough, early working notes on this model are
73
+ [here](https://docs.google.com/document/d/1fbkfkBzp16WbnCg7RDuRDvgzInA6XQu3xh4NCjV-WDA). These are now somewhat out of date.
74
74
 
75
75
 
76
76
 
@@ -200,10 +200,15 @@ Where `FULL-PATH-TO-REPO` represent the whole path to the PVNet repo on your loc
200
200
 
201
201
  ### Running the batch creation script
202
202
 
203
- Run the save_batches.py script to create batches with the following example arguments as:
203
+ Run the save_batches.py script to create batches if setting parameters in the datamodule config (`streamed_batches.yaml` in this example):
204
204
 
205
205
  ```
206
- python scripts/save_batches.py datamodule=streamed_batches +batch_output_dir="./output" +num_train_batches=10 +num_val_batches=5
206
+ python scripts/save_batches.py
207
+ ```
208
+ or with the following example arguments to override config:
209
+
210
+ ```
211
+ python scripts/save_batches.py datamodule=streamed_batches datamodule.batch_output_dir="./output" datamodule.num_train_batches=10 datamodule.num_val_batches=5
207
212
  ```
208
213
 
209
214
  In this function the datamodule argument looks for a config under `PVNet/configs/datamodule`. The examples here are either to use "premade_batches" or "streamed_batches".
@@ -391,6 +396,11 @@ val data batches, you can now train PVNet by running:
391
396
  python run.py
392
397
  ```
393
398
 
399
+ ## Backtest
400
+
401
+ If you have succesfully trained a PVNet model and have a saved model checkpoint you can create a backtest using this, e.g. forecasts on historical data to evaluate forecast accuracy/skill. This can be done by running one of the scripts in this repo such as [the UK gsp backtest script](scripts/backtest_uk_gsp.py) or the [the pv site backtest script](scripts/backtest_sites.py), further info on how to run these are in each backtest file.
402
+
403
+
394
404
  ## Testing
395
405
 
396
406
  You can use `python -m pytest tests` to run tests
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PVNet
3
- Version: 3.0.36
3
+ Version: 3.0.38
4
4
  Summary: PVNet
5
5
  Author-email: Peter Dudfield <info@openclimatefix.org>
6
6
  Description-Content-Type: text/markdown
@@ -65,12 +65,12 @@ together.
65
65
 
66
66
  ## Experiments
67
67
 
68
- **Link to our workshop paper coming soon**
68
+ Our paper based on this repo was accepted into the Tackling Climate Change with Machine Learning workshop at ICLR 2024 and can be viewed [here](https://www.climatechange.ai/papers/iclr2024/46).
69
69
 
70
- Some very rough working notes on this model are
71
- [here](https://docs.google.com/document/d/1fbkfkBzp16WbnCg7RDuRDvgzInA6XQu3xh4NCjV-WDA/edit?usp=sharing).
70
+ Some slightly more structured notes on deliberate experiments we have performed with PVNet are [here](https://docs.google.com/document/d/1VumDwWd8YAfvXbOtJEv3ZJm_FHQDzrKXR0jU9vnvGQg).
72
71
 
73
- Some slightly more structured notes on deliberate experiments we have performed with PVNet are [here](https://docs.google.com/document/d/1VumDwWd8YAfvXbOtJEv3ZJm_FHQDzrKXR0jU9vnvGQg/edit?usp=sharing)
72
+ Some very rough, early working notes on this model are
73
+ [here](https://docs.google.com/document/d/1fbkfkBzp16WbnCg7RDuRDvgzInA6XQu3xh4NCjV-WDA). These are now somewhat out of date.
74
74
 
75
75
 
76
76
 
@@ -200,10 +200,15 @@ Where `FULL-PATH-TO-REPO` represent the whole path to the PVNet repo on your loc
200
200
 
201
201
  ### Running the batch creation script
202
202
 
203
- Run the save_batches.py script to create batches with the following example arguments as:
203
+ Run the save_batches.py script to create batches if setting parameters in the datamodule config (`streamed_batches.yaml` in this example):
204
204
 
205
205
  ```
206
- python scripts/save_batches.py datamodule=streamed_batches +batch_output_dir="./output" +num_train_batches=10 +num_val_batches=5
206
+ python scripts/save_batches.py
207
+ ```
208
+ or with the following example arguments to override config:
209
+
210
+ ```
211
+ python scripts/save_batches.py datamodule=streamed_batches datamodule.batch_output_dir="./output" datamodule.num_train_batches=10 datamodule.num_val_batches=5
207
212
  ```
208
213
 
209
214
  In this function the datamodule argument looks for a config under `PVNet/configs/datamodule`. The examples here are either to use "premade_batches" or "streamed_batches".
@@ -391,6 +396,11 @@ val data batches, you can now train PVNet by running:
391
396
  python run.py
392
397
  ```
393
398
 
399
+ ## Backtest
400
+
401
+ If you have succesfully trained a PVNet model and have a saved model checkpoint you can create a backtest using this, e.g. forecasts on historical data to evaluate forecast accuracy/skill. This can be done by running one of the scripts in this repo such as [the UK gsp backtest script](scripts/backtest_uk_gsp.py) or the [the pv site backtest script](scripts/backtest_sites.py), further info on how to run these are in each backtest file.
402
+
403
+
394
404
  ## Testing
395
405
 
396
406
  You can use `python -m pytest tests` to run tests
@@ -42,4 +42,5 @@ pvnet/models/multimodal/linear_networks/networks.py
42
42
  pvnet/models/multimodal/site_encoders/__init__.py
43
43
  pvnet/models/multimodal/site_encoders/basic_blocks.py
44
44
  pvnet/models/multimodal/site_encoders/encoders.py
45
- tests/test_end2end.py
45
+ tests/test_end2end.py
46
+ tests/test_utils.py
@@ -17,12 +17,12 @@ together.
17
17
 
18
18
  ## Experiments
19
19
 
20
- **Link to our workshop paper coming soon**
20
+ Our paper based on this repo was accepted into the Tackling Climate Change with Machine Learning workshop at ICLR 2024 and can be viewed [here](https://www.climatechange.ai/papers/iclr2024/46).
21
21
 
22
- Some very rough working notes on this model are
23
- [here](https://docs.google.com/document/d/1fbkfkBzp16WbnCg7RDuRDvgzInA6XQu3xh4NCjV-WDA/edit?usp=sharing).
22
+ Some slightly more structured notes on deliberate experiments we have performed with PVNet are [here](https://docs.google.com/document/d/1VumDwWd8YAfvXbOtJEv3ZJm_FHQDzrKXR0jU9vnvGQg).
24
23
 
25
- Some slightly more structured notes on deliberate experiments we have performed with PVNet are [here](https://docs.google.com/document/d/1VumDwWd8YAfvXbOtJEv3ZJm_FHQDzrKXR0jU9vnvGQg/edit?usp=sharing)
24
+ Some very rough, early working notes on this model are
25
+ [here](https://docs.google.com/document/d/1fbkfkBzp16WbnCg7RDuRDvgzInA6XQu3xh4NCjV-WDA). These are now somewhat out of date.
26
26
 
27
27
 
28
28
 
@@ -152,10 +152,15 @@ Where `FULL-PATH-TO-REPO` represent the whole path to the PVNet repo on your loc
152
152
 
153
153
  ### Running the batch creation script
154
154
 
155
- Run the save_batches.py script to create batches with the following example arguments as:
155
+ Run the save_batches.py script to create batches if setting parameters in the datamodule config (`streamed_batches.yaml` in this example):
156
156
 
157
157
  ```
158
- python scripts/save_batches.py datamodule=streamed_batches +batch_output_dir="./output" +num_train_batches=10 +num_val_batches=5
158
+ python scripts/save_batches.py
159
+ ```
160
+ or with the following example arguments to override config:
161
+
162
+ ```
163
+ python scripts/save_batches.py datamodule=streamed_batches datamodule.batch_output_dir="./output" datamodule.num_train_batches=10 datamodule.num_val_batches=5
159
164
  ```
160
165
 
161
166
  In this function the datamodule argument looks for a config under `PVNet/configs/datamodule`. The examples here are either to use "premade_batches" or "streamed_batches".
@@ -343,6 +348,11 @@ val data batches, you can now train PVNet by running:
343
348
  python run.py
344
349
  ```
345
350
 
351
+ ## Backtest
352
+
353
+ If you have succesfully trained a PVNet model and have a saved model checkpoint you can create a backtest using this, e.g. forecasts on historical data to evaluate forecast accuracy/skill. This can be done by running one of the scripts in this repo such as [the UK gsp backtest script](scripts/backtest_uk_gsp.py) or the [the pv site backtest script](scripts/backtest_sites.py), further info on how to run these are in each backtest file.
354
+
355
+
346
356
  ## Testing
347
357
 
348
358
  You can use `python -m pytest tests` to run tests
@@ -0,0 +1,2 @@
1
+ """PVNet"""
2
+ __version__ = "3.0.38"
@@ -34,7 +34,7 @@ class PVSiteDataModule(BaseDataModule):
34
34
  def _get_premade_batches_datapipe(self, subdir, shuffle=False):
35
35
  filenames = list(glob.glob(f"{self.batch_dir}/{subdir}/*.nc"))
36
36
  data_pipeline = pvnet_site_netcdf_datapipe(
37
- keys=["pv", "nwp"],
37
+ keys=["pv", "nwp"], # add other keys e.g. sat if used as input in site model
38
38
  filenames=filenames,
39
39
  )
40
40
  data_pipeline = (
@@ -69,6 +69,34 @@ class GSPLocationLookup:
69
69
  )
70
70
 
71
71
 
72
+ class SiteLocationLookup:
73
+ """Query object for site location from site ID"""
74
+
75
+ def __init__(self, long: xr.DataArray, lat: xr.DataArray):
76
+ """Query object for site location from site ID
77
+
78
+ Args:
79
+ long: DataArray of the longitude coordinates for any given site ID
80
+ lat: DataArray of the latitude coordinates for any given site ID
81
+
82
+ """
83
+ self.longitude = long
84
+ self.latitude = lat
85
+
86
+ def __call__(self, site_id: int) -> Location:
87
+ """Returns the locations for the input site IDs.
88
+
89
+ Args:
90
+ site_id: Integer ID of the site
91
+ """
92
+ return Location(
93
+ coordinate_system="lon_lat",
94
+ x=self.longitude.sel(pv_system_id=site_id).item(),
95
+ y=self.latitude.sel(pv_system_id=site_id).item(),
96
+ id=site_id,
97
+ )
98
+
99
+
72
100
  def extras(config: DictConfig) -> None:
73
101
  """A couple of optional utilities.
74
102
 
@@ -0,0 +1,38 @@
1
+ from ocf_datapipes.utils.location import Location
2
+ from pvnet.utils import SiteLocationLookup
3
+ import xarray as xr
4
+ import pytest
5
+
6
+
7
+ @pytest.mark.parametrize(
8
+ "lookup_site_id, expected_x, expected_y, expected_id",
9
+ [
10
+ (1, -1.99106, 48.709865, 1),
11
+ (0, 0.30693, 51.509865, 0),
12
+ (2, -1.56106, 56.203865, 2),
13
+ ],
14
+ )
15
+ def test_site_location_lookup(lookup_site_id, expected_x, expected_y, expected_id):
16
+ # setup
17
+ site_ids = [0, 1, 2]
18
+ longs = [0.30693, -1.99106, -1.56106]
19
+ lats = [51.509865, 48.709865, 56.203865]
20
+ da_long = xr.DataArray(
21
+ data=longs,
22
+ dims="pv_system_id",
23
+ coords=dict(site_id=(["pv_system_id"], site_ids), long=(["pv_system_id"], longs)),
24
+ )
25
+ da_lat = xr.DataArray(
26
+ data=lats,
27
+ dims="pv_system_id",
28
+ coords=dict(site_id=(["pv_system_id"], site_ids), long=(["pv_system_id"], lats)),
29
+ )
30
+ # Actual testing part
31
+ site_lookup = SiteLocationLookup(long=da_long, lat=da_lat)
32
+
33
+ # retrieve location of site 1
34
+ site_location: Location = site_lookup(lookup_site_id)
35
+
36
+ assert site_location.x == expected_x
37
+ assert site_location.y == expected_y
38
+ assert site_location.id == expected_id
@@ -1,2 +0,0 @@
1
- """PVNet"""
2
- __version__ = "3.0.36"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes