Skip to content

Commit

Permalink
Merge pull request #344 from pypsa-meets-earth/Params_override_respot
Browse files Browse the repository at this point in the history
Add to override_respot + panning_horizons wildcard
  • Loading branch information
energyLS authored Jun 12, 2024
2 parents ed9c88c + 3528981 commit be1d16e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 23 deletions.
5 changes: 5 additions & 0 deletions Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ wildcard_constraints:
discountrate="[-+a-zA-Z0-9\.\s]*",
demand="[-+a-zA-Z0-9\.\s]*",
h2export="[0-9]+m?|all",
planning_horizons="20[2-9][0-9]|2100",


if not config.get("disable_subworkflow", False):
Expand Down Expand Up @@ -257,6 +258,10 @@ rule add_export:


rule override_respot:
params:
run=config["run"],
custom_data=config["custom_data"],
countries=config["countries"],
input:
**{
f"custom_res_pot_{tech}_{planning_horizons}_{discountrate}": f"resources/custom_renewables/{tech}_{planning_horizons}_{discountrate}_potential.csv"
Expand Down
29 changes: 6 additions & 23 deletions scripts/override_respot.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def override_values(tech, year, dr):
n.mremove("Generator", to_drop)

if snakemake.wildcards["planning_horizons"] == 2050:
directory = "results/" + snakemake.config.run.replace("2050", "2030")
directory = "results/" + snakemake.params.run.replace("2050", "2030")
n_name = snakemake.input.network.split("/")[-1].replace(
n.config["scenario"]["clusters"], ""
)
Expand Down Expand Up @@ -85,12 +85,12 @@ def override_values(tech, year, dr):
overrides = override_component_attrs(snakemake.input.overrides)
n = pypsa.Network(snakemake.input.network, override_component_attrs=overrides)
m = n.copy()
if snakemake.config["custom_data"]["renewables"]:
if snakemake.params.custom_data["renewables"]:
buses = list(n.buses[n.buses.carrier == "AC"].index)
energy_totals = pd.read_csv(snakemake.input.energy_totals, index_col=0)
countries = snakemake.config["countries"]
if snakemake.config["custom_data"]["renewables"]:
techs = snakemake.config["custom_data"]["renewables"]
countries = snakemake.params.countries
if snakemake.params.custom_data["renewables"]:
techs = snakemake.params.custom_data["renewables"]
year = snakemake.wildcards["planning_horizons"]
dr = snakemake.wildcards["discountrate"]

Expand All @@ -102,24 +102,7 @@ def override_values(tech, year, dr):
else:
print("No RES potential techs to override...")

if (
snakemake.config["custom_data"]["add_existing"]
and snakemake.wildcards["planning_horizons"] == "2030"
):
n.generators.loc["MAR010003 onwind", "p_nom_min"] = 50
n.generators.loc["MAR010005 offwind", "p_nom_min"] = 120
n.generators.loc["MAR010005 offwind", "p_nom_max"] = 120
n.generators.loc["MAR010001 onwind", "p_nom_min"] = 154
n.generators.loc["MAR004005 onwind", "p_nom_min"] = 150
n.generators.loc["MAR003003 onwind", "p_nom_min"] = 180
n.generators.loc["MAR006003 onwind", "p_nom_min"] = 60
n.generators.loc["MAR011001 onwind", "p_nom_min"] = 208

n.generators.loc["MAR003001 csp", "p_nom_min"] = 500

n.generators.loc["MAR003001 solar", "p_nom_min"] = 72

if snakemake.config["custom_data"]["elec_demand"]:
if snakemake.params.custom_data["elec_demand"]:
for country in countries:
n.loads_t.p_set.filter(like=country)[buses] = (
(
Expand Down

0 comments on commit be1d16e

Please sign in to comment.