PVNet 3.0.21__tar.gz → 3.0.23__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.21 → PVNet-3.0.23}/PKG-INFO +2 -2
- {PVNet-3.0.21 → PVNet-3.0.23}/PVNet.egg-info/PKG-INFO +2 -2
- {PVNet-3.0.21 → PVNet-3.0.23}/PVNet.egg-info/requires.txt +1 -1
- PVNet-3.0.23/pvnet/__init__.py +2 -0
- {PVNet-3.0.21 → PVNet-3.0.23}/pvnet/data/datamodule.py +1 -2
- {PVNet-3.0.21 → PVNet-3.0.23}/pvnet/data/pv_site_datamodule.py +1 -2
- PVNet-3.0.23/pvnet/data/utils.py +19 -0
- {PVNet-3.0.21 → PVNet-3.0.23}/pvnet/data/wind_datamodule.py +1 -2
- {PVNet-3.0.21 → PVNet-3.0.23}/pvnet/models/base_model.py +3 -2
- {PVNet-3.0.21 → PVNet-3.0.23}/pvnet/models/multimodal/unimodal_teacher.py +10 -1
- {PVNet-3.0.21 → PVNet-3.0.23}/pvnet/optimizers.py +0 -1
- {PVNet-3.0.21 → PVNet-3.0.23}/requirements.txt +1 -1
- PVNet-3.0.21/pvnet/__init__.py +0 -2
- PVNet-3.0.21/pvnet/data/utils.py +0 -47
- {PVNet-3.0.21 → PVNet-3.0.23}/LICENSE +0 -0
- {PVNet-3.0.21 → PVNet-3.0.23}/MANIFEST.in +0 -0
- {PVNet-3.0.21 → PVNet-3.0.23}/PVNet.egg-info/SOURCES.txt +0 -0
- {PVNet-3.0.21 → PVNet-3.0.23}/PVNet.egg-info/dependency_links.txt +0 -0
- {PVNet-3.0.21 → PVNet-3.0.23}/PVNet.egg-info/top_level.txt +0 -0
- {PVNet-3.0.21 → PVNet-3.0.23}/README.md +0 -0
- {PVNet-3.0.21 → PVNet-3.0.23}/pvnet/callbacks.py +0 -0
- {PVNet-3.0.21 → PVNet-3.0.23}/pvnet/data/__init__.py +0 -0
- {PVNet-3.0.21 → PVNet-3.0.23}/pvnet/data/base.py +0 -0
- {PVNet-3.0.21 → PVNet-3.0.23}/pvnet/models/__init__.py +0 -0
- {PVNet-3.0.21 → PVNet-3.0.23}/pvnet/models/baseline/__init__.py +0 -0
- {PVNet-3.0.21 → PVNet-3.0.23}/pvnet/models/baseline/last_value.py +0 -0
- {PVNet-3.0.21 → PVNet-3.0.23}/pvnet/models/baseline/single_value.py +0 -0
- {PVNet-3.0.21 → PVNet-3.0.23}/pvnet/models/ensemble.py +0 -0
- {PVNet-3.0.21 → PVNet-3.0.23}/pvnet/models/multimodal/__init__.py +0 -0
- {PVNet-3.0.21 → PVNet-3.0.23}/pvnet/models/multimodal/basic_blocks.py +0 -0
- {PVNet-3.0.21 → PVNet-3.0.23}/pvnet/models/multimodal/encoders/__init__.py +0 -0
- {PVNet-3.0.21 → PVNet-3.0.23}/pvnet/models/multimodal/encoders/basic_blocks.py +0 -0
- {PVNet-3.0.21 → PVNet-3.0.23}/pvnet/models/multimodal/encoders/encoders2d.py +0 -0
- {PVNet-3.0.21 → PVNet-3.0.23}/pvnet/models/multimodal/encoders/encoders3d.py +0 -0
- {PVNet-3.0.21 → PVNet-3.0.23}/pvnet/models/multimodal/encoders/encodersRNN.py +0 -0
- {PVNet-3.0.21 → PVNet-3.0.23}/pvnet/models/multimodal/linear_networks/__init__.py +0 -0
- {PVNet-3.0.21 → PVNet-3.0.23}/pvnet/models/multimodal/linear_networks/basic_blocks.py +0 -0
- {PVNet-3.0.21 → PVNet-3.0.23}/pvnet/models/multimodal/linear_networks/networks.py +0 -0
- {PVNet-3.0.21 → PVNet-3.0.23}/pvnet/models/multimodal/multimodal.py +0 -0
- {PVNet-3.0.21 → PVNet-3.0.23}/pvnet/models/multimodal/multimodal_base.py +0 -0
- {PVNet-3.0.21 → PVNet-3.0.23}/pvnet/models/multimodal/site_encoders/__init__.py +0 -0
- {PVNet-3.0.21 → PVNet-3.0.23}/pvnet/models/multimodal/site_encoders/basic_blocks.py +0 -0
- {PVNet-3.0.21 → PVNet-3.0.23}/pvnet/models/multimodal/site_encoders/encoders.py +0 -0
- {PVNet-3.0.21 → PVNet-3.0.23}/pvnet/models/utils.py +0 -0
- {PVNet-3.0.21 → PVNet-3.0.23}/pvnet/training.py +0 -0
- {PVNet-3.0.21 → PVNet-3.0.23}/pvnet/utils.py +0 -0
- {PVNet-3.0.21 → PVNet-3.0.23}/pyproject.toml +0 -0
- {PVNet-3.0.21 → PVNet-3.0.23}/requirements-dev.txt +0 -0
- {PVNet-3.0.21 → PVNet-3.0.23}/setup.cfg +0 -0
- {PVNet-3.0.21 → PVNet-3.0.23}/setup.py +0 -0
- {PVNet-3.0.21 → PVNet-3.0.23}/tests/__init__.py +0 -0
- {PVNet-3.0.21 → PVNet-3.0.23}/tests/conftest.py +0 -0
- {PVNet-3.0.21 → PVNet-3.0.23}/tests/test_end2end.py +0 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: PVNet
|
|
3
|
-
Version: 3.0.
|
|
3
|
+
Version: 3.0.23
|
|
4
4
|
Summary: PVNet
|
|
5
5
|
Author: Peter Dudfield
|
|
6
6
|
Author-email: info@openclimatefix.org
|
|
7
7
|
License: MIT
|
|
8
8
|
Description-Content-Type: text/markdown
|
|
9
9
|
License-File: LICENSE
|
|
10
|
-
Requires-Dist: ocf_datapipes>=3.
|
|
10
|
+
Requires-Dist: ocf_datapipes>=3.3.6
|
|
11
11
|
Requires-Dist: ocf_ml_metrics>=0.0.11
|
|
12
12
|
Requires-Dist: numpy
|
|
13
13
|
Requires-Dist: pandas
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: PVNet
|
|
3
|
-
Version: 3.0.
|
|
3
|
+
Version: 3.0.23
|
|
4
4
|
Summary: PVNet
|
|
5
5
|
Author: Peter Dudfield
|
|
6
6
|
Author-email: info@openclimatefix.org
|
|
7
7
|
License: MIT
|
|
8
8
|
Description-Content-Type: text/markdown
|
|
9
9
|
License-File: LICENSE
|
|
10
|
-
Requires-Dist: ocf_datapipes>=3.
|
|
10
|
+
Requires-Dist: ocf_datapipes>=3.3.6
|
|
11
11
|
Requires-Dist: ocf_ml_metrics>=0.0.11
|
|
12
12
|
Requires-Dist: numpy
|
|
13
13
|
Requires-Dist: pandas
|
|
@@ -3,12 +3,11 @@
|
|
|
3
3
|
import resource
|
|
4
4
|
|
|
5
5
|
import torch
|
|
6
|
-
from ocf_datapipes.batch import stack_np_examples_into_batch
|
|
6
|
+
from ocf_datapipes.batch import batch_to_tensor, stack_np_examples_into_batch
|
|
7
7
|
from ocf_datapipes.training.pvnet import pvnet_datapipe
|
|
8
8
|
from torch.utils.data.datapipes.iter import FileLister
|
|
9
9
|
|
|
10
10
|
from pvnet.data.base import BaseDataModule
|
|
11
|
-
from pvnet.data.utils import batch_to_tensor
|
|
12
11
|
|
|
13
12
|
rlimit = resource.getrlimit(resource.RLIMIT_NOFILE)
|
|
14
13
|
resource.setrlimit(resource.RLIMIT_NOFILE, (2048, rlimit[1]))
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
""" Data module for pytorch lightning """
|
|
2
2
|
import glob
|
|
3
3
|
|
|
4
|
-
from ocf_datapipes.batch import BatchKey, stack_np_examples_into_batch
|
|
4
|
+
from ocf_datapipes.batch import BatchKey, batch_to_tensor, stack_np_examples_into_batch
|
|
5
5
|
from ocf_datapipes.training.pvnet_site import pvnet_site_netcdf_datapipe
|
|
6
6
|
|
|
7
7
|
from pvnet.data.base import BaseDataModule
|
|
8
|
-
from pvnet.data.utils import batch_to_tensor
|
|
9
8
|
|
|
10
9
|
|
|
11
10
|
class PVSiteDataModule(BaseDataModule):
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"""Utils common between Wind and PV datamodules"""
|
|
2
|
+
from ocf_datapipes.batch import BatchKey, unstack_np_batch_into_examples
|
|
3
|
+
from torch.utils.data import IterDataPipe, functional_datapipe
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@functional_datapipe("split_batches")
|
|
7
|
+
class BatchSplitter(IterDataPipe):
|
|
8
|
+
"""Pipeline step to split batches of data and yield single examples"""
|
|
9
|
+
|
|
10
|
+
def __init__(self, source_datapipe: IterDataPipe, splitting_key: BatchKey = BatchKey.gsp):
|
|
11
|
+
"""Pipeline step to split batches of data and yield single examples"""
|
|
12
|
+
self.source_datapipe = source_datapipe
|
|
13
|
+
self.splitting_key = splitting_key
|
|
14
|
+
|
|
15
|
+
def __iter__(self):
|
|
16
|
+
"""Opens the NWP data"""
|
|
17
|
+
for batch in self.source_datapipe:
|
|
18
|
+
for example in unstack_np_batch_into_examples(batch):
|
|
19
|
+
yield example
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
""" Data module for pytorch lightning """
|
|
2
2
|
import glob
|
|
3
3
|
|
|
4
|
-
from ocf_datapipes.batch import BatchKey, stack_np_examples_into_batch
|
|
4
|
+
from ocf_datapipes.batch import BatchKey, batch_to_tensor, stack_np_examples_into_batch
|
|
5
5
|
from ocf_datapipes.training.windnet import windnet_netcdf_datapipe
|
|
6
6
|
|
|
7
7
|
from pvnet.data.base import BaseDataModule
|
|
8
|
-
from pvnet.data.utils import batch_to_tensor
|
|
9
8
|
|
|
10
9
|
|
|
11
10
|
class WindDataModule(BaseDataModule):
|
|
@@ -165,7 +165,7 @@ class PVNetModelHubMixin(PyTorchModelHubMixin):
|
|
|
165
165
|
self,
|
|
166
166
|
save_directory: Union[str, Path],
|
|
167
167
|
config: dict,
|
|
168
|
-
data_config: Union[str, Path],
|
|
168
|
+
data_config: Optional[Union[str, Path]],
|
|
169
169
|
repo_id: Optional[str] = None,
|
|
170
170
|
push_to_hub: bool = False,
|
|
171
171
|
wandb_ids: Optional[Union[list[str], str]] = None,
|
|
@@ -206,7 +206,8 @@ class PVNetModelHubMixin(PyTorchModelHubMixin):
|
|
|
206
206
|
(save_directory / CONFIG_NAME).write_text(json.dumps(config, indent=4))
|
|
207
207
|
|
|
208
208
|
# Save cleaned datapipes configuration file
|
|
209
|
-
|
|
209
|
+
if data_config is not None:
|
|
210
|
+
make_clean_data_config(data_config, save_directory / DATA_CONFIG_NAME)
|
|
210
211
|
|
|
211
212
|
# Creating and saving model card.
|
|
212
213
|
card_data = ModelCardData(language="en", license="mit", library_name="pytorch")
|
|
@@ -369,7 +369,10 @@ class Model(MultimodalBaseModel):
|
|
|
369
369
|
def convert_to_multimodal_model(self, config):
|
|
370
370
|
"""Convert the model into a multimodal model class whilst preserving weights"""
|
|
371
371
|
config = config.copy()
|
|
372
|
-
|
|
372
|
+
|
|
373
|
+
if "cold_start" in config:
|
|
374
|
+
del config["cold_start"]
|
|
375
|
+
|
|
373
376
|
config["_target_"] = "pvnet.models.multimodal.multimodal.Model"
|
|
374
377
|
|
|
375
378
|
sources = []
|
|
@@ -416,4 +419,10 @@ class Model(MultimodalBaseModel):
|
|
|
416
419
|
|
|
417
420
|
multimodal_model.output_network.load_state_dict(self.output_network.state_dict())
|
|
418
421
|
|
|
422
|
+
if self.embedding_dim:
|
|
423
|
+
multimodal_model.embed.load_state_dict(self.embed.state_dict())
|
|
424
|
+
|
|
425
|
+
if self.include_sun:
|
|
426
|
+
multimodal_model.sun_fc1.load_state_dict(self.sun_fc1.state_dict())
|
|
427
|
+
|
|
419
428
|
return multimodal_model, config
|
|
@@ -185,7 +185,6 @@ class AdamWReduceLROnPlateau(AbstractOptimizer):
|
|
|
185
185
|
if not isinstance(self._lr, float):
|
|
186
186
|
return self._call_multi(model)
|
|
187
187
|
else:
|
|
188
|
-
assert False
|
|
189
188
|
default_lr = self._lr if model.lr is None else model.lr
|
|
190
189
|
opt = torch.optim.AdamW(model.parameters(), lr=default_lr, **self.opt_kwargs)
|
|
191
190
|
sch = torch.optim.lr_scheduler.ReduceLROnPlateau(
|
PVNet-3.0.21/pvnet/__init__.py
DELETED
PVNet-3.0.21/pvnet/data/utils.py
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"""Utils common between Wind and PV datamodules"""
|
|
2
|
-
import numpy as np
|
|
3
|
-
import torch
|
|
4
|
-
from ocf_datapipes.batch import BatchKey, unstack_np_batch_into_examples
|
|
5
|
-
from torch.utils.data import IterDataPipe, functional_datapipe
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
def copy_batch_to_device(batch, device):
|
|
9
|
-
"""Moves a dict-batch of tensors to new device."""
|
|
10
|
-
batch_copy = {}
|
|
11
|
-
|
|
12
|
-
for k, v in batch.items():
|
|
13
|
-
if isinstance(v, dict):
|
|
14
|
-
# Recursion to reach the nested NWP
|
|
15
|
-
batch_copy[k] = copy_batch_to_device(v, device)
|
|
16
|
-
elif isinstance(v, torch.Tensor):
|
|
17
|
-
batch_copy[k] = v.to(device)
|
|
18
|
-
else:
|
|
19
|
-
batch_copy[k] = v
|
|
20
|
-
return batch_copy
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
def batch_to_tensor(batch):
|
|
24
|
-
"""Moves numpy batch to a tensor"""
|
|
25
|
-
for k, v in batch.items():
|
|
26
|
-
if isinstance(v, dict):
|
|
27
|
-
# Recursion to reach the nested NWP
|
|
28
|
-
batch[k] = batch_to_tensor(v)
|
|
29
|
-
elif isinstance(v, np.ndarray) and np.issubdtype(v.dtype, np.number):
|
|
30
|
-
batch[k] = torch.as_tensor(v)
|
|
31
|
-
return batch
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
@functional_datapipe("split_batches")
|
|
35
|
-
class BatchSplitter(IterDataPipe):
|
|
36
|
-
"""Pipeline step to split batches of data and yield single examples"""
|
|
37
|
-
|
|
38
|
-
def __init__(self, source_datapipe: IterDataPipe, splitting_key: BatchKey = BatchKey.gsp):
|
|
39
|
-
"""Pipeline step to split batches of data and yield single examples"""
|
|
40
|
-
self.source_datapipe = source_datapipe
|
|
41
|
-
self.splitting_key = splitting_key
|
|
42
|
-
|
|
43
|
-
def __iter__(self):
|
|
44
|
-
"""Opens the NWP data"""
|
|
45
|
-
for batch in self.source_datapipe:
|
|
46
|
-
for example in unstack_np_batch_into_examples(batch):
|
|
47
|
-
yield example
|
|
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
|