PVNet 3.0.64__tar.gz → 4.0.1__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.1/MANIFEST.in +2 -0
- {pvnet-3.0.64 → pvnet-4.0.1}/PKG-INFO +52 -19
- {pvnet-3.0.64 → pvnet-4.0.1}/PVNet.egg-info/PKG-INFO +52 -19
- {pvnet-3.0.64 → pvnet-4.0.1}/PVNet.egg-info/SOURCES.txt +6 -5
- {pvnet-3.0.64 → pvnet-4.0.1}/PVNet.egg-info/requires.txt +1 -0
- {pvnet-3.0.64 → pvnet-4.0.1}/README.md +49 -17
- pvnet-4.0.1/pvnet/__init__.py +2 -0
- pvnet-4.0.1/pvnet/data/__init__.py +3 -0
- pvnet-4.0.1/pvnet/data/base_datamodule.py +118 -0
- pvnet-4.0.1/pvnet/data/site_datamodule.py +53 -0
- pvnet-4.0.1/pvnet/data/uk_regional_datamodule.py +54 -0
- {pvnet-3.0.64 → pvnet-4.0.1}/pvnet/models/base_model.py +35 -78
- {pvnet-3.0.64 → pvnet-4.0.1}/pvnet/models/baseline/last_value.py +2 -3
- {pvnet-3.0.64 → pvnet-4.0.1}/pvnet/models/baseline/single_value.py +1 -2
- {pvnet-3.0.64 → pvnet-4.0.1}/pvnet/models/ensemble.py +1 -1
- pvnet-4.0.1/pvnet/models/model_cards/pv_india_model_card_template.md +51 -0
- pvnet-4.0.1/pvnet/models/model_cards/pv_uk_regional_model_card_template.md +54 -0
- pvnet-4.0.1/pvnet/models/model_cards/wind_india_model_card_template.md +51 -0
- {pvnet-3.0.64 → pvnet-4.0.1}/pvnet/models/multimodal/multimodal.py +24 -70
- {pvnet-3.0.64 → pvnet-4.0.1}/pvnet/models/multimodal/multimodal_base.py +8 -9
- {pvnet-3.0.64 → pvnet-4.0.1}/pvnet/models/multimodal/site_encoders/basic_blocks.py +1 -1
- {pvnet-3.0.64 → pvnet-4.0.1}/pvnet/models/multimodal/site_encoders/encoders.py +22 -22
- {pvnet-3.0.64 → pvnet-4.0.1}/pvnet/models/multimodal/unimodal_teacher.py +26 -27
- {pvnet-3.0.64 → pvnet-4.0.1}/pvnet/models/utils.py +8 -63
- {pvnet-3.0.64 → pvnet-4.0.1}/pvnet/training.py +1 -6
- {pvnet-3.0.64 → pvnet-4.0.1}/pvnet/utils.py +6 -52
- {pvnet-3.0.64 → pvnet-4.0.1}/pyproject.toml +1 -0
- {pvnet-3.0.64 → pvnet-4.0.1}/tests/test_end2end.py +3 -0
- {pvnet-3.0.64 → pvnet-4.0.1}/tests/test_utils.py +1 -1
- pvnet-3.0.64/MANIFEST.in +0 -1
- pvnet-3.0.64/pvnet/__init__.py +0 -2
- pvnet-3.0.64/pvnet/data/__init__.py +0 -2
- pvnet-3.0.64/pvnet/data/base.py +0 -116
- pvnet-3.0.64/pvnet/data/datamodule.py +0 -57
- pvnet-3.0.64/pvnet/data/pv_site_datamodule.py +0 -67
- pvnet-3.0.64/pvnet/data/utils.py +0 -19
- pvnet-3.0.64/pvnet/data/wind_datamodule.py +0 -62
- {pvnet-3.0.64 → pvnet-4.0.1}/LICENSE +0 -0
- {pvnet-3.0.64 → pvnet-4.0.1}/PVNet.egg-info/dependency_links.txt +0 -0
- {pvnet-3.0.64 → pvnet-4.0.1}/PVNet.egg-info/top_level.txt +0 -0
- {pvnet-3.0.64 → pvnet-4.0.1}/pvnet/callbacks.py +0 -0
- {pvnet-3.0.64 → pvnet-4.0.1}/pvnet/load_model.py +0 -0
- {pvnet-3.0.64 → pvnet-4.0.1}/pvnet/models/__init__.py +0 -0
- {pvnet-3.0.64 → pvnet-4.0.1}/pvnet/models/baseline/__init__.py +0 -0
- {pvnet-3.0.64 → pvnet-4.0.1}/pvnet/models/multimodal/__init__.py +0 -0
- {pvnet-3.0.64 → pvnet-4.0.1}/pvnet/models/multimodal/basic_blocks.py +0 -0
- {pvnet-3.0.64 → pvnet-4.0.1}/pvnet/models/multimodal/encoders/__init__.py +0 -0
- {pvnet-3.0.64 → pvnet-4.0.1}/pvnet/models/multimodal/encoders/basic_blocks.py +0 -0
- {pvnet-3.0.64 → pvnet-4.0.1}/pvnet/models/multimodal/encoders/encoders2d.py +0 -0
- {pvnet-3.0.64 → pvnet-4.0.1}/pvnet/models/multimodal/encoders/encoders3d.py +0 -0
- {pvnet-3.0.64 → pvnet-4.0.1}/pvnet/models/multimodal/encoders/encodersRNN.py +0 -0
- {pvnet-3.0.64 → pvnet-4.0.1}/pvnet/models/multimodal/linear_networks/__init__.py +0 -0
- {pvnet-3.0.64 → pvnet-4.0.1}/pvnet/models/multimodal/linear_networks/basic_blocks.py +0 -0
- {pvnet-3.0.64 → pvnet-4.0.1}/pvnet/models/multimodal/linear_networks/networks.py +0 -0
- {pvnet-3.0.64 → pvnet-4.0.1}/pvnet/models/multimodal/site_encoders/__init__.py +0 -0
- {pvnet-3.0.64 → pvnet-4.0.1}/pvnet/optimizers.py +0 -0
- {pvnet-3.0.64 → pvnet-4.0.1}/setup.cfg +0 -0
pvnet-4.0.1/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.1
|
|
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
|
|
|
@@ -134,31 +138,29 @@ OCF maintains a Zarr formatted version of the German Weather Service's (DWD)
|
|
|
134
138
|
ICON-EU NWP model here:
|
|
135
139
|
https://huggingface.co/datasets/openclimatefix/dwd-icon-eu which includes the UK
|
|
136
140
|
|
|
137
|
-
Please note that the current version of [ICON loader]([url](https://github.com/openclimatefix/ocf_datapipes/blob/9ec252eeee44937c12ab52699579bdcace76e72f/ocf_datapipes/load/nwp/providers/icon.py#L9-L30)) supports a different format. If you want to use our ICON-EU dataset or your own NWP source, you can create a loader for it using [the instructions here]([url](https://github.com/openclimatefix/ocf_datapipes/tree/main/ocf_datapipes/load#nwp)).
|
|
138
|
-
|
|
139
141
|
**PV**\
|
|
140
142
|
OCF maintains a dataset of PV generation from 1311 private PV installations
|
|
141
143
|
here: https://huggingface.co/datasets/openclimatefix/uk_pv
|
|
142
144
|
|
|
143
145
|
|
|
144
|
-
### Connecting with
|
|
146
|
+
### Connecting with ocf-data-sampler for batch creation
|
|
145
147
|
|
|
146
|
-
Outside the PVNet repo, clone the ocf-
|
|
148
|
+
Outside the PVNet repo, clone the ocf-data-sampler repo and exit the conda env created for PVNet: https://github.com/openclimatefix/ocf-data-sampler
|
|
147
149
|
```bash
|
|
148
|
-
git clone --depth 1 https://github.com/openclimatefix/
|
|
149
|
-
conda create -n
|
|
150
|
+
git clone --depth 1 https://github.com/openclimatefix/ocf-data-sampler.git
|
|
151
|
+
conda create -n ocf-data-sampler python=3.11
|
|
150
152
|
```
|
|
151
153
|
|
|
152
|
-
Then go inside the
|
|
154
|
+
Then go inside the ocf-data-sampler repo to add packages
|
|
153
155
|
|
|
154
156
|
```bash
|
|
155
|
-
pip install
|
|
157
|
+
pip install .
|
|
156
158
|
```
|
|
157
159
|
|
|
158
|
-
Then exit this environment, and enter back into the pvnet conda environment and install
|
|
160
|
+
Then exit this environment, and enter back into the pvnet conda environment and install ocf-data-sampler in editable mode (-e). This means the package is directly linked to the source code in the ocf-data-sampler repo.
|
|
159
161
|
|
|
160
162
|
```bash
|
|
161
|
-
pip install -e <PATH-TO-
|
|
163
|
+
pip install -e <PATH-TO-ocf-data-sampler-REPO>
|
|
162
164
|
```
|
|
163
165
|
|
|
164
166
|
## Generating pre-made batches of data for training/validation of PVNet
|
|
@@ -193,20 +195,20 @@ This is also where you can update the train, val & test periods to cover the dat
|
|
|
193
195
|
|
|
194
196
|
### Running the batch creation script
|
|
195
197
|
|
|
196
|
-
Run the `
|
|
198
|
+
Run the `save_samples.py` script to create batches with the parameters specified in the datamodule config (`streamed_batches.yaml` in this example):
|
|
197
199
|
|
|
198
200
|
```bash
|
|
199
|
-
python scripts/
|
|
201
|
+
python scripts/save_samples.py
|
|
200
202
|
```
|
|
201
203
|
PVNet uses
|
|
202
204
|
[hydra](https://hydra.cc/) which enables us to pass variables via the command
|
|
203
205
|
line that will override the configuration defined in the `./configs` directory, like this:
|
|
204
206
|
|
|
205
207
|
```bash
|
|
206
|
-
python scripts/
|
|
208
|
+
python scripts/save_samples.py datamodule=streamed_batches datamodule.sample_output_dir="./output" datamodule.num_train_batches=10 datamodule.num_val_batches=5
|
|
207
209
|
```
|
|
208
210
|
|
|
209
|
-
`scripts/
|
|
211
|
+
`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
212
|
|
|
211
213
|
If downloading private data from a GCP bucket make sure to authenticate gcloud (the public satellite data does not need authentication):
|
|
212
214
|
|
|
@@ -230,7 +232,7 @@ satellite:
|
|
|
230
232
|
- "gs://public-datasets-eumetsat-solar-forecasting/satellite/EUMETSAT/SEVIRI_RSS/v4/2021_nonhrv.zarr"
|
|
231
233
|
```
|
|
232
234
|
|
|
233
|
-
|
|
235
|
+
ocf-data-sampler is currently set up to use 11 channels from the satellite data, the 12th of which is HRV and is not included in these.
|
|
234
236
|
|
|
235
237
|
|
|
236
238
|
### Training PVNet
|
|
@@ -245,7 +247,7 @@ Make sure to update the following config files before training your model:
|
|
|
245
247
|
2. In `configs/model/local_multimodal.yaml`:
|
|
246
248
|
- 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
249
|
- `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 `
|
|
250
|
+
- `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
251
|
3. In `configs/local_trainer.yaml`:
|
|
250
252
|
- set `accelerator: 0` if running on a system without a supported GPU
|
|
251
253
|
|
|
@@ -264,7 +266,7 @@ defaults:
|
|
|
264
266
|
- hydra: default.yaml
|
|
265
267
|
```
|
|
266
268
|
|
|
267
|
-
Assuming you ran the `
|
|
269
|
+
Assuming you ran the `save_samples.py` script to generate some premade train and
|
|
268
270
|
val data batches, you can now train PVNet by running:
|
|
269
271
|
|
|
270
272
|
```
|
|
@@ -279,3 +281,34 @@ If you have successfully trained a PVNet model and have a saved model checkpoint
|
|
|
279
281
|
## Testing
|
|
280
282
|
|
|
281
283
|
You can use `python -m pytest tests` to run tests
|
|
284
|
+
|
|
285
|
+
## Contributors ✨
|
|
286
|
+
|
|
287
|
+
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
|
|
288
|
+
|
|
289
|
+
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
|
290
|
+
<!-- prettier-ignore-start -->
|
|
291
|
+
<!-- markdownlint-disable -->
|
|
292
|
+
<table>
|
|
293
|
+
<tbody>
|
|
294
|
+
<tr>
|
|
295
|
+
<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>
|
|
296
|
+
<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>
|
|
297
|
+
<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>
|
|
298
|
+
<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>
|
|
299
|
+
<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>
|
|
300
|
+
<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>
|
|
301
|
+
<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>
|
|
302
|
+
</tr>
|
|
303
|
+
<tr>
|
|
304
|
+
<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>
|
|
305
|
+
</tr>
|
|
306
|
+
</tbody>
|
|
307
|
+
</table>
|
|
308
|
+
|
|
309
|
+
<!-- markdownlint-restore -->
|
|
310
|
+
<!-- prettier-ignore-end -->
|
|
311
|
+
|
|
312
|
+
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
313
|
+
|
|
314
|
+
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.1
|
|
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
|
|
|
@@ -134,31 +138,29 @@ OCF maintains a Zarr formatted version of the German Weather Service's (DWD)
|
|
|
134
138
|
ICON-EU NWP model here:
|
|
135
139
|
https://huggingface.co/datasets/openclimatefix/dwd-icon-eu which includes the UK
|
|
136
140
|
|
|
137
|
-
Please note that the current version of [ICON loader]([url](https://github.com/openclimatefix/ocf_datapipes/blob/9ec252eeee44937c12ab52699579bdcace76e72f/ocf_datapipes/load/nwp/providers/icon.py#L9-L30)) supports a different format. If you want to use our ICON-EU dataset or your own NWP source, you can create a loader for it using [the instructions here]([url](https://github.com/openclimatefix/ocf_datapipes/tree/main/ocf_datapipes/load#nwp)).
|
|
138
|
-
|
|
139
141
|
**PV**\
|
|
140
142
|
OCF maintains a dataset of PV generation from 1311 private PV installations
|
|
141
143
|
here: https://huggingface.co/datasets/openclimatefix/uk_pv
|
|
142
144
|
|
|
143
145
|
|
|
144
|
-
### Connecting with
|
|
146
|
+
### Connecting with ocf-data-sampler for batch creation
|
|
145
147
|
|
|
146
|
-
Outside the PVNet repo, clone the ocf-
|
|
148
|
+
Outside the PVNet repo, clone the ocf-data-sampler repo and exit the conda env created for PVNet: https://github.com/openclimatefix/ocf-data-sampler
|
|
147
149
|
```bash
|
|
148
|
-
git clone --depth 1 https://github.com/openclimatefix/
|
|
149
|
-
conda create -n
|
|
150
|
+
git clone --depth 1 https://github.com/openclimatefix/ocf-data-sampler.git
|
|
151
|
+
conda create -n ocf-data-sampler python=3.11
|
|
150
152
|
```
|
|
151
153
|
|
|
152
|
-
Then go inside the
|
|
154
|
+
Then go inside the ocf-data-sampler repo to add packages
|
|
153
155
|
|
|
154
156
|
```bash
|
|
155
|
-
pip install
|
|
157
|
+
pip install .
|
|
156
158
|
```
|
|
157
159
|
|
|
158
|
-
Then exit this environment, and enter back into the pvnet conda environment and install
|
|
160
|
+
Then exit this environment, and enter back into the pvnet conda environment and install ocf-data-sampler in editable mode (-e). This means the package is directly linked to the source code in the ocf-data-sampler repo.
|
|
159
161
|
|
|
160
162
|
```bash
|
|
161
|
-
pip install -e <PATH-TO-
|
|
163
|
+
pip install -e <PATH-TO-ocf-data-sampler-REPO>
|
|
162
164
|
```
|
|
163
165
|
|
|
164
166
|
## Generating pre-made batches of data for training/validation of PVNet
|
|
@@ -193,20 +195,20 @@ This is also where you can update the train, val & test periods to cover the dat
|
|
|
193
195
|
|
|
194
196
|
### Running the batch creation script
|
|
195
197
|
|
|
196
|
-
Run the `
|
|
198
|
+
Run the `save_samples.py` script to create batches with the parameters specified in the datamodule config (`streamed_batches.yaml` in this example):
|
|
197
199
|
|
|
198
200
|
```bash
|
|
199
|
-
python scripts/
|
|
201
|
+
python scripts/save_samples.py
|
|
200
202
|
```
|
|
201
203
|
PVNet uses
|
|
202
204
|
[hydra](https://hydra.cc/) which enables us to pass variables via the command
|
|
203
205
|
line that will override the configuration defined in the `./configs` directory, like this:
|
|
204
206
|
|
|
205
207
|
```bash
|
|
206
|
-
python scripts/
|
|
208
|
+
python scripts/save_samples.py datamodule=streamed_batches datamodule.sample_output_dir="./output" datamodule.num_train_batches=10 datamodule.num_val_batches=5
|
|
207
209
|
```
|
|
208
210
|
|
|
209
|
-
`scripts/
|
|
211
|
+
`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
212
|
|
|
211
213
|
If downloading private data from a GCP bucket make sure to authenticate gcloud (the public satellite data does not need authentication):
|
|
212
214
|
|
|
@@ -230,7 +232,7 @@ satellite:
|
|
|
230
232
|
- "gs://public-datasets-eumetsat-solar-forecasting/satellite/EUMETSAT/SEVIRI_RSS/v4/2021_nonhrv.zarr"
|
|
231
233
|
```
|
|
232
234
|
|
|
233
|
-
|
|
235
|
+
ocf-data-sampler is currently set up to use 11 channels from the satellite data, the 12th of which is HRV and is not included in these.
|
|
234
236
|
|
|
235
237
|
|
|
236
238
|
### Training PVNet
|
|
@@ -245,7 +247,7 @@ Make sure to update the following config files before training your model:
|
|
|
245
247
|
2. In `configs/model/local_multimodal.yaml`:
|
|
246
248
|
- 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
249
|
- `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 `
|
|
250
|
+
- `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
251
|
3. In `configs/local_trainer.yaml`:
|
|
250
252
|
- set `accelerator: 0` if running on a system without a supported GPU
|
|
251
253
|
|
|
@@ -264,7 +266,7 @@ defaults:
|
|
|
264
266
|
- hydra: default.yaml
|
|
265
267
|
```
|
|
266
268
|
|
|
267
|
-
Assuming you ran the `
|
|
269
|
+
Assuming you ran the `save_samples.py` script to generate some premade train and
|
|
268
270
|
val data batches, you can now train PVNet by running:
|
|
269
271
|
|
|
270
272
|
```
|
|
@@ -279,3 +281,34 @@ If you have successfully trained a PVNet model and have a saved model checkpoint
|
|
|
279
281
|
## Testing
|
|
280
282
|
|
|
281
283
|
You can use `python -m pytest tests` to run tests
|
|
284
|
+
|
|
285
|
+
## Contributors ✨
|
|
286
|
+
|
|
287
|
+
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
|
|
288
|
+
|
|
289
|
+
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
|
290
|
+
<!-- prettier-ignore-start -->
|
|
291
|
+
<!-- markdownlint-disable -->
|
|
292
|
+
<table>
|
|
293
|
+
<tbody>
|
|
294
|
+
<tr>
|
|
295
|
+
<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>
|
|
296
|
+
<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>
|
|
297
|
+
<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>
|
|
298
|
+
<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>
|
|
299
|
+
<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>
|
|
300
|
+
<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>
|
|
301
|
+
<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>
|
|
302
|
+
</tr>
|
|
303
|
+
<tr>
|
|
304
|
+
<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>
|
|
305
|
+
</tr>
|
|
306
|
+
</tbody>
|
|
307
|
+
</table>
|
|
308
|
+
|
|
309
|
+
<!-- markdownlint-restore -->
|
|
310
|
+
<!-- prettier-ignore-end -->
|
|
311
|
+
|
|
312
|
+
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
313
|
+
|
|
314
|
+
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
|
|
|
@@ -86,31 +89,29 @@ OCF maintains a Zarr formatted version of the German Weather Service's (DWD)
|
|
|
86
89
|
ICON-EU NWP model here:
|
|
87
90
|
https://huggingface.co/datasets/openclimatefix/dwd-icon-eu which includes the UK
|
|
88
91
|
|
|
89
|
-
Please note that the current version of [ICON loader]([url](https://github.com/openclimatefix/ocf_datapipes/blob/9ec252eeee44937c12ab52699579bdcace76e72f/ocf_datapipes/load/nwp/providers/icon.py#L9-L30)) supports a different format. If you want to use our ICON-EU dataset or your own NWP source, you can create a loader for it using [the instructions here]([url](https://github.com/openclimatefix/ocf_datapipes/tree/main/ocf_datapipes/load#nwp)).
|
|
90
|
-
|
|
91
92
|
**PV**\
|
|
92
93
|
OCF maintains a dataset of PV generation from 1311 private PV installations
|
|
93
94
|
here: https://huggingface.co/datasets/openclimatefix/uk_pv
|
|
94
95
|
|
|
95
96
|
|
|
96
|
-
### Connecting with
|
|
97
|
+
### Connecting with ocf-data-sampler for batch creation
|
|
97
98
|
|
|
98
|
-
Outside the PVNet repo, clone the ocf-
|
|
99
|
+
Outside the PVNet repo, clone the ocf-data-sampler repo and exit the conda env created for PVNet: https://github.com/openclimatefix/ocf-data-sampler
|
|
99
100
|
```bash
|
|
100
|
-
git clone --depth 1 https://github.com/openclimatefix/
|
|
101
|
-
conda create -n
|
|
101
|
+
git clone --depth 1 https://github.com/openclimatefix/ocf-data-sampler.git
|
|
102
|
+
conda create -n ocf-data-sampler python=3.11
|
|
102
103
|
```
|
|
103
104
|
|
|
104
|
-
Then go inside the
|
|
105
|
+
Then go inside the ocf-data-sampler repo to add packages
|
|
105
106
|
|
|
106
107
|
```bash
|
|
107
|
-
pip install
|
|
108
|
+
pip install .
|
|
108
109
|
```
|
|
109
110
|
|
|
110
|
-
Then exit this environment, and enter back into the pvnet conda environment and install
|
|
111
|
+
Then exit this environment, and enter back into the pvnet conda environment and install ocf-data-sampler in editable mode (-e). This means the package is directly linked to the source code in the ocf-data-sampler repo.
|
|
111
112
|
|
|
112
113
|
```bash
|
|
113
|
-
pip install -e <PATH-TO-
|
|
114
|
+
pip install -e <PATH-TO-ocf-data-sampler-REPO>
|
|
114
115
|
```
|
|
115
116
|
|
|
116
117
|
## Generating pre-made batches of data for training/validation of PVNet
|
|
@@ -145,20 +146,20 @@ This is also where you can update the train, val & test periods to cover the dat
|
|
|
145
146
|
|
|
146
147
|
### Running the batch creation script
|
|
147
148
|
|
|
148
|
-
Run the `
|
|
149
|
+
Run the `save_samples.py` script to create batches with the parameters specified in the datamodule config (`streamed_batches.yaml` in this example):
|
|
149
150
|
|
|
150
151
|
```bash
|
|
151
|
-
python scripts/
|
|
152
|
+
python scripts/save_samples.py
|
|
152
153
|
```
|
|
153
154
|
PVNet uses
|
|
154
155
|
[hydra](https://hydra.cc/) which enables us to pass variables via the command
|
|
155
156
|
line that will override the configuration defined in the `./configs` directory, like this:
|
|
156
157
|
|
|
157
158
|
```bash
|
|
158
|
-
python scripts/
|
|
159
|
+
python scripts/save_samples.py datamodule=streamed_batches datamodule.sample_output_dir="./output" datamodule.num_train_batches=10 datamodule.num_val_batches=5
|
|
159
160
|
```
|
|
160
161
|
|
|
161
|
-
`scripts/
|
|
162
|
+
`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
163
|
|
|
163
164
|
If downloading private data from a GCP bucket make sure to authenticate gcloud (the public satellite data does not need authentication):
|
|
164
165
|
|
|
@@ -182,7 +183,7 @@ satellite:
|
|
|
182
183
|
- "gs://public-datasets-eumetsat-solar-forecasting/satellite/EUMETSAT/SEVIRI_RSS/v4/2021_nonhrv.zarr"
|
|
183
184
|
```
|
|
184
185
|
|
|
185
|
-
|
|
186
|
+
ocf-data-sampler is currently set up to use 11 channels from the satellite data, the 12th of which is HRV and is not included in these.
|
|
186
187
|
|
|
187
188
|
|
|
188
189
|
### Training PVNet
|
|
@@ -197,7 +198,7 @@ Make sure to update the following config files before training your model:
|
|
|
197
198
|
2. In `configs/model/local_multimodal.yaml`:
|
|
198
199
|
- 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
200
|
- `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 `
|
|
201
|
+
- `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
202
|
3. In `configs/local_trainer.yaml`:
|
|
202
203
|
- set `accelerator: 0` if running on a system without a supported GPU
|
|
203
204
|
|
|
@@ -216,7 +217,7 @@ defaults:
|
|
|
216
217
|
- hydra: default.yaml
|
|
217
218
|
```
|
|
218
219
|
|
|
219
|
-
Assuming you ran the `
|
|
220
|
+
Assuming you ran the `save_samples.py` script to generate some premade train and
|
|
220
221
|
val data batches, you can now train PVNet by running:
|
|
221
222
|
|
|
222
223
|
```
|
|
@@ -231,3 +232,34 @@ If you have successfully trained a PVNet model and have a saved model checkpoint
|
|
|
231
232
|
## Testing
|
|
232
233
|
|
|
233
234
|
You can use `python -m pytest tests` to run tests
|
|
235
|
+
|
|
236
|
+
## Contributors ✨
|
|
237
|
+
|
|
238
|
+
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
|
|
239
|
+
|
|
240
|
+
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
|
241
|
+
<!-- prettier-ignore-start -->
|
|
242
|
+
<!-- markdownlint-disable -->
|
|
243
|
+
<table>
|
|
244
|
+
<tbody>
|
|
245
|
+
<tr>
|
|
246
|
+
<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>
|
|
247
|
+
<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>
|
|
248
|
+
<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>
|
|
249
|
+
<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>
|
|
250
|
+
<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>
|
|
251
|
+
<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>
|
|
252
|
+
<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>
|
|
253
|
+
</tr>
|
|
254
|
+
<tr>
|
|
255
|
+
<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>
|
|
256
|
+
</tr>
|
|
257
|
+
</tbody>
|
|
258
|
+
</table>
|
|
259
|
+
|
|
260
|
+
<!-- markdownlint-restore -->
|
|
261
|
+
<!-- prettier-ignore-end -->
|
|
262
|
+
|
|
263
|
+
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
264
|
+
|
|
265
|
+
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)
|