From e602aed0193ebbd936d441523d49974e2ac63223 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=2E=20M=C3=B8ller?= Date: Thu, 7 May 2026 09:59:16 +0200 Subject: [PATCH] Added temporary verification for the number of ensemble members being one --- CHANGELOG.md | 4 ++++ sunflow/main.py | 2 ++ sunflow/validation.py | 23 +++++++++++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1174b3f..29b9fcc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Added a check for the number of ensemble members, as the code currently supports only one [!13](https://github.com/dmidk/sunflow/pull/13), @KristianHMoller + ## [v1.1.0] ### Added diff --git a/sunflow/main.py b/sunflow/main.py index e7402b2..13a765b 100644 --- a/sunflow/main.py +++ b/sunflow/main.py @@ -31,6 +31,7 @@ validate_clearsky_shapes, validate_config, validate_data_shape, + validate_nowcast_config, validate_run_mode, verify_environment_variables, ) @@ -407,6 +408,7 @@ def cli() -> None: validate_run_mode(run_mode, dataset_name) validate_config(config, dataset_name) + validate_nowcast_config(nowcast_config) verify_environment_variables(run_mode, dataset_name) # Determine the time steps to run diff --git a/sunflow/validation.py b/sunflow/validation.py index 09c9e2c..21a1cae 100644 --- a/sunflow/validation.py +++ b/sunflow/validation.py @@ -9,6 +9,8 @@ import xarray as xr from loguru import logger +from .config import NowcastConfig + class MissingClearskyDataError(RuntimeError): pass @@ -44,6 +46,27 @@ def validate_config(config: dict[str, Any], dataset_name: str) -> None: sys.exit(1) +def validate_nowcast_config(nowcast_config: NowcastConfig) -> None: + """Validate that the options selected for the nowcast config are valid. + + Checks the nowcast config created from imported environment variables. + Exits immediately for invalid choices. + + Args: + nowcast_config: Instance of the NowcastConfig class + loaded from environment variables in config.py. + + Raises: + SystemExit: If any invalid choice is detected. + """ + if nowcast_config.ens_members != 1: + logger.error( + f"Invalid nowcast configuration: Currently, only ens_members=1 is supported. " + f"Current value: {nowcast_config.ens_members}. Exiting.\n" + ) + sys.exit(1) + + def validate_run_mode(run_mode: str, dataset_name: str) -> None: """Validate that the run mode is compatible with the dataset.