PVNet 3.0.39__tar.gz → 3.0.41__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-3.0.39 → pvnet-3.0.41}/PKG-INFO +43 -171
- {pvnet-3.0.39 → pvnet-3.0.41}/PVNet.egg-info/PKG-INFO +43 -171
- pvnet-3.0.41/README.md +230 -0
- pvnet-3.0.41/pvnet/__init__.py +2 -0
- {pvnet-3.0.39 → pvnet-3.0.41}/pvnet/models/multimodal/multimodal.py +20 -13
- pvnet-3.0.39/README.md +0 -358
- pvnet-3.0.39/pvnet/__init__.py +0 -2
- {pvnet-3.0.39 → pvnet-3.0.41}/LICENSE +0 -0
- {pvnet-3.0.39 → pvnet-3.0.41}/MANIFEST.in +0 -0
- {pvnet-3.0.39 → pvnet-3.0.41}/PVNet.egg-info/SOURCES.txt +0 -0
- {pvnet-3.0.39 → pvnet-3.0.41}/PVNet.egg-info/dependency_links.txt +0 -0
- {pvnet-3.0.39 → pvnet-3.0.41}/PVNet.egg-info/requires.txt +0 -0
- {pvnet-3.0.39 → pvnet-3.0.41}/PVNet.egg-info/top_level.txt +0 -0
- {pvnet-3.0.39 → pvnet-3.0.41}/pvnet/callbacks.py +0 -0
- {pvnet-3.0.39 → pvnet-3.0.41}/pvnet/data/__init__.py +0 -0
- {pvnet-3.0.39 → pvnet-3.0.41}/pvnet/data/base.py +0 -0
- {pvnet-3.0.39 → pvnet-3.0.41}/pvnet/data/datamodule.py +0 -0
- {pvnet-3.0.39 → pvnet-3.0.41}/pvnet/data/pv_site_datamodule.py +0 -0
- {pvnet-3.0.39 → pvnet-3.0.41}/pvnet/data/utils.py +0 -0
- {pvnet-3.0.39 → pvnet-3.0.41}/pvnet/data/wind_datamodule.py +0 -0
- {pvnet-3.0.39 → pvnet-3.0.41}/pvnet/load_model.py +0 -0
- {pvnet-3.0.39 → pvnet-3.0.41}/pvnet/models/__init__.py +0 -0
- {pvnet-3.0.39 → pvnet-3.0.41}/pvnet/models/base_model.py +0 -0
- {pvnet-3.0.39 → pvnet-3.0.41}/pvnet/models/baseline/__init__.py +0 -0
- {pvnet-3.0.39 → pvnet-3.0.41}/pvnet/models/baseline/last_value.py +0 -0
- {pvnet-3.0.39 → pvnet-3.0.41}/pvnet/models/baseline/single_value.py +0 -0
- {pvnet-3.0.39 → pvnet-3.0.41}/pvnet/models/ensemble.py +0 -0
- {pvnet-3.0.39 → pvnet-3.0.41}/pvnet/models/multimodal/__init__.py +0 -0
- {pvnet-3.0.39 → pvnet-3.0.41}/pvnet/models/multimodal/basic_blocks.py +0 -0
- {pvnet-3.0.39 → pvnet-3.0.41}/pvnet/models/multimodal/encoders/__init__.py +0 -0
- {pvnet-3.0.39 → pvnet-3.0.41}/pvnet/models/multimodal/encoders/basic_blocks.py +0 -0
- {pvnet-3.0.39 → pvnet-3.0.41}/pvnet/models/multimodal/encoders/encoders2d.py +0 -0
- {pvnet-3.0.39 → pvnet-3.0.41}/pvnet/models/multimodal/encoders/encoders3d.py +0 -0
- {pvnet-3.0.39 → pvnet-3.0.41}/pvnet/models/multimodal/encoders/encodersRNN.py +0 -0
- {pvnet-3.0.39 → pvnet-3.0.41}/pvnet/models/multimodal/linear_networks/__init__.py +0 -0
- {pvnet-3.0.39 → pvnet-3.0.41}/pvnet/models/multimodal/linear_networks/basic_blocks.py +0 -0
- {pvnet-3.0.39 → pvnet-3.0.41}/pvnet/models/multimodal/linear_networks/networks.py +0 -0
- {pvnet-3.0.39 → pvnet-3.0.41}/pvnet/models/multimodal/multimodal_base.py +0 -0
- {pvnet-3.0.39 → pvnet-3.0.41}/pvnet/models/multimodal/site_encoders/__init__.py +0 -0
- {pvnet-3.0.39 → pvnet-3.0.41}/pvnet/models/multimodal/site_encoders/basic_blocks.py +0 -0
- {pvnet-3.0.39 → pvnet-3.0.41}/pvnet/models/multimodal/site_encoders/encoders.py +0 -0
- {pvnet-3.0.39 → pvnet-3.0.41}/pvnet/models/multimodal/unimodal_teacher.py +0 -0
- {pvnet-3.0.39 → pvnet-3.0.41}/pvnet/models/utils.py +0 -0
- {pvnet-3.0.39 → pvnet-3.0.41}/pvnet/optimizers.py +0 -0
- {pvnet-3.0.39 → pvnet-3.0.41}/pvnet/training.py +0 -0
- {pvnet-3.0.39 → pvnet-3.0.41}/pvnet/utils.py +0 -0
- {pvnet-3.0.39 → pvnet-3.0.41}/pyproject.toml +0 -0
- {pvnet-3.0.39 → pvnet-3.0.41}/setup.cfg +0 -0
- {pvnet-3.0.39 → pvnet-3.0.41}/tests/test_end2end.py +0 -0
- {pvnet-3.0.39 → pvnet-3.0.41}/tests/test_utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: PVNet
|
|
3
|
-
Version: 3.0.
|
|
3
|
+
Version: 3.0.41
|
|
4
4
|
Summary: PVNet
|
|
5
5
|
Author-email: Peter Dudfield <info@openclimatefix.org>
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -48,14 +48,14 @@ Requires-Dist: PVNet[all_models,dev]; extra == "all"
|
|
|
48
48
|
|
|
49
49
|
# PVNet 2.1
|
|
50
50
|
|
|
51
|
-
[](https://github.com/openclimatefix/PVNet/actions/workflows/release.yml)
|
|
52
52
|
|
|
53
|
-
This project is used for training PVNet and running
|
|
53
|
+
This project is used for training PVNet and running PVNet on live data.
|
|
54
54
|
|
|
55
55
|
PVNet2 is a multi-modal late-fusion model that largely inherits the same architecture from
|
|
56
|
-
[PVNet1.0](https://github.com/openclimatefix/predict_pv_yield). The NWP and
|
|
56
|
+
[PVNet1.0](https://github.com/openclimatefix/predict_pv_yield). The NWP (Numerical Weather Prediction) and
|
|
57
57
|
satellite data are sent through some neural network which encodes them down to
|
|
58
|
-
1D intermediate representations. These are concatenated together with the GSP
|
|
58
|
+
1D intermediate representations. These are concatenated together with the GSP (Grid Supply Point)
|
|
59
59
|
output history, the calculated solar coordinates (azimuth and elevation) and the
|
|
60
60
|
GSP ID which has been put through an embedding layer. This 1D concatenated
|
|
61
61
|
feature vector is put through an output network which outputs predictions of the
|
|
@@ -104,7 +104,7 @@ pip install ".[dev]"
|
|
|
104
104
|
|
|
105
105
|
## Getting started with running PVNet
|
|
106
106
|
|
|
107
|
-
Before running any code in
|
|
107
|
+
Before running any code in PVNet, copy the example configuration to a
|
|
108
108
|
configs directory:
|
|
109
109
|
|
|
110
110
|
```
|
|
@@ -122,14 +122,14 @@ suggested locations for downloading such datasets below:
|
|
|
122
122
|
|
|
123
123
|
**GSP (Grid Supply Point)** - Regional PV generation data\
|
|
124
124
|
The University of Sheffield provides API access to download this data:
|
|
125
|
-
https://www.solar.sheffield.ac.uk/
|
|
125
|
+
https://www.solar.sheffield.ac.uk/api/
|
|
126
126
|
|
|
127
127
|
Documentation for querying generation data aggregated by GSP region can be found
|
|
128
128
|
here:
|
|
129
129
|
https://docs.google.com/document/d/e/2PACX-1vSDFb-6dJ2kIFZnsl-pBQvcH4inNQCA4lYL9cwo80bEHQeTK8fONLOgDf6Wm4ze_fxonqK3EVBVoAIz/pub#h.9d97iox3wzmd
|
|
130
130
|
|
|
131
131
|
**NWP (Numerical weather predictions)**\
|
|
132
|
-
OCF maintains a Zarr formatted version the German Weather Service's (DWD)
|
|
132
|
+
OCF maintains a Zarr formatted version of the German Weather Service's (DWD)
|
|
133
133
|
ICON-EU NWP model here:
|
|
134
134
|
https://huggingface.co/datasets/openclimatefix/dwd-icon-eu which includes the UK
|
|
135
135
|
|
|
@@ -169,66 +169,56 @@ cp -r configs.example configs
|
|
|
169
169
|
|
|
170
170
|
### Set up and config example for batch creation
|
|
171
171
|
|
|
172
|
-
We will use the example
|
|
173
|
-
`/PVNet/configs/datamodule/configuration/gcp_configuration.yaml`
|
|
174
|
-
Ensure that the file paths are set to the correct locations in
|
|
175
|
-
`gcp_configuration.yaml`.
|
|
172
|
+
We will use the following example config file for creating batches: `/PVNet/configs/datamodule/configuration/example_configuration.yaml`. Ensure that the file paths are set to the correct locations in `example_configuration.yaml`: search for `PLACEHOLDER` to find where to input the location of the files. You will need to comment out or delete the parts of `example_configuration.yaml` pertaining to the data you are not using.
|
|
176
173
|
|
|
177
|
-
`PLACEHOLDER` is used to indcate where to input the location of the files.
|
|
178
174
|
|
|
179
|
-
|
|
175
|
+
When creating batches, an additional datamodule config located in `PVNet/configs/datamodule` is passed into the batch creation script: `streamed_batches.yaml`. Like before, a placeholder variable is used when specifying which configuration to use:
|
|
180
176
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
With your configuration in place, you can proceed to create batches. PVNet uses
|
|
185
|
-
[hydra](https://hydra.cc/) which enables us to pass variables via the command
|
|
186
|
-
line that will override the configuration defined in the `./configs` directory.
|
|
187
|
-
|
|
188
|
-
When creating batches, an additional config is used which is passed into the batch creation script. This is the datamodule config located `PVNet/configs/datamodule`.
|
|
189
|
-
|
|
190
|
-
For this example we will be using the `streamed_batches.yaml` config. Like before, a placeholder variable is used when specifing which configuration to use:
|
|
191
|
-
|
|
192
|
-
`configuration: "PLACEHOLDER.yaml"`
|
|
177
|
+
```yaml
|
|
178
|
+
configuration: "PLACEHOLDER.yaml"
|
|
179
|
+
```
|
|
193
180
|
|
|
194
|
-
This should be given the whole path to the config on your local machine,
|
|
181
|
+
This should be given the whole path to the config on your local machine, for example:
|
|
195
182
|
|
|
196
|
-
|
|
197
|
-
|
|
183
|
+
```yaml
|
|
184
|
+
configuration: "/FULL-PATH-TO-REPO/PVNet/configs/datamodule/configuration/example_configuration.yaml"
|
|
185
|
+
```
|
|
198
186
|
|
|
199
187
|
Where `FULL-PATH-TO-REPO` represent the whole path to the PVNet repo on your local machine.
|
|
200
188
|
|
|
189
|
+
This is also where you can update the train, val & test periods to cover the data you have access to.
|
|
190
|
+
|
|
201
191
|
### Running the batch creation script
|
|
202
192
|
|
|
203
|
-
Run the save_batches.py script to create batches
|
|
193
|
+
Run the `save_batches.py` script to create batches with the parameters specified in the datamodule config (`streamed_batches.yaml` in this example):
|
|
204
194
|
|
|
205
|
-
```
|
|
195
|
+
```bash
|
|
206
196
|
python scripts/save_batches.py
|
|
207
197
|
```
|
|
208
|
-
|
|
198
|
+
PVNet uses
|
|
199
|
+
[hydra](https://hydra.cc/) which enables us to pass variables via the command
|
|
200
|
+
line that will override the configuration defined in the `./configs` directory, like this:
|
|
209
201
|
|
|
210
|
-
```
|
|
202
|
+
```bash
|
|
211
203
|
python scripts/save_batches.py datamodule=streamed_batches datamodule.batch_output_dir="./output" datamodule.num_train_batches=10 datamodule.num_val_batches=5
|
|
212
204
|
```
|
|
213
205
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
Its important that the dates set for the training, validation and testing in the datamodule (`streamed_batches.yaml`) config are within the ranges of the dates set for the input features in the configuration (`gcp_configuration.yaml`).
|
|
206
|
+
`scripts/save_batches.py` needs a config under `PVNet/configs/datamodule`. You can adapt `streamed_batches.yaml` or create your own in the same folder.
|
|
217
207
|
|
|
218
|
-
If downloading private data from a
|
|
208
|
+
If downloading private data from a GCP bucket make sure to authenticate gcloud (the public satellite data does not need authentication):
|
|
219
209
|
|
|
220
210
|
```
|
|
221
211
|
gcloud auth login
|
|
222
212
|
```
|
|
223
213
|
|
|
224
|
-
|
|
214
|
+
Files stored in multiple locations can be added as a list. For example, in the `example_configuration.yaml` file we can supply a path to satellite data stored on a bucket:
|
|
225
215
|
|
|
226
216
|
```yaml
|
|
227
217
|
satellite:
|
|
228
218
|
satellite_zarr_path: gs://solar-pv-nowcasting-data/satellite/EUMETSAT/SEVIRI_RSS/v4/2020_nonhrv.zarr
|
|
229
219
|
```
|
|
230
220
|
|
|
231
|
-
|
|
221
|
+
Or to satellite data hosted by Google:
|
|
232
222
|
|
|
233
223
|
```yaml
|
|
234
224
|
satellite:
|
|
@@ -236,145 +226,27 @@ satellite:
|
|
|
236
226
|
- "gs://public-datasets-eumetsat-solar-forecasting/satellite/EUMETSAT/SEVIRI_RSS/v4/2020_nonhrv.zarr"
|
|
237
227
|
- "gs://public-datasets-eumetsat-solar-forecasting/satellite/EUMETSAT/SEVIRI_RSS/v4/2021_nonhrv.zarr"
|
|
238
228
|
```
|
|
239
|
-
|
|
229
|
+
|
|
230
|
+
Datapipes are currently set up to use 11 channels from the satellite data, the 12th of which is HRV and is not included in these.
|
|
240
231
|
|
|
241
232
|
|
|
242
233
|
### Training PVNet
|
|
243
234
|
|
|
244
235
|
How PVNet is run is determined by the extensive configuration in the config
|
|
245
|
-
files. The
|
|
246
|
-
created using the steps and batch creation config mentioned above.
|
|
247
|
-
|
|
248
|
-
You should create the following configs before trying to train a model locally,
|
|
249
|
-
as so:
|
|
250
|
-
|
|
251
|
-
In `configs/datamodule/local_premade_batches.yaml`:
|
|
252
|
-
|
|
253
|
-
```yaml
|
|
254
|
-
_target_: pvnet.data.datamodule.DataModule
|
|
255
|
-
configuration: null
|
|
256
|
-
batch_dir: "./output" # where the batches are saved
|
|
257
|
-
num_workers: 20
|
|
258
|
-
prefetch_factor: 2
|
|
259
|
-
batch_size: 8
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
In `configs/model/local_multimodal.yaml`:
|
|
236
|
+
files. The configs stored in `PVNet/configs.example` should work with batches created using the steps and batch creation config mentioned above.
|
|
263
237
|
|
|
264
|
-
|
|
265
|
-
_target_: pvnet.models.multimodal.multimodal.Model
|
|
266
|
-
|
|
267
|
-
output_quantiles: [0.02, 0.1, 0.25, 0.5, 0.75, 0.9, 0.98]
|
|
268
|
-
|
|
269
|
-
#--------------------------------------------
|
|
270
|
-
# NWP encoder
|
|
271
|
-
#--------------------------------------------
|
|
272
|
-
|
|
273
|
-
nwp_encoders_dict:
|
|
274
|
-
ukv:
|
|
275
|
-
_target_: pvnet.models.multimodal.encoders.encoders3d.DefaultPVNet
|
|
276
|
-
_partial_: True
|
|
277
|
-
in_channels: 10
|
|
278
|
-
out_features: 256
|
|
279
|
-
number_of_conv3d_layers: 6
|
|
280
|
-
conv3d_channels: 32
|
|
281
|
-
image_size_pixels: 24
|
|
282
|
-
|
|
283
|
-
#--------------------------------------------
|
|
284
|
-
# Sat encoder settings
|
|
285
|
-
#--------------------------------------------
|
|
286
|
-
|
|
287
|
-
# Ignored as premade batches were created without satellite data
|
|
288
|
-
# sat_encoder:
|
|
289
|
-
# _target_: pvnet.models.multimodal.encoders.encoders3d.DefaultPVNet
|
|
290
|
-
# _partial_: True
|
|
291
|
-
# in_channels: 11
|
|
292
|
-
# out_features: 256
|
|
293
|
-
# number_of_conv3d_layers: 6
|
|
294
|
-
# conv3d_channels: 32
|
|
295
|
-
# image_size_pixels: 24
|
|
296
|
-
|
|
297
|
-
add_image_embedding_channel: False
|
|
298
|
-
|
|
299
|
-
#--------------------------------------------
|
|
300
|
-
# PV encoder settings
|
|
301
|
-
#--------------------------------------------
|
|
302
|
-
|
|
303
|
-
pv_encoder:
|
|
304
|
-
_target_: pvnet.models.multimodal.site_encoders.encoders.SingleAttentionNetwork
|
|
305
|
-
_partial_: True
|
|
306
|
-
num_sites: 349
|
|
307
|
-
out_features: 40
|
|
308
|
-
num_heads: 4
|
|
309
|
-
kdim: 40
|
|
310
|
-
pv_id_embed_dim: 20
|
|
311
|
-
|
|
312
|
-
#--------------------------------------------
|
|
313
|
-
# Tabular network settings
|
|
314
|
-
#--------------------------------------------
|
|
315
|
-
|
|
316
|
-
output_network:
|
|
317
|
-
_target_: pvnet.models.multimodal.linear_networks.networks.ResFCNet2
|
|
318
|
-
_partial_: True
|
|
319
|
-
fc_hidden_features: 128
|
|
320
|
-
n_res_blocks: 6
|
|
321
|
-
res_block_layers: 2
|
|
322
|
-
dropout_frac: 0.0
|
|
323
|
-
|
|
324
|
-
embedding_dim: 16
|
|
325
|
-
include_sun: True
|
|
326
|
-
include_gsp_yield_history: False
|
|
327
|
-
|
|
328
|
-
#--------------------------------------------
|
|
329
|
-
# Times
|
|
330
|
-
#--------------------------------------------
|
|
331
|
-
|
|
332
|
-
# Foreast and time settings
|
|
333
|
-
history_minutes: 60
|
|
334
|
-
forecast_minutes: 120
|
|
335
|
-
|
|
336
|
-
min_sat_delay_minutes: 60
|
|
337
|
-
|
|
338
|
-
sat_history_minutes: 90
|
|
339
|
-
pv_history_minutes: 60
|
|
340
|
-
|
|
341
|
-
# These must be set for each NWP encoder
|
|
342
|
-
nwp_history_minutes:
|
|
343
|
-
ukv: 60
|
|
344
|
-
nwp_forecast_minutes:
|
|
345
|
-
ukv: 120
|
|
346
|
-
|
|
347
|
-
# ----------------------------------------------
|
|
348
|
-
# Optimizer
|
|
349
|
-
# ----------------------------------------------
|
|
350
|
-
optimizer:
|
|
351
|
-
_target_: pvnet.optimizers.EmbAdamWReduceLROnPlateau
|
|
352
|
-
lr: 0.0001
|
|
353
|
-
weight_decay: 0.01
|
|
354
|
-
amsgrad: True
|
|
355
|
-
patience: 5
|
|
356
|
-
factor: 0.1
|
|
357
|
-
threshold: 0.002
|
|
358
|
-
```
|
|
238
|
+
Make sure to update the following config files before training your model:
|
|
359
239
|
|
|
360
|
-
In `configs/
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
min_epochs: null
|
|
369
|
-
max_epochs: null
|
|
370
|
-
reload_dataloaders_every_n_epochs: 0
|
|
371
|
-
num_sanity_val_steps: 8
|
|
372
|
-
fast_dev_run: false
|
|
373
|
-
accumulate_grad_batches: 4
|
|
374
|
-
log_every_n_steps: 50
|
|
375
|
-
```
|
|
240
|
+
1. In `configs/datamodule/local_premade_batches.yaml`:
|
|
241
|
+
- update `batch_dir` to point to the directory you stored your batches in during batch creation
|
|
242
|
+
2. In `configs/model/local_multimodal.yaml`:
|
|
243
|
+
- 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:
|
|
244
|
+
- `in_channels`: number of variables your NWP source supplies
|
|
245
|
+
- `image_size_pixels`: spatial crop of your NWP data. It depends on the spatial resolution of your NWP; should match `nwp_image_size_pixels_height` and/or `nwp_image_size_pixels_width` in `datamodule/example_configs.yaml`, unless transformations such as coarsening was applied (e. g. as for ECMWF data)
|
|
246
|
+
3. In `configs/local_trainer.yaml`:
|
|
247
|
+
- set `accelerator: 0` if running on a system without a supported GPU
|
|
376
248
|
|
|
377
|
-
|
|
249
|
+
If creating copies of the config files instead of modifying existing ones, update `defaults` in the main `./configs/config.yaml` file to use
|
|
378
250
|
your customised config files:
|
|
379
251
|
|
|
380
252
|
```yaml
|
|
@@ -398,7 +270,7 @@ python run.py
|
|
|
398
270
|
|
|
399
271
|
## Backtest
|
|
400
272
|
|
|
401
|
-
If you have
|
|
273
|
+
If you have successfully 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
274
|
|
|
403
275
|
|
|
404
276
|
## Testing
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: PVNet
|
|
3
|
-
Version: 3.0.
|
|
3
|
+
Version: 3.0.41
|
|
4
4
|
Summary: PVNet
|
|
5
5
|
Author-email: Peter Dudfield <info@openclimatefix.org>
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -48,14 +48,14 @@ Requires-Dist: PVNet[all_models,dev]; extra == "all"
|
|
|
48
48
|
|
|
49
49
|
# PVNet 2.1
|
|
50
50
|
|
|
51
|
-
[](https://github.com/openclimatefix/PVNet/actions/workflows/release.yml)
|
|
52
52
|
|
|
53
|
-
This project is used for training PVNet and running
|
|
53
|
+
This project is used for training PVNet and running PVNet on live data.
|
|
54
54
|
|
|
55
55
|
PVNet2 is a multi-modal late-fusion model that largely inherits the same architecture from
|
|
56
|
-
[PVNet1.0](https://github.com/openclimatefix/predict_pv_yield). The NWP and
|
|
56
|
+
[PVNet1.0](https://github.com/openclimatefix/predict_pv_yield). The NWP (Numerical Weather Prediction) and
|
|
57
57
|
satellite data are sent through some neural network which encodes them down to
|
|
58
|
-
1D intermediate representations. These are concatenated together with the GSP
|
|
58
|
+
1D intermediate representations. These are concatenated together with the GSP (Grid Supply Point)
|
|
59
59
|
output history, the calculated solar coordinates (azimuth and elevation) and the
|
|
60
60
|
GSP ID which has been put through an embedding layer. This 1D concatenated
|
|
61
61
|
feature vector is put through an output network which outputs predictions of the
|
|
@@ -104,7 +104,7 @@ pip install ".[dev]"
|
|
|
104
104
|
|
|
105
105
|
## Getting started with running PVNet
|
|
106
106
|
|
|
107
|
-
Before running any code in
|
|
107
|
+
Before running any code in PVNet, copy the example configuration to a
|
|
108
108
|
configs directory:
|
|
109
109
|
|
|
110
110
|
```
|
|
@@ -122,14 +122,14 @@ suggested locations for downloading such datasets below:
|
|
|
122
122
|
|
|
123
123
|
**GSP (Grid Supply Point)** - Regional PV generation data\
|
|
124
124
|
The University of Sheffield provides API access to download this data:
|
|
125
|
-
https://www.solar.sheffield.ac.uk/
|
|
125
|
+
https://www.solar.sheffield.ac.uk/api/
|
|
126
126
|
|
|
127
127
|
Documentation for querying generation data aggregated by GSP region can be found
|
|
128
128
|
here:
|
|
129
129
|
https://docs.google.com/document/d/e/2PACX-1vSDFb-6dJ2kIFZnsl-pBQvcH4inNQCA4lYL9cwo80bEHQeTK8fONLOgDf6Wm4ze_fxonqK3EVBVoAIz/pub#h.9d97iox3wzmd
|
|
130
130
|
|
|
131
131
|
**NWP (Numerical weather predictions)**\
|
|
132
|
-
OCF maintains a Zarr formatted version the German Weather Service's (DWD)
|
|
132
|
+
OCF maintains a Zarr formatted version of the German Weather Service's (DWD)
|
|
133
133
|
ICON-EU NWP model here:
|
|
134
134
|
https://huggingface.co/datasets/openclimatefix/dwd-icon-eu which includes the UK
|
|
135
135
|
|
|
@@ -169,66 +169,56 @@ cp -r configs.example configs
|
|
|
169
169
|
|
|
170
170
|
### Set up and config example for batch creation
|
|
171
171
|
|
|
172
|
-
We will use the example
|
|
173
|
-
`/PVNet/configs/datamodule/configuration/gcp_configuration.yaml`
|
|
174
|
-
Ensure that the file paths are set to the correct locations in
|
|
175
|
-
`gcp_configuration.yaml`.
|
|
172
|
+
We will use the following example config file for creating batches: `/PVNet/configs/datamodule/configuration/example_configuration.yaml`. Ensure that the file paths are set to the correct locations in `example_configuration.yaml`: search for `PLACEHOLDER` to find where to input the location of the files. You will need to comment out or delete the parts of `example_configuration.yaml` pertaining to the data you are not using.
|
|
176
173
|
|
|
177
|
-
`PLACEHOLDER` is used to indcate where to input the location of the files.
|
|
178
174
|
|
|
179
|
-
|
|
175
|
+
When creating batches, an additional datamodule config located in `PVNet/configs/datamodule` is passed into the batch creation script: `streamed_batches.yaml`. Like before, a placeholder variable is used when specifying which configuration to use:
|
|
180
176
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
With your configuration in place, you can proceed to create batches. PVNet uses
|
|
185
|
-
[hydra](https://hydra.cc/) which enables us to pass variables via the command
|
|
186
|
-
line that will override the configuration defined in the `./configs` directory.
|
|
187
|
-
|
|
188
|
-
When creating batches, an additional config is used which is passed into the batch creation script. This is the datamodule config located `PVNet/configs/datamodule`.
|
|
189
|
-
|
|
190
|
-
For this example we will be using the `streamed_batches.yaml` config. Like before, a placeholder variable is used when specifing which configuration to use:
|
|
191
|
-
|
|
192
|
-
`configuration: "PLACEHOLDER.yaml"`
|
|
177
|
+
```yaml
|
|
178
|
+
configuration: "PLACEHOLDER.yaml"
|
|
179
|
+
```
|
|
193
180
|
|
|
194
|
-
This should be given the whole path to the config on your local machine,
|
|
181
|
+
This should be given the whole path to the config on your local machine, for example:
|
|
195
182
|
|
|
196
|
-
|
|
197
|
-
|
|
183
|
+
```yaml
|
|
184
|
+
configuration: "/FULL-PATH-TO-REPO/PVNet/configs/datamodule/configuration/example_configuration.yaml"
|
|
185
|
+
```
|
|
198
186
|
|
|
199
187
|
Where `FULL-PATH-TO-REPO` represent the whole path to the PVNet repo on your local machine.
|
|
200
188
|
|
|
189
|
+
This is also where you can update the train, val & test periods to cover the data you have access to.
|
|
190
|
+
|
|
201
191
|
### Running the batch creation script
|
|
202
192
|
|
|
203
|
-
Run the save_batches.py script to create batches
|
|
193
|
+
Run the `save_batches.py` script to create batches with the parameters specified in the datamodule config (`streamed_batches.yaml` in this example):
|
|
204
194
|
|
|
205
|
-
```
|
|
195
|
+
```bash
|
|
206
196
|
python scripts/save_batches.py
|
|
207
197
|
```
|
|
208
|
-
|
|
198
|
+
PVNet uses
|
|
199
|
+
[hydra](https://hydra.cc/) which enables us to pass variables via the command
|
|
200
|
+
line that will override the configuration defined in the `./configs` directory, like this:
|
|
209
201
|
|
|
210
|
-
```
|
|
202
|
+
```bash
|
|
211
203
|
python scripts/save_batches.py datamodule=streamed_batches datamodule.batch_output_dir="./output" datamodule.num_train_batches=10 datamodule.num_val_batches=5
|
|
212
204
|
```
|
|
213
205
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
Its important that the dates set for the training, validation and testing in the datamodule (`streamed_batches.yaml`) config are within the ranges of the dates set for the input features in the configuration (`gcp_configuration.yaml`).
|
|
206
|
+
`scripts/save_batches.py` needs a config under `PVNet/configs/datamodule`. You can adapt `streamed_batches.yaml` or create your own in the same folder.
|
|
217
207
|
|
|
218
|
-
If downloading private data from a
|
|
208
|
+
If downloading private data from a GCP bucket make sure to authenticate gcloud (the public satellite data does not need authentication):
|
|
219
209
|
|
|
220
210
|
```
|
|
221
211
|
gcloud auth login
|
|
222
212
|
```
|
|
223
213
|
|
|
224
|
-
|
|
214
|
+
Files stored in multiple locations can be added as a list. For example, in the `example_configuration.yaml` file we can supply a path to satellite data stored on a bucket:
|
|
225
215
|
|
|
226
216
|
```yaml
|
|
227
217
|
satellite:
|
|
228
218
|
satellite_zarr_path: gs://solar-pv-nowcasting-data/satellite/EUMETSAT/SEVIRI_RSS/v4/2020_nonhrv.zarr
|
|
229
219
|
```
|
|
230
220
|
|
|
231
|
-
|
|
221
|
+
Or to satellite data hosted by Google:
|
|
232
222
|
|
|
233
223
|
```yaml
|
|
234
224
|
satellite:
|
|
@@ -236,145 +226,27 @@ satellite:
|
|
|
236
226
|
- "gs://public-datasets-eumetsat-solar-forecasting/satellite/EUMETSAT/SEVIRI_RSS/v4/2020_nonhrv.zarr"
|
|
237
227
|
- "gs://public-datasets-eumetsat-solar-forecasting/satellite/EUMETSAT/SEVIRI_RSS/v4/2021_nonhrv.zarr"
|
|
238
228
|
```
|
|
239
|
-
|
|
229
|
+
|
|
230
|
+
Datapipes are currently set up to use 11 channels from the satellite data, the 12th of which is HRV and is not included in these.
|
|
240
231
|
|
|
241
232
|
|
|
242
233
|
### Training PVNet
|
|
243
234
|
|
|
244
235
|
How PVNet is run is determined by the extensive configuration in the config
|
|
245
|
-
files. The
|
|
246
|
-
created using the steps and batch creation config mentioned above.
|
|
247
|
-
|
|
248
|
-
You should create the following configs before trying to train a model locally,
|
|
249
|
-
as so:
|
|
250
|
-
|
|
251
|
-
In `configs/datamodule/local_premade_batches.yaml`:
|
|
252
|
-
|
|
253
|
-
```yaml
|
|
254
|
-
_target_: pvnet.data.datamodule.DataModule
|
|
255
|
-
configuration: null
|
|
256
|
-
batch_dir: "./output" # where the batches are saved
|
|
257
|
-
num_workers: 20
|
|
258
|
-
prefetch_factor: 2
|
|
259
|
-
batch_size: 8
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
In `configs/model/local_multimodal.yaml`:
|
|
236
|
+
files. The configs stored in `PVNet/configs.example` should work with batches created using the steps and batch creation config mentioned above.
|
|
263
237
|
|
|
264
|
-
|
|
265
|
-
_target_: pvnet.models.multimodal.multimodal.Model
|
|
266
|
-
|
|
267
|
-
output_quantiles: [0.02, 0.1, 0.25, 0.5, 0.75, 0.9, 0.98]
|
|
268
|
-
|
|
269
|
-
#--------------------------------------------
|
|
270
|
-
# NWP encoder
|
|
271
|
-
#--------------------------------------------
|
|
272
|
-
|
|
273
|
-
nwp_encoders_dict:
|
|
274
|
-
ukv:
|
|
275
|
-
_target_: pvnet.models.multimodal.encoders.encoders3d.DefaultPVNet
|
|
276
|
-
_partial_: True
|
|
277
|
-
in_channels: 10
|
|
278
|
-
out_features: 256
|
|
279
|
-
number_of_conv3d_layers: 6
|
|
280
|
-
conv3d_channels: 32
|
|
281
|
-
image_size_pixels: 24
|
|
282
|
-
|
|
283
|
-
#--------------------------------------------
|
|
284
|
-
# Sat encoder settings
|
|
285
|
-
#--------------------------------------------
|
|
286
|
-
|
|
287
|
-
# Ignored as premade batches were created without satellite data
|
|
288
|
-
# sat_encoder:
|
|
289
|
-
# _target_: pvnet.models.multimodal.encoders.encoders3d.DefaultPVNet
|
|
290
|
-
# _partial_: True
|
|
291
|
-
# in_channels: 11
|
|
292
|
-
# out_features: 256
|
|
293
|
-
# number_of_conv3d_layers: 6
|
|
294
|
-
# conv3d_channels: 32
|
|
295
|
-
# image_size_pixels: 24
|
|
296
|
-
|
|
297
|
-
add_image_embedding_channel: False
|
|
298
|
-
|
|
299
|
-
#--------------------------------------------
|
|
300
|
-
# PV encoder settings
|
|
301
|
-
#--------------------------------------------
|
|
302
|
-
|
|
303
|
-
pv_encoder:
|
|
304
|
-
_target_: pvnet.models.multimodal.site_encoders.encoders.SingleAttentionNetwork
|
|
305
|
-
_partial_: True
|
|
306
|
-
num_sites: 349
|
|
307
|
-
out_features: 40
|
|
308
|
-
num_heads: 4
|
|
309
|
-
kdim: 40
|
|
310
|
-
pv_id_embed_dim: 20
|
|
311
|
-
|
|
312
|
-
#--------------------------------------------
|
|
313
|
-
# Tabular network settings
|
|
314
|
-
#--------------------------------------------
|
|
315
|
-
|
|
316
|
-
output_network:
|
|
317
|
-
_target_: pvnet.models.multimodal.linear_networks.networks.ResFCNet2
|
|
318
|
-
_partial_: True
|
|
319
|
-
fc_hidden_features: 128
|
|
320
|
-
n_res_blocks: 6
|
|
321
|
-
res_block_layers: 2
|
|
322
|
-
dropout_frac: 0.0
|
|
323
|
-
|
|
324
|
-
embedding_dim: 16
|
|
325
|
-
include_sun: True
|
|
326
|
-
include_gsp_yield_history: False
|
|
327
|
-
|
|
328
|
-
#--------------------------------------------
|
|
329
|
-
# Times
|
|
330
|
-
#--------------------------------------------
|
|
331
|
-
|
|
332
|
-
# Foreast and time settings
|
|
333
|
-
history_minutes: 60
|
|
334
|
-
forecast_minutes: 120
|
|
335
|
-
|
|
336
|
-
min_sat_delay_minutes: 60
|
|
337
|
-
|
|
338
|
-
sat_history_minutes: 90
|
|
339
|
-
pv_history_minutes: 60
|
|
340
|
-
|
|
341
|
-
# These must be set for each NWP encoder
|
|
342
|
-
nwp_history_minutes:
|
|
343
|
-
ukv: 60
|
|
344
|
-
nwp_forecast_minutes:
|
|
345
|
-
ukv: 120
|
|
346
|
-
|
|
347
|
-
# ----------------------------------------------
|
|
348
|
-
# Optimizer
|
|
349
|
-
# ----------------------------------------------
|
|
350
|
-
optimizer:
|
|
351
|
-
_target_: pvnet.optimizers.EmbAdamWReduceLROnPlateau
|
|
352
|
-
lr: 0.0001
|
|
353
|
-
weight_decay: 0.01
|
|
354
|
-
amsgrad: True
|
|
355
|
-
patience: 5
|
|
356
|
-
factor: 0.1
|
|
357
|
-
threshold: 0.002
|
|
358
|
-
```
|
|
238
|
+
Make sure to update the following config files before training your model:
|
|
359
239
|
|
|
360
|
-
In `configs/
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
min_epochs: null
|
|
369
|
-
max_epochs: null
|
|
370
|
-
reload_dataloaders_every_n_epochs: 0
|
|
371
|
-
num_sanity_val_steps: 8
|
|
372
|
-
fast_dev_run: false
|
|
373
|
-
accumulate_grad_batches: 4
|
|
374
|
-
log_every_n_steps: 50
|
|
375
|
-
```
|
|
240
|
+
1. In `configs/datamodule/local_premade_batches.yaml`:
|
|
241
|
+
- update `batch_dir` to point to the directory you stored your batches in during batch creation
|
|
242
|
+
2. In `configs/model/local_multimodal.yaml`:
|
|
243
|
+
- 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:
|
|
244
|
+
- `in_channels`: number of variables your NWP source supplies
|
|
245
|
+
- `image_size_pixels`: spatial crop of your NWP data. It depends on the spatial resolution of your NWP; should match `nwp_image_size_pixels_height` and/or `nwp_image_size_pixels_width` in `datamodule/example_configs.yaml`, unless transformations such as coarsening was applied (e. g. as for ECMWF data)
|
|
246
|
+
3. In `configs/local_trainer.yaml`:
|
|
247
|
+
- set `accelerator: 0` if running on a system without a supported GPU
|
|
376
248
|
|
|
377
|
-
|
|
249
|
+
If creating copies of the config files instead of modifying existing ones, update `defaults` in the main `./configs/config.yaml` file to use
|
|
378
250
|
your customised config files:
|
|
379
251
|
|
|
380
252
|
```yaml
|
|
@@ -398,7 +270,7 @@ python run.py
|
|
|
398
270
|
|
|
399
271
|
## Backtest
|
|
400
272
|
|
|
401
|
-
If you have
|
|
273
|
+
If you have successfully 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
274
|
|
|
403
275
|
|
|
404
276
|
## Testing
|