From 339ccc602697f6196681bb1b3fa63a4a26720f40 Mon Sep 17 00:00:00 2001 From: lisazeyen Date: Tue, 2 Aug 2022 08:52:48 +0200 Subject: [PATCH] remove snakemake dependencies --- scripts/prepare_sector_network.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index 5d1594fc..1afcbde9 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -158,7 +158,7 @@ def get(item, investment_year=None): return item -def co2_emissions_year(countries, input_eurostat, opts, year): +def co2_emissions_year(countries, input_eurostat, opts, emissions_scope, report_year, year): """ Calculate CO2 emissions in one specific year (e.g. 1990 or 2018). """ @@ -186,7 +186,7 @@ def co2_emissions_year(countries, input_eurostat, opts, year): # TODO: move to own rule with sector-opts wildcard? -def build_carbon_budget(o, fn): +def build_carbon_budget(o, input_eurostat, fn, emissions_scope, report_year): """ Distribute carbon budget following beta or exponential transition path. """ @@ -203,10 +203,12 @@ def build_carbon_budget(o, fn): countries = n.buses.country.dropna().unique() - e_1990 = co2_emissions_year(countries, snakemake.input.eurostat, opts, year=1990) + e_1990 = co2_emissions_year(countries, input_eurostat, opts, emissions_scope, + report_year, year=1990) #emissions at the beginning of the path (last year available 2018) - e_0 = co2_emissions_year(countries, snakemake.input.eurostat, opts, year=2018) + e_0 = co2_emissions_year(countries, input_eurostat, opts, emissions_scope, + report_year,year=2018) planning_horizons = snakemake.config['scenario']['planning_horizons'] t_0 = planning_horizons[0] @@ -2439,7 +2441,9 @@ if __name__ == "__main__": limit_type = "carbon budget" fn = snakemake.config['results_dir'] + snakemake.config['run'] + '/csvs/carbon_budget_distribution.csv' if not os.path.exists(fn): - build_carbon_budget(o, fn) + emissions_scope = snakemake.config["energy"]["emissions"] + report_year = snakemake.config["energy"]["eurostat_report_year"] + build_carbon_budget(o, snakemake.input.eurostat, fn, emissions_scope, report_year) co2_cap = pd.read_csv(fn, index_col=0).squeeze() limit = co2_cap.loc[investment_year] break