* data: retrieve gdp and pop raw data for UA,MD * Updated retrieval code. * add_electricity script for UA and MD using updated, endogenised GDP and PPP data. * Outsourced building of gdp and ppp. Only called when UA and/or MD are in country list. * Accepted suggestion by @fneum in retrieve rule. * Cleaned determine_availability_matrix_MD_UA.py, removed redundant code * Updated build_gdp_pop_non_nuts3 script to use the mean to distribute GDP p.c. Added release notes. Bug fixes. * Bug fixes --> 'ppp' to 'pop' * Bug fix: only distribute load to buses with substation. * Updated to download GDP and population raster via PyPSA-Eur zenodo databundle. Removal of dedicated retrieve function. Updated release notes. * Updated release notes. * correct input file paths * update zenodo url for databundle release v0.3.0 * doc: update release_notes * minor adjustments: benchmark, increase mem_mb, remove plots, handling of optional inputs --------- Co-authored-by: bobbyxng <bobbyxng@gmail.com> Co-authored-by: Bobby Xiong <36541459+bobbyxng@users.noreply.github.com> Co-authored-by: Fabian Neumann <fabian.neumann@outlook.de>
69 lines
2.0 KiB
Python
69 lines
2.0 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Copyright 2019-2024 Fabian Hofmann (TUB, FIAS), Fabian Neumann (TUB)
|
|
# SPDX-FileCopyrightText: : 2017-2024 The PyPSA-Eur Authors
|
|
#
|
|
# SPDX-License-Identifier: MIT
|
|
"""
|
|
.. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.3517935.svg
|
|
:target: https://doi.org/10.5281/zenodo.3517935
|
|
|
|
The data bundle contains common GIS datasets like NUTS3 shapes, EEZ shapes,
|
|
CORINE Landcover, Natura 2000 and also electricity specific summary statistics
|
|
like historic per country yearly totals of hydro generation, GDP and population
|
|
data on NUTS3 levels and energy balances.
|
|
|
|
This rule downloads the data bundle from `zenodo
|
|
<https://doi.org/10.5281/zenodo.3517935>`_ and extracts it in the ``data``
|
|
sub-directory, such that all files of the bundle are stored in the
|
|
``data/bundle`` subdirectory.
|
|
|
|
**Outputs**
|
|
|
|
- ``data/bundle``: input data collected from various sources
|
|
|
|
"""
|
|
|
|
import logging
|
|
import tarfile
|
|
from pathlib import Path
|
|
|
|
from _helpers import (
|
|
configure_logging,
|
|
progress_retrieve,
|
|
set_scenario_config,
|
|
validate_checksum,
|
|
)
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
if "snakemake" not in globals():
|
|
from _helpers import mock_snakemake
|
|
|
|
snakemake = mock_snakemake("retrieve_databundle")
|
|
rootpath = ".."
|
|
else:
|
|
rootpath = "."
|
|
configure_logging(snakemake)
|
|
set_scenario_config(snakemake)
|
|
|
|
url = "https://zenodo.org/records/12760663/files/bundle.tar.xz"
|
|
|
|
tarball_fn = Path(f"{rootpath}/bundle.tar.xz")
|
|
to_fn = Path(rootpath) / Path(snakemake.output[0]).parent.parent
|
|
|
|
logger.info(f"Downloading databundle from '{url}'.")
|
|
disable_progress = snakemake.config["run"].get("disable_progressbar", False)
|
|
progress_retrieve(url, tarball_fn, disable=disable_progress)
|
|
|
|
validate_checksum(tarball_fn, url)
|
|
|
|
logger.info("Extracting databundle.")
|
|
tarfile.open(tarball_fn).extractall(to_fn)
|
|
|
|
logger.info("Unlinking tarball.")
|
|
tarball_fn.unlink()
|
|
|
|
logger.info(f"Databundle available in '{to_fn}'.")
|