Skip to content

Rule base_network

Workflow Diagram

See the complete workflow in the repository.

digraph snakemake_dag { graph [bgcolor=white, margin=0, size="8,5" ]; node [fontname=sans, fontsize=10, penwidth=2, shape=box, style=rounded ]; edge [color=grey, penwidth=2 ]; 4 [color="0.50 0.6 0.85", label=add_electricity]; 5 [color="0.36 0.6 0.85", label=build_bus_regions]; 6 [color="0.58 0.6 0.85", fillcolor=gray, label=base_network, style=filled]; 6 -> 4; 6 -> 5; 7 [color="0.31 0.6 0.85", label=build_powerplants]; 6 -> 7; 9 [color="0.22 0.6 0.85", label=build_renewable_profiles]; 6 -> 9; 8 [color="0.28 0.6 0.85", label=build_shapes]; 8 -> 6; 11 [color="0.03 0.6 0.85", label=prepare_links_p_nom]; 11 -> 6; }

Script Documentation

Creates the network topology from a OpenStreetMap.

Relevant Settings

.. code:: yaml

snapshots:

countries:

electricity:
    voltages:

lines:
    types:
    s_max_pu:
    under_construction:

links:
    p_max_pu:
    p_nom_max:
    under_construction:

transformers:
    x:
    s_nom:
    type:

.. seealso:: Documentation of the configuration file config.yaml at :ref:snapshots_cf, :ref:meta_cf, :ref:electricity_cf, :ref:load_options_cf, :ref:lines_cf, :ref:links_cf, :ref:transformers_cf

Inputs

Outputs

  • networks/base.nc

    .. image:: /img/base.png :width: 33 %

Description

get_country(df)

Extract the two-letter country code from the tags column.

Parameters

df : pd.DataFrame DataFrame that may contain a tags column with OSM tag strings.

Returns

pd.Series Series of ISO 3166-1 alpha-2 country codes, or NaN where absent.

Compute and attach the underwater fraction for each HVDC link.

n : pypsa.Network Network whose links component is updated in-place. fp_offshore_shapes : str Path to the offshore shapes file (GeoPackage or shapefile).

base_network(inputs, base_network_config, countries_config, hvdc_as_lines_config, lines_config, links_config, snapshots_config, transformers_config, voltages_config)

Build the base PyPSA network from OSM-derived component tables.

Loads buses, lines, transformers, and converters from CSV files, assigns electrical parameters, imports all components into a new :class:pypsa.Network, and returns it ready for further processing.

When hvdc_as_lines_config is True, DC lines are imported as PyPSA Line components; otherwise they are modelled as Link components.

Parameters

inputs : snakemake.io.Namedlist Snakemake input paths: osm_buses, osm_lines, osm_transformers, osm_converters, country_shapes, offshore_shapes. base_network_config : dict base_network section of config.yaml. countries_config : list List of ISO 3166-1 alpha-2 country codes to include. hvdc_as_lines_config : bool If True, treat HVDC lines as PyPSA Line components. lines_config : dict lines section of config.yaml. links_config : dict links section of config.yaml. snapshots_config : dict snapshots section passed to :meth:pypsa.Network.set_snapshots. transformers_config : dict transformers section of config.yaml. voltages_config : list Nominal voltages (kV) to retain.

Returns

pypsa.Network Fully assembled base network with buses, lines, links, transformers, converters, country assignments, and underwater fractions.