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

Update to OSM-prebuilt v0.6 #1431

Merged
merged 38 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
a1d076c
Implemented line merge over virtual bus functionality.
bobbyxng Oct 14, 2024
0287872
Implemented: Aggregating identical lines, bus merging to stations, cr…
bobbyxng Oct 15, 2024
ce15373
Implemented: Mapping of lines to buses and extending lines to buses.
bobbyxng Oct 16, 2024
77f77c8
Finished implementing converters and links.
bobbyxng Oct 17, 2024
24145f7
Finished implementation of entirely new build_osm_network.py script.
bobbyxng Oct 18, 2024
9aca61a
Merge branch 'master' into osm-interconnectors
bobbyxng Oct 18, 2024
fc5b36c
Updated configtables.
bobbyxng Oct 18, 2024
43cf668
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 18, 2024
caf8eb9
Temporarily disabled tqdm in retrieve. Line splitting disabled as well.
bobbyxng Oct 19, 2024
6b00178
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 19, 2024
fb653fb
Implemented relations. Running, converging workflow.
bobbyxng Oct 22, 2024
b2c21f7
Added updated simplify_network.py
bobbyxng Oct 22, 2024
2aefa9b
Cleaned up code.
bobbyxng Oct 22, 2024
5420fec
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 22, 2024
9b24312
Updated doc
bobbyxng Oct 22, 2024
4ef062f
Merge remote-tracking branch 'refs/remotes/origin/osm-relations' into…
bobbyxng Oct 22, 2024
8aec857
Reactivated line splitting.
bobbyxng Oct 22, 2024
13391d6
Updated build_osm_network.
bobbyxng Oct 23, 2024
639eef7
Cleaned up code.
bobbyxng Oct 23, 2024
aca66fb
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 23, 2024
0cca562
Added 400 kV voltage level to config.default
bobbyxng Oct 23, 2024
b3fec47
Merge branch 'osm-relations' of https://github.com/pypsa/pypsa-eur in…
bobbyxng Oct 23, 2024
db2f593
Merge branch 'master' into osm-relations
bobbyxng Oct 25, 2024
e9f7798
Updated Zenodo link
bobbyxng Oct 25, 2024
c7c453d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 25, 2024
8fa4c43
Cleaned up code based on PR comments
bobbyxng Nov 6, 2024
527410d
Merge branch 'master' into osm-relations
bobbyxng Nov 6, 2024
0770e21
Added docstrings.
bobbyxng Nov 6, 2024
74b8eb3
Merge branch 'master' into osm-relations
fneum Nov 10, 2024
6a53661
Merge master into branch.
bobbyxng Nov 13, 2024
9effab0
Updated prepare_osm_network to include interactive map. Added electri…
bobbyxng Nov 13, 2024
45bcd6f
Updated config.default. Removed dummy configs.
bobbyxng Nov 13, 2024
76b7521
Updated retriever to include map.html
bobbyxng Nov 13, 2024
4c492ed
Add custom busmaps
bobbyxng Nov 13, 2024
bf4a195
Added GB busmaps, 37 is london clustered. 314 is london clustered for…
bobbyxng Nov 16, 2024
18e687d
Merge branch 'master' into osm-prebuilt-0.6
bobbyxng Nov 19, 2024
cb21f29
Removed data files, updated docs.
bobbyxng Nov 19, 2024
8b68b93
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 19, 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
2 changes: 1 addition & 1 deletion config/config.default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ co2_budget:
electricity:
voltages: [220., 300., 330., 380., 400., 500., 750.]
base_network: osm-prebuilt
osm-prebuilt-version: 0.5
osm-prebuilt-version: 0.6
gaslimit_enable: false
gaslimit: false
co2limit_enable: false
Expand Down
2 changes: 1 addition & 1 deletion doc/configtables/electricity.csv
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
,Unit,Values,Description
voltages,kV,"Any subset of {220., 300., 330., 380., 400., 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.5", "Choose the version of the prebuilt OSM network. Defaults to latest Zenodo release."
osm-prebuilt-version, --, "float, any value in range 0.1-0.6", "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``.
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
8 changes: 4 additions & 4 deletions doc/data-base-network.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ The map might take a moment to load. To view it in full screen, click `here <bas

``data/osm-prebuilt``

- **Source:** OpenStreetMap; Xiong, B., Neumann, F., & Brown, T. (2024).
- **Source:** OpenStreetMap; Xiong, B., Fioriti, D., Neumann, F., Riepin I. & Brown, T. (2024).
Prebuilt Electricity Network for PyPSA-Eur based on OpenStreetMap Data (0.5)
[Data set]. Zenodo. https://doi.org/10.5281/zenodo.13981528
- **Link:** https://zenodo.org/records/13981528
- **License:** ODbL (`reference <https://zenodo.org/records/13981528>`)
[Data set]. Zenodo. https://doi.org/10.5281/zenodo.14144752
- **Link:** https://zenodo.org/records/14144752
- **License:** ODbL (`reference <https://zenodo.org/records/14144752>`)
- **Description:** Pre-built data of high-voltage transmission grid in Europe from OpenStreetMap.

This dataset contains a topologically connected representation of the European
Expand Down
2 changes: 1 addition & 1 deletion doc/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Upcoming Release
- Single transformers for each combination of voltage level per substation. Transformers now have a capacity s_nom based on connected lines
- Use of OSM relations where available and unambiguous (Overwriting all lines that are members of the respective relation to avoid duplicates)

* Updated osm-prebuilt base network to version 0.5, for changelog, see https://zenodo.org/records/13981528
* Updated osm-prebuilt base network to version 0.6, for changelog, see https://zenodo.org/records/14144752

* Bugfix: vehicle-to-grid dispatch capacity is now limited by the fraction of vehicles participating in demand-side-management, halving the dispatch capacity under the default demand-side management participation rate of 0.5.

Expand Down
2 changes: 2 additions & 0 deletions rules/build_electricity.smk
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,8 @@ if config["electricity"]["base_network"] == "osm-raw":
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"),
stations_polygon=resources("osm-raw/build/geojson/stations_polygon.geojson"),
buses_polygon=resources("osm-raw/build/geojson/buses_polygon.geojson"),
log:
logs("build_osm_network.log"),
benchmark:
Expand Down
5 changes: 5 additions & 0 deletions rules/development.smk
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@
if config["electricity"]["base_network"] == "osm-raw":

rule prepare_osm_network_release:
params:
line_types=config["lines"]["types"],
input:
base_network=resources("networks/base.nc"),
stations_polygon=resources("osm-raw/build/geojson/stations_polygon.geojson"),
buses_polygon=resources("osm-raw/build/geojson/buses_polygon.geojson"),
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"),
map=resources("osm-raw/release/map.html"),
log:
logs("prepare_osm_network_release.log"),
benchmark:
Expand Down
5 changes: 5 additions & 0 deletions rules/retrieve.smk
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,7 @@ if config["enable"]["retrieve"] and (
0.3: "13358976",
0.4: "13759222",
0.5: "13981528",
0.6: "14144752",
}

# update rule to use the correct version
Expand All @@ -566,12 +567,16 @@ if config["enable"]["retrieve"] and (
transformers=storage(
f"https://zenodo.org/records/{osm_prebuilt_version[config['electricity']['osm-prebuilt-version']]}/files/transformers.csv"
),
map=storage(
f"https://zenodo.org/records/{osm_prebuilt_version[config['electricity']['osm-prebuilt-version']]}/files/map.html"
),
output:
buses=f"data/osm-prebuilt/{config['electricity']['osm-prebuilt-version']}/buses.csv",
converters=f"data/osm-prebuilt/{config['electricity']['osm-prebuilt-version']}/converters.csv",
lines=f"data/osm-prebuilt/{config['electricity']['osm-prebuilt-version']}/lines.csv",
links=f"data/osm-prebuilt/{config['electricity']['osm-prebuilt-version']}/links.csv",
transformers=f"data/osm-prebuilt/{config['electricity']['osm-prebuilt-version']}/transformers.csv",
map=f"data/osm-prebuilt/{config['electricity']['osm-prebuilt-version']}/map.html",
log:
"logs/retrieve_osm_prebuilt.log",
threads: 1
Expand Down
43 changes: 35 additions & 8 deletions scripts/build_osm_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -1429,7 +1429,7 @@ def _finalise_network(all_buses, converters, lines, links, transformers):
lines_all["voltage"] = lines_all["voltage"] / 1000
lines_all["length"] = lines_all["length"].round(2)
lines_all["under_construction"] = False
lines_all["tags"] = lines_all["contains_lines"]
lines_all["tags"] = lines_all["contains_lines"].apply(lambda x: ";".join(x))
lines_all["underground"] = lines_all["underground"].replace({True: "t", False: "f"})
lines_all["under_construction"] = lines_all["under_construction"].replace(
{True: "t", False: "f"}
Expand Down Expand Up @@ -1581,12 +1581,33 @@ def build_network(
lines["length"] = lines.to_crs(DISTANCE_CRS).length
links["length"] = links.to_crs(DISTANCE_CRS).length

# Shapes
stations_polygon = stations[["station_id", "geometry"]].copy()
all_buses_polygon = buses_polygon.copy()
all_buses_polygon["dc"] = False
all_buses_polygon = pd.concat(
[
all_buses_polygon,
dc_buses[["bus_id", "polygon", "dc"]].rename(
columns={"polygon": "geometry"}
),
]
)

### Saving outputs to PyPSA-compatible format
buses_final, converters_final, lines_final, links_final, transformers_final = (
_finalise_network(all_buses, converters, lines, links, transformers)
)

return buses_final, converters_final, lines_final, links_final, transformers_final
return (
buses_final,
converters_final,
lines_final,
links_final,
transformers_final,
stations_polygon,
all_buses_polygon,
)


if __name__ == "__main__":
Expand All @@ -1604,16 +1625,18 @@ def build_network(
country_shapes = gpd.read_file(snakemake.input["country_shapes"]).set_index("name")

# Build network
buses, converters, lines, links, transformers = build_network(
snakemake.input,
country_shapes,
voltages,
line_types,
buses, converters, lines, links, transformers, stations_polygon, buses_polygon = (
build_network(
snakemake.input,
country_shapes,
voltages,
line_types,
)
)

# Export to csv for base_network
buses.to_csv(snakemake.output["substations"], quotechar="'")
lines.drop(columns=["tags"]).to_csv(snakemake.output["lines"], quotechar="'")
lines.to_csv(snakemake.output["lines"], quotechar="'")
links.to_csv(snakemake.output["links"], quotechar="'")
converters.to_csv(snakemake.output["converters"], quotechar="'")
transformers.to_csv(snakemake.output["transformers"], quotechar="'")
Expand All @@ -1624,3 +1647,7 @@ def build_network(
links.to_file(snakemake.output["links_geojson"])
converters.to_file(snakemake.output["converters_geojson"])
transformers.to_file(snakemake.output["transformers_geojson"])

# Export polygons for visualisation
stations_polygon.to_file(snakemake.output["stations_polygon"])
buses_polygon.to_file(snakemake.output["buses_polygon"])
Loading
Loading