From 7cb677d0e6056f52560e6ddb53e88f76861d8fc2 Mon Sep 17 00:00:00 2001 From: chrstphtrs Date: Tue, 24 Oct 2023 16:39:58 +0200 Subject: [PATCH] clean up function add_co2limit_country --- scripts/solve_network.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/scripts/solve_network.py b/scripts/solve_network.py index f5dd79e0..b372b366 100644 --- a/scripts/solve_network.py +++ b/scripts/solve_network.py @@ -764,7 +764,7 @@ def add_pipe_retrofit_constraint(n): n.model.add_constraints(lhs == rhs, name="Link-pipe_retrofit") -def add_co2limit_country(n, config, limit_countries, nyears=1.0): +def add_co2limit_country(n, limit_countries, nyears=1.0): """ Add a set of emissions limit constraints for specified countries. @@ -780,10 +780,7 @@ def add_co2limit_country(n, config, limit_countries, nyears=1.0): """ logger.info(f"Adding CO2 budget limit for each country as per unit of 1990 levels") - # TODO: n.config (submodule) vs snakemake.config (main module, overwrite/overwritten config)? - # countries = config.countries - # print(config) - countries = ['AT', 'BE', 'CH', 'CZ', 'DE', 'DK', 'FR', 'GB', 'LU', 'NL', 'NO', 'PL', 'SE'] + countries = n.config["countries"] # TODO: import function from prepare_sector_network? Move to common place? sectors = emission_sectors_from_opts(opts) @@ -814,7 +811,7 @@ def add_co2limit_country(n, config, limit_countries, nyears=1.0): n.links["efficiency"].apply(lambda x: 1.0).rename("efficiency0") ) elif port == str(1): - efficiency = n.links["efficiency"].rename("efficiency1") + efficiency = n.links["efficiency"] else: efficiency = n.links[f"efficiency{port}"] mask = n.links[f"bus{port}"].map(n.buses.carrier).eq("co2") @@ -889,7 +886,7 @@ def extra_functionality(n, snapshots): # add co2 constraint for each country logger.info(f"Add CO2 limit for each country") - add_co2limit_country(n, config, limit_countries, nyears) + add_co2limit_country(n, limit_countries, nyears) def solve_network(n, config, solving, opts="", **kwargs):