2023-03-06 08:27:45 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2024-02-19 15:21:48 +00:00
|
|
|
# SPDX-FileCopyrightText: : 2021-2024 The PyPSA-Eur Authors
|
2023-03-06 17:49:23 +00:00
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: MIT
|
2021-11-03 19:34:43 +00:00
|
|
|
"""
|
|
|
|
Retrieve gas infrastructure data from
|
2024-04-15 13:14:02 +00:00
|
|
|
https://zenodo.org/records/4767098/files/IGGIELGN.zip.
|
2021-11-03 19:34:43 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
import logging
|
|
|
|
import zipfile
|
|
|
|
from pathlib import Path
|
|
|
|
|
2024-02-12 10:53:20 +00:00
|
|
|
from _helpers import (
|
|
|
|
configure_logging,
|
|
|
|
progress_retrieve,
|
|
|
|
set_scenario_config,
|
|
|
|
validate_checksum,
|
2024-02-12 10:54:13 +00:00
|
|
|
)
|
2023-03-06 08:27:45 +00:00
|
|
|
|
2021-11-03 19:34:43 +00:00
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
if "snakemake" not in globals():
|
2023-03-06 18:09:45 +00:00
|
|
|
from _helpers import mock_snakemake
|
2023-03-06 08:27:45 +00:00
|
|
|
|
2021-11-03 19:34:43 +00:00
|
|
|
snakemake = mock_snakemake("retrieve_gas_network_data")
|
|
|
|
rootpath = ".."
|
|
|
|
else:
|
|
|
|
rootpath = "."
|
2024-02-12 10:53:20 +00:00
|
|
|
configure_logging(snakemake)
|
|
|
|
set_scenario_config(snakemake)
|
2021-11-03 19:34:43 +00:00
|
|
|
|
2024-04-15 13:14:02 +00:00
|
|
|
url = "https://zenodo.org/records/4767098/files/IGGIELGN.zip"
|
2021-11-03 19:34:43 +00:00
|
|
|
|
|
|
|
# Save locations
|
|
|
|
zip_fn = Path(f"{rootpath}/IGGIELGN.zip")
|
2023-05-12 11:59:41 +00:00
|
|
|
to_fn = Path(rootpath) / Path(snakemake.output[0]).parent.parent
|
2021-11-03 19:34:43 +00:00
|
|
|
|
|
|
|
logger.info(f"Downloading databundle from '{url}'.")
|
2023-03-07 19:37:47 +00:00
|
|
|
disable_progress = snakemake.config["run"].get("disable_progressbar", False)
|
|
|
|
progress_retrieve(url, zip_fn, disable=disable_progress)
|
2021-11-03 19:34:43 +00:00
|
|
|
|
2023-12-29 11:34:14 +00:00
|
|
|
validate_checksum(zip_fn, url)
|
|
|
|
|
2023-03-07 16:21:00 +00:00
|
|
|
logger.info("Extracting databundle.")
|
2021-11-03 19:34:43 +00:00
|
|
|
zipfile.ZipFile(zip_fn).extractall(to_fn)
|
|
|
|
|
|
|
|
zip_fn.unlink()
|
|
|
|
|
|
|
|
logger.info(f"Gas infrastructure data available in '{to_fn}'.")
|