diff --git a/doc/release_notes.rst b/doc/release_notes.rst index b0a9cfff6..bb7334c67 100644 --- a/doc/release_notes.rst +++ b/doc/release_notes.rst @@ -20,12 +20,9 @@ E.g. if a new rule becomes available describe how to use it `snakemake -j1 run_t * Minor bug-fixing for GADM_ID format naming. `PR #980 `__ and `PR #986 `__ - * Keep data on the original voltage value when rebasing voltages to the standard values and adjust the transmission capacity accordingly. `PR #898 `__ -* Minor bug-fixing for GADM_ID format naming. `PR #980 `__ - -* Fix download_osm_data compatibility for earth-osm v2.1. `PR #954 `__ +* Fix download_osm_data compatibility for earth-osm v2.1. `PR #954 `__ and `PR #988 `__ PyPSA-Earth 0.3.0 ================= diff --git a/scripts/download_osm_data.py b/scripts/download_osm_data.py index b01a17608..aeafb3089 100644 --- a/scripts/download_osm_data.py +++ b/scripts/download_osm_data.py @@ -120,7 +120,7 @@ def convert_iso_to_geofk( out_path = Path.joinpath(store_path_resources, "out") names = ["generator", "cable", "line", "substation"] - format = ["csv", "geojson"] + out_formats = ["csv", "geojson"] new_files = os.listdir(out_path) # list downloaded osm files # earth-osm (eo) only outputs files with content @@ -128,14 +128,14 @@ def convert_iso_to_geofk( # This is a workaround to create empty files for the workflow # Rename and move osm files to the resources folder output - for file in new_files: - for name in names: - for f in format: - ext = f"{name}.{f}" - if ext in file: - new_file_name = Path.joinpath( - store_path_resources, f"all_raw_{name}s.{f}" - ) - old_file_name = Path.joinpath(out_path, file) - logger.info(f"Move {old_file_name} to {new_file_name}") - shutil.move(old_file_name, new_file_name) + for name in names: + for f in out_formats: + new_file_name = Path.joinpath(store_path_resources, f"all_raw_{name}s.{f}") + old_files = list(Path(out_path).glob(f"*{name}.{f}")) + # if file is missing, create empty file, otherwise rename it an move it + if not old_files: + with open(new_file_name, "w") as f: + pass + else: + logger.info(f"Move {old_files[0]} to {new_file_name}") + shutil.move(old_files[0], new_file_name)