From 27eea273bd20559dcf02d32ed0638c2938fb4acf Mon Sep 17 00:00:00 2001 From: Fabian Date: Thu, 15 Jun 2023 19:12:30 +0200 Subject: [PATCH] harmonize params names --- rules/build_electricity.smk | 9 +++------ rules/build_sector.smk | 7 ++++--- scripts/add_electricity.py | 21 ++++++--------------- scripts/build_sequestration_potentials.py | 2 +- scripts/prepare_network.py | 2 +- scripts/prepare_sector_network.py | 4 ++-- 6 files changed, 17 insertions(+), 28 deletions(-) diff --git a/rules/build_electricity.smk b/rules/build_electricity.smk index 9d4315df..44ebf404 100644 --- a/rules/build_electricity.smk +++ b/rules/build_electricity.smk @@ -320,11 +320,10 @@ rule simplify_network: aggregation_strategies=config["clustering"].get("aggregation_strategies", {}), focus_weights=config.get("focus_weights", None), renewable_carriers=config["electricity"]["renewable_carriers"], - costs=config["costs"], max_hours=config["electricity"]["max_hours"], length_factor=config["lines"]["length_factor"], p_max_pu=config["links"].get("p_max_pu", 1.0), - solver_name=config["solving"]["solver"]["name"], + costs=config["costs"], input: network=RESOURCES + "networks/elec.nc", tech_costs=COSTS, @@ -357,10 +356,9 @@ rule cluster_network: focus_weights=config.get("focus_weights", None), renewable_carriers=config["electricity"]["renewable_carriers"], conventional_carriers=config["electricity"].get("conventional_carriers", []), - costs=config["costs"], max_hours=config["electricity"]["max_hours"], length_factor=config["lines"]["length_factor"], - solver_name=config["solving"]["solver"]["name"], + costs=config["costs"], input: network=RESOURCES + "networks/elec_s{simpl}.nc", regions_onshore=RESOURCES + "regions_onshore_elec_s{simpl}.geojson", @@ -393,9 +391,9 @@ rule cluster_network: rule add_extra_components: params: - costs=config["costs"], extendable_carriers=config["electricity"]["extendable_carriers"], max_hours=config["electricity"]["max_hours"], + costs=config["costs"], input: network=RESOURCES + "networks/elec_s{simpl}_{clusters}.nc", tech_costs=COSTS, @@ -418,7 +416,6 @@ rule prepare_network: params: links=config["links"], lines=config["lines"], - solver_name=config["solving"]["solver"]["name"], co2base=config["electricity"]["co2base"], co2limit=config["electricity"]["co2limit"], gaslimit=config["electricity"].get("gaslimit"), diff --git a/rules/build_sector.smk b/rules/build_sector.smk index e15394ff..1c3507fd 100644 --- a/rules/build_sector.smk +++ b/rules/build_sector.smk @@ -330,7 +330,9 @@ if config["sector"]["regional_co2_sequestration_potential"]["enable"]: rule build_sequestration_potentials: params: - co2seq_potential=config["sector"]["regional_co2_sequestration_potential"], + sequestration_potential=config["sector"][ + "regional_co2_sequestration_potential" + ], input: sequestration_potential=HTTP.remote( "https://raw.githubusercontent.com/ericzhou571/Co2Storage/main/resources/complete_map_2020_unit_Mt.geojson", @@ -705,7 +707,6 @@ rule build_transport_demand: rule prepare_sector_network: params: co2_budget=config["co2_budget"], - solver_name=config["solving"]["solver"]["name"], conventional_carriers=config["existing_capacities"]["conventional_carriers"], foresight=config["foresight"], costs=config["costs"], @@ -716,7 +717,7 @@ rule prepare_sector_network: planning_horizons=config["scenario"]["planning_horizons"], countries=config["countries"], emissions_scope=config["energy"]["emissions"], - report_year=config["energy"]["eurostat_report_year"], + eurostat_report_year=config["energy"]["eurostat_report_year"], RDIR=RDIR, input: **build_retro_cost_output, diff --git a/scripts/add_electricity.py b/scripts/add_electricity.py index d98dc767..e2f7fb65 100755 --- a/scripts/add_electricity.py +++ b/scripts/add_electricity.py @@ -137,7 +137,7 @@ def _add_missing_carriers_from_costs(n, costs, carriers): n.import_components_from_dataframe(emissions, "Carrier") -def load_costs(tech_costs, params, max_hours, Nyears=1.0): +def load_costs(tech_costs, costs, max_hours, Nyears=1.0): # set all asset costs and other parameters costs = pd.read_csv(tech_costs, index_col=[0, 1]).sort_index() @@ -145,7 +145,7 @@ def load_costs(tech_costs, params, max_hours, Nyears=1.0): costs.loc[costs.unit.str.contains("/kW"), "value"] *= 1e3 costs.unit = costs.unit.str.replace("/kW", "/MW") - fill_values = params["fill_values"] + fill_values = costs["fill_values"] costs = costs.value.unstack().fillna(fill_values) costs["capital_cost"] = ( @@ -168,8 +168,8 @@ def load_costs(tech_costs, params, max_hours, Nyears=1.0): costs.at["CCGT", "co2_emissions"] = costs.at["gas", "co2_emissions"] costs.at["solar", "capital_cost"] = ( - params["rooftop_share"] * costs.at["solar-rooftop", "capital_cost"] - + (1 - params["rooftop_share"]) * costs.at["solar-utility", "capital_cost"] + costs["rooftop_share"] * costs.at["solar-rooftop", "capital_cost"] + + (1 - costs["rooftop_share"]) * costs.at["solar-utility", "capital_cost"] ) def costs_for_storage(store, link1, link2=None, max_hours=1.0): @@ -193,7 +193,7 @@ def load_costs(tech_costs, params, max_hours, Nyears=1.0): ) for attr in ("marginal_cost", "capital_cost"): - overwrites = params.get(attr) + overwrites = costs.get(attr) if overwrites is not None: overwrites = pd.Series(overwrites) costs.loc[overwrites.index, attr] = overwrites @@ -728,16 +728,6 @@ if __name__ == "__main__": ) ppl = load_powerplants(snakemake.input.powerplants) - if "renewable_carriers" in params.electricity: - renewable_carriers = set(params.electricity["renewable_carriers"]) - else: - logger.warning( - "Missing key `renewable_carriers` under config entry `electricity`. " - "In future versions, this will raise an error. " - "Falling back to carriers listed under `renewable`." - ) - renewable_carriers = params.renewable - attach_load( n, snakemake.input.regions, @@ -749,6 +739,7 @@ if __name__ == "__main__": update_transmission_costs(n, costs, params.length_factor) + renewable_carriers = set(params.electricity["renewable_carriers"]) extendable_carriers = params.electricity["extendable_carriers"] conventional_carriers = params.electricity["conventional_carriers"] conventional_inputs = { diff --git a/scripts/build_sequestration_potentials.py b/scripts/build_sequestration_potentials.py index 0e59e55b..e19a96da 100644 --- a/scripts/build_sequestration_potentials.py +++ b/scripts/build_sequestration_potentials.py @@ -41,7 +41,7 @@ if __name__ == "__main__": "build_sequestration_potentials", simpl="", clusters="181" ) - cf = snakemake.params.co2seq_potential + cf = snakemake.params.sequestration_potential gdf = gpd.read_file(snakemake.input.sequestration_potential[0]) diff --git a/scripts/prepare_network.py b/scripts/prepare_network.py index e48ee162..adbfa36c 100755 --- a/scripts/prepare_network.py +++ b/scripts/prepare_network.py @@ -269,7 +269,7 @@ if __name__ == "__main__": for o in opts: m = re.match(r"^\d+seg$", o, re.IGNORECASE) if m is not None: - solver_name = snakemake.params.solver_name + solver_name = snakemake.config["solving"]["solver"]["name"] n = apply_time_segmentation(n, m.group(0)[:-3], solver_name) break diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index 77fab4f8..73adf522 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -3369,7 +3369,7 @@ if __name__ == "__main__": if options["allam_cycle"]: add_allam(n, costs) - solver_name = snakemake.params.solver_name + solver_name = snakemake.config["solving"]["solver"]["name"] n = set_temporal_aggregation(n, opts, solver_name) limit_type = "config" @@ -3381,7 +3381,7 @@ if __name__ == "__main__": fn = "results/" + snakemake.params.RDIR + "/csvs/carbon_budget_distribution.csv" if not os.path.exists(fn): emissions_scope = snakemake.params.emissions_scope - report_year = snakemake.params.report_year + report_year = snakemake.params.eurostat_report_year build_carbon_budget( o, snakemake.input.eurostat, fn, emissions_scope, report_year )