Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Sep 18, 2024
1 parent 8cdb8a1 commit 9fde689
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions scripts/prepare_sector_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -4543,7 +4543,7 @@ def add_import_options(
import_nodes["hvdc-to-elec"] = 15000

import_config = snakemake.params["sector"]["import"]
cost_year = snakemake.params["costs"]["year"] # noqa: F841
cost_year = snakemake.params["costs"]["year"] # noqa: F841

ports = pd.read_csv(snakemake.input.ports, index_col=0)

Expand Down Expand Up @@ -4574,16 +4574,18 @@ def add_import_options(
}

terminal_capital_cost = {
"shipping-lch4": 7018, # €/MW/a
"shipping-lh2": 7018 * 1.2, #+20% compared to LNG
"shipping-lch4": 7018, # €/MW/a
"shipping-lh2": 7018 * 1.2, # +20% compared to LNG
}

import_costs = pd.read_parquet(
snakemake.input.import_costs
).reset_index().query("year == @cost_year and scenario == 'default'")
import_costs = (
pd.read_parquet(snakemake.input.import_costs)
.reset_index()
.query("year == @cost_year and scenario == 'default'")
)

cols = ["esc", "exporter", "importer", "value"]
fields = ["Cost per MWh delivered", "Cost per t delivered"] # noqa: F841
fields = ["Cost per MWh delivered", "Cost per t delivered"] # noqa: F841
import_costs = import_costs.query("subcategory in @fields")[cols]
import_costs.rename(columns={"value": "marginal_cost"}, inplace=True)

Expand All @@ -4594,7 +4596,9 @@ def add_import_options(
if endogenous_hvdc and "hvdc-to-elec" in import_options:
add_endogenous_hvdc_import_options(n, import_options.pop("hvdc-to-elec"))

export_buses = import_costs.query("esc in @import_options").exporter.unique() + " export"
export_buses = (
import_costs.query("esc in @import_options").exporter.unique() + " export"
)
n.madd("Bus", export_buses, carrier="export")
n.madd(
"Store",
Expand All @@ -4616,8 +4620,10 @@ def add_import_options(
import_nodes_tech = import_nodes[tech].dropna()
forbidden_importers = []
if "pipeline" in tech:
forbidden_importers.extend(["DE", "BE", "FR", "GB"]) # internal entrypoints
forbidden_importers.extend(["EE", "LT", "LV", "FI"]) # entrypoints via RU_BY
forbidden_importers.extend(["DE", "BE", "FR", "GB"]) # internal entrypoints
forbidden_importers.extend(
["EE", "LT", "LV", "FI"]
) # entrypoints via RU_BY
sel = ~import_nodes_tech.index.str.contains("|".join(forbidden_importers))
import_nodes_tech = import_nodes_tech.loc[sel]

Expand Down Expand Up @@ -4651,7 +4657,9 @@ def add_import_options(

upper_p_nom_max = import_config["p_nom_max"].get(tech, np.inf)
import_nodes_p_nom = import_nodes_tech.loc[df.importer.unique()]
p_nom_max = import_nodes_p_nom.mul(capacity_boost).clip(upper=upper_p_nom_max).values
p_nom_max = (
import_nodes_p_nom.mul(capacity_boost).clip(upper=upper_p_nom_max).values
)
p_nom_min = (
import_nodes_p_nom.clip(upper=upper_p_nom_max).values
if tech == "shipping-lch4"
Expand Down Expand Up @@ -4705,7 +4713,8 @@ def add_import_options(
for tech in set(import_options).intersection(copperplated_options):
marginal_costs = (
import_costs.query("esc == @tech")
.groupby("exporter").marginal_cost.min()
.groupby("exporter")
.marginal_cost.min()
.mul(import_options[tech])
)

Expand All @@ -4717,7 +4726,7 @@ def add_import_options(
)

# using energy content of iron as proxy: 2.1 MWh/t
unit_to_mwh = 2.1 if tech in ["shipping-steel", "shipping-hbi"] else 1.
unit_to_mwh = 2.1 if tech in ["shipping-steel", "shipping-hbi"] else 1.0

suffix = bus_suffix[tech]

Expand Down

0 comments on commit 9fde689

Please sign in to comment.