From cd8001116dcd2bb553c5f981a59b33a36b2769e3 Mon Sep 17 00:00:00 2001 From: Thomas Gilon Date: Thu, 11 Jan 2024 14:11:25 +0100 Subject: [PATCH] Add warning when negative bev availability profile values --- doc/release_notes.rst | 3 ++- scripts/build_transport_demand.py | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/doc/release_notes.rst b/doc/release_notes.rst index be6be9fd8..a6a1b4853 100644 --- a/doc/release_notes.rst +++ b/doc/release_notes.rst @@ -12,7 +12,8 @@ Upcoming Release * New configuration option ``everywhere_powerplants`` to build conventional powerplants everywhere, irrespective of existing powerplants locations, in the network (https://github.com/PyPSA/pypsa-eur/pull/850). -* Remove option for wave energy as technology data is not maintained. +* Remove option for wave energy as technology data is not maintained. +* Add warning when BEV availability weekly profile has negative values in `build_transport_demand`. PyPSA-Eur 0.9.0 (5th January 2024) diff --git a/scripts/build_transport_demand.py b/scripts/build_transport_demand.py index 0bcfb7ed6..be8ad4141 100644 --- a/scripts/build_transport_demand.py +++ b/scripts/build_transport_demand.py @@ -8,11 +8,17 @@ availability and demand-side management constraints. """ +import logging + import numpy as np import pandas as pd import xarray as xr + +from _helpers import configure_logging from _helpers import generate_periodic_profiles +logger = logging.getLogger(__name__) + def build_nodal_transport_data(fn, pop_layout): transport_data = pd.read_csv(fn, index_col=0) @@ -130,6 +136,10 @@ def bev_availability_profile(fn, snapshots, nodes, options): traffic.mean() - traffic.min() ) + if not avail[avail < 0].empty: + logger.warning("The BEV availability weekly profile has negative values which can " + "lead to infeasibility.") + return generate_periodic_profiles( dt_index=snapshots, nodes=nodes, @@ -160,6 +170,7 @@ def bev_dsm_profile(snapshots, nodes, options): simpl="", clusters=48, ) + configure_logging(snakemake) pop_layout = pd.read_csv(snakemake.input.clustered_pop_layout, index_col=0)