2023-03-06 08:27:45 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2021-11-03 19:34:43 +00:00
|
|
|
"""
|
2023-03-06 08:27:45 +00:00
|
|
|
Retrieve gas infrastructure data from
|
|
|
|
https://zenodo.org/record/4767098/files/IGGIELGN.zip.
|
2021-11-03 19:34:43 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
import logging
|
|
|
|
import zipfile
|
|
|
|
from pathlib import Path
|
|
|
|
|
2023-03-06 08:27:45 +00:00
|
|
|
from helper import progress_retrieve
|
|
|
|
|
2021-11-03 19:34:43 +00:00
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2023-03-06 08:27:45 +00:00
|
|
|
if "snakemake" not in globals():
|
2021-11-03 19:34:43 +00:00
|
|
|
from helper import mock_snakemake
|
2023-03-06 08:27:45 +00:00
|
|
|
|
|
|
|
snakemake = mock_snakemake("retrieve_gas_network_data")
|
|
|
|
rootpath = ".."
|
2021-11-03 19:34:43 +00:00
|
|
|
else:
|
2023-03-06 08:27:45 +00:00
|
|
|
rootpath = "."
|
2021-11-03 19:34:43 +00:00
|
|
|
|
|
|
|
url = "https://zenodo.org/record/4767098/files/IGGIELGN.zip"
|
|
|
|
|
|
|
|
# Save locations
|
|
|
|
zip_fn = Path(f"{rootpath}/IGGIELGN.zip")
|
|
|
|
to_fn = Path(f"{rootpath}/data/gas_network/scigrid-gas")
|
|
|
|
|
|
|
|
logger.info(f"Downloading databundle from '{url}'.")
|
|
|
|
progress_retrieve(url, zip_fn)
|
|
|
|
|
|
|
|
logger.info(f"Extracting databundle.")
|
|
|
|
zipfile.ZipFile(zip_fn).extractall(to_fn)
|
|
|
|
|
|
|
|
zip_fn.unlink()
|
|
|
|
|
|
|
|
logger.info(f"Gas infrastructure data available in '{to_fn}'.")
|