PVNet 3.0.43__tar.gz → 3.0.45__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.43 → pvnet-3.0.45}/PKG-INFO +1 -1
- {pvnet-3.0.43 → pvnet-3.0.45}/PVNet.egg-info/PKG-INFO +1 -1
- pvnet-3.0.45/pvnet/__init__.py +2 -0
- {pvnet-3.0.43 → pvnet-3.0.45}/pvnet/models/base_model.py +78 -5
- {pvnet-3.0.43 → pvnet-3.0.45}/pvnet/models/multimodal/multimodal.py +7 -1
- pvnet-3.0.43/pvnet/__init__.py +0 -2
- {pvnet-3.0.43 → pvnet-3.0.45}/LICENSE +0 -0
- {pvnet-3.0.43 → pvnet-3.0.45}/MANIFEST.in +0 -0
- {pvnet-3.0.43 → pvnet-3.0.45}/PVNet.egg-info/SOURCES.txt +0 -0
- {pvnet-3.0.43 → pvnet-3.0.45}/PVNet.egg-info/dependency_links.txt +0 -0
- {pvnet-3.0.43 → pvnet-3.0.45}/PVNet.egg-info/requires.txt +0 -0
- {pvnet-3.0.43 → pvnet-3.0.45}/PVNet.egg-info/top_level.txt +0 -0
- {pvnet-3.0.43 → pvnet-3.0.45}/README.md +0 -0
- {pvnet-3.0.43 → pvnet-3.0.45}/pvnet/callbacks.py +0 -0
- {pvnet-3.0.43 → pvnet-3.0.45}/pvnet/data/__init__.py +0 -0
- {pvnet-3.0.43 → pvnet-3.0.45}/pvnet/data/base.py +0 -0
- {pvnet-3.0.43 → pvnet-3.0.45}/pvnet/data/datamodule.py +0 -0
- {pvnet-3.0.43 → pvnet-3.0.45}/pvnet/data/pv_site_datamodule.py +0 -0
- {pvnet-3.0.43 → pvnet-3.0.45}/pvnet/data/utils.py +0 -0
- {pvnet-3.0.43 → pvnet-3.0.45}/pvnet/data/wind_datamodule.py +0 -0
- {pvnet-3.0.43 → pvnet-3.0.45}/pvnet/load_model.py +0 -0
- {pvnet-3.0.43 → pvnet-3.0.45}/pvnet/models/__init__.py +0 -0
- {pvnet-3.0.43 → pvnet-3.0.45}/pvnet/models/baseline/__init__.py +0 -0
- {pvnet-3.0.43 → pvnet-3.0.45}/pvnet/models/baseline/last_value.py +0 -0
- {pvnet-3.0.43 → pvnet-3.0.45}/pvnet/models/baseline/single_value.py +0 -0
- {pvnet-3.0.43 → pvnet-3.0.45}/pvnet/models/ensemble.py +0 -0
- {pvnet-3.0.43 → pvnet-3.0.45}/pvnet/models/multimodal/__init__.py +0 -0
- {pvnet-3.0.43 → pvnet-3.0.45}/pvnet/models/multimodal/basic_blocks.py +0 -0
- {pvnet-3.0.43 → pvnet-3.0.45}/pvnet/models/multimodal/encoders/__init__.py +0 -0
- {pvnet-3.0.43 → pvnet-3.0.45}/pvnet/models/multimodal/encoders/basic_blocks.py +0 -0
- {pvnet-3.0.43 → pvnet-3.0.45}/pvnet/models/multimodal/encoders/encoders2d.py +0 -0
- {pvnet-3.0.43 → pvnet-3.0.45}/pvnet/models/multimodal/encoders/encoders3d.py +0 -0
- {pvnet-3.0.43 → pvnet-3.0.45}/pvnet/models/multimodal/encoders/encodersRNN.py +0 -0
- {pvnet-3.0.43 → pvnet-3.0.45}/pvnet/models/multimodal/linear_networks/__init__.py +0 -0
- {pvnet-3.0.43 → pvnet-3.0.45}/pvnet/models/multimodal/linear_networks/basic_blocks.py +0 -0
- {pvnet-3.0.43 → pvnet-3.0.45}/pvnet/models/multimodal/linear_networks/networks.py +0 -0
- {pvnet-3.0.43 → pvnet-3.0.45}/pvnet/models/multimodal/multimodal_base.py +0 -0
- {pvnet-3.0.43 → pvnet-3.0.45}/pvnet/models/multimodal/site_encoders/__init__.py +0 -0
- {pvnet-3.0.43 → pvnet-3.0.45}/pvnet/models/multimodal/site_encoders/basic_blocks.py +0 -0
- {pvnet-3.0.43 → pvnet-3.0.45}/pvnet/models/multimodal/site_encoders/encoders.py +0 -0
- {pvnet-3.0.43 → pvnet-3.0.45}/pvnet/models/multimodal/unimodal_teacher.py +0 -0
- {pvnet-3.0.43 → pvnet-3.0.45}/pvnet/models/utils.py +0 -0
- {pvnet-3.0.43 → pvnet-3.0.45}/pvnet/optimizers.py +0 -0
- {pvnet-3.0.43 → pvnet-3.0.45}/pvnet/training.py +0 -0
- {pvnet-3.0.43 → pvnet-3.0.45}/pvnet/utils.py +0 -0
- {pvnet-3.0.43 → pvnet-3.0.45}/pyproject.toml +0 -0
- {pvnet-3.0.43 → pvnet-3.0.45}/setup.cfg +0 -0
- {pvnet-3.0.43 → pvnet-3.0.45}/tests/test_end2end.py +0 -0
- {pvnet-3.0.43 → pvnet-3.0.45}/tests/test_utils.py +0 -0
|
@@ -79,6 +79,68 @@ def make_clean_data_config(input_path, output_path, placeholder="PLACEHOLDER"):
|
|
|
79
79
|
yaml.dump(config, outfile, default_flow_style=False)
|
|
80
80
|
|
|
81
81
|
|
|
82
|
+
def minimize_data_config(input_path, output_path, model):
|
|
83
|
+
"""Strip out parts of the data config which aren't used by the model
|
|
84
|
+
|
|
85
|
+
Args:
|
|
86
|
+
input_path: Path to input datapipes configuration file
|
|
87
|
+
output_path: Location to save the output configuration file
|
|
88
|
+
model: The PVNet model object
|
|
89
|
+
"""
|
|
90
|
+
with open(input_path) as cfg:
|
|
91
|
+
config = yaml.load(cfg, Loader=yaml.FullLoader)
|
|
92
|
+
|
|
93
|
+
if "nwp" in config["input_data"]:
|
|
94
|
+
if not model.include_nwp:
|
|
95
|
+
del config["input_data"]["nwp"]
|
|
96
|
+
else:
|
|
97
|
+
for nwp_source in config["input_data"]["nwp"].keys():
|
|
98
|
+
nwp_config = config["input_data"]["nwp"][nwp_source]
|
|
99
|
+
|
|
100
|
+
if nwp_source not in model.nwp_encoders_dict:
|
|
101
|
+
# If not used, delete this source from the config
|
|
102
|
+
del config["input_data"]["nwp"][nwp_source]
|
|
103
|
+
else:
|
|
104
|
+
# Replace the image size
|
|
105
|
+
nwp_pixel_size = model.nwp_encoders_dict[nwp_source].image_size_pixels
|
|
106
|
+
nwp_config["nwp_image_size_pixels_height"] = nwp_pixel_size
|
|
107
|
+
nwp_config["nwp_image_size_pixels_width"] = nwp_pixel_size
|
|
108
|
+
|
|
109
|
+
# Replace the forecast minutes
|
|
110
|
+
nwp_config["forecast_minutes"] = (
|
|
111
|
+
model.nwp_encoders_dict[nwp_source].sequence_length
|
|
112
|
+
- nwp_config["history_minutes"] / nwp_config["time_resolution_minutes"]
|
|
113
|
+
- 1
|
|
114
|
+
) * nwp_config["time_resolution_minutes"]
|
|
115
|
+
|
|
116
|
+
if "satellite" in config["input_data"]:
|
|
117
|
+
if not model.include_sat:
|
|
118
|
+
del config["input_data"]["satellite"]
|
|
119
|
+
else:
|
|
120
|
+
sat_config = config["input_data"]["satellite"]
|
|
121
|
+
|
|
122
|
+
# Replace the image size
|
|
123
|
+
sat_pixel_size = model.sat_encoder.image_size_pixels
|
|
124
|
+
sat_config["satellite_image_size_pixels_height"] = sat_pixel_size
|
|
125
|
+
sat_config["satellite_image_size_pixels_width"] = sat_pixel_size
|
|
126
|
+
|
|
127
|
+
# Replace the satellite delay
|
|
128
|
+
sat_config["live_delay_minutes"] = model.min_sat_delay_minutes
|
|
129
|
+
|
|
130
|
+
if "pv" in config["input_data"]:
|
|
131
|
+
if not model.include_pv:
|
|
132
|
+
del config["input_data"]["pv"]
|
|
133
|
+
|
|
134
|
+
if "gsp" in config["input_data"]:
|
|
135
|
+
gsp_config = config["input_data"]["gsp"]
|
|
136
|
+
|
|
137
|
+
# Replace the forecast minutes
|
|
138
|
+
gsp_config["forecast_minutes"] = model.forecast_minutes
|
|
139
|
+
|
|
140
|
+
with open(output_path, "w") as outfile:
|
|
141
|
+
yaml.dump(config, outfile, default_flow_style=False)
|
|
142
|
+
|
|
143
|
+
|
|
82
144
|
class PVNetModelHubMixin(PyTorchModelHubMixin):
|
|
83
145
|
"""
|
|
84
146
|
Implementation of [`PyTorchModelHubMixin`] to provide model Hub upload/download capabilities.
|
|
@@ -207,7 +269,13 @@ class PVNetModelHubMixin(PyTorchModelHubMixin):
|
|
|
207
269
|
|
|
208
270
|
# Save cleaned datapipes configuration file
|
|
209
271
|
if data_config is not None:
|
|
210
|
-
|
|
272
|
+
new_data_config_path = save_directory / DATA_CONFIG_NAME
|
|
273
|
+
|
|
274
|
+
# Replace the input filenames with place holders
|
|
275
|
+
make_clean_data_config(data_config, new_data_config_path)
|
|
276
|
+
|
|
277
|
+
# Taylor the data config to the model being saved
|
|
278
|
+
minimize_data_config(new_data_config_path, new_data_config_path, self)
|
|
211
279
|
|
|
212
280
|
# Creating and saving model card.
|
|
213
281
|
card_data = ModelCardData(language="en", license="mit", library_name="pytorch")
|
|
@@ -245,7 +313,7 @@ class PVNetModelHubMixin(PyTorchModelHubMixin):
|
|
|
245
313
|
|
|
246
314
|
|
|
247
315
|
class BaseModel(pl.LightningModule, PVNetModelHubMixin):
|
|
248
|
-
"""
|
|
316
|
+
"""Abstract base class for PVNet submodels"""
|
|
249
317
|
|
|
250
318
|
def __init__(
|
|
251
319
|
self,
|
|
@@ -257,6 +325,7 @@ class BaseModel(pl.LightningModule, PVNetModelHubMixin):
|
|
|
257
325
|
interval_minutes: int = 30,
|
|
258
326
|
timestep_intervals_to_plot: Optional[list[int]] = None,
|
|
259
327
|
use_weighted_loss: bool = False,
|
|
328
|
+
forecast_minutes_ignore: Optional[int] = 0,
|
|
260
329
|
):
|
|
261
330
|
"""Abtstract base class for PVNet submodels.
|
|
262
331
|
|
|
@@ -270,6 +339,8 @@ class BaseModel(pl.LightningModule, PVNetModelHubMixin):
|
|
|
270
339
|
interval_minutes: The interval in minutes between each timestep in the data
|
|
271
340
|
timestep_intervals_to_plot: Intervals, in timesteps, to plot during training
|
|
272
341
|
use_weighted_loss: Whether to use a weighted loss function
|
|
342
|
+
forecast_minutes_ignore: Number of forecast minutes to ignore when calculating losses.
|
|
343
|
+
For example if set to 60, the model doesnt predict the first 60 minutes
|
|
273
344
|
"""
|
|
274
345
|
super().__init__()
|
|
275
346
|
|
|
@@ -292,10 +363,12 @@ class BaseModel(pl.LightningModule, PVNetModelHubMixin):
|
|
|
292
363
|
self.forecast_minutes = forecast_minutes
|
|
293
364
|
self.output_quantiles = output_quantiles
|
|
294
365
|
self.interval_minutes = interval_minutes
|
|
366
|
+
self.forecast_minutes_ignore = forecast_minutes_ignore
|
|
295
367
|
|
|
296
368
|
# Number of timestemps for 30 minutely data
|
|
297
369
|
self.history_len = history_minutes // interval_minutes
|
|
298
|
-
self.forecast_len = forecast_minutes // interval_minutes
|
|
370
|
+
self.forecast_len = (forecast_minutes - forecast_minutes_ignore) // interval_minutes
|
|
371
|
+
self.forecast_len_ignore = forecast_minutes_ignore // interval_minutes
|
|
299
372
|
|
|
300
373
|
self.weighted_losses = WeightedLosses(forecast_length=self.forecast_len)
|
|
301
374
|
|
|
@@ -334,7 +407,7 @@ class BaseModel(pl.LightningModule, PVNetModelHubMixin):
|
|
|
334
407
|
y_median = y_quantiles[..., idx]
|
|
335
408
|
return y_median
|
|
336
409
|
|
|
337
|
-
def
|
|
410
|
+
def _calculate_quantile_loss(self, y_quantiles, y):
|
|
338
411
|
"""Calculate quantile loss.
|
|
339
412
|
|
|
340
413
|
Note:
|
|
@@ -366,7 +439,7 @@ class BaseModel(pl.LightningModule, PVNetModelHubMixin):
|
|
|
366
439
|
losses = {}
|
|
367
440
|
|
|
368
441
|
if self.use_quantile_regression:
|
|
369
|
-
losses["quantile_loss"] = self.
|
|
442
|
+
losses["quantile_loss"] = self._calculate_quantile_loss(y_hat, y)
|
|
370
443
|
y_hat = self._quantiles_to_prediction(y_hat)
|
|
371
444
|
|
|
372
445
|
# calculate mse, mae
|
|
@@ -71,6 +71,7 @@ class Model(MultimodalBaseModel):
|
|
|
71
71
|
timestep_intervals_to_plot: Optional[list[int]] = None,
|
|
72
72
|
adapt_batches: Optional[bool] = False,
|
|
73
73
|
use_weighted_loss: Optional[bool] = False,
|
|
74
|
+
forecast_minutes_ignore: Optional[int] = 0,
|
|
74
75
|
):
|
|
75
76
|
"""Neural network which combines information from different sources.
|
|
76
77
|
|
|
@@ -131,6 +132,8 @@ class Model(MultimodalBaseModel):
|
|
|
131
132
|
the model to use. This allows us to overprepare batches and slice from them for the
|
|
132
133
|
data we need for a model run.
|
|
133
134
|
use_weighted_loss: Whether to use a weighted loss function
|
|
135
|
+
forecast_minutes_ignore: Number of forecast minutes to ignore when calculating losses.
|
|
136
|
+
For example if set to 60, the model doesnt predict the first 60 minutes
|
|
134
137
|
"""
|
|
135
138
|
|
|
136
139
|
self.include_gsp_yield_history = include_gsp_yield_history
|
|
@@ -143,6 +146,7 @@ class Model(MultimodalBaseModel):
|
|
|
143
146
|
self.embedding_dim = embedding_dim
|
|
144
147
|
self.add_image_embedding_channel = add_image_embedding_channel
|
|
145
148
|
self.interval_minutes = interval_minutes
|
|
149
|
+
self.min_sat_delay_minutes = min_sat_delay_minutes
|
|
146
150
|
self.adapt_batches = adapt_batches
|
|
147
151
|
|
|
148
152
|
super().__init__(
|
|
@@ -154,6 +158,7 @@ class Model(MultimodalBaseModel):
|
|
|
154
158
|
interval_minutes=interval_minutes,
|
|
155
159
|
timestep_intervals_to_plot=timestep_intervals_to_plot,
|
|
156
160
|
use_weighted_loss=use_weighted_loss,
|
|
161
|
+
forecast_minutes_ignore=forecast_minutes_ignore,
|
|
157
162
|
)
|
|
158
163
|
|
|
159
164
|
# Number of features expected by the output_network
|
|
@@ -271,7 +276,8 @@ class Model(MultimodalBaseModel):
|
|
|
271
276
|
|
|
272
277
|
if self.include_sun:
|
|
273
278
|
self.sun_fc1 = nn.Linear(
|
|
274
|
-
in_features=2
|
|
279
|
+
in_features=2
|
|
280
|
+
* (self.forecast_len + self.forecast_len_ignore + self.history_len + 1),
|
|
275
281
|
out_features=16,
|
|
276
282
|
)
|
|
277
283
|
|
pvnet-3.0.43/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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|