Skip to content

Commit

Permalink
fix: make previous OSM versions compatible (#1495)
Browse files Browse the repository at this point in the history
* fix: make previous OSM versions compatible

* [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>
  • Loading branch information
FabianHofmann and pre-commit-ci[bot] authored Jan 15, 2025
1 parent 939ec25 commit 62afc9e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 28 deletions.
1 change: 0 additions & 1 deletion matplotlibrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
#
# SPDX-License-Identifier: CC0-1.0
font.family: sans-serif
font.sans-serif: Ubuntu, DejaVu Sans
image.cmap: viridis
figure.autolayout : True
42 changes: 15 additions & 27 deletions rules/retrieve.smk
Original file line number Diff line number Diff line change
Expand Up @@ -539,8 +539,11 @@ if config["enable"]["retrieve"]:
if config["enable"]["retrieve"] and (
config["electricity"]["base_network"] == "osm-prebuilt"
):
# Dictionary of prebuilt versions, e.g. 0.3 : "13358976"
osm_prebuilt_version = {
OSM_VERSION = config["electricity"]["osm-prebuilt-version"]
OSM_COMPONENTS = ["buses", "converters", "lines", "links", "transformers"]
if OSM_VERSION >= 0.6:
OSM_COMPONENTS.append("map")
OSM_ZENODO_IDS = {
0.1: "12799202",
0.2: "13342577",
0.3: "13358976",
Expand All @@ -552,37 +555,22 @@ if config["enable"]["retrieve"] and (
# update rule to use the correct version
rule retrieve_osm_prebuilt:
input:
buses=storage(
f"https://zenodo.org/records/{osm_prebuilt_version[config['electricity']['osm-prebuilt-version']]}/files/buses.csv"
),
converters=storage(
f"https://zenodo.org/records/{osm_prebuilt_version[config['electricity']['osm-prebuilt-version']]}/files/converters.csv"
),
lines=storage(
f"https://zenodo.org/records/{osm_prebuilt_version[config['electricity']['osm-prebuilt-version']]}/files/lines.csv"
),
links=storage(
f"https://zenodo.org/records/{osm_prebuilt_version[config['electricity']['osm-prebuilt-version']]}/files/links.csv"
),
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"
),
[
storage(
f"https://zenodo.org/records/{OSM_ZENODO_IDS[OSM_VERSION]}/files/{component}.csv"
)
for component in OSM_COMPONENTS
],
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",
[
f"data/osm-prebuilt/{OSM_VERSION}/{component}.csv"
for component in OSM_COMPONENTS
],
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])
Expand Down

0 comments on commit 62afc9e

Please sign in to comment.