PVNet 3.0.63__tar.gz → 4.0.0__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.
- pvnet-4.0.0/MANIFEST.in +2 -0
- {pvnet-3.0.63 → pvnet-4.0.0}/PKG-INFO +43 -8
- {pvnet-3.0.63 → pvnet-4.0.0}/PVNet.egg-info/PKG-INFO +43 -8
- {pvnet-3.0.63 → pvnet-4.0.0}/PVNet.egg-info/SOURCES.txt +6 -5
- {pvnet-3.0.63 → pvnet-4.0.0}/PVNet.egg-info/requires.txt +1 -0
- {pvnet-3.0.63 → pvnet-4.0.0}/README.md +40 -6
- pvnet-4.0.0/pvnet/__init__.py +2 -0
- pvnet-4.0.0/pvnet/data/__init__.py +3 -0
- pvnet-4.0.0/pvnet/data/base_datamodule.py +118 -0
- pvnet-4.0.0/pvnet/data/site_datamodule.py +53 -0
- pvnet-4.0.0/pvnet/data/uk_regional_datamodule.py +54 -0
- {pvnet-3.0.63 → pvnet-4.0.0}/pvnet/models/base_model.py +33 -76
- {pvnet-3.0.63 → pvnet-4.0.0}/pvnet/models/baseline/last_value.py +2 -3
- {pvnet-3.0.63 → pvnet-4.0.0}/pvnet/models/baseline/single_value.py +1 -2
- {pvnet-3.0.63 → pvnet-4.0.0}/pvnet/models/ensemble.py +1 -1
- pvnet-4.0.0/pvnet/models/model_cards/pv_india_model_card_template.md +51 -0
- pvnet-4.0.0/pvnet/models/model_cards/pv_uk_regional_model_card_template.md +54 -0
- pvnet-4.0.0/pvnet/models/model_cards/wind_india_model_card_template.md +51 -0
- {pvnet-3.0.63 → pvnet-4.0.0}/pvnet/models/multimodal/multimodal.py +24 -70
- {pvnet-3.0.63 → pvnet-4.0.0}/pvnet/models/multimodal/multimodal_base.py +8 -9
- {pvnet-3.0.63 → pvnet-4.0.0}/pvnet/models/multimodal/site_encoders/basic_blocks.py +1 -1
- {pvnet-3.0.63 → pvnet-4.0.0}/pvnet/models/multimodal/site_encoders/encoders.py +23 -22
- {pvnet-3.0.63 → pvnet-4.0.0}/pvnet/models/multimodal/unimodal_teacher.py +26 -27
- {pvnet-3.0.63 → pvnet-4.0.0}/pvnet/models/utils.py +8 -63
- {pvnet-3.0.63 → pvnet-4.0.0}/pvnet/training.py +1 -6
- {pvnet-3.0.63 → pvnet-4.0.0}/pvnet/utils.py +6 -52
- {pvnet-3.0.63 → pvnet-4.0.0}/pyproject.toml +1 -0
- {pvnet-3.0.63 → pvnet-4.0.0}/tests/test_end2end.py +3 -0
- pvnet-3.0.63/MANIFEST.in +0 -1
- pvnet-3.0.63/pvnet/__init__.py +0 -2
- pvnet-3.0.63/pvnet/data/__init__.py +0 -2
- pvnet-3.0.63/pvnet/data/base.py +0 -116
- pvnet-3.0.63/pvnet/data/datamodule.py +0 -57
- pvnet-3.0.63/pvnet/data/pv_site_datamodule.py +0 -67
- pvnet-3.0.63/pvnet/data/utils.py +0 -19
- pvnet-3.0.63/pvnet/data/wind_datamodule.py +0 -62
- {pvnet-3.0.63 → pvnet-4.0.0}/LICENSE +0 -0
- {pvnet-3.0.63 → pvnet-4.0.0}/PVNet.egg-info/dependency_links.txt +0 -0
- {pvnet-3.0.63 → pvnet-4.0.0}/PVNet.egg-info/top_level.txt +0 -0
- {pvnet-3.0.63 → pvnet-4.0.0}/pvnet/callbacks.py +0 -0
- {pvnet-3.0.63 → pvnet-4.0.0}/pvnet/load_model.py +0 -0
- {pvnet-3.0.63 → pvnet-4.0.0}/pvnet/models/__init__.py +0 -0
- {pvnet-3.0.63 → pvnet-4.0.0}/pvnet/models/baseline/__init__.py +0 -0
- {pvnet-3.0.63 → pvnet-4.0.0}/pvnet/models/multimodal/__init__.py +0 -0
- {pvnet-3.0.63 → pvnet-4.0.0}/pvnet/models/multimodal/basic_blocks.py +0 -0
- {pvnet-3.0.63 → pvnet-4.0.0}/pvnet/models/multimodal/encoders/__init__.py +0 -0
- {pvnet-3.0.63 → pvnet-4.0.0}/pvnet/models/multimodal/encoders/basic_blocks.py +0 -0
- {pvnet-3.0.63 → pvnet-4.0.0}/pvnet/models/multimodal/encoders/encoders2d.py +0 -0
- {pvnet-3.0.63 → pvnet-4.0.0}/pvnet/models/multimodal/encoders/encoders3d.py +0 -0
- {pvnet-3.0.63 → pvnet-4.0.0}/pvnet/models/multimodal/encoders/encodersRNN.py +0 -0
- {pvnet-3.0.63 → pvnet-4.0.0}/pvnet/models/multimodal/linear_networks/__init__.py +0 -0
- {pvnet-3.0.63 → pvnet-4.0.0}/pvnet/models/multimodal/linear_networks/basic_blocks.py +0 -0
- {pvnet-3.0.63 → pvnet-4.0.0}/pvnet/models/multimodal/linear_networks/networks.py +0 -0
- {pvnet-3.0.63 → pvnet-4.0.0}/pvnet/models/multimodal/site_encoders/__init__.py +0 -0
- {pvnet-3.0.63 → pvnet-4.0.0}/pvnet/optimizers.py +0 -0
- {pvnet-3.0.63 → pvnet-4.0.0}/setup.cfg +0 -0
- {pvnet-3.0.63 → pvnet-4.0.0}/tests/test_utils.py +0 -0
pvnet-4.0.0/MANIFEST.in
ADDED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: PVNet
|
|
3
|
-
Version:
|
|
3
|
+
Version: 4.0.0
|
|
4
4
|
Summary: PVNet
|
|
5
5
|
Author-email: Peter Dudfield <info@openclimatefix.org>
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
7
7
|
License-File: LICENSE
|
|
8
|
+
Requires-Dist: ocf_data_sampler==0.1.7
|
|
8
9
|
Requires-Dist: ocf_datapipes>=3.3.34
|
|
9
10
|
Requires-Dist: ocf_ml_metrics>=0.0.11
|
|
10
11
|
Requires-Dist: numpy
|
|
@@ -47,6 +48,9 @@ Provides-Extra: all
|
|
|
47
48
|
Requires-Dist: PVNet[all_models,dev]; extra == "all"
|
|
48
49
|
|
|
49
50
|
# PVNet 2.1
|
|
51
|
+
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
|
52
|
+
[](#contributors-)
|
|
53
|
+
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
|
50
54
|
|
|
51
55
|
[](https://github.com/openclimatefix/PVNet/actions/workflows/release.yml) [](https://github.com/openclimatefix/ocf-meta-repo?tab=readme-ov-file#overview-of-ocfs-nowcasting-repositories)
|
|
52
56
|
|
|
@@ -193,20 +197,20 @@ This is also where you can update the train, val & test periods to cover the dat
|
|
|
193
197
|
|
|
194
198
|
### Running the batch creation script
|
|
195
199
|
|
|
196
|
-
Run the `
|
|
200
|
+
Run the `save_samples.py` script to create batches with the parameters specified in the datamodule config (`streamed_batches.yaml` in this example):
|
|
197
201
|
|
|
198
202
|
```bash
|
|
199
|
-
python scripts/
|
|
203
|
+
python scripts/save_samples.py
|
|
200
204
|
```
|
|
201
205
|
PVNet uses
|
|
202
206
|
[hydra](https://hydra.cc/) which enables us to pass variables via the command
|
|
203
207
|
line that will override the configuration defined in the `./configs` directory, like this:
|
|
204
208
|
|
|
205
209
|
```bash
|
|
206
|
-
python scripts/
|
|
210
|
+
python scripts/save_samples.py datamodule=streamed_batches datamodule.sample_output_dir="./output" datamodule.num_train_batches=10 datamodule.num_val_batches=5
|
|
207
211
|
```
|
|
208
212
|
|
|
209
|
-
`scripts/
|
|
213
|
+
`scripts/save_samples.py` needs a config under `PVNet/configs/datamodule`. You can adapt `streamed_batches.yaml` or create your own in the same folder.
|
|
210
214
|
|
|
211
215
|
If downloading private data from a GCP bucket make sure to authenticate gcloud (the public satellite data does not need authentication):
|
|
212
216
|
|
|
@@ -245,7 +249,7 @@ Make sure to update the following config files before training your model:
|
|
|
245
249
|
2. In `configs/model/local_multimodal.yaml`:
|
|
246
250
|
- update the list of encoders to reflect the data sources you are using. If you are using different NWP sources, the encoders for these should follow the same structure with two important updates:
|
|
247
251
|
- `in_channels`: number of variables your NWP source supplies
|
|
248
|
-
- `image_size_pixels`: spatial crop of your NWP data. It depends on the spatial resolution of your NWP; should match `
|
|
252
|
+
- `image_size_pixels`: spatial crop of your NWP data. It depends on the spatial resolution of your NWP; should match `image_size_pixels_height` and/or `image_size_pixels_width` in `datamodule/configuration/site_example_configuration.yaml` for the NWP, unless transformations such as coarsening was applied (e. g. as for ECMWF data)
|
|
249
253
|
3. In `configs/local_trainer.yaml`:
|
|
250
254
|
- set `accelerator: 0` if running on a system without a supported GPU
|
|
251
255
|
|
|
@@ -264,7 +268,7 @@ defaults:
|
|
|
264
268
|
- hydra: default.yaml
|
|
265
269
|
```
|
|
266
270
|
|
|
267
|
-
Assuming you ran the `
|
|
271
|
+
Assuming you ran the `save_samples.py` script to generate some premade train and
|
|
268
272
|
val data batches, you can now train PVNet by running:
|
|
269
273
|
|
|
270
274
|
```
|
|
@@ -279,3 +283,34 @@ If you have successfully trained a PVNet model and have a saved model checkpoint
|
|
|
279
283
|
## Testing
|
|
280
284
|
|
|
281
285
|
You can use `python -m pytest tests` to run tests
|
|
286
|
+
|
|
287
|
+
## Contributors ✨
|
|
288
|
+
|
|
289
|
+
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
|
|
290
|
+
|
|
291
|
+
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
|
292
|
+
<!-- prettier-ignore-start -->
|
|
293
|
+
<!-- markdownlint-disable -->
|
|
294
|
+
<table>
|
|
295
|
+
<tbody>
|
|
296
|
+
<tr>
|
|
297
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/felix-e-h-p"><img src="https://avatars.githubusercontent.com/u/137530077?v=4?s=100" width="100px;" alt="Felix"/><br /><sub><b>Felix</b></sub></a><br /><a href="https://github.com/openclimatefix/PVNet/commits?author=felix-e-h-p" title="Code">💻</a></td>
|
|
298
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Sukh-P"><img src="https://avatars.githubusercontent.com/u/42407101?v=4?s=100" width="100px;" alt="Sukhil Patel"/><br /><sub><b>Sukhil Patel</b></sub></a><br /><a href="https://github.com/openclimatefix/PVNet/commits?author=Sukh-P" title="Code">💻</a></td>
|
|
299
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/dfulu"><img src="https://avatars.githubusercontent.com/u/41546094?v=4?s=100" width="100px;" alt="James Fulton"/><br /><sub><b>James Fulton</b></sub></a><br /><a href="https://github.com/openclimatefix/PVNet/commits?author=dfulu" title="Code">💻</a></td>
|
|
300
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/AUdaltsova"><img src="https://avatars.githubusercontent.com/u/43303448?v=4?s=100" width="100px;" alt="Alexandra Udaltsova"/><br /><sub><b>Alexandra Udaltsova</b></sub></a><br /><a href="https://github.com/openclimatefix/PVNet/commits?author=AUdaltsova" title="Code">💻</a></td>
|
|
301
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/zakwatts"><img src="https://avatars.githubusercontent.com/u/47150349?v=4?s=100" width="100px;" alt="Megawattz"/><br /><sub><b>Megawattz</b></sub></a><br /><a href="https://github.com/openclimatefix/PVNet/commits?author=zakwatts" title="Code">💻</a></td>
|
|
302
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/peterdudfield"><img src="https://avatars.githubusercontent.com/u/34686298?v=4?s=100" width="100px;" alt="Peter Dudfield"/><br /><sub><b>Peter Dudfield</b></sub></a><br /><a href="https://github.com/openclimatefix/PVNet/commits?author=peterdudfield" title="Code">💻</a></td>
|
|
303
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/mahdilamb"><img src="https://avatars.githubusercontent.com/u/4696915?v=4?s=100" width="100px;" alt="Mahdi Lamb"/><br /><sub><b>Mahdi Lamb</b></sub></a><br /><a href="#infra-mahdilamb" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a></td>
|
|
304
|
+
</tr>
|
|
305
|
+
<tr>
|
|
306
|
+
<td align="center" valign="top" width="14.28%"><a href="https://www.jacobbieker.com"><img src="https://avatars.githubusercontent.com/u/7170359?v=4?s=100" width="100px;" alt="Jacob Prince-Bieker"/><br /><sub><b>Jacob Prince-Bieker</b></sub></a><br /><a href="https://github.com/openclimatefix/PVNet/commits?author=jacobbieker" title="Code">💻</a></td>
|
|
307
|
+
</tr>
|
|
308
|
+
</tbody>
|
|
309
|
+
</table>
|
|
310
|
+
|
|
311
|
+
<!-- markdownlint-restore -->
|
|
312
|
+
<!-- prettier-ignore-end -->
|
|
313
|
+
|
|
314
|
+
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
315
|
+
|
|
316
|
+
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: PVNet
|
|
3
|
-
Version:
|
|
3
|
+
Version: 4.0.0
|
|
4
4
|
Summary: PVNet
|
|
5
5
|
Author-email: Peter Dudfield <info@openclimatefix.org>
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
7
7
|
License-File: LICENSE
|
|
8
|
+
Requires-Dist: ocf_data_sampler==0.1.7
|
|
8
9
|
Requires-Dist: ocf_datapipes>=3.3.34
|
|
9
10
|
Requires-Dist: ocf_ml_metrics>=0.0.11
|
|
10
11
|
Requires-Dist: numpy
|
|
@@ -47,6 +48,9 @@ Provides-Extra: all
|
|
|
47
48
|
Requires-Dist: PVNet[all_models,dev]; extra == "all"
|
|
48
49
|
|
|
49
50
|
# PVNet 2.1
|
|
51
|
+
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
|
52
|
+
[](#contributors-)
|
|
53
|
+
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
|
50
54
|
|
|
51
55
|
[](https://github.com/openclimatefix/PVNet/actions/workflows/release.yml) [](https://github.com/openclimatefix/ocf-meta-repo?tab=readme-ov-file#overview-of-ocfs-nowcasting-repositories)
|
|
52
56
|
|
|
@@ -193,20 +197,20 @@ This is also where you can update the train, val & test periods to cover the dat
|
|
|
193
197
|
|
|
194
198
|
### Running the batch creation script
|
|
195
199
|
|
|
196
|
-
Run the `
|
|
200
|
+
Run the `save_samples.py` script to create batches with the parameters specified in the datamodule config (`streamed_batches.yaml` in this example):
|
|
197
201
|
|
|
198
202
|
```bash
|
|
199
|
-
python scripts/
|
|
203
|
+
python scripts/save_samples.py
|
|
200
204
|
```
|
|
201
205
|
PVNet uses
|
|
202
206
|
[hydra](https://hydra.cc/) which enables us to pass variables via the command
|
|
203
207
|
line that will override the configuration defined in the `./configs` directory, like this:
|
|
204
208
|
|
|
205
209
|
```bash
|
|
206
|
-
python scripts/
|
|
210
|
+
python scripts/save_samples.py datamodule=streamed_batches datamodule.sample_output_dir="./output" datamodule.num_train_batches=10 datamodule.num_val_batches=5
|
|
207
211
|
```
|
|
208
212
|
|
|
209
|
-
`scripts/
|
|
213
|
+
`scripts/save_samples.py` needs a config under `PVNet/configs/datamodule`. You can adapt `streamed_batches.yaml` or create your own in the same folder.
|
|
210
214
|
|
|
211
215
|
If downloading private data from a GCP bucket make sure to authenticate gcloud (the public satellite data does not need authentication):
|
|
212
216
|
|
|
@@ -245,7 +249,7 @@ Make sure to update the following config files before training your model:
|
|
|
245
249
|
2. In `configs/model/local_multimodal.yaml`:
|
|
246
250
|
- update the list of encoders to reflect the data sources you are using. If you are using different NWP sources, the encoders for these should follow the same structure with two important updates:
|
|
247
251
|
- `in_channels`: number of variables your NWP source supplies
|
|
248
|
-
- `image_size_pixels`: spatial crop of your NWP data. It depends on the spatial resolution of your NWP; should match `
|
|
252
|
+
- `image_size_pixels`: spatial crop of your NWP data. It depends on the spatial resolution of your NWP; should match `image_size_pixels_height` and/or `image_size_pixels_width` in `datamodule/configuration/site_example_configuration.yaml` for the NWP, unless transformations such as coarsening was applied (e. g. as for ECMWF data)
|
|
249
253
|
3. In `configs/local_trainer.yaml`:
|
|
250
254
|
- set `accelerator: 0` if running on a system without a supported GPU
|
|
251
255
|
|
|
@@ -264,7 +268,7 @@ defaults:
|
|
|
264
268
|
- hydra: default.yaml
|
|
265
269
|
```
|
|
266
270
|
|
|
267
|
-
Assuming you ran the `
|
|
271
|
+
Assuming you ran the `save_samples.py` script to generate some premade train and
|
|
268
272
|
val data batches, you can now train PVNet by running:
|
|
269
273
|
|
|
270
274
|
```
|
|
@@ -279,3 +283,34 @@ If you have successfully trained a PVNet model and have a saved model checkpoint
|
|
|
279
283
|
## Testing
|
|
280
284
|
|
|
281
285
|
You can use `python -m pytest tests` to run tests
|
|
286
|
+
|
|
287
|
+
## Contributors ✨
|
|
288
|
+
|
|
289
|
+
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
|
|
290
|
+
|
|
291
|
+
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
|
292
|
+
<!-- prettier-ignore-start -->
|
|
293
|
+
<!-- markdownlint-disable -->
|
|
294
|
+
<table>
|
|
295
|
+
<tbody>
|
|
296
|
+
<tr>
|
|
297
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/felix-e-h-p"><img src="https://avatars.githubusercontent.com/u/137530077?v=4?s=100" width="100px;" alt="Felix"/><br /><sub><b>Felix</b></sub></a><br /><a href="https://github.com/openclimatefix/PVNet/commits?author=felix-e-h-p" title="Code">💻</a></td>
|
|
298
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Sukh-P"><img src="https://avatars.githubusercontent.com/u/42407101?v=4?s=100" width="100px;" alt="Sukhil Patel"/><br /><sub><b>Sukhil Patel</b></sub></a><br /><a href="https://github.com/openclimatefix/PVNet/commits?author=Sukh-P" title="Code">💻</a></td>
|
|
299
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/dfulu"><img src="https://avatars.githubusercontent.com/u/41546094?v=4?s=100" width="100px;" alt="James Fulton"/><br /><sub><b>James Fulton</b></sub></a><br /><a href="https://github.com/openclimatefix/PVNet/commits?author=dfulu" title="Code">💻</a></td>
|
|
300
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/AUdaltsova"><img src="https://avatars.githubusercontent.com/u/43303448?v=4?s=100" width="100px;" alt="Alexandra Udaltsova"/><br /><sub><b>Alexandra Udaltsova</b></sub></a><br /><a href="https://github.com/openclimatefix/PVNet/commits?author=AUdaltsova" title="Code">💻</a></td>
|
|
301
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/zakwatts"><img src="https://avatars.githubusercontent.com/u/47150349?v=4?s=100" width="100px;" alt="Megawattz"/><br /><sub><b>Megawattz</b></sub></a><br /><a href="https://github.com/openclimatefix/PVNet/commits?author=zakwatts" title="Code">💻</a></td>
|
|
302
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/peterdudfield"><img src="https://avatars.githubusercontent.com/u/34686298?v=4?s=100" width="100px;" alt="Peter Dudfield"/><br /><sub><b>Peter Dudfield</b></sub></a><br /><a href="https://github.com/openclimatefix/PVNet/commits?author=peterdudfield" title="Code">💻</a></td>
|
|
303
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/mahdilamb"><img src="https://avatars.githubusercontent.com/u/4696915?v=4?s=100" width="100px;" alt="Mahdi Lamb"/><br /><sub><b>Mahdi Lamb</b></sub></a><br /><a href="#infra-mahdilamb" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a></td>
|
|
304
|
+
</tr>
|
|
305
|
+
<tr>
|
|
306
|
+
<td align="center" valign="top" width="14.28%"><a href="https://www.jacobbieker.com"><img src="https://avatars.githubusercontent.com/u/7170359?v=4?s=100" width="100px;" alt="Jacob Prince-Bieker"/><br /><sub><b>Jacob Prince-Bieker</b></sub></a><br /><a href="https://github.com/openclimatefix/PVNet/commits?author=jacobbieker" title="Code">💻</a></td>
|
|
307
|
+
</tr>
|
|
308
|
+
</tbody>
|
|
309
|
+
</table>
|
|
310
|
+
|
|
311
|
+
<!-- markdownlint-restore -->
|
|
312
|
+
<!-- prettier-ignore-end -->
|
|
313
|
+
|
|
314
|
+
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
315
|
+
|
|
316
|
+
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
|
|
@@ -14,11 +14,9 @@ pvnet/optimizers.py
|
|
|
14
14
|
pvnet/training.py
|
|
15
15
|
pvnet/utils.py
|
|
16
16
|
pvnet/data/__init__.py
|
|
17
|
-
pvnet/data/
|
|
18
|
-
pvnet/data/
|
|
19
|
-
pvnet/data/
|
|
20
|
-
pvnet/data/utils.py
|
|
21
|
-
pvnet/data/wind_datamodule.py
|
|
17
|
+
pvnet/data/base_datamodule.py
|
|
18
|
+
pvnet/data/site_datamodule.py
|
|
19
|
+
pvnet/data/uk_regional_datamodule.py
|
|
22
20
|
pvnet/models/__init__.py
|
|
23
21
|
pvnet/models/base_model.py
|
|
24
22
|
pvnet/models/ensemble.py
|
|
@@ -26,6 +24,9 @@ pvnet/models/utils.py
|
|
|
26
24
|
pvnet/models/baseline/__init__.py
|
|
27
25
|
pvnet/models/baseline/last_value.py
|
|
28
26
|
pvnet/models/baseline/single_value.py
|
|
27
|
+
pvnet/models/model_cards/pv_india_model_card_template.md
|
|
28
|
+
pvnet/models/model_cards/pv_uk_regional_model_card_template.md
|
|
29
|
+
pvnet/models/model_cards/wind_india_model_card_template.md
|
|
29
30
|
pvnet/models/multimodal/__init__.py
|
|
30
31
|
pvnet/models/multimodal/basic_blocks.py
|
|
31
32
|
pvnet/models/multimodal/multimodal.py
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
# PVNet 2.1
|
|
2
|
+
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
|
3
|
+
[](#contributors-)
|
|
4
|
+
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
|
2
5
|
|
|
3
6
|
[](https://github.com/openclimatefix/PVNet/actions/workflows/release.yml) [](https://github.com/openclimatefix/ocf-meta-repo?tab=readme-ov-file#overview-of-ocfs-nowcasting-repositories)
|
|
4
7
|
|
|
@@ -145,20 +148,20 @@ This is also where you can update the train, val & test periods to cover the dat
|
|
|
145
148
|
|
|
146
149
|
### Running the batch creation script
|
|
147
150
|
|
|
148
|
-
Run the `
|
|
151
|
+
Run the `save_samples.py` script to create batches with the parameters specified in the datamodule config (`streamed_batches.yaml` in this example):
|
|
149
152
|
|
|
150
153
|
```bash
|
|
151
|
-
python scripts/
|
|
154
|
+
python scripts/save_samples.py
|
|
152
155
|
```
|
|
153
156
|
PVNet uses
|
|
154
157
|
[hydra](https://hydra.cc/) which enables us to pass variables via the command
|
|
155
158
|
line that will override the configuration defined in the `./configs` directory, like this:
|
|
156
159
|
|
|
157
160
|
```bash
|
|
158
|
-
python scripts/
|
|
161
|
+
python scripts/save_samples.py datamodule=streamed_batches datamodule.sample_output_dir="./output" datamodule.num_train_batches=10 datamodule.num_val_batches=5
|
|
159
162
|
```
|
|
160
163
|
|
|
161
|
-
`scripts/
|
|
164
|
+
`scripts/save_samples.py` needs a config under `PVNet/configs/datamodule`. You can adapt `streamed_batches.yaml` or create your own in the same folder.
|
|
162
165
|
|
|
163
166
|
If downloading private data from a GCP bucket make sure to authenticate gcloud (the public satellite data does not need authentication):
|
|
164
167
|
|
|
@@ -197,7 +200,7 @@ Make sure to update the following config files before training your model:
|
|
|
197
200
|
2. In `configs/model/local_multimodal.yaml`:
|
|
198
201
|
- update the list of encoders to reflect the data sources you are using. If you are using different NWP sources, the encoders for these should follow the same structure with two important updates:
|
|
199
202
|
- `in_channels`: number of variables your NWP source supplies
|
|
200
|
-
- `image_size_pixels`: spatial crop of your NWP data. It depends on the spatial resolution of your NWP; should match `
|
|
203
|
+
- `image_size_pixels`: spatial crop of your NWP data. It depends on the spatial resolution of your NWP; should match `image_size_pixels_height` and/or `image_size_pixels_width` in `datamodule/configuration/site_example_configuration.yaml` for the NWP, unless transformations such as coarsening was applied (e. g. as for ECMWF data)
|
|
201
204
|
3. In `configs/local_trainer.yaml`:
|
|
202
205
|
- set `accelerator: 0` if running on a system without a supported GPU
|
|
203
206
|
|
|
@@ -216,7 +219,7 @@ defaults:
|
|
|
216
219
|
- hydra: default.yaml
|
|
217
220
|
```
|
|
218
221
|
|
|
219
|
-
Assuming you ran the `
|
|
222
|
+
Assuming you ran the `save_samples.py` script to generate some premade train and
|
|
220
223
|
val data batches, you can now train PVNet by running:
|
|
221
224
|
|
|
222
225
|
```
|
|
@@ -231,3 +234,34 @@ If you have successfully trained a PVNet model and have a saved model checkpoint
|
|
|
231
234
|
## Testing
|
|
232
235
|
|
|
233
236
|
You can use `python -m pytest tests` to run tests
|
|
237
|
+
|
|
238
|
+
## Contributors ✨
|
|
239
|
+
|
|
240
|
+
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
|
|
241
|
+
|
|
242
|
+
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
|
243
|
+
<!-- prettier-ignore-start -->
|
|
244
|
+
<!-- markdownlint-disable -->
|
|
245
|
+
<table>
|
|
246
|
+
<tbody>
|
|
247
|
+
<tr>
|
|
248
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/felix-e-h-p"><img src="https://avatars.githubusercontent.com/u/137530077?v=4?s=100" width="100px;" alt="Felix"/><br /><sub><b>Felix</b></sub></a><br /><a href="https://github.com/openclimatefix/PVNet/commits?author=felix-e-h-p" title="Code">💻</a></td>
|
|
249
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Sukh-P"><img src="https://avatars.githubusercontent.com/u/42407101?v=4?s=100" width="100px;" alt="Sukhil Patel"/><br /><sub><b>Sukhil Patel</b></sub></a><br /><a href="https://github.com/openclimatefix/PVNet/commits?author=Sukh-P" title="Code">💻</a></td>
|
|
250
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/dfulu"><img src="https://avatars.githubusercontent.com/u/41546094?v=4?s=100" width="100px;" alt="James Fulton"/><br /><sub><b>James Fulton</b></sub></a><br /><a href="https://github.com/openclimatefix/PVNet/commits?author=dfulu" title="Code">💻</a></td>
|
|
251
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/AUdaltsova"><img src="https://avatars.githubusercontent.com/u/43303448?v=4?s=100" width="100px;" alt="Alexandra Udaltsova"/><br /><sub><b>Alexandra Udaltsova</b></sub></a><br /><a href="https://github.com/openclimatefix/PVNet/commits?author=AUdaltsova" title="Code">💻</a></td>
|
|
252
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/zakwatts"><img src="https://avatars.githubusercontent.com/u/47150349?v=4?s=100" width="100px;" alt="Megawattz"/><br /><sub><b>Megawattz</b></sub></a><br /><a href="https://github.com/openclimatefix/PVNet/commits?author=zakwatts" title="Code">💻</a></td>
|
|
253
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/peterdudfield"><img src="https://avatars.githubusercontent.com/u/34686298?v=4?s=100" width="100px;" alt="Peter Dudfield"/><br /><sub><b>Peter Dudfield</b></sub></a><br /><a href="https://github.com/openclimatefix/PVNet/commits?author=peterdudfield" title="Code">💻</a></td>
|
|
254
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/mahdilamb"><img src="https://avatars.githubusercontent.com/u/4696915?v=4?s=100" width="100px;" alt="Mahdi Lamb"/><br /><sub><b>Mahdi Lamb</b></sub></a><br /><a href="#infra-mahdilamb" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a></td>
|
|
255
|
+
</tr>
|
|
256
|
+
<tr>
|
|
257
|
+
<td align="center" valign="top" width="14.28%"><a href="https://www.jacobbieker.com"><img src="https://avatars.githubusercontent.com/u/7170359?v=4?s=100" width="100px;" alt="Jacob Prince-Bieker"/><br /><sub><b>Jacob Prince-Bieker</b></sub></a><br /><a href="https://github.com/openclimatefix/PVNet/commits?author=jacobbieker" title="Code">💻</a></td>
|
|
258
|
+
</tr>
|
|
259
|
+
</tbody>
|
|
260
|
+
</table>
|
|
261
|
+
|
|
262
|
+
<!-- markdownlint-restore -->
|
|
263
|
+
<!-- prettier-ignore-end -->
|
|
264
|
+
|
|
265
|
+
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
266
|
+
|
|
267
|
+
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
""" Data module for pytorch lightning """
|
|
2
|
+
|
|
3
|
+
from glob import glob
|
|
4
|
+
|
|
5
|
+
from lightning.pytorch import LightningDataModule
|
|
6
|
+
from ocf_data_sampler.numpy_sample.collate import stack_np_samples_into_batch
|
|
7
|
+
from ocf_data_sampler.sample.base import (
|
|
8
|
+
NumpyBatch,
|
|
9
|
+
SampleBase,
|
|
10
|
+
TensorBatch,
|
|
11
|
+
batch_to_tensor,
|
|
12
|
+
)
|
|
13
|
+
from torch.utils.data import DataLoader, Dataset
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def collate_fn(samples: list[NumpyBatch]) -> TensorBatch:
|
|
17
|
+
"""Convert a list of NumpySample samples to a tensor batch"""
|
|
18
|
+
return batch_to_tensor(stack_np_samples_into_batch(samples))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class PremadeSamplesDataset(Dataset):
|
|
22
|
+
"""Dataset to load samples from
|
|
23
|
+
|
|
24
|
+
Args:
|
|
25
|
+
sample_dir: Path to the directory of pre-saved samples.
|
|
26
|
+
sample_class: sample class type to use for save/load/to_numpy
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
def __init__(self, sample_dir: str, sample_class: SampleBase):
|
|
30
|
+
"""Initialise PremadeSamplesDataset"""
|
|
31
|
+
self.sample_paths = glob(f"{sample_dir}/*")
|
|
32
|
+
self.sample_class = sample_class
|
|
33
|
+
|
|
34
|
+
def __len__(self):
|
|
35
|
+
return len(self.sample_paths)
|
|
36
|
+
|
|
37
|
+
def __getitem__(self, idx):
|
|
38
|
+
sample = self.sample_class.load(self.sample_paths[idx])
|
|
39
|
+
return sample.to_numpy()
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class BaseDataModule(LightningDataModule):
|
|
43
|
+
"""Base Datamodule for training pvnet and using pvnet pipeline in ocf-data-sampler."""
|
|
44
|
+
|
|
45
|
+
def __init__(
|
|
46
|
+
self,
|
|
47
|
+
configuration: str | None = None,
|
|
48
|
+
sample_dir: str | None = None,
|
|
49
|
+
batch_size: int = 16,
|
|
50
|
+
num_workers: int = 0,
|
|
51
|
+
prefetch_factor: int | None = None,
|
|
52
|
+
train_period: list[str | None] = [None, None],
|
|
53
|
+
val_period: list[str | None] = [None, None],
|
|
54
|
+
):
|
|
55
|
+
"""Base Datamodule for training pvnet architecture.
|
|
56
|
+
|
|
57
|
+
Can also be used with pre-made batches if `sample_dir` is set.
|
|
58
|
+
|
|
59
|
+
Args:
|
|
60
|
+
configuration: Path to ocf-data-sampler configuration file.
|
|
61
|
+
sample_dir: Path to the directory of pre-saved samples. Cannot be used together with
|
|
62
|
+
`configuration` or '[train/val]_period'.
|
|
63
|
+
batch_size: Batch size.
|
|
64
|
+
num_workers: Number of workers to use in multiprocess batch loading.
|
|
65
|
+
prefetch_factor: Number of data will be prefetched at the end of each worker process.
|
|
66
|
+
train_period: Date range filter for train dataloader.
|
|
67
|
+
val_period: Date range filter for val dataloader.
|
|
68
|
+
|
|
69
|
+
"""
|
|
70
|
+
super().__init__()
|
|
71
|
+
|
|
72
|
+
if not ((sample_dir is not None) ^ (configuration is not None)):
|
|
73
|
+
raise ValueError("Exactly one of `sample_dir` or `configuration` must be set.")
|
|
74
|
+
|
|
75
|
+
if sample_dir is not None:
|
|
76
|
+
if any([period != [None, None] for period in [train_period, val_period]]):
|
|
77
|
+
raise ValueError("Cannot set `(train/val)_period` with presaved samples")
|
|
78
|
+
|
|
79
|
+
self.configuration = configuration
|
|
80
|
+
self.sample_dir = sample_dir
|
|
81
|
+
self.train_period = train_period
|
|
82
|
+
self.val_period = val_period
|
|
83
|
+
|
|
84
|
+
self._common_dataloader_kwargs = dict(
|
|
85
|
+
batch_size=batch_size,
|
|
86
|
+
sampler=None,
|
|
87
|
+
batch_sampler=None,
|
|
88
|
+
num_workers=num_workers,
|
|
89
|
+
collate_fn=collate_fn,
|
|
90
|
+
pin_memory=False,
|
|
91
|
+
drop_last=False,
|
|
92
|
+
timeout=0,
|
|
93
|
+
worker_init_fn=None,
|
|
94
|
+
prefetch_factor=prefetch_factor,
|
|
95
|
+
persistent_workers=False,
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
def _get_streamed_samples_dataset(self, start_time, end_time) -> Dataset:
|
|
99
|
+
raise NotImplementedError
|
|
100
|
+
|
|
101
|
+
def _get_premade_samples_dataset(self, subdir) -> Dataset:
|
|
102
|
+
raise NotImplementedError
|
|
103
|
+
|
|
104
|
+
def train_dataloader(self) -> DataLoader:
|
|
105
|
+
"""Construct train dataloader"""
|
|
106
|
+
if self.sample_dir is not None:
|
|
107
|
+
dataset = self._get_premade_samples_dataset("train")
|
|
108
|
+
else:
|
|
109
|
+
dataset = self._get_streamed_samples_dataset(*self.train_period)
|
|
110
|
+
return DataLoader(dataset, shuffle=True, **self._common_dataloader_kwargs)
|
|
111
|
+
|
|
112
|
+
def val_dataloader(self) -> DataLoader:
|
|
113
|
+
"""Construct val dataloader"""
|
|
114
|
+
if self.sample_dir is not None:
|
|
115
|
+
dataset = self._get_premade_samples_dataset("val")
|
|
116
|
+
else:
|
|
117
|
+
dataset = self._get_streamed_samples_dataset(*self.val_period)
|
|
118
|
+
return DataLoader(dataset, shuffle=False, **self._common_dataloader_kwargs)
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
""" Data module for pytorch lightning """
|
|
2
|
+
|
|
3
|
+
from ocf_data_sampler.sample.site import SiteSample
|
|
4
|
+
from ocf_data_sampler.torch_datasets.datasets.site import SitesDataset
|
|
5
|
+
from torch.utils.data import Dataset
|
|
6
|
+
|
|
7
|
+
from pvnet.data.base_datamodule import BaseDataModule, PremadeSamplesDataset
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class SiteDataModule(BaseDataModule):
|
|
11
|
+
"""Datamodule for training pvnet and using pvnet pipeline in `ocf-data-sampler`."""
|
|
12
|
+
|
|
13
|
+
def __init__(
|
|
14
|
+
self,
|
|
15
|
+
configuration: str | None = None,
|
|
16
|
+
sample_dir: str | None = None,
|
|
17
|
+
batch_size: int = 16,
|
|
18
|
+
num_workers: int = 0,
|
|
19
|
+
prefetch_factor: int | None = None,
|
|
20
|
+
train_period: list[str | None] = [None, None],
|
|
21
|
+
val_period: list[str | None] = [None, None],
|
|
22
|
+
):
|
|
23
|
+
"""Datamodule for training pvnet architecture.
|
|
24
|
+
|
|
25
|
+
Can also be used with pre-made batches if `sample_dir` is set.
|
|
26
|
+
|
|
27
|
+
Args:
|
|
28
|
+
configuration: Path to datapipe configuration file.
|
|
29
|
+
sample_dir: Path to the directory of pre-saved samples. Cannot be used together with
|
|
30
|
+
`configuration` or '[train/val]_period'.
|
|
31
|
+
batch_size: Batch size.
|
|
32
|
+
num_workers: Number of workers to use in multiprocess batch loading.
|
|
33
|
+
prefetch_factor: Number of data will be prefetched at the end of each worker process.
|
|
34
|
+
train_period: Date range filter for train dataloader.
|
|
35
|
+
val_period: Date range filter for val dataloader.
|
|
36
|
+
|
|
37
|
+
"""
|
|
38
|
+
super().__init__(
|
|
39
|
+
configuration=configuration,
|
|
40
|
+
sample_dir=sample_dir,
|
|
41
|
+
batch_size=batch_size,
|
|
42
|
+
num_workers=num_workers,
|
|
43
|
+
prefetch_factor=prefetch_factor,
|
|
44
|
+
train_period=train_period,
|
|
45
|
+
val_period=val_period,
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
def _get_streamed_samples_dataset(self, start_time, end_time) -> Dataset:
|
|
49
|
+
return SitesDataset(self.configuration, start_time=start_time, end_time=end_time)
|
|
50
|
+
|
|
51
|
+
def _get_premade_samples_dataset(self, subdir) -> Dataset:
|
|
52
|
+
split_dir = f"{self.sample_dir}/{subdir}"
|
|
53
|
+
return PremadeSamplesDataset(split_dir, SiteSample)
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
""" Data module for pytorch lightning """
|
|
2
|
+
|
|
3
|
+
from ocf_data_sampler.sample.uk_regional import UKRegionalSample
|
|
4
|
+
from ocf_data_sampler.torch_datasets.datasets.pvnet_uk import PVNetUKRegionalDataset
|
|
5
|
+
from torch.utils.data import Dataset
|
|
6
|
+
|
|
7
|
+
from pvnet.data.base_datamodule import BaseDataModule, PremadeSamplesDataset
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class DataModule(BaseDataModule):
|
|
11
|
+
"""Datamodule for training pvnet and using pvnet pipeline in `ocf_datapipes`."""
|
|
12
|
+
|
|
13
|
+
def __init__(
|
|
14
|
+
self,
|
|
15
|
+
configuration: str | None = None,
|
|
16
|
+
sample_dir: str | None = None,
|
|
17
|
+
batch_size: int = 16,
|
|
18
|
+
num_workers: int = 0,
|
|
19
|
+
prefetch_factor: int | None = None,
|
|
20
|
+
train_period: list[str | None] = [None, None],
|
|
21
|
+
val_period: list[str | None] = [None, None],
|
|
22
|
+
):
|
|
23
|
+
"""Datamodule for training pvnet architecture.
|
|
24
|
+
|
|
25
|
+
Can also be used with pre-made batches if `sample_dir` is set.
|
|
26
|
+
|
|
27
|
+
Args:
|
|
28
|
+
configuration: Path to datapipe configuration file.
|
|
29
|
+
sample_dir: Path to the directory of pre-saved samples. Cannot be used together with
|
|
30
|
+
`configuration` or '[train/val]_period'.
|
|
31
|
+
batch_size: Batch size.
|
|
32
|
+
num_workers: Number of workers to use in multiprocess batch loading.
|
|
33
|
+
prefetch_factor: Number of data will be prefetched at the end of each worker process.
|
|
34
|
+
train_period: Date range filter for train dataloader.
|
|
35
|
+
val_period: Date range filter for val dataloader.
|
|
36
|
+
|
|
37
|
+
"""
|
|
38
|
+
super().__init__(
|
|
39
|
+
configuration=configuration,
|
|
40
|
+
sample_dir=sample_dir,
|
|
41
|
+
batch_size=batch_size,
|
|
42
|
+
num_workers=num_workers,
|
|
43
|
+
prefetch_factor=prefetch_factor,
|
|
44
|
+
train_period=train_period,
|
|
45
|
+
val_period=val_period,
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
def _get_streamed_samples_dataset(self, start_time, end_time) -> Dataset:
|
|
49
|
+
return PVNetUKRegionalDataset(self.configuration, start_time=start_time, end_time=end_time)
|
|
50
|
+
|
|
51
|
+
def _get_premade_samples_dataset(self, subdir) -> Dataset:
|
|
52
|
+
split_dir = f"{self.sample_dir}/{subdir}"
|
|
53
|
+
# Returns a dict of np arrays
|
|
54
|
+
return PremadeSamplesDataset(split_dir, UKRegionalSample)
|