Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Major improvement to OSM-based electricity grid (e.g. using relations, preserving substation locations) #1384

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions config/config.default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ co2_budget:

# docs in https://pypsa-eur.readthedocs.io/en/latest/configuration.html#electricity
electricity:
voltages: [200., 220., 300., 380., 500., 750.]
voltages: [220., 300., 330., 380., 500., 750.]
base_network: osm-prebuilt
osm-prebuilt-version: 0.4
gaslimit_enable: false
Expand Down Expand Up @@ -278,9 +278,9 @@ conventional:
# docs in https://pypsa-eur.readthedocs.io/en/latest/configuration.html#lines
lines:
types:
200.: "Al/St 240/40 2-bundle 200.0"
220.: "Al/St 240/40 2-bundle 220.0"
300.: "Al/St 240/40 3-bundle 300.0"
330.: "Al/St 240/40 3-bundle 300.0"
380.: "Al/St 240/40 4-bundle 380.0"
500.: "Al/St 240/40 4-bundle 380.0"
750.: "Al/St 560/50 4-bundle 750.0"
Expand Down
2 changes: 1 addition & 1 deletion doc/configtables/electricity.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
,Unit,Values,Description
voltages,kV,"Any subset of {200., 220., 300., 380., 500., 750.}",Voltage levels to consider
voltages,kV,"Any subset of {220., 300., 330., 380., 500., 750.}",Voltage levels to consider
base_network, --, "Any value in {'entsoegridkit', 'osm-prebuilt', 'osm-raw}", "Specify the underlying base network, i.e. GridKit (based on ENTSO-E web map extract, OpenStreetMap (OSM) prebuilt or raw (built from raw OSM data), takes longer."
osm-prebuilt-version, --, "float, any value in range 0.1-0.4", "Choose the version of the prebuilt OSM network. Defaults to latest Zenodo release."
gaslimit_enable,bool,true or false,Add an overall absolute gas limit configured in ``electricity: gaslimit``.
Expand Down
11 changes: 9 additions & 2 deletions rules/build_electricity.smk
Original file line number Diff line number Diff line change
Expand Up @@ -757,8 +757,8 @@ if config["electricity"]["base_network"] == "osm-raw":
"data/osm-raw/{country}/lines_way.json",
country=config_provider("countries"),
),
links_relation=expand(
"data/osm-raw/{country}/links_relation.json",
routes_relation=expand(
"data/osm-raw/{country}/routes_relation.json",
country=config_provider("countries"),
),
substations_way=expand(
Expand All @@ -774,6 +774,7 @@ if config["electricity"]["base_network"] == "osm-raw":
output:
substations=resources("osm-raw/clean/substations.geojson"),
substations_polygon=resources("osm-raw/clean/substations_polygon.geojson"),
converters_polygon=resources("osm-raw/clean/converters_polygon.geojson"),
lines=resources("osm-raw/clean/lines.geojson"),
links=resources("osm-raw/clean/links.geojson"),
log:
Expand All @@ -792,8 +793,14 @@ if config["electricity"]["base_network"] == "osm-raw":
if config["electricity"]["base_network"] == "osm-raw":

rule build_osm_network:
params:
countries=config_provider("countries"),
voltages=config_provider("electricity", "voltages"),
line_types=config_provider("lines", "types"),
input:
substations=resources("osm-raw/clean/substations.geojson"),
substations_polygon=resources("osm-raw/clean/substations_polygon.geojson"),
converters_polygon=resources("osm-raw/clean/converters_polygon.geojson"),
lines=resources("osm-raw/clean/lines.geojson"),
links=resources("osm-raw/clean/links.geojson"),
country_shapes=resources("country_shapes.geojson"),
Expand Down
5 changes: 3 additions & 2 deletions rules/retrieve.smk
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ if config["enable"]["retrieve"] and (
0.2: "13342577",
0.3: "13358976",
0.4: "13759222",
0.5: "13759222", # TODO update link after validation
}

# update rule to use the correct version
Expand Down Expand Up @@ -592,7 +593,7 @@ if config["enable"]["retrieve"] and (
output:
cables_way="data/osm-raw/{country}/cables_way.json",
lines_way="data/osm-raw/{country}/lines_way.json",
links_relation="data/osm-raw/{country}/links_relation.json",
routes_relation="data/osm-raw/{country}/routes_relation.json",
substations_way="data/osm-raw/{country}/substations_way.json",
substations_relation="data/osm-raw/{country}/substations_relation.json",
log:
Expand All @@ -619,7 +620,7 @@ if config["enable"]["retrieve"] and (
country=config_provider("countries"),
),
expand(
"data/osm-raw/{country}/links_relation.json",
"data/osm-raw/{country}/routes_relation.json",
country=config_provider("countries"),
),
expand(
Expand Down
2 changes: 2 additions & 0 deletions scripts/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,8 @@ def aggregate_costs(n, flatten=False, opts=None, existing_only=False):

def progress_retrieve(url, file, disable=False):
headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)"}
# Hotfix - Bug, tqdm not working with disable=False
disable = True

if disable:
response = requests.get(url, headers=headers, stream=True)
Expand Down
3 changes: 2 additions & 1 deletion scripts/base_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,8 @@ def _set_electrical_parameters_transformers(transformers, config):

## Add transformer parameters
transformers["x"] = config.get("x", 0.1)
transformers["s_nom"] = config.get("s_nom", 2000)
if "s_nom" not in transformers:
transformers["s_nom"] = config.get("s_nom", 2000)
transformers["type"] = config.get("type", "")

return transformers
Expand Down
6 changes: 4 additions & 2 deletions scripts/build_gdp_pop_non_nuts3.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ def calc_gdp_pop(country, regions, gdp_non_nuts3, pop_non_nuts3):
if "snakemake" not in globals():
from _helpers import mock_snakemake

snakemake = mock_snakemake("build_gdp_pop_non_nuts3")
snakemake = mock_snakemake(
"build_gdp_pop_non_nuts3", configfiles=["config/config.osm-raw.yaml"]
)
configure_logging(snakemake)
set_scenario_config(snakemake)

Expand All @@ -146,4 +148,4 @@ def calc_gdp_pop(country, regions, gdp_non_nuts3, pop_non_nuts3):
logger.info(
f"Exporting GDP and POP values for non-NUTS3 regions {snakemake.output}"
)
gdp_pop.reset_index().to_file(snakemake.output, driver="GeoJSON")
gdp_pop.reset_index().to_file(snakemake.output[0], driver="GeoJSON")
Loading
Loading