PVNet 2.6.9__tar.gz → 2.6.10__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-2.6.9 → PVNet-2.6.10}/PKG-INFO +99 -97
- {PVNet-2.6.9 → PVNet-2.6.10}/PVNet.egg-info/PKG-INFO +99 -97
- {PVNet-2.6.9 → PVNet-2.6.10}/PVNet.egg-info/requires.txt +1 -0
- {PVNet-2.6.9 → PVNet-2.6.10}/README.md +97 -96
- PVNet-2.6.10/pvnet/__init__.py +2 -0
- {PVNet-2.6.9 → PVNet-2.6.10}/pvnet/models/base_model.py +6 -3
- {PVNet-2.6.9 → PVNet-2.6.10}/pvnet/models/multimodal/multimodal.py +17 -3
- {PVNet-2.6.9 → PVNet-2.6.10}/pvnet/utils.py +12 -7
- {PVNet-2.6.9 → PVNet-2.6.10}/requirements.txt +2 -0
- PVNet-2.6.9/pvnet/__init__.py +0 -2
- {PVNet-2.6.9 → PVNet-2.6.10}/LICENSE +0 -0
- {PVNet-2.6.9 → PVNet-2.6.10}/MANIFEST.in +0 -0
- {PVNet-2.6.9 → PVNet-2.6.10}/PVNet.egg-info/SOURCES.txt +0 -0
- {PVNet-2.6.9 → PVNet-2.6.10}/PVNet.egg-info/dependency_links.txt +0 -0
- {PVNet-2.6.9 → PVNet-2.6.10}/PVNet.egg-info/top_level.txt +0 -0
- {PVNet-2.6.9 → PVNet-2.6.10}/pvnet/callbacks.py +0 -0
- {PVNet-2.6.9 → PVNet-2.6.10}/pvnet/data/__init__.py +0 -0
- {PVNet-2.6.9 → PVNet-2.6.10}/pvnet/data/datamodule.py +0 -0
- {PVNet-2.6.9 → PVNet-2.6.10}/pvnet/data/utils.py +0 -0
- {PVNet-2.6.9 → PVNet-2.6.10}/pvnet/data/wind_datamodule.py +0 -0
- {PVNet-2.6.9 → PVNet-2.6.10}/pvnet/models/__init__.py +0 -0
- {PVNet-2.6.9 → PVNet-2.6.10}/pvnet/models/baseline/__init__.py +0 -0
- {PVNet-2.6.9 → PVNet-2.6.10}/pvnet/models/baseline/last_value.py +0 -0
- {PVNet-2.6.9 → PVNet-2.6.10}/pvnet/models/baseline/single_value.py +0 -0
- {PVNet-2.6.9 → PVNet-2.6.10}/pvnet/models/multimodal/__init__.py +0 -0
- {PVNet-2.6.9 → PVNet-2.6.10}/pvnet/models/multimodal/basic_blocks.py +0 -0
- {PVNet-2.6.9 → PVNet-2.6.10}/pvnet/models/multimodal/deep_supervision.py +0 -0
- {PVNet-2.6.9 → PVNet-2.6.10}/pvnet/models/multimodal/encoders/__init__.py +0 -0
- {PVNet-2.6.9 → PVNet-2.6.10}/pvnet/models/multimodal/encoders/basic_blocks.py +0 -0
- {PVNet-2.6.9 → PVNet-2.6.10}/pvnet/models/multimodal/encoders/encoders2d.py +0 -0
- {PVNet-2.6.9 → PVNet-2.6.10}/pvnet/models/multimodal/encoders/encoders3d.py +0 -0
- {PVNet-2.6.9 → PVNet-2.6.10}/pvnet/models/multimodal/encoders/encodersRNN.py +0 -0
- {PVNet-2.6.9 → PVNet-2.6.10}/pvnet/models/multimodal/linear_networks/__init__.py +0 -0
- {PVNet-2.6.9 → PVNet-2.6.10}/pvnet/models/multimodal/linear_networks/basic_blocks.py +0 -0
- {PVNet-2.6.9 → PVNet-2.6.10}/pvnet/models/multimodal/linear_networks/networks.py +0 -0
- {PVNet-2.6.9 → PVNet-2.6.10}/pvnet/models/multimodal/nwp_weighting.py +0 -0
- {PVNet-2.6.9 → PVNet-2.6.10}/pvnet/models/multimodal/site_encoders/__init__.py +0 -0
- {PVNet-2.6.9 → PVNet-2.6.10}/pvnet/models/multimodal/site_encoders/basic_blocks.py +0 -0
- {PVNet-2.6.9 → PVNet-2.6.10}/pvnet/models/multimodal/site_encoders/encoders.py +0 -0
- {PVNet-2.6.9 → PVNet-2.6.10}/pvnet/models/multimodal/weather_residual.py +0 -0
- {PVNet-2.6.9 → PVNet-2.6.10}/pvnet/models/utils.py +0 -0
- {PVNet-2.6.9 → PVNet-2.6.10}/pvnet/optimizers.py +0 -0
- {PVNet-2.6.9 → PVNet-2.6.10}/pvnet/training.py +0 -0
- {PVNet-2.6.9 → PVNet-2.6.10}/pyproject.toml +0 -0
- {PVNet-2.6.9 → PVNet-2.6.10}/requirements-dev.txt +0 -0
- {PVNet-2.6.9 → PVNet-2.6.10}/setup.cfg +0 -0
- {PVNet-2.6.9 → PVNet-2.6.10}/setup.py +0 -0
- {PVNet-2.6.9 → PVNet-2.6.10}/tests/__init__.py +0 -0
- {PVNet-2.6.9 → PVNet-2.6.10}/tests/conftest.py +0 -0
- {PVNet-2.6.9 → PVNet-2.6.10}/tests/test_end2end.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: PVNet
|
|
3
|
-
Version: 2.6.
|
|
3
|
+
Version: 2.6.10
|
|
4
4
|
Summary: PVNet
|
|
5
5
|
Author: Peter Dudfield
|
|
6
6
|
Author-email: info@openclimatefix.org
|
|
@@ -32,6 +32,7 @@ Requires-Dist: hydra-core
|
|
|
32
32
|
Requires-Dist: python-dotenv
|
|
33
33
|
Requires-Dist: hydra-optuna-sweeper
|
|
34
34
|
Requires-Dist: rich
|
|
35
|
+
Requires-Dist: gcsfs
|
|
35
36
|
Provides-Extra: all-models
|
|
36
37
|
Requires-Dist: pytorch-tabnet; extra == "all-models"
|
|
37
38
|
Requires-Dist: efficientnet_pytorch; extra == "all-models"
|
|
@@ -66,12 +67,26 @@ cd PVNet
|
|
|
66
67
|
pip install -r requirements.txt
|
|
67
68
|
```
|
|
68
69
|
|
|
70
|
+
The commit history is extensive. To save download time, use a depth of 1:
|
|
71
|
+
```bash
|
|
72
|
+
git clone --depth 1 https://github.com/openclimatefix/PVNet.git
|
|
73
|
+
```
|
|
74
|
+
This means only the latest commit and its associated files will be downloaded.
|
|
75
|
+
|
|
76
|
+
Next, in the PVNet repo, install PVNet as an editable package:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
pip install -e .
|
|
80
|
+
```
|
|
81
|
+
|
|
69
82
|
### Additional development dependencies
|
|
70
83
|
|
|
71
84
|
```bash
|
|
72
85
|
pip install -r requirements-dev.txt
|
|
73
86
|
```
|
|
74
87
|
|
|
88
|
+
|
|
89
|
+
|
|
75
90
|
## Getting started with running PVNet
|
|
76
91
|
|
|
77
92
|
Before running any code in within PVNet, copy the example configuration to a
|
|
@@ -107,116 +122,103 @@ https://huggingface.co/datasets/openclimatefix/dwd-icon-eu which includes the UK
|
|
|
107
122
|
OCF maintains a dataset of PV generation from 1311 private PV installations
|
|
108
123
|
here: https://huggingface.co/datasets/openclimatefix/uk_pv
|
|
109
124
|
|
|
110
|
-
### Generating pre-made batches of data for training/validation of PVNet
|
|
111
125
|
|
|
112
|
-
|
|
113
|
-
PVNet models.
|
|
126
|
+
### Connecting with ocf_datapipes for batch creation
|
|
114
127
|
|
|
115
|
-
|
|
116
|
-
|
|
128
|
+
Outside the PVNet repo, clone the ocf-datapipes repo and exit the conda env created for PVNet: https://github.com/openclimatefix/ocf_datapipes
|
|
129
|
+
```bash
|
|
130
|
+
git clone --depth 1 https://github.com/openclimatefix/ocf_datapipes.git
|
|
131
|
+
conda create -n ocf_datapipes python=3.10
|
|
132
|
+
```
|
|
117
133
|
|
|
118
|
-
|
|
119
|
-
`./configs/datamodule/configiration/local_configuration.yaml` and paste the
|
|
120
|
-
sample config (shown below)
|
|
121
|
-
2. Duplicate the `./configs/datamodule/ocf_datapipes.yaml` to
|
|
122
|
-
`./configs/datamodule/_local_ocf_datapipes.yaml` and ensure the
|
|
123
|
-
`configuration` key points to your newly created configuration file in
|
|
124
|
-
step 1.
|
|
125
|
-
3. Also in this file, update the train, val & test periods to cover the data you
|
|
126
|
-
have access to.
|
|
127
|
-
4. To get you started with your own configuration file, see the sample config
|
|
128
|
-
below. Update the data paths to the location of your local GSP, NWP and PV
|
|
129
|
-
datasets:
|
|
134
|
+
Then go inside the ocf_datapipes repo to add packages
|
|
130
135
|
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
description: Demo config
|
|
134
|
-
name: demo_datamodule_config
|
|
135
|
-
|
|
136
|
-
input_data:
|
|
137
|
-
default_history_minutes: 60
|
|
138
|
-
default_forecast_minutes: 120
|
|
139
|
-
|
|
140
|
-
gsp:
|
|
141
|
-
gsp_zarr_path: /path/to/gsp-data.zarr
|
|
142
|
-
history_minutes: 60
|
|
143
|
-
forecast_minutes: 120
|
|
144
|
-
time_resolution_minutes: 30
|
|
145
|
-
start_datetime: "2019-01-01T00:00:00"
|
|
146
|
-
end_datetime: "2019-01-08T00:00:00"
|
|
147
|
-
metadata_only: false
|
|
148
|
-
|
|
149
|
-
nwp:
|
|
150
|
-
ukv:
|
|
151
|
-
nwp_zarr_path: /path/to/nwp-data.zarr
|
|
152
|
-
history_minutes: 60
|
|
153
|
-
forecast_minutes: 120
|
|
154
|
-
time_resolution_minutes: 60
|
|
155
|
-
nwp_channels: # comment out channels as appropriate
|
|
156
|
-
- t # 2-metre temperature
|
|
157
|
-
- dswrf # downwards short-wave radiation flux
|
|
158
|
-
- dlwrf # downwards long-wave radiation flux
|
|
159
|
-
- hcc # high cloud cover
|
|
160
|
-
- mcc # medium cloud cover
|
|
161
|
-
- lcc # low cloud cover
|
|
162
|
-
- vis # visability
|
|
163
|
-
- r # relative humidity
|
|
164
|
-
- prate # precipitation rate
|
|
165
|
-
- si10 # 10-metre wind speed | live = unknown
|
|
166
|
-
nwp_image_size_pixels_height: 24
|
|
167
|
-
nwp_image_size_pixels_width: 24
|
|
168
|
-
nwp_provider: ukv
|
|
169
|
-
|
|
170
|
-
pv:
|
|
171
|
-
pv_files_groups:
|
|
172
|
-
- label: pvoutput.org
|
|
173
|
-
pv_filename: /path/to/pv-data/pv.netcdf
|
|
174
|
-
pv_metadata_filename: /path/to/pv-data/metadata.csv
|
|
175
|
-
history_minutes: 60
|
|
176
|
-
forecast_minutes: 0 # PVNet assumes no future PV generation
|
|
177
|
-
time_resolution_minutes: 5
|
|
178
|
-
start_datetime: "2019-01-01T00:00:00"
|
|
179
|
-
end_datetime: "2019-01-08T00:00:00"
|
|
180
|
-
pv_image_size_meters_height: 24
|
|
181
|
-
pv_image_size_meters_width: 24
|
|
182
|
-
pv_ml_ids: [154,155,156,158,159,160,162,164,165,166,167,168,169,171,173,177,178,179,181,182,185,186,187,188,189,190,191,192,193,197,198,199,200,202,204,205,206,208,209,211,214,215,216,217,218,219,220,221,225,229,230,232,233,234,236,242,243,245,252,254,255,256,257,258,260,261,262,265,267,268,272,273,275,276,277,280,281,282,283,287,289,291,292,293,294,295,296,297,298,301,302,303,304,306,307,309,310,311,317,318,319,320,321,322,323,325,326,329,332,333,335,336,338,340,342,344,345,346,348,349,352,354,355,356,357,360,362,363,368,369,370,371,372,374,375,376,378,380,382,384,385,388,390,391,393,396,397,398,399,400,401,403,404,405,406,407,409,411,412,413,414,415,416,417,418,419,420,421,422,423,424,425,426,427,429,431,435,437,438,440,441,444,447,450,451,453,456,457,458,459,464,465,466,467,468,470,471,473,474,476,477,479,480,481,482,485,486,488,490,491,492,493,496,498,501,503,506,507,508,509,510,511,512,513,515,516,517,519,520,521,522,524,526,527,528,531,532,536,537,538,540,541,542,543,544,545,549,550,551,552,553,554,556,557,560,561,563,566,568,571,572,575,576,577,579,580,581,582,584,585,588,590,594,595,597,600,602,603,604,606,611,613,614,616,618,620,622,623,624,625,626,628,629,630,631,636,637,638,640,641,642,644,645,646,650,651,652,653,654,655,657,660,661,662,663,666,667,668,670,675,676,679,681,683,684,685,687,696,698,701,702,703,704,706,710,722,723,724,725,727,728,729,730,732,733,734,735,736,737,]
|
|
183
|
-
n_pv_systems_per_example: 128
|
|
184
|
-
get_center: false
|
|
185
|
-
is_live: false
|
|
186
|
-
|
|
187
|
-
satellite:
|
|
188
|
-
satellite_zarr_path: "" # Left empty to avoid using satellite data
|
|
189
|
-
history_minutes: 60
|
|
190
|
-
forecast_minutes: 0
|
|
191
|
-
live_delay_minutes: 30
|
|
192
|
-
time_resolution_minutes: 5
|
|
193
|
-
satellite_channels:
|
|
194
|
-
- IR_016
|
|
195
|
-
- IR_039
|
|
196
|
-
- IR_087
|
|
197
|
-
- IR_097
|
|
198
|
-
- IR_108
|
|
199
|
-
- IR_120
|
|
200
|
-
- IR_134
|
|
201
|
-
- VIS006
|
|
202
|
-
- VIS008
|
|
203
|
-
- WV_062
|
|
204
|
-
- WV_073
|
|
205
|
-
satellite_image_size_pixels_height: 24
|
|
206
|
-
satellite_image_size_pixels_width: 24
|
|
136
|
+
```bash
|
|
137
|
+
pip install -r requirements.txt requirements-dev.txt
|
|
207
138
|
```
|
|
208
139
|
|
|
140
|
+
Then exit this environment, and enter back into the pvnet conda environment and install ocf_datapies in editable mode (-e). This means the package is directly linked to the source code in the ocf_datapies repo.
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
pip install -e <PATH-TO-ocf_datapipes-REPO>
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Generating pre-made batches of data for training/validation of PVNet
|
|
147
|
+
|
|
148
|
+
PVNet contains a script for generating batches of data suitable for training the PVNet models. To run the script you will need to make some modifications to the datamodule configuration.
|
|
149
|
+
|
|
150
|
+
Make sure you have copied the example configs (as already stated above):
|
|
151
|
+
```
|
|
152
|
+
cp -r configs.example configs
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Set up and config example for batch creation
|
|
156
|
+
|
|
157
|
+
We will use the example of creating batches using data from gcp:
|
|
158
|
+
`/PVNet/configs/datamodule/configuration/gcp_configuration.yaml`
|
|
159
|
+
Ensure that the file paths are set to the correct locations in
|
|
160
|
+
`gcp_configuration.yaml`.
|
|
161
|
+
|
|
162
|
+
`PLACEHOLDER` is used to indcate where to input the location of the files.
|
|
163
|
+
|
|
164
|
+
For OCF use cases, file locations can be found in `template_configuration.yaml` located alongside `gcp_configuration.yaml`.
|
|
165
|
+
|
|
166
|
+
In these configurations you can update the train, val & test periods to cover the data you have access to.
|
|
167
|
+
|
|
168
|
+
|
|
209
169
|
With your configuration in place, you can proceed to create batches. PVNet uses
|
|
210
170
|
[hydra](https://hydra.cc/) which enables us to pass variables via the command
|
|
211
171
|
line that will override the configuration defined in the `./configs` directory.
|
|
212
172
|
|
|
213
|
-
|
|
214
|
-
|
|
173
|
+
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`.
|
|
174
|
+
|
|
175
|
+
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:
|
|
176
|
+
|
|
177
|
+
`configuration: "PLACEHOLDER.yaml"`
|
|
178
|
+
|
|
179
|
+
This should be given the whole path to the config on your local machine, such as for our example it should be changed to:
|
|
180
|
+
|
|
181
|
+
`configuration: "/FULL-PATH-TO-REPO/PVNet/configs/datamodule/configuration/gcp_configuration.yaml"
|
|
182
|
+
`
|
|
183
|
+
|
|
184
|
+
Where `FULL-PATH-TO-REPO` represent the whole path to the PVNet repo on your local machine.
|
|
185
|
+
|
|
186
|
+
### Running the batch creation script
|
|
187
|
+
|
|
188
|
+
Run the save_batches.py script to create batches with the following example arguments as:
|
|
215
189
|
|
|
216
190
|
```
|
|
217
|
-
python scripts/save_batches.py datamodule=
|
|
191
|
+
python scripts/save_batches.py datamodule=streamed_batches +batch_output_dir="./output" +num_train_batches=10 +num_val_batches=5
|
|
218
192
|
```
|
|
219
193
|
|
|
194
|
+
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".
|
|
195
|
+
|
|
196
|
+
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`).
|
|
197
|
+
|
|
198
|
+
If downloading private data from a gcp bucket make sure to authenticate gcloud (the public satellite data does not need authentication):
|
|
199
|
+
|
|
200
|
+
```
|
|
201
|
+
gcloud auth login
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
For files stored in multiple locations they can be added as list. For example from the gcp_configuration.yaml file we can change from satellite data stored on a bucket:
|
|
205
|
+
|
|
206
|
+
```
|
|
207
|
+
satellite:
|
|
208
|
+
satellite_zarr_path: gs://solar-pv-nowcasting-data/satellite/EUMETSAT/SEVIRI_RSS/v4/2020_nonhrv.zarr
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
To satellite data hosted by Google:
|
|
212
|
+
|
|
213
|
+
```
|
|
214
|
+
satellite:
|
|
215
|
+
satellite_zarr_paths:
|
|
216
|
+
- "gs://public-datasets-eumetsat-solar-forecasting/satellite/EUMETSAT/SEVIRI_RSS/v4/2020_nonhrv.zarr"
|
|
217
|
+
- "gs://public-datasets-eumetsat-solar-forecasting/satellite/EUMETSAT/SEVIRI_RSS/v4/2021_nonhrv.zarr"
|
|
218
|
+
```
|
|
219
|
+
Datapipes is currently set up to use 11 channels from the satellite data, the 12th of which is HRV and is not included in these.
|
|
220
|
+
|
|
221
|
+
|
|
220
222
|
### Training PVNet
|
|
221
223
|
|
|
222
224
|
How PVNet is run is determined by the extensive configuration in the config
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: PVNet
|
|
3
|
-
Version: 2.6.
|
|
3
|
+
Version: 2.6.10
|
|
4
4
|
Summary: PVNet
|
|
5
5
|
Author: Peter Dudfield
|
|
6
6
|
Author-email: info@openclimatefix.org
|
|
@@ -32,6 +32,7 @@ Requires-Dist: hydra-core
|
|
|
32
32
|
Requires-Dist: python-dotenv
|
|
33
33
|
Requires-Dist: hydra-optuna-sweeper
|
|
34
34
|
Requires-Dist: rich
|
|
35
|
+
Requires-Dist: gcsfs
|
|
35
36
|
Provides-Extra: all-models
|
|
36
37
|
Requires-Dist: pytorch-tabnet; extra == "all-models"
|
|
37
38
|
Requires-Dist: efficientnet_pytorch; extra == "all-models"
|
|
@@ -66,12 +67,26 @@ cd PVNet
|
|
|
66
67
|
pip install -r requirements.txt
|
|
67
68
|
```
|
|
68
69
|
|
|
70
|
+
The commit history is extensive. To save download time, use a depth of 1:
|
|
71
|
+
```bash
|
|
72
|
+
git clone --depth 1 https://github.com/openclimatefix/PVNet.git
|
|
73
|
+
```
|
|
74
|
+
This means only the latest commit and its associated files will be downloaded.
|
|
75
|
+
|
|
76
|
+
Next, in the PVNet repo, install PVNet as an editable package:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
pip install -e .
|
|
80
|
+
```
|
|
81
|
+
|
|
69
82
|
### Additional development dependencies
|
|
70
83
|
|
|
71
84
|
```bash
|
|
72
85
|
pip install -r requirements-dev.txt
|
|
73
86
|
```
|
|
74
87
|
|
|
88
|
+
|
|
89
|
+
|
|
75
90
|
## Getting started with running PVNet
|
|
76
91
|
|
|
77
92
|
Before running any code in within PVNet, copy the example configuration to a
|
|
@@ -107,116 +122,103 @@ https://huggingface.co/datasets/openclimatefix/dwd-icon-eu which includes the UK
|
|
|
107
122
|
OCF maintains a dataset of PV generation from 1311 private PV installations
|
|
108
123
|
here: https://huggingface.co/datasets/openclimatefix/uk_pv
|
|
109
124
|
|
|
110
|
-
### Generating pre-made batches of data for training/validation of PVNet
|
|
111
125
|
|
|
112
|
-
|
|
113
|
-
PVNet models.
|
|
126
|
+
### Connecting with ocf_datapipes for batch creation
|
|
114
127
|
|
|
115
|
-
|
|
116
|
-
|
|
128
|
+
Outside the PVNet repo, clone the ocf-datapipes repo and exit the conda env created for PVNet: https://github.com/openclimatefix/ocf_datapipes
|
|
129
|
+
```bash
|
|
130
|
+
git clone --depth 1 https://github.com/openclimatefix/ocf_datapipes.git
|
|
131
|
+
conda create -n ocf_datapipes python=3.10
|
|
132
|
+
```
|
|
117
133
|
|
|
118
|
-
|
|
119
|
-
`./configs/datamodule/configiration/local_configuration.yaml` and paste the
|
|
120
|
-
sample config (shown below)
|
|
121
|
-
2. Duplicate the `./configs/datamodule/ocf_datapipes.yaml` to
|
|
122
|
-
`./configs/datamodule/_local_ocf_datapipes.yaml` and ensure the
|
|
123
|
-
`configuration` key points to your newly created configuration file in
|
|
124
|
-
step 1.
|
|
125
|
-
3. Also in this file, update the train, val & test periods to cover the data you
|
|
126
|
-
have access to.
|
|
127
|
-
4. To get you started with your own configuration file, see the sample config
|
|
128
|
-
below. Update the data paths to the location of your local GSP, NWP and PV
|
|
129
|
-
datasets:
|
|
134
|
+
Then go inside the ocf_datapipes repo to add packages
|
|
130
135
|
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
description: Demo config
|
|
134
|
-
name: demo_datamodule_config
|
|
135
|
-
|
|
136
|
-
input_data:
|
|
137
|
-
default_history_minutes: 60
|
|
138
|
-
default_forecast_minutes: 120
|
|
139
|
-
|
|
140
|
-
gsp:
|
|
141
|
-
gsp_zarr_path: /path/to/gsp-data.zarr
|
|
142
|
-
history_minutes: 60
|
|
143
|
-
forecast_minutes: 120
|
|
144
|
-
time_resolution_minutes: 30
|
|
145
|
-
start_datetime: "2019-01-01T00:00:00"
|
|
146
|
-
end_datetime: "2019-01-08T00:00:00"
|
|
147
|
-
metadata_only: false
|
|
148
|
-
|
|
149
|
-
nwp:
|
|
150
|
-
ukv:
|
|
151
|
-
nwp_zarr_path: /path/to/nwp-data.zarr
|
|
152
|
-
history_minutes: 60
|
|
153
|
-
forecast_minutes: 120
|
|
154
|
-
time_resolution_minutes: 60
|
|
155
|
-
nwp_channels: # comment out channels as appropriate
|
|
156
|
-
- t # 2-metre temperature
|
|
157
|
-
- dswrf # downwards short-wave radiation flux
|
|
158
|
-
- dlwrf # downwards long-wave radiation flux
|
|
159
|
-
- hcc # high cloud cover
|
|
160
|
-
- mcc # medium cloud cover
|
|
161
|
-
- lcc # low cloud cover
|
|
162
|
-
- vis # visability
|
|
163
|
-
- r # relative humidity
|
|
164
|
-
- prate # precipitation rate
|
|
165
|
-
- si10 # 10-metre wind speed | live = unknown
|
|
166
|
-
nwp_image_size_pixels_height: 24
|
|
167
|
-
nwp_image_size_pixels_width: 24
|
|
168
|
-
nwp_provider: ukv
|
|
169
|
-
|
|
170
|
-
pv:
|
|
171
|
-
pv_files_groups:
|
|
172
|
-
- label: pvoutput.org
|
|
173
|
-
pv_filename: /path/to/pv-data/pv.netcdf
|
|
174
|
-
pv_metadata_filename: /path/to/pv-data/metadata.csv
|
|
175
|
-
history_minutes: 60
|
|
176
|
-
forecast_minutes: 0 # PVNet assumes no future PV generation
|
|
177
|
-
time_resolution_minutes: 5
|
|
178
|
-
start_datetime: "2019-01-01T00:00:00"
|
|
179
|
-
end_datetime: "2019-01-08T00:00:00"
|
|
180
|
-
pv_image_size_meters_height: 24
|
|
181
|
-
pv_image_size_meters_width: 24
|
|
182
|
-
pv_ml_ids: [154,155,156,158,159,160,162,164,165,166,167,168,169,171,173,177,178,179,181,182,185,186,187,188,189,190,191,192,193,197,198,199,200,202,204,205,206,208,209,211,214,215,216,217,218,219,220,221,225,229,230,232,233,234,236,242,243,245,252,254,255,256,257,258,260,261,262,265,267,268,272,273,275,276,277,280,281,282,283,287,289,291,292,293,294,295,296,297,298,301,302,303,304,306,307,309,310,311,317,318,319,320,321,322,323,325,326,329,332,333,335,336,338,340,342,344,345,346,348,349,352,354,355,356,357,360,362,363,368,369,370,371,372,374,375,376,378,380,382,384,385,388,390,391,393,396,397,398,399,400,401,403,404,405,406,407,409,411,412,413,414,415,416,417,418,419,420,421,422,423,424,425,426,427,429,431,435,437,438,440,441,444,447,450,451,453,456,457,458,459,464,465,466,467,468,470,471,473,474,476,477,479,480,481,482,485,486,488,490,491,492,493,496,498,501,503,506,507,508,509,510,511,512,513,515,516,517,519,520,521,522,524,526,527,528,531,532,536,537,538,540,541,542,543,544,545,549,550,551,552,553,554,556,557,560,561,563,566,568,571,572,575,576,577,579,580,581,582,584,585,588,590,594,595,597,600,602,603,604,606,611,613,614,616,618,620,622,623,624,625,626,628,629,630,631,636,637,638,640,641,642,644,645,646,650,651,652,653,654,655,657,660,661,662,663,666,667,668,670,675,676,679,681,683,684,685,687,696,698,701,702,703,704,706,710,722,723,724,725,727,728,729,730,732,733,734,735,736,737,]
|
|
183
|
-
n_pv_systems_per_example: 128
|
|
184
|
-
get_center: false
|
|
185
|
-
is_live: false
|
|
186
|
-
|
|
187
|
-
satellite:
|
|
188
|
-
satellite_zarr_path: "" # Left empty to avoid using satellite data
|
|
189
|
-
history_minutes: 60
|
|
190
|
-
forecast_minutes: 0
|
|
191
|
-
live_delay_minutes: 30
|
|
192
|
-
time_resolution_minutes: 5
|
|
193
|
-
satellite_channels:
|
|
194
|
-
- IR_016
|
|
195
|
-
- IR_039
|
|
196
|
-
- IR_087
|
|
197
|
-
- IR_097
|
|
198
|
-
- IR_108
|
|
199
|
-
- IR_120
|
|
200
|
-
- IR_134
|
|
201
|
-
- VIS006
|
|
202
|
-
- VIS008
|
|
203
|
-
- WV_062
|
|
204
|
-
- WV_073
|
|
205
|
-
satellite_image_size_pixels_height: 24
|
|
206
|
-
satellite_image_size_pixels_width: 24
|
|
136
|
+
```bash
|
|
137
|
+
pip install -r requirements.txt requirements-dev.txt
|
|
207
138
|
```
|
|
208
139
|
|
|
140
|
+
Then exit this environment, and enter back into the pvnet conda environment and install ocf_datapies in editable mode (-e). This means the package is directly linked to the source code in the ocf_datapies repo.
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
pip install -e <PATH-TO-ocf_datapipes-REPO>
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Generating pre-made batches of data for training/validation of PVNet
|
|
147
|
+
|
|
148
|
+
PVNet contains a script for generating batches of data suitable for training the PVNet models. To run the script you will need to make some modifications to the datamodule configuration.
|
|
149
|
+
|
|
150
|
+
Make sure you have copied the example configs (as already stated above):
|
|
151
|
+
```
|
|
152
|
+
cp -r configs.example configs
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Set up and config example for batch creation
|
|
156
|
+
|
|
157
|
+
We will use the example of creating batches using data from gcp:
|
|
158
|
+
`/PVNet/configs/datamodule/configuration/gcp_configuration.yaml`
|
|
159
|
+
Ensure that the file paths are set to the correct locations in
|
|
160
|
+
`gcp_configuration.yaml`.
|
|
161
|
+
|
|
162
|
+
`PLACEHOLDER` is used to indcate where to input the location of the files.
|
|
163
|
+
|
|
164
|
+
For OCF use cases, file locations can be found in `template_configuration.yaml` located alongside `gcp_configuration.yaml`.
|
|
165
|
+
|
|
166
|
+
In these configurations you can update the train, val & test periods to cover the data you have access to.
|
|
167
|
+
|
|
168
|
+
|
|
209
169
|
With your configuration in place, you can proceed to create batches. PVNet uses
|
|
210
170
|
[hydra](https://hydra.cc/) which enables us to pass variables via the command
|
|
211
171
|
line that will override the configuration defined in the `./configs` directory.
|
|
212
172
|
|
|
213
|
-
|
|
214
|
-
|
|
173
|
+
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`.
|
|
174
|
+
|
|
175
|
+
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:
|
|
176
|
+
|
|
177
|
+
`configuration: "PLACEHOLDER.yaml"`
|
|
178
|
+
|
|
179
|
+
This should be given the whole path to the config on your local machine, such as for our example it should be changed to:
|
|
180
|
+
|
|
181
|
+
`configuration: "/FULL-PATH-TO-REPO/PVNet/configs/datamodule/configuration/gcp_configuration.yaml"
|
|
182
|
+
`
|
|
183
|
+
|
|
184
|
+
Where `FULL-PATH-TO-REPO` represent the whole path to the PVNet repo on your local machine.
|
|
185
|
+
|
|
186
|
+
### Running the batch creation script
|
|
187
|
+
|
|
188
|
+
Run the save_batches.py script to create batches with the following example arguments as:
|
|
215
189
|
|
|
216
190
|
```
|
|
217
|
-
python scripts/save_batches.py datamodule=
|
|
191
|
+
python scripts/save_batches.py datamodule=streamed_batches +batch_output_dir="./output" +num_train_batches=10 +num_val_batches=5
|
|
218
192
|
```
|
|
219
193
|
|
|
194
|
+
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".
|
|
195
|
+
|
|
196
|
+
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`).
|
|
197
|
+
|
|
198
|
+
If downloading private data from a gcp bucket make sure to authenticate gcloud (the public satellite data does not need authentication):
|
|
199
|
+
|
|
200
|
+
```
|
|
201
|
+
gcloud auth login
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
For files stored in multiple locations they can be added as list. For example from the gcp_configuration.yaml file we can change from satellite data stored on a bucket:
|
|
205
|
+
|
|
206
|
+
```
|
|
207
|
+
satellite:
|
|
208
|
+
satellite_zarr_path: gs://solar-pv-nowcasting-data/satellite/EUMETSAT/SEVIRI_RSS/v4/2020_nonhrv.zarr
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
To satellite data hosted by Google:
|
|
212
|
+
|
|
213
|
+
```
|
|
214
|
+
satellite:
|
|
215
|
+
satellite_zarr_paths:
|
|
216
|
+
- "gs://public-datasets-eumetsat-solar-forecasting/satellite/EUMETSAT/SEVIRI_RSS/v4/2020_nonhrv.zarr"
|
|
217
|
+
- "gs://public-datasets-eumetsat-solar-forecasting/satellite/EUMETSAT/SEVIRI_RSS/v4/2021_nonhrv.zarr"
|
|
218
|
+
```
|
|
219
|
+
Datapipes is currently set up to use 11 channels from the satellite data, the 12th of which is HRV and is not included in these.
|
|
220
|
+
|
|
221
|
+
|
|
220
222
|
### Training PVNet
|
|
221
223
|
|
|
222
224
|
How PVNet is run is determined by the extensive configuration in the config
|
|
@@ -28,12 +28,26 @@ cd PVNet
|
|
|
28
28
|
pip install -r requirements.txt
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
+
The commit history is extensive. To save download time, use a depth of 1:
|
|
32
|
+
```bash
|
|
33
|
+
git clone --depth 1 https://github.com/openclimatefix/PVNet.git
|
|
34
|
+
```
|
|
35
|
+
This means only the latest commit and its associated files will be downloaded.
|
|
36
|
+
|
|
37
|
+
Next, in the PVNet repo, install PVNet as an editable package:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
pip install -e .
|
|
41
|
+
```
|
|
42
|
+
|
|
31
43
|
### Additional development dependencies
|
|
32
44
|
|
|
33
45
|
```bash
|
|
34
46
|
pip install -r requirements-dev.txt
|
|
35
47
|
```
|
|
36
48
|
|
|
49
|
+
|
|
50
|
+
|
|
37
51
|
## Getting started with running PVNet
|
|
38
52
|
|
|
39
53
|
Before running any code in within PVNet, copy the example configuration to a
|
|
@@ -69,116 +83,103 @@ https://huggingface.co/datasets/openclimatefix/dwd-icon-eu which includes the UK
|
|
|
69
83
|
OCF maintains a dataset of PV generation from 1311 private PV installations
|
|
70
84
|
here: https://huggingface.co/datasets/openclimatefix/uk_pv
|
|
71
85
|
|
|
72
|
-
### Generating pre-made batches of data for training/validation of PVNet
|
|
73
86
|
|
|
74
|
-
|
|
75
|
-
PVNet models.
|
|
87
|
+
### Connecting with ocf_datapipes for batch creation
|
|
76
88
|
|
|
77
|
-
|
|
78
|
-
|
|
89
|
+
Outside the PVNet repo, clone the ocf-datapipes repo and exit the conda env created for PVNet: https://github.com/openclimatefix/ocf_datapipes
|
|
90
|
+
```bash
|
|
91
|
+
git clone --depth 1 https://github.com/openclimatefix/ocf_datapipes.git
|
|
92
|
+
conda create -n ocf_datapipes python=3.10
|
|
93
|
+
```
|
|
79
94
|
|
|
80
|
-
|
|
81
|
-
`./configs/datamodule/configiration/local_configuration.yaml` and paste the
|
|
82
|
-
sample config (shown below)
|
|
83
|
-
2. Duplicate the `./configs/datamodule/ocf_datapipes.yaml` to
|
|
84
|
-
`./configs/datamodule/_local_ocf_datapipes.yaml` and ensure the
|
|
85
|
-
`configuration` key points to your newly created configuration file in
|
|
86
|
-
step 1.
|
|
87
|
-
3. Also in this file, update the train, val & test periods to cover the data you
|
|
88
|
-
have access to.
|
|
89
|
-
4. To get you started with your own configuration file, see the sample config
|
|
90
|
-
below. Update the data paths to the location of your local GSP, NWP and PV
|
|
91
|
-
datasets:
|
|
95
|
+
Then go inside the ocf_datapipes repo to add packages
|
|
92
96
|
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
description: Demo config
|
|
96
|
-
name: demo_datamodule_config
|
|
97
|
-
|
|
98
|
-
input_data:
|
|
99
|
-
default_history_minutes: 60
|
|
100
|
-
default_forecast_minutes: 120
|
|
101
|
-
|
|
102
|
-
gsp:
|
|
103
|
-
gsp_zarr_path: /path/to/gsp-data.zarr
|
|
104
|
-
history_minutes: 60
|
|
105
|
-
forecast_minutes: 120
|
|
106
|
-
time_resolution_minutes: 30
|
|
107
|
-
start_datetime: "2019-01-01T00:00:00"
|
|
108
|
-
end_datetime: "2019-01-08T00:00:00"
|
|
109
|
-
metadata_only: false
|
|
110
|
-
|
|
111
|
-
nwp:
|
|
112
|
-
ukv:
|
|
113
|
-
nwp_zarr_path: /path/to/nwp-data.zarr
|
|
114
|
-
history_minutes: 60
|
|
115
|
-
forecast_minutes: 120
|
|
116
|
-
time_resolution_minutes: 60
|
|
117
|
-
nwp_channels: # comment out channels as appropriate
|
|
118
|
-
- t # 2-metre temperature
|
|
119
|
-
- dswrf # downwards short-wave radiation flux
|
|
120
|
-
- dlwrf # downwards long-wave radiation flux
|
|
121
|
-
- hcc # high cloud cover
|
|
122
|
-
- mcc # medium cloud cover
|
|
123
|
-
- lcc # low cloud cover
|
|
124
|
-
- vis # visability
|
|
125
|
-
- r # relative humidity
|
|
126
|
-
- prate # precipitation rate
|
|
127
|
-
- si10 # 10-metre wind speed | live = unknown
|
|
128
|
-
nwp_image_size_pixels_height: 24
|
|
129
|
-
nwp_image_size_pixels_width: 24
|
|
130
|
-
nwp_provider: ukv
|
|
131
|
-
|
|
132
|
-
pv:
|
|
133
|
-
pv_files_groups:
|
|
134
|
-
- label: pvoutput.org
|
|
135
|
-
pv_filename: /path/to/pv-data/pv.netcdf
|
|
136
|
-
pv_metadata_filename: /path/to/pv-data/metadata.csv
|
|
137
|
-
history_minutes: 60
|
|
138
|
-
forecast_minutes: 0 # PVNet assumes no future PV generation
|
|
139
|
-
time_resolution_minutes: 5
|
|
140
|
-
start_datetime: "2019-01-01T00:00:00"
|
|
141
|
-
end_datetime: "2019-01-08T00:00:00"
|
|
142
|
-
pv_image_size_meters_height: 24
|
|
143
|
-
pv_image_size_meters_width: 24
|
|
144
|
-
pv_ml_ids: [154,155,156,158,159,160,162,164,165,166,167,168,169,171,173,177,178,179,181,182,185,186,187,188,189,190,191,192,193,197,198,199,200,202,204,205,206,208,209,211,214,215,216,217,218,219,220,221,225,229,230,232,233,234,236,242,243,245,252,254,255,256,257,258,260,261,262,265,267,268,272,273,275,276,277,280,281,282,283,287,289,291,292,293,294,295,296,297,298,301,302,303,304,306,307,309,310,311,317,318,319,320,321,322,323,325,326,329,332,333,335,336,338,340,342,344,345,346,348,349,352,354,355,356,357,360,362,363,368,369,370,371,372,374,375,376,378,380,382,384,385,388,390,391,393,396,397,398,399,400,401,403,404,405,406,407,409,411,412,413,414,415,416,417,418,419,420,421,422,423,424,425,426,427,429,431,435,437,438,440,441,444,447,450,451,453,456,457,458,459,464,465,466,467,468,470,471,473,474,476,477,479,480,481,482,485,486,488,490,491,492,493,496,498,501,503,506,507,508,509,510,511,512,513,515,516,517,519,520,521,522,524,526,527,528,531,532,536,537,538,540,541,542,543,544,545,549,550,551,552,553,554,556,557,560,561,563,566,568,571,572,575,576,577,579,580,581,582,584,585,588,590,594,595,597,600,602,603,604,606,611,613,614,616,618,620,622,623,624,625,626,628,629,630,631,636,637,638,640,641,642,644,645,646,650,651,652,653,654,655,657,660,661,662,663,666,667,668,670,675,676,679,681,683,684,685,687,696,698,701,702,703,704,706,710,722,723,724,725,727,728,729,730,732,733,734,735,736,737,]
|
|
145
|
-
n_pv_systems_per_example: 128
|
|
146
|
-
get_center: false
|
|
147
|
-
is_live: false
|
|
148
|
-
|
|
149
|
-
satellite:
|
|
150
|
-
satellite_zarr_path: "" # Left empty to avoid using satellite data
|
|
151
|
-
history_minutes: 60
|
|
152
|
-
forecast_minutes: 0
|
|
153
|
-
live_delay_minutes: 30
|
|
154
|
-
time_resolution_minutes: 5
|
|
155
|
-
satellite_channels:
|
|
156
|
-
- IR_016
|
|
157
|
-
- IR_039
|
|
158
|
-
- IR_087
|
|
159
|
-
- IR_097
|
|
160
|
-
- IR_108
|
|
161
|
-
- IR_120
|
|
162
|
-
- IR_134
|
|
163
|
-
- VIS006
|
|
164
|
-
- VIS008
|
|
165
|
-
- WV_062
|
|
166
|
-
- WV_073
|
|
167
|
-
satellite_image_size_pixels_height: 24
|
|
168
|
-
satellite_image_size_pixels_width: 24
|
|
97
|
+
```bash
|
|
98
|
+
pip install -r requirements.txt requirements-dev.txt
|
|
169
99
|
```
|
|
170
100
|
|
|
101
|
+
Then exit this environment, and enter back into the pvnet conda environment and install ocf_datapies in editable mode (-e). This means the package is directly linked to the source code in the ocf_datapies repo.
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
pip install -e <PATH-TO-ocf_datapipes-REPO>
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Generating pre-made batches of data for training/validation of PVNet
|
|
108
|
+
|
|
109
|
+
PVNet contains a script for generating batches of data suitable for training the PVNet models. To run the script you will need to make some modifications to the datamodule configuration.
|
|
110
|
+
|
|
111
|
+
Make sure you have copied the example configs (as already stated above):
|
|
112
|
+
```
|
|
113
|
+
cp -r configs.example configs
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Set up and config example for batch creation
|
|
117
|
+
|
|
118
|
+
We will use the example of creating batches using data from gcp:
|
|
119
|
+
`/PVNet/configs/datamodule/configuration/gcp_configuration.yaml`
|
|
120
|
+
Ensure that the file paths are set to the correct locations in
|
|
121
|
+
`gcp_configuration.yaml`.
|
|
122
|
+
|
|
123
|
+
`PLACEHOLDER` is used to indcate where to input the location of the files.
|
|
124
|
+
|
|
125
|
+
For OCF use cases, file locations can be found in `template_configuration.yaml` located alongside `gcp_configuration.yaml`.
|
|
126
|
+
|
|
127
|
+
In these configurations you can update the train, val & test periods to cover the data you have access to.
|
|
128
|
+
|
|
129
|
+
|
|
171
130
|
With your configuration in place, you can proceed to create batches. PVNet uses
|
|
172
131
|
[hydra](https://hydra.cc/) which enables us to pass variables via the command
|
|
173
132
|
line that will override the configuration defined in the `./configs` directory.
|
|
174
133
|
|
|
175
|
-
|
|
176
|
-
|
|
134
|
+
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`.
|
|
135
|
+
|
|
136
|
+
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:
|
|
137
|
+
|
|
138
|
+
`configuration: "PLACEHOLDER.yaml"`
|
|
139
|
+
|
|
140
|
+
This should be given the whole path to the config on your local machine, such as for our example it should be changed to:
|
|
141
|
+
|
|
142
|
+
`configuration: "/FULL-PATH-TO-REPO/PVNet/configs/datamodule/configuration/gcp_configuration.yaml"
|
|
143
|
+
`
|
|
144
|
+
|
|
145
|
+
Where `FULL-PATH-TO-REPO` represent the whole path to the PVNet repo on your local machine.
|
|
146
|
+
|
|
147
|
+
### Running the batch creation script
|
|
148
|
+
|
|
149
|
+
Run the save_batches.py script to create batches with the following example arguments as:
|
|
177
150
|
|
|
178
151
|
```
|
|
179
|
-
python scripts/save_batches.py datamodule=
|
|
152
|
+
python scripts/save_batches.py datamodule=streamed_batches +batch_output_dir="./output" +num_train_batches=10 +num_val_batches=5
|
|
180
153
|
```
|
|
181
154
|
|
|
155
|
+
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".
|
|
156
|
+
|
|
157
|
+
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`).
|
|
158
|
+
|
|
159
|
+
If downloading private data from a gcp bucket make sure to authenticate gcloud (the public satellite data does not need authentication):
|
|
160
|
+
|
|
161
|
+
```
|
|
162
|
+
gcloud auth login
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
For files stored in multiple locations they can be added as list. For example from the gcp_configuration.yaml file we can change from satellite data stored on a bucket:
|
|
166
|
+
|
|
167
|
+
```
|
|
168
|
+
satellite:
|
|
169
|
+
satellite_zarr_path: gs://solar-pv-nowcasting-data/satellite/EUMETSAT/SEVIRI_RSS/v4/2020_nonhrv.zarr
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
To satellite data hosted by Google:
|
|
173
|
+
|
|
174
|
+
```
|
|
175
|
+
satellite:
|
|
176
|
+
satellite_zarr_paths:
|
|
177
|
+
- "gs://public-datasets-eumetsat-solar-forecasting/satellite/EUMETSAT/SEVIRI_RSS/v4/2020_nonhrv.zarr"
|
|
178
|
+
- "gs://public-datasets-eumetsat-solar-forecasting/satellite/EUMETSAT/SEVIRI_RSS/v4/2021_nonhrv.zarr"
|
|
179
|
+
```
|
|
180
|
+
Datapipes is currently set up to use 11 channels from the satellite data, the 12th of which is HRV and is not included in these.
|
|
181
|
+
|
|
182
|
+
|
|
182
183
|
### Training PVNet
|
|
183
184
|
|
|
184
185
|
How PVNet is run is determined by the extensive configuration in the config
|
|
@@ -234,6 +234,7 @@ class BaseModel(pl.LightningModule, PVNetModelHubMixin):
|
|
|
234
234
|
forecast_minutes: int,
|
|
235
235
|
optimizer: AbstractOptimizer,
|
|
236
236
|
output_quantiles: Optional[list[float]] = None,
|
|
237
|
+
target_key: BatchKey = BatchKey.gsp,
|
|
237
238
|
):
|
|
238
239
|
"""Abtstract base class for PVNet submodels.
|
|
239
240
|
|
|
@@ -243,10 +244,12 @@ class BaseModel(pl.LightningModule, PVNetModelHubMixin):
|
|
|
243
244
|
optimizer (AbstractOptimizer): Optimizer
|
|
244
245
|
output_quantiles: A list of float (0.0, 1.0) quantiles to predict values for. If set to
|
|
245
246
|
None the output is a single value.
|
|
247
|
+
target_key: The key of the target variable in the batch
|
|
246
248
|
"""
|
|
247
249
|
super().__init__()
|
|
248
250
|
|
|
249
251
|
self._optimizer = optimizer
|
|
252
|
+
self._target_key = target_key
|
|
250
253
|
|
|
251
254
|
# Model must have lr to allow tuning
|
|
252
255
|
# This setting is only used when lr is tuned with callback
|
|
@@ -424,7 +427,7 @@ class BaseModel(pl.LightningModule, PVNetModelHubMixin):
|
|
|
424
427
|
def training_step(self, batch, batch_idx):
|
|
425
428
|
"""Run training step"""
|
|
426
429
|
y_hat = self(batch)
|
|
427
|
-
y = batch[
|
|
430
|
+
y = batch[self._target_key][:, -self.forecast_len_30 :, 0]
|
|
428
431
|
|
|
429
432
|
losses = self._calculate_common_losses(y, y_hat)
|
|
430
433
|
losses = {f"{k}/train": v for k, v in losses.items()}
|
|
@@ -440,7 +443,7 @@ class BaseModel(pl.LightningModule, PVNetModelHubMixin):
|
|
|
440
443
|
def validation_step(self, batch: dict, batch_idx):
|
|
441
444
|
"""Run validation step"""
|
|
442
445
|
y_hat = self(batch)
|
|
443
|
-
y = batch[
|
|
446
|
+
y = batch[self._target_key][:, -self.forecast_len_30 :, 0]
|
|
444
447
|
|
|
445
448
|
losses = self._calculate_common_losses(y, y_hat)
|
|
446
449
|
losses.update(self._calculate_val_losses(y, y_hat))
|
|
@@ -484,7 +487,7 @@ class BaseModel(pl.LightningModule, PVNetModelHubMixin):
|
|
|
484
487
|
def test_step(self, batch, batch_idx):
|
|
485
488
|
"""Run test step"""
|
|
486
489
|
y_hat = self(batch)
|
|
487
|
-
y = batch[
|
|
490
|
+
y = batch[self._target_key][:, -self.forecast_len_30 :, 0]
|
|
488
491
|
|
|
489
492
|
losses = self._calculate_common_losses(y, y_hat)
|
|
490
493
|
losses.update(self._calculate_val_losses(y, y_hat))
|
|
@@ -54,6 +54,7 @@ class Model(BaseModel):
|
|
|
54
54
|
nwp_history_minutes: Optional[int] = None,
|
|
55
55
|
pv_history_minutes: Optional[int] = None,
|
|
56
56
|
optimizer: AbstractOptimizer = pvnet.optimizers.Adam(),
|
|
57
|
+
target_key: str = "gsp",
|
|
57
58
|
):
|
|
58
59
|
"""Neural network which combines information from different sources.
|
|
59
60
|
|
|
@@ -94,6 +95,7 @@ class Model(BaseModel):
|
|
|
94
95
|
pv_history_minutes: Length of recent site-level PV data data used as input. Defaults to
|
|
95
96
|
`history_minutes` if not provided.
|
|
96
97
|
optimizer: Optimizer factory function used for network.
|
|
98
|
+
target_key: The key of the target variable in the batch.
|
|
97
99
|
"""
|
|
98
100
|
|
|
99
101
|
self.include_gsp_yield_history = include_gsp_yield_history
|
|
@@ -103,8 +105,15 @@ class Model(BaseModel):
|
|
|
103
105
|
self.include_sun = include_sun
|
|
104
106
|
self.embedding_dim = embedding_dim
|
|
105
107
|
self.add_image_embedding_channel = add_image_embedding_channel
|
|
106
|
-
|
|
107
|
-
|
|
108
|
+
self.target_key_name = target_key
|
|
109
|
+
|
|
110
|
+
super().__init__(
|
|
111
|
+
history_minutes=history_minutes,
|
|
112
|
+
forecast_minutes=forecast_minutes,
|
|
113
|
+
optimizer=optimizer,
|
|
114
|
+
output_quantiles=output_quantiles,
|
|
115
|
+
target_key=BatchKey.gsp if target_key == "gsp" else BatchKey.pv,
|
|
116
|
+
)
|
|
108
117
|
|
|
109
118
|
# Number of features expected by the output_network
|
|
110
119
|
# Add to this as network pices are constructed
|
|
@@ -228,7 +237,12 @@ class Model(BaseModel):
|
|
|
228
237
|
# *********************** PV Data *************************************
|
|
229
238
|
# Add site-level PV yield
|
|
230
239
|
if self.include_pv:
|
|
231
|
-
|
|
240
|
+
if self.target_key_name != "pv":
|
|
241
|
+
modes["pv"] = self.pv_encoder(x)
|
|
242
|
+
else:
|
|
243
|
+
# Target is PV, so only take the history
|
|
244
|
+
pv_history = x[BatchKey.pv][:, : self.history_len_30].float()
|
|
245
|
+
modes["pv"] = self.pv_encoder(pv_history)
|
|
232
246
|
|
|
233
247
|
# *********************** GSP Data ************************************
|
|
234
248
|
# add gsp yield history
|
|
@@ -242,19 +242,24 @@ def finish(
|
|
|
242
242
|
wandb.finish()
|
|
243
243
|
|
|
244
244
|
|
|
245
|
-
def plot_batch_forecasts(batch, y_hat, batch_idx=None, quantiles=None):
|
|
245
|
+
def plot_batch_forecasts(batch, y_hat, batch_idx=None, quantiles=None, key_to_plot: str = "gsp"):
|
|
246
246
|
"""Plot a batch of data and the forecast from that batch"""
|
|
247
247
|
|
|
248
248
|
def _get_numpy(key):
|
|
249
249
|
return batch[key].cpu().numpy().squeeze()
|
|
250
250
|
|
|
251
|
-
|
|
251
|
+
y_key = BatchKey.gsp if key_to_plot == "gsp" else BatchKey.pv
|
|
252
|
+
y_id_key = BatchKey.gsp_id if key_to_plot == "gsp" else BatchKey.pv_id
|
|
253
|
+
t0_idx_key = BatchKey.gsp_t0_idx if key_to_plot == "gsp" else BatchKey.pv_t0_idx
|
|
254
|
+
time_utc_key = BatchKey.gsp_time_utc if key_to_plot == "gsp" else BatchKey.pv_time_utc
|
|
255
|
+
plotting_name = key_to_plot.upper()
|
|
256
|
+
y = batch[y_key].cpu().numpy()
|
|
252
257
|
y_hat = y_hat.cpu().numpy()
|
|
253
258
|
|
|
254
|
-
gsp_ids = batch[
|
|
255
|
-
batch[
|
|
259
|
+
gsp_ids = batch[y_id_key].cpu().numpy().squeeze()
|
|
260
|
+
batch[t0_idx_key]
|
|
256
261
|
|
|
257
|
-
times_utc = batch[
|
|
262
|
+
times_utc = batch[time_utc_key].cpu().numpy().squeeze().astype("datetime64[s]")
|
|
258
263
|
times_utc = [pd.to_datetime(t) for t in times_utc]
|
|
259
264
|
|
|
260
265
|
batch_size = y.shape[0]
|
|
@@ -294,9 +299,9 @@ def plot_batch_forecasts(batch, y_hat, batch_idx=None, quantiles=None):
|
|
|
294
299
|
ax.set_xlabel("Time (hour of day)")
|
|
295
300
|
|
|
296
301
|
if batch_idx is not None:
|
|
297
|
-
title = f"Normed
|
|
302
|
+
title = f"Normed {plotting_name} output : batch_idx={batch_idx}"
|
|
298
303
|
else:
|
|
299
|
-
title = "Normed
|
|
304
|
+
title = f"Normed {plotting_name} output"
|
|
300
305
|
plt.suptitle(title)
|
|
301
306
|
plt.tight_layout()
|
|
302
307
|
|
PVNet-2.6.9/pvnet/__init__.py
DELETED
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|