def download_pysteps_data(dir_path, force=True):
    """
    Download pysteps data from github.

    Parameters
    ----------
    dir_path: str
        Path to directory where the psyteps data will be placed.
    force: bool
        If the destination directory exits and force=False, a DirectoryNotEmpty
        exception if raised.
        If force=True, the data will we downloaded in the destination directory and may
        override existing files.
    """

    # Check if directory exists but is not empty
    if os.path.exists(dir_path) and os.path.isdir(dir_path):
        if os.listdir(dir_path) and not force:
            raise DirectoryNotEmpty(
                dir_path + "is not empty.\n"
                "Set force=True force the extraction of the files."
            )
    else:
        os.makedirs(dir_path)

    # NOTE:
    # The http response from github can either contain Content-Length (size of the file)
    # or use chunked Transfer-Encoding.
    # If Transfer-Encoding is chunked, then the Content-Length is not available since
    # the content is dynamically generated and we can't know the length a priori easily.
    pbar = ShowProgress()
    print("Downloading pysteps-data from github.")
    tmp_file_name, _ = request.urlretrieve(
        "https://github.com/pySTEPS/pysteps-data/archive/master.zip",
        reporthook=pbar,
    )
    pbar.end(message="Download complete\n")

    with ZipFile(tmp_file_name, "r") as zip_obj:
        tmp_dir = TemporaryDirectory()

        # Extract all the contents of zip file in the temp directory
        common_path = os.path.commonprefix(zip_obj.namelist())

        zip_obj.extractall(tmp_dir.name)

        shutil.copytree(
            os.path.join(tmp_dir.name, common_path), dir_path, dirs_exist_ok=True
        )
Download pysteps data from github.

Parameters
----------
dir_path: str
Path to directory where the psyteps data will be placed.
force: bool
If the destination directory exits and force=False, a DirectoryNotEmpty
exception if raised.
If force=True, the data will we downloaded in the destination directory and may
override existing files.
pysteps/datasets.py