Skip to content

Commit

Permalink
Merge commit '98056118202d8139005af098ec62a12743bd04dd' into runvl-pv
Browse files Browse the repository at this point in the history
  • Loading branch information
peterdudfield committed Jan 6, 2025
2 parents 21dcf30 + 9805611 commit 9b496e9
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.1.25
current_version = 1.1.27
commit = True
tag = True
message = Bump version: {current_version} → {new_version} [ci skip]
Expand Down
2 changes: 1 addition & 1 deletion india_forecast_app/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"""India Forecast App"""
__version__ = "1.1.25"
__version__ = "1.1.27"
7 changes: 7 additions & 0 deletions india_forecast_app/models/all_models.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ models:
client: ad
asset_type: wind
adjuster_average_minutes: 15
- name: windnet_ad_sites_generation_delay
type: pvnet
id: openclimatefix/windnet_ad_sites
version: bced479c5c3ab198bfce7d5cb4e02f8679be3297
client: ad
asset_type: wind
adjuster_average_minutes: 15
# this is just a dummy one
- name: dummy
type: dummy
Expand Down
18 changes: 15 additions & 3 deletions india_forecast_app/models/pvnet/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@
import numpy as np
import pandas as pd
import torch
from ocf_datapipes.batch import batch_to_tensor, copy_batch_to_device, stack_np_examples_into_batch
from ocf_datapipes.batch import (
BatchKey,
batch_to_tensor,
copy_batch_to_device,
stack_np_examples_into_batch,
)
from ocf_datapipes.training.pvnet_site import construct_sliced_data_pipeline as pv_base_pipeline
from ocf_datapipes.training.windnet import DictDatasetIterDataPipe, split_dataset_dict_dp
from ocf_datapipes.training.windnet import construct_sliced_data_pipeline as wind_base_pipeline
Expand Down Expand Up @@ -95,6 +100,10 @@ def predict(self, site_id: str, timestamp: dt.datetime):
for i, batch in enumerate(self.dataloader):
log.info(f"Predicting for batch: {i}")

if self.name == "windnet_ad_sites_generation_delay":
# this is a bit of hack, but it's important to do what was done in training
batch[BatchKey.wind][:, int(batch[BatchKey.wind_t0_idx])] = -1

# save batch
save_batch(batch=batch, i=i, model_name=self.name, site_uuid=self.site_uuid)

Expand Down Expand Up @@ -242,7 +251,7 @@ def _prepare_data_sources(self):
source_nwp_path=os.environ["NWP_MO_GLOBAL_ZARR_PATH"],
dest_nwp_path=nwp_mo_global_path,
source="mo_global",
config=self.config["input_data"]["nwp"]["mo_global"]
config=self.config["input_data"]["nwp"]["mo_global"],
)
)

Expand All @@ -264,7 +273,10 @@ def _prepare_data_sources(self):
generation_da = self.generation_data["data"].to_xarray()

# get the minimum timestamp in generation data
min_timestamp = generation_da.index.min().values
if len(generation_da.index) > 0:
min_timestamp = generation_da.index.min().values
else:
min_timestamp = self.t0 - pd.Timedelta(hours=24)
# Add the forecast timesteps to the generation, with 0 values
# 192 is 48 hours of 15 min intervals
forecast_timesteps = pd.date_range(
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "india_forecast_app"
version = "1.1.25"
version = "1.1.27"
description = "Runs wind and PV forecasts for India and saves to database"
authors = ["Chris Briggs <[email protected]>"]
readme = "README.md"
Expand Down
8 changes: 4 additions & 4 deletions tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,13 @@ def test_app_client_ad(

app_run(timestamp=None, write_to_db=True)

# 2 pv models, 1 wind model
# 2 pv models, 2 wind model
# x2 for adjuster
n_forecasts = 3 * 2
# one models is 8 hours, two model is 4 hours
n_forecasts = 4 * 2
# one models is 8 hours, three model is 4 hours
# x 4 for each 15 minutes
# x 2 for adjuster
n_forecast_values = (8 + 4 + 4) * 4 * 2
n_forecast_values = (8 + 4 + 4 + 4) * 4 * 2

assert db_session.query(ForecastSQL).count() == init_n_forecasts + n_forecasts
assert db_session.query(ForecastValueSQL).count() == init_n_forecast_values + n_forecast_values
Expand Down

0 comments on commit 9b496e9

Please sign in to comment.