From eb2fbe5582e748468e8763018d826d9193b2c049 Mon Sep 17 00:00:00 2001 From: Jacob Bieker Date: Thu, 8 Feb 2024 16:21:50 +0000 Subject: [PATCH 1/4] Add solar position for PV-sites --- pvnet/models/multimodal/multimodal.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pvnet/models/multimodal/multimodal.py b/pvnet/models/multimodal/multimodal.py index 86254c8b..99c6bcdd 100644 --- a/pvnet/models/multimodal/multimodal.py +++ b/pvnet/models/multimodal/multimodal.py @@ -342,9 +342,16 @@ def forward(self, x): modes["sensor"] = self.sensor_encoder(x_tmp) if self.include_sun: - sun = torch.cat( - (x[BatchKey.gsp_solar_azimuth], x[BatchKey.gsp_solar_elevation]), dim=1 - ).float() + if self.target_key_name == "gsp": + sun = torch.cat( + (x[BatchKey.gsp_solar_azimuth], x[BatchKey.gsp_solar_elevation]), dim=1 + ).float() + elif self.target_key_name == "pv": + sun = torch.cat( + (x[BatchKey.pv_solar_azimuth], x[BatchKey.pv_solar_elevation]), dim=1 + ).float() + else: + raise ValueError(f"Unknown target key for sun elevation {self.target_key_name}") sun = self.sun_fc1(sun) modes["sun"] = sun From fb53e0aaf3d1d15a98b6b17926021a51efb71a3f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 8 Feb 2024 16:22:46 +0000 Subject: [PATCH 2/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pvnet/models/base_model.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pvnet/models/base_model.py b/pvnet/models/base_model.py index 7c814ea3..db56946f 100644 --- a/pvnet/models/base_model.py +++ b/pvnet/models/base_model.py @@ -62,8 +62,8 @@ def make_clean_data_config(input_path, output_path, placeholder="PLACEHOLDER"): if "nwp" in config["input_data"]: for source in config["input_data"]["nwp"]: - if config["input_data"]["nwp"][source][f"nwp_zarr_path"] != "": - config["input_data"]["nwp"][source][f"nwp_zarr_path"] = f"{placeholder}.zarr" + if config["input_data"]["nwp"][source]["nwp_zarr_path"] != "": + config["input_data"]["nwp"][source]["nwp_zarr_path"] = f"{placeholder}.zarr" if "pv" in config["input_data"]: for d in config["input_data"]["pv"]["pv_files_groups"]: From b283ac4068923bf8a3e59ef3f353016d37f9e4ed Mon Sep 17 00:00:00 2001 From: Jacob Bieker Date: Thu, 8 Feb 2024 16:27:40 +0000 Subject: [PATCH 3/4] Simplify --- pvnet/models/multimodal/multimodal.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/pvnet/models/multimodal/multimodal.py b/pvnet/models/multimodal/multimodal.py index 99c6bcdd..6cbe66b8 100644 --- a/pvnet/models/multimodal/multimodal.py +++ b/pvnet/models/multimodal/multimodal.py @@ -342,16 +342,9 @@ def forward(self, x): modes["sensor"] = self.sensor_encoder(x_tmp) if self.include_sun: - if self.target_key_name == "gsp": - sun = torch.cat( - (x[BatchKey.gsp_solar_azimuth], x[BatchKey.gsp_solar_elevation]), dim=1 - ).float() - elif self.target_key_name == "pv": - sun = torch.cat( - (x[BatchKey.pv_solar_azimuth], x[BatchKey.pv_solar_elevation]), dim=1 - ).float() - else: - raise ValueError(f"Unknown target key for sun elevation {self.target_key_name}") + sun = torch.cat( + (x[BatchKey[f"{self.target_key_name}_solar_azimuth"]], x[BatchKey[f"{self.target_key_name}_solar_elevation"]]), dim=1 + ).float() sun = self.sun_fc1(sun) modes["sun"] = sun From 74aae2b8632b3cb2ec96ad570cc69092d87a64f9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 8 Feb 2024 16:27:58 +0000 Subject: [PATCH 4/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pvnet/models/multimodal/multimodal.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pvnet/models/multimodal/multimodal.py b/pvnet/models/multimodal/multimodal.py index 6cbe66b8..f4145649 100644 --- a/pvnet/models/multimodal/multimodal.py +++ b/pvnet/models/multimodal/multimodal.py @@ -343,7 +343,11 @@ def forward(self, x): if self.include_sun: sun = torch.cat( - (x[BatchKey[f"{self.target_key_name}_solar_azimuth"]], x[BatchKey[f"{self.target_key_name}_solar_elevation"]]), dim=1 + ( + x[BatchKey[f"{self.target_key_name}_solar_azimuth"]], + x[BatchKey[f"{self.target_key_name}_solar_elevation"]], + ), + dim=1, ).float() sun = self.sun_fc1(sun) modes["sun"] = sun