From 71c1a7fbefffa6e5efdff8c8da8361f5b8065f2c Mon Sep 17 00:00:00 2001 From: virio-andreyana <114650479+virio-andreyana@users.noreply.github.com> Date: Tue, 25 Apr 2023 14:43:04 +0200 Subject: [PATCH] add the function add_missing_carrier add_missing_carrier() are applied on python script where new components are added. The function runs ideally after all of the new components are added and before add_nice_carrier_names() --- scripts/add_electricity.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/add_electricity.py b/scripts/add_electricity.py index 1d32bce1..57a18a73 100755 --- a/scripts/add_electricity.py +++ b/scripts/add_electricity.py @@ -120,6 +120,11 @@ def calculate_annuity(n, r): else: return 1 / n +def add_missing_carrier(n): + components = [n.buses, n.generators, n.lines, n.links, n.storage_units, n.stores] + for c in components: + missing_carrier = np.setdiff1d(c.carrier.unique(),n.carriers.index) + n.madd("Carrier",missing_carrier) def _add_missing_carriers_from_costs(n, costs, carriers): missing_carriers = pd.Index(carriers).difference(n.carriers.index) @@ -832,7 +837,8 @@ if __name__ == "__main__": estimate_renewable_capacities(n, snakemake.config) update_p_nom_max(n) - + + add_missing_carrier(n) add_nice_carrier_names(n, snakemake.config) n.meta = snakemake.config