diff --git a/doc/release_notes.rst b/doc/release_notes.rst index 325462ad..f8460e14 100644 --- a/doc/release_notes.rst +++ b/doc/release_notes.rst @@ -11,6 +11,8 @@ Release Notes .. Upcoming Release .. ================ +* bugfix: The carrier of stores was silently overwritten by their bus_carrier as a side effect when building the co2 constraints + * bugfix: The oil generator was incorrectly dropped when the config `oil_refining_emissions` was greater than zero. This was the default behaviour in 0.12.0. PyPSA-Eur 0.12.0 (30th August 2024) diff --git a/scripts/solve_network.py b/scripts/solve_network.py index c70d4d3c..bdc10dd1 100644 --- a/scripts/solve_network.py +++ b/scripts/solve_network.py @@ -330,8 +330,8 @@ def add_carbon_constraint(n, snapshots): continue # stores - n.stores["carrier"] = n.stores.bus.map(n.buses.carrier) - stores = n.stores.query("carrier in @emissions.index and not e_cyclic") + bus_carrier = n.stores.bus.map(n.buses.carrier) + stores = n.stores[bus_carrier.isin(emissions.index) & ~n.stores.e_cyclic] if not stores.empty: last = n.snapshot_weightings.reset_index().groupby("period").last() last_i = last.set_index([last.index, last.timestep]).index @@ -356,8 +356,8 @@ def add_carbon_budget_constraint(n, snapshots): continue # stores - n.stores["carrier"] = n.stores.bus.map(n.buses.carrier) - stores = n.stores.query("carrier in @emissions.index and not e_cyclic") + bus_carrier = n.stores.bus.map(n.buses.carrier) + stores = n.stores[bus_carrier.isin(emissions.index) & ~n.stores.e_cyclic] if not stores.empty: last = n.snapshot_weightings.reset_index().groupby("period").last() last_i = last.set_index([last.index, last.timestep]).index @@ -1000,8 +1000,8 @@ def add_co2_atmosphere_constraint(n, snapshots): continue # stores - n.stores["carrier"] = n.stores.bus.map(n.buses.carrier) - stores = n.stores.query("carrier in @emissions.index and not e_cyclic") + bus_carrier = n.stores.bus.map(n.buses.carrier) + stores = n.stores[bus_carrier.isin(emissions.index) & ~n.stores.e_cyclic] if not stores.empty: last_i = snapshots[-1] lhs = n.model["Store-e"].loc[last_i, stores.index]