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

Introducing OpenStreetMap high-voltage grid to PyPSA-Eur #1079

Merged
merged 156 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
156 commits
Select commit Hold shift + click to select a range
d92b69a
Implemented which uses the overpass API to download power features f…
bobbyxng Apr 23, 2024
2f2d32e
Merge branch 'PyPSA:master' into osm-network-fast
bobbyxng Apr 24, 2024
6352c03
Extended rule by input.
bobbyxng Apr 24, 2024
6e8842f
Merge branch 'PyPSA:master' into osm-network-fast
bobbyxng Apr 26, 2024
87b4cce
Bug fixes and improvements to clean_osm_data.py. Added in retrieve_o…
bobbyxng Apr 29, 2024
b7167e7
Merge branch 'PyPSA:master' into osm-network-fast
bobbyxng Apr 29, 2024
e6c9acc
Updated clean_osm_data and retrieve_osm_data to create clean substati…
bobbyxng May 3, 2024
85aa3f1
Finished clean_osm_data function.
bobbyxng May 6, 2024
49c1baf
Added check whether line is a circle. If so, drop it.
bobbyxng May 6, 2024
ff053e4
Merge branch 'PyPSA:master' into osm-network-fast
bobbyxng May 6, 2024
75cffe4
Extended build_electricity.smk by build_osm_network.py
bobbyxng May 6, 2024
4c71c37
Merge branch 'osm-network-fast' of https://github.com/bobbyxng/pypsa-…
bobbyxng May 7, 2024
efb9611
Added build_osm_network
bobbyxng May 7, 2024
193e605
Merge branch 'PyPSA:master' into osm-network-fast
bobbyxng May 7, 2024
266a8d0
Working osm-network-fast
bobbyxng May 7, 2024
6264bf8
Bug fixes.
bobbyxng May 7, 2024
bae4701
Merge branch 'PyPSA:master' into osm-network-fast
bobbyxng May 14, 2024
027fbde
Finalised and cleaned including docstrings.
bobbyxng May 15, 2024
dc829d2
Added try catch to retrieve_osm_data. Allows for parallelisation of d…
bobbyxng May 15, 2024
7bb153b
Updated cleaning process.
bobbyxng May 15, 2024
5ef4d71
Set maximum number of threads for retrieving to 4, wrt. fair usage po…
bobbyxng May 15, 2024
f961ab8
Intermediate update on clean_osm_data.py. Added docstrings.
bobbyxng May 16, 2024
3b90765
Bug fix.
bobbyxng May 16, 2024
93f09a5
Bug fix.
bobbyxng May 16, 2024
98f50ac
Bug fixes in data types out of clean_osm_data
bobbyxng May 16, 2024
4f2308d
Significant improvements to retrieve_osm_data, clean_osm_data. Cleane…
bobbyxng May 17, 2024
50c7411
Catch-up to master/osm-network-fast
bobbyxng May 21, 2024
84bdb40
Merge branch 'PyPSA:master' into osm-network-fast
bobbyxng May 21, 2024
068d0c6
Merge branch 'PyPSA:master' into osm-network-fast
bobbyxng May 21, 2024
da94a96
Cleaned config.
bobbyxng May 22, 2024
4c8e48d
Merge branch 'osm-network-fast' of https://github.com/bobbyxng/pypsa-…
bobbyxng May 22, 2024
6fe4ee4
Merge branch 'PyPSA:master' into osm-network-fast
bobbyxng May 22, 2024
095d936
Fixes.
bobbyxng May 22, 2024
6032f96
Bug fixes.
bobbyxng May 22, 2024
7bd83b4
Updated default config
bobbyxng May 22, 2024
d30ad7f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 22, 2024
739a406
Merge branch 'PyPSA:master' into osm-network-fast
bobbyxng May 24, 2024
f2761a2
Removed overpass from required packages. Not needed anymore.
bobbyxng May 24, 2024
c71a3b9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 24, 2024
ff882e6
Added links_relations (route = power, frequency = 0) to retrieval. Th…
bobbyxng May 24, 2024
e16ba57
Merge branch 'osm-network-fast' of https://github.com/bobbyxng/pypsa-…
bobbyxng May 24, 2024
0c0aff7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 24, 2024
8c96cc0
Merge branch 'PyPSA:master' into osm-network-fast
bobbyxng May 24, 2024
9c4dd31
Merge branch 'PyPSA:master' into osm-network-fast
bobbyxng May 28, 2024
ea9b383
Work-in-progress clean_osm_data
bobbyxng May 28, 2024
055699b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 28, 2024
b35d1ca
Merge branch 'PyPSA:master' into osm-network-fast
bobbyxng May 30, 2024
2b9d698
Added clean links output to clean_osm_data. Script uses OSM relations…
bobbyxng May 31, 2024
ff2b839
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 31, 2024
24aa2e0
New code for integrating HVDC links. Using relations. Base network im…
bobbyxng Jun 3, 2024
d4c74fc
New code for integrating HVDC links. Using relations. Base network im…
bobbyxng Jun 3, 2024
f9e3eec
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 3, 2024
212ac84
Merge branch 'PyPSA:master' into osm-network-fast
bobbyxng Jun 4, 2024
aeb80a2
removed manual line dropping.
bobbyxng Jun 4, 2024
637d28c
Updated clean script
bobbyxng Jun 6, 2024
f5e5171
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 6, 2024
3bebcc0
reverted Snakefile to default: sync settings
bobbyxng Jun 6, 2024
b44d669
Merge branch 'PyPSA:master' into osm-network-fast
bobbyxng Jun 6, 2024
a2ee16f
added prebuilt functionality.
bobbyxng Jun 6, 2024
10b5146
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 6, 2024
38de271
Updated build_electricity.smk to work with scenario management.
bobbyxng Jun 7, 2024
bb55ad7
removed commented-out code.
bobbyxng Jun 7, 2024
a629dba
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 7, 2024
3e2f7d3
removed commented-out code.
bobbyxng Jun 10, 2024
e712735
Consolidated base_network scripts to single script for gridkit, osm-r…
bobbyxng Jun 10, 2024
6469ff4
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 10, 2024
221b165
Fixed bug in pdf export by substituting pdf export with svg.
bobbyxng Jun 11, 2024
9bcdbc0
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 11, 2024
0a39ce1
Merge branch 'PyPSA:master' into osm-network-fast
bobbyxng Jun 11, 2024
afb9e52
Bug-fix Snakefile
bobbyxng Jun 11, 2024
878a8b6
Merge branch 'PyPSA:master' into osm-network-fast
bobbyxng Jun 12, 2024
c1d6461
Merge branch 'PyPSA:master' into osm-network-fast
bobbyxng Jun 17, 2024
3d2169a
dropped not needed columns from build_osm_network.
bobbyxng Jun 17, 2024
f2bd9bf
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 17, 2024
10643cd
Merge branch 'PyPSA:master' into osm-network-fast
bobbyxng Jun 18, 2024
acda4c4
Updated build_shapes, config.default and clean_osm_data.
bobbyxng Jun 18, 2024
777f7ea
pre-commit changes.
bobbyxng Jun 18, 2024
58e5129
test
bobbyxng Jun 19, 2024
917c52c
Added initial prepare_osm_network_release.py script
bobbyxng Jun 19, 2024
2163edd
Merge branch 'PyPSA:master' into osm-network-fast
bobbyxng Jun 20, 2024
f2c8676
Merge branch 'PyPSA:master' into osm-network-fast
bobbyxng Jun 20, 2024
2a3ad5c
Finalised prepare_osm_network_release script to build clean and stabl…
bobbyxng Jun 21, 2024
38ee3da
Added new rules/development.smk
bobbyxng Jun 21, 2024
7ed45d2
Merge branch 'PyPSA:master' into osm-network-fast
bobbyxng Jun 21, 2024
0d9ba2e
Updated clean_osm_data to add substation_centroid to linestrings
bobbyxng Jun 25, 2024
c818cd9
Updated clean_osm_data to add substation_centroid to linestrings
bobbyxng Jun 25, 2024
af3b415
Updated clean_osm_data to add substation_centroid to linestrings
bobbyxng Jun 25, 2024
45bccfc
Updated clean_osm_data to add substation_centroid to linestrings
bobbyxng Jun 25, 2024
0db49f2
Added osm-prebuilt functionality and zenodo sandbox repository.
bobbyxng Jun 25, 2024
ee2e025
Merge branch 'PyPSA:master' into osm-network-fast
bobbyxng Jul 2, 2024
4bd4a65
Merge branch 'PyPSA:master' into osm-network-fast
bobbyxng Jul 5, 2024
c748e4a
Merge remote-tracking branch 'upstream/master' into osm-network-fast
bobbyxng Jul 10, 2024
0c7f2d9
Merge branch 'osm-network-fast' of https://github.com/bobbyxng/pypsa-…
bobbyxng Jul 10, 2024
4f4f7c6
Updated clean_osm_data to geopandas v.1.01
bobbyxng Jul 10, 2024
0b5a1fe
Made base_network and build_osm_network function more robust for empt…
bobbyxng Jul 10, 2024
e0ae315
Made base_network and build_osm_network function more robust for empt…
bobbyxng Jul 10, 2024
801daf5
Merge branch 'PyPSA:master' into osm-network-fast
bobbyxng Jul 11, 2024
69e66a5
Merge branch 'PyPSA:master' into osm-network-fast
bobbyxng Jul 12, 2024
2990299
Bug fix in base_network. Voltage level null is now kept (relevant e.g…
bobbyxng Jul 12, 2024
44aa963
Merge branch 'PyPSA:master' into osm-network-fast
bobbyxng Jul 14, 2024
c0e6e43
Merge with hcanges in upstream PR 1146. Fixing UA and MD.
bobbyxng Jul 15, 2024
5ca3ec5
Merge branch 'osm-network-fast' of https://github.com/bobbyxng/pypsa-…
bobbyxng Jul 15, 2024
84bf9ec
Updated Zenodo and fixed prepare_osm_network_release
bobbyxng Jul 15, 2024
7d96dd2
Updated osm network release.
bobbyxng Jul 15, 2024
d53e758
Merge branch 'PyPSA:master' into osm-network-fast
bobbyxng Jul 15, 2024
867de1e
Updated prepare osm network release.
bobbyxng Jul 15, 2024
3b0c924
Merge branch 'osm-network-fast' of https://github.com/bobbyxng/pypsa-…
bobbyxng Jul 15, 2024
69f9fa6
Merge branch 'PyPSA:master' into osm-network-fast
bobbyxng Jul 16, 2024
41dff32
Updated MD, UA scripts.
bobbyxng Jul 16, 2024
75f146c
Cleaned determine_availability_matrix_MD_UA.py, removed redundant code
bobbyxng Jul 16, 2024
44f4636
Bug fixes.
bobbyxng Jul 16, 2024
712c476
Bug fixes for UA MD scripts.
bobbyxng Jul 16, 2024
5071c29
Rename of build script.
bobbyxng Jul 16, 2024
d8941f2
Bug fix: only distribute load to buses with substation.
bobbyxng Jul 16, 2024
f234c9c
Updated zenodo sandbox repository.
bobbyxng Jul 17, 2024
f7d8992
Updated config.default
bobbyxng Jul 18, 2024
2f33785
Merge with master.
bobbyxng Jul 22, 2024
d5bb7f8
Merge branch 'PyPSA:master' into osm-network-fast
bobbyxng Jul 23, 2024
4c9a055
Cleaned config.default.yaml: Related settings grouped together and re…
bobbyxng Jul 23, 2024
306883f
Cleaned config.default.yaml: Related settings grouped together and re…
bobbyxng Jul 23, 2024
77ac356
Updated Zenodo repositories for OSM-prebuilt to offcial publication.
bobbyxng Jul 23, 2024
f671792
Updated configtables
bobbyxng Jul 30, 2024
5392e64
Merged with master
bobbyxng Jul 30, 2024
ff560ec
Merge branch 'PyPSA:master' into osm-network-fast
bobbyxng Aug 1, 2024
05aedb1
Merge branch 'PyPSA:master' into osm-network-fast
bobbyxng Aug 5, 2024
ce65d3d
Merge branch 'PyPSA:master' into osm-network-fast
bobbyxng Aug 5, 2024
b53249e
Merge branch 'PyPSA:master' into osm-network-fast
bobbyxng Aug 7, 2024
008df4b
Updated links.csv: Under_construction lines to in commission.
bobbyxng Aug 9, 2024
210ef80
Updated link 8394 and parameter_corrections: Continuation of North-Se…
bobbyxng Aug 9, 2024
d0c0e18
Merge branch 'PyPSA:master' into osm-network-fast
bobbyxng Aug 14, 2024
4144431
Merge branch 'PyPSA:master' into osm-network-fast
bobbyxng Aug 14, 2024
e33edfe
Major update: fix simplify_network, fix Corsica, updated build_osm_ne…
bobbyxng Aug 14, 2024
f6a5ecf
Merge branch 'PyPSA:master' into osm-network-fast
bobbyxng Aug 14, 2024
0ad15d9
Merge branch 'PyPSA:master' into osm-network-fast
bobbyxng Aug 14, 2024
b143f49
remove config backup
bobbyxng Aug 14, 2024
f87eec5
Bug fix: Carrier type of all supernodes corrected to 'AC'
bobbyxng Aug 15, 2024
e097fc4
Bug fix: Carrier type of all supernodes corrected to 'AC'
bobbyxng Aug 15, 2024
2864375
Merge remote-tracking branch 'origin/master' into osm-network-fast
bobbyxng Aug 19, 2024
864321e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 19, 2024
9b66345
Updated rules and base_network for compatibility with TYNDP projects.
bobbyxng Aug 19, 2024
dfcac7f
Merge branch 'osm-network-fast' of https://github.com/bobbyxng/pypsa-…
bobbyxng Aug 19, 2024
412acd8
Updated Zenodo repository and prebuilt network to include 150 kV HVDC…
bobbyxng Aug 19, 2024
1aa8b6c
Merge branch 'PyPSA:master' into osm-network-fast
bobbyxng Aug 20, 2024
f1526fb
Removed outdated config backup.
bobbyxng Aug 20, 2024
761d71c
Merge branch 'PyPSA:master' into osm-network-fast
bobbyxng Aug 21, 2024
7be5217
Implemented all comments from PR #1079. Cleaned up OSM implementation.
bobbyxng Aug 21, 2024
d3f439b
Merge branch 'osm-network-fast' of https://github.com/bobbyxng/pypsa-…
bobbyxng Aug 21, 2024
48c2cae
Bug fix: Added all voltages, 200 kV-750 kV, to default config.
bobbyxng Aug 21, 2024
89f0955
Cleaning and bugfixes.
bobbyxng Aug 21, 2024
07a7a64
Updated Zenodo repository to https://zenodo.org/records/13358976. Add…
bobbyxng Aug 22, 2024
6be527f
Apply suggestions from code review
fneum Aug 22, 2024
c7cfd45
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 22, 2024
259b4ec
simplify_network: handle complicated transformer topologies
fneum Aug 22, 2024
e1d4b49
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 22, 2024
cd9855f
syntax fix
fneum Aug 22, 2024
88c8faa
Merge branch 'osm-network-fast' of github.com:bobbyxng/pypsa-eur into…
fneum Aug 22, 2024
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
1 change: 1 addition & 0 deletions Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ include: "rules/build_sector.smk"
include: "rules/solve_electricity.smk"
include: "rules/postprocess.smk"
include: "rules/validate.smk"
include: "rules/development.smk"


if config["foresight"] == "overnight":
Expand Down
7 changes: 4 additions & 3 deletions config/config.default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ scenario:
ll:
- vopt
clusters:
- 38
- 41
- 128
- 256
opts:
Expand Down Expand Up @@ -74,7 +74,6 @@ enable:
custom_busmap: false
drop_leap_day: true


# docs in https://pypsa-eur.readthedocs.io/en/latest/configuration.html#co2-budget
co2_budget:
2020: 0.701
Expand All @@ -87,7 +86,8 @@ co2_budget:

# docs in https://pypsa-eur.readthedocs.io/en/latest/configuration.html#electricity
electricity:
voltages: [220., 300., 380., 500., 750.]
bobbyxng marked this conversation as resolved.
Show resolved Hide resolved
voltages: [200., 220., 300., 380., 500., 750.]
base_network: entsoegridkit
gaslimit_enable: false
gaslimit: false
co2limit_enable: false
Expand Down Expand Up @@ -276,6 +276,7 @@ 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"
380.: "Al/St 240/40 4-bundle 380.0"
Expand Down
3 changes: 2 additions & 1 deletion doc/configtables/electricity.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
,Unit,Values,Description
voltages,kV,"Any subset of {220., 300., 380.}",Voltage levels to consider
voltages,kV,"Any subset of {200., 220., 300., 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."
gaslimit_enable,bool,true or false,Add an overall absolute gas limit configured in ``electricity: gaslimit``.
gaslimit,MWhth,float or false,Global gas usage limit
co2limit_enable,bool,true or false,Add an overall absolute carbon-dioxide emissions limit configured in ``electricity: co2limit`` in :mod:`prepare_network`. **Warning:** This option should currently only be used with electricity-only networks, not for sector-coupled networks..
Expand Down
2 changes: 2 additions & 0 deletions doc/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ Upcoming Release

* Enable parallelism in :mod:`determine_availability_matrix_MD_UA.py` and remove plots. This requires the use of temporary files.

* Added new major feature to create the base_network from OpenStreetMap (OSM) data (PR https://github.com/PyPSA/pypsa-eur/pull/1079). Note that a heuristics based cleaning process is used for lines and links where electrical parameters are incomplete, missing, or ambiguous. Through ``electricity["base_network"]``, the base network can be set to "entsoegridkit" (original default setting, deprecated soon), "osm-prebuilt" (which downloads the latest prebuilt snapshot based on OSM data from Zenodo), or "osm-raw" which retrieves (once) and cleans the raw OSM data and subsequently builds the network. Note that this process may take a few minutes.

* Updated pre-built `weather data cutouts
<https://zenodo.org/records/12791128>`__. These are now merged cutouts with
solar irradiation from the new SARAH-3 dataset while taking all other
Expand Down
1 change: 1 addition & 0 deletions envs/environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ dependencies:
- pyxlsb
- graphviz
- pre-commit
- geojson

# Keep in conda environment when calling ipython
- ipython
Expand Down
97 changes: 90 additions & 7 deletions rules/build_electricity.smk
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,19 @@ rule build_powerplants:
"../scripts/build_powerplants.py"


def input_base_network(w):
base_network = config_provider("electricity", "base_network")(w)
components = {"buses", "lines", "links", "converters", "transformers"}
if base_network == "osm-raw":
inputs = {c: resources(f"osm-raw/build/{c}.csv") for c in components}
else:
inputs = {c: f"data/{base_network}/{c}.csv" for c in components}
if base_network == "entsoegridkit":
inputs["parameter_corrections"] = "data/parameter_corrections.yaml"
inputs["links_p_nom"] = "data/links_p_nom.csv"
return inputs


rule base_network:
params:
countries=config_provider("countries"),
Expand All @@ -58,13 +71,7 @@ rule base_network:
lines=config_provider("lines"),
transformers=config_provider("transformers"),
input:
eg_buses="data/entsoegridkit/buses.csv",
eg_lines="data/entsoegridkit/lines.csv",
eg_links="data/entsoegridkit/links.csv",
eg_converters="data/entsoegridkit/converters.csv",
eg_transformers="data/entsoegridkit/transformers.csv",
parameter_corrections="data/parameter_corrections.yaml",
links_p_nom="data/links_p_nom.csv",
unpack(input_base_network),
country_shapes=resources("country_shapes.geojson"),
offshore_shapes=resources("offshore_shapes.geojson"),
europe_shape=resources("europe_shape.geojson"),
Expand Down Expand Up @@ -629,3 +636,79 @@ rule prepare_network:
"../envs/environment.yaml"
script:
"../scripts/prepare_network.py"


if config["electricity"]["base_network"] == "osm-raw":

rule clean_osm_data:
input:
cables_way=expand(
"data/osm-raw/{country}/cables_way.json",
country=config_provider("countries"),
),
lines_way=expand(
"data/osm-raw/{country}/lines_way.json",
country=config_provider("countries"),
),
links_relation=expand(
"data/osm-raw/{country}/links_relation.json",
country=config_provider("countries"),
),
substations_way=expand(
"data/osm-raw/{country}/substations_way.json",
country=config_provider("countries"),
),
substations_relation=expand(
"data/osm-raw/{country}/substations_relation.json",
country=config_provider("countries"),
),
offshore_shapes=resources("offshore_shapes.geojson"),
country_shapes=resources("country_shapes.geojson"),
output:
substations=resources("osm-raw/clean/substations.geojson"),
substations_polygon=resources("osm-raw/clean/substations_polygon.geojson"),
lines=resources("osm-raw/clean/lines.geojson"),
links=resources("osm-raw/clean/links.geojson"),
log:
logs("clean_osm_data.log"),
benchmark:
benchmarks("clean_osm_data")
threads: 1
resources:
mem_mb=4000,
conda:
"../envs/environment.yaml"
script:
"../scripts/clean_osm_data.py"


if config["electricity"]["base_network"] == "osm-raw":

rule build_osm_network:
input:
substations=resources("osm-raw/clean/substations.geojson"),
lines=resources("osm-raw/clean/lines.geojson"),
links=resources("osm-raw/clean/links.geojson"),
country_shapes=resources("country_shapes.geojson"),
output:
lines=resources("osm-raw/build/lines.csv"),
links=resources("osm-raw/build/links.csv"),
converters=resources("osm-raw/build/converters.csv"),
transformers=resources("osm-raw/build/transformers.csv"),
substations=resources("osm-raw/build/buses.csv"),
lines_geojson=resources("osm-raw/build/geojson/lines.geojson"),
links_geojson=resources("osm-raw/build/geojson/links.geojson"),
converters_geojson=resources("osm-raw/build/geojson/converters.geojson"),
transformers_geojson=resources("osm-raw/build/geojson/transformers.geojson"),
substations_geojson=resources("osm-raw/build/geojson/buses.geojson"),
log:
logs("build_osm_network.log"),
benchmark:
benchmarks("build_osm_network")
threads: 1
resources:
mem_mb=4000,
conda:
"../envs/environment.yaml"
script:
"../scripts/build_osm_network.py"
26 changes: 26 additions & 0 deletions rules/development.smk
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# SPDX-FileCopyrightText: : 2023-2024 The PyPSA-Eur Authors
#
# SPDX-License-Identifier: MIT

if config["electricity"]["base_network"] == "osm-raw":

rule prepare_osm_network_release:
input:
base_network=resources("networks/base.nc"),
output:
buses=resources("osm-raw/release/buses.csv"),
converters=resources("osm-raw/release/converters.csv"),
lines=resources("osm-raw/release/lines.csv"),
links=resources("osm-raw/release/links.csv"),
transformers=resources("osm-raw/release/transformers.csv"),
log:
logs("prepare_osm_network_release.log"),
benchmark:
benchmarks("prepare_osm_network_release")
threads: 1
resources:
mem_mb=1000,
conda:
"../envs/environment.yaml"
script:
"../scripts/prepare_osm_network_release.py"
82 changes: 82 additions & 0 deletions rules/retrieve.smk
Original file line number Diff line number Diff line change
Expand Up @@ -390,3 +390,85 @@ if config["enable"]["retrieve"]:
"../envs/retrieve.yaml"
script:
"../scripts/retrieve_monthly_fuel_prices.py"


if config["enable"]["retrieve"] and (
config["electricity"]["base_network"] == "osm-prebuilt"
):

rule retrieve_osm_prebuilt:
input:
buses=storage("https://zenodo.org/records/13358976/files/buses.csv"),
converters=storage(
"https://zenodo.org/records/13358976/files/converters.csv"
),
lines=storage("https://zenodo.org/records/13358976/files/lines.csv"),
links=storage("https://zenodo.org/records/13358976/files/links.csv"),
transformers=storage(
"https://zenodo.org/records/13358976/files/transformers.csv"
),
output:
buses="data/osm-prebuilt/buses.csv",
converters="data/osm-prebuilt/converters.csv",
lines="data/osm-prebuilt/lines.csv",
links="data/osm-prebuilt/links.csv",
transformers="data/osm-prebuilt/transformers.csv",
log:
"logs/retrieve_osm_prebuilt.log",
threads: 1
resources:
mem_mb=500,
retries: 2
run:
for key in input.keys():
move(input[key], output[key])
bobbyxng marked this conversation as resolved.
Show resolved Hide resolved
validate_checksum(output[key], input[key])



if config["enable"]["retrieve"] and (
config["electricity"]["base_network"] == "osm-raw"
):

rule retrieve_osm_data:
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",
substations_way="data/osm-raw/{country}/substations_way.json",
substations_relation="data/osm-raw/{country}/substations_relation.json",
log:
"logs/retrieve_osm_data_{country}.log",
threads: 1
conda:
"../envs/retrieve.yaml"
script:
"../scripts/retrieve_osm_data.py"


if config["enable"]["retrieve"] and (
config["electricity"]["base_network"] == "osm-raw"
):

rule retrieve_osm_data_all:
input:
expand(
"data/osm-raw/{country}/cables_way.json",
country=config_provider("countries"),
),
expand(
"data/osm-raw/{country}/lines_way.json",
country=config_provider("countries"),
),
expand(
"data/osm-raw/{country}/links_relation.json",
country=config_provider("countries"),
),
expand(
"data/osm-raw/{country}/substations_way.json",
country=config_provider("countries"),
),
expand(
"data/osm-raw/{country}/substations_relation.json",
country=config_provider("countries"),
),
Loading
Loading