From c907d59253e90b4aa8c54baaa54f4a44b67f8b4f Mon Sep 17 00:00:00 2001 From: Fabian Neumann Date: Wed, 7 Aug 2024 15:20:08 +0200 Subject: [PATCH] remove unused rule `prepare_links_p_nom` (#1203) * remove rule * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- config/config.default.yaml | 1 - doc/configtables/enable.csv | 1 - doc/preparation.rst | 5 -- doc/release_notes.rst | 2 + rules/build_electricity.smk | 15 ------ scripts/prepare_links_p_nom.py | 95 ---------------------------------- 6 files changed, 2 insertions(+), 117 deletions(-) delete mode 100644 scripts/prepare_links_p_nom.py diff --git a/config/config.default.yaml b/config/config.default.yaml index 5229c385..99655d72 100644 --- a/config/config.default.yaml +++ b/config/config.default.yaml @@ -67,7 +67,6 @@ snapshots: # docs in https://pypsa-eur.readthedocs.io/en/latest/configuration.html#enable enable: retrieve: auto - prepare_links_p_nom: false retrieve_databundle: true retrieve_cost_data: true build_cutout: false diff --git a/doc/configtables/enable.csv b/doc/configtables/enable.csv index c74d0eff..0268319e 100644 --- a/doc/configtables/enable.csv +++ b/doc/configtables/enable.csv @@ -1,6 +1,5 @@ ,Unit,Values,Description enable,str or bool,"{auto, true, false}","Switch to include (true) or exclude (false) the retrieve_* rules of snakemake into the workflow; 'auto' sets true|false based on availability of an internet connection to prevent issues with snakemake failing due to lack of internet connection." -prepare_links_p_nom,bool,"{true, false}","Switch to retrieve current HVDC projects from `Wikipedia `_" retrieve_databundle,bool,"{true, false}","Switch to retrieve databundle from zenodo via the rule :mod:`retrieve_databundle` or whether to keep a custom databundle located in the corresponding folder." retrieve_cost_data,bool,"{true, false}","Switch to retrieve technology cost data from `technology-data repository `_." build_cutout,bool,"{true, false}","Switch to enable the building of cutouts via the rule :mod:`build_cutout`." diff --git a/doc/preparation.rst b/doc/preparation.rst index 4585f4db..83f9781c 100644 --- a/doc/preparation.rst +++ b/doc/preparation.rst @@ -41,11 +41,6 @@ Rule ``build_cutout`` .. automodule:: build_cutout -Rule ``prepare_links_p_nom`` -=============================== - -.. automodule:: prepare_links_p_nom - .. _base: Rule ``base_network`` diff --git a/doc/release_notes.rst b/doc/release_notes.rst index 9ce418b2..528d94df 100644 --- a/doc/release_notes.rst +++ b/doc/release_notes.rst @@ -10,6 +10,8 @@ Release Notes Upcoming Release ================ +* The rule ``prepare_links_p_nom`` was removed since it was outdated and not used. + * Changed heat pump COP approximation for central heating to be based on `Jensen et al. (2018) `__ and a default forward temperature of 90C. This is more realistic for district heating than the previously used approximation method. * split solid biomass potentials into solid biomass and municipal solid waste. Add option to use municipal solid waste. This option is only activated in combination with the flag ``waste_to_energy`` diff --git a/rules/build_electricity.smk b/rules/build_electricity.smk index 10e5dfc0..64bd85a1 100644 --- a/rules/build_electricity.smk +++ b/rules/build_electricity.smk @@ -2,21 +2,6 @@ # # SPDX-License-Identifier: MIT -if config["enable"].get("prepare_links_p_nom", False): - - rule prepare_links_p_nom: - output: - "data/links_p_nom.csv", - log: - logs("prepare_links_p_nom.log"), - threads: 1 - resources: - mem_mb=1500, - conda: - "../envs/environment.yaml" - script: - "../scripts/prepare_links_p_nom.py" - rule build_electricity_demand: params: diff --git a/scripts/prepare_links_p_nom.py b/scripts/prepare_links_p_nom.py deleted file mode 100644 index 7c1ed211..00000000 --- a/scripts/prepare_links_p_nom.py +++ /dev/null @@ -1,95 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -# SPDX-FileCopyrightText: : 2017-2024 The PyPSA-Eur Authors -# -# SPDX-License-Identifier: MIT -""" -Extracts capacities of HVDC links from `Wikipedia. - -`_. - -Relevant Settings ------------------ - -.. code:: yaml - - enable: - prepare_links_p_nom: - -.. seealso:: - Documentation of the configuration file ``config/config.yaml`` at - :ref:`toplevel_cf` - -Inputs ------- - -*None* - -Outputs -------- - -- ``data/links_p_nom.csv``: A plain download of https://en.wikipedia.org/wiki/List_of_HVDC_projects#Europe plus extracted coordinates. - -Description ------------ - -*None* -""" - -import logging - -import pandas as pd -from _helpers import configure_logging, set_scenario_config - -logger = logging.getLogger(__name__) - - -def multiply(s): - return s.str[0].astype(float) * s.str[1].astype(float) - - -def extract_coordinates(s): - regex = ( - r"(\d{1,2})°(\d{1,2})′(\d{1,2})″(N|S) " r"(\d{1,2})°(\d{1,2})′(\d{1,2})″(E|W)" - ) - e = s.str.extract(regex, expand=True) - lat = ( - e[0].astype(float) + (e[1].astype(float) + e[2].astype(float) / 60.0) / 60.0 - ) * e[3].map({"N": +1.0, "S": -1.0}) - lon = ( - e[4].astype(float) + (e[5].astype(float) + e[6].astype(float) / 60.0) / 60.0 - ) * e[7].map({"E": +1.0, "W": -1.0}) - return lon, lat - - -if __name__ == "__main__": - if "snakemake" not in globals(): - from _helpers import mock_snakemake # rule must be enabled in config - - snakemake = mock_snakemake("prepare_links_p_nom", simpl="") - configure_logging(snakemake) - set_scenario_config(snakemake) - - links_p_nom = pd.read_html( - "https://en.wikipedia.org/wiki/List_of_HVDC_projects", header=0, match="SwePol" - )[0] - - mw = "Power (MW)" - m_b = links_p_nom[mw].str.contains("x").fillna(False) - - links_p_nom.loc[m_b, mw] = links_p_nom.loc[m_b, mw].str.split("x").pipe(multiply) - links_p_nom[mw] = ( - links_p_nom[mw].str.extract("[-/]?([\d.]+)", expand=False).astype(float) - ) - - links_p_nom["x1"], links_p_nom["y1"] = extract_coordinates( - links_p_nom["Converterstation 1"] - ) - links_p_nom["x2"], links_p_nom["y2"] = extract_coordinates( - links_p_nom["Converterstation 2"] - ) - - links_p_nom.dropna(subset=["x1", "y1", "x2", "y2"]).to_csv( - snakemake.output[0], index=False - )