How to use the pooch.create function in pooch

To help you get started, we’ve selected a few pooch examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github JustinGOSSES / predictatops / predictatops / fetch_demo_data.py View on Github external
NOTE: This was changed since version 1 to pull in a single zip file and unzip it as that's faster than pulling in each file unzipped individually!
"""


##### import statements #####
import pooch
import os
from zipfile import ZipFile

# Get the version string from your project. You have one of these, right?
# from . import version

data_path = "../data/Mannville_input_data/"

# Create a new friend to manage your sample data storage
GOODBOY = pooch.create(
    # Folder where the data will be stored. For a sensible default, use the default
    # cache folder for your OS.
    # path=pooch.os_cache("mypackage_test"),
    # path=pooch.os_cache("mypackage_test"),
    path=data_path,
    # Base URL of the remote data store. Will call .format on this string to insert
    # https://github.com/JustinGOSSES/predictatops/
    # the version (see below).  https://github.com/JustinGOSSES/MannvilleGroup_Strat_Hackathon/tree/master/SPE_006_originalData
    #base_url="https://github.com/JustinGOSSES/predictatops/raw/{version}/demo/mannville_demo_data/",
    base_url="https://github.com/JustinGOSSES/predictatops/raw/{version}/demo/",
    # Pooches are versioned so that you can use multiple versions of a package
    # simultaneously. Use PEP440 compliant version number. The version will be
    # appended to the path.
    #version="v0.0.0-alpha",
    version="v0.0.3-alpha",
    # If a version as a "+XX.XXXXX" suffix, we'll assume that this is a dev version
github icepack / icepack / icepack / datasets.py View on Github external
password = getpass('EarthData password: ')
    auth = (username, password)

    login = requests.get(url)
    downloader = pooch.HTTPDownloader(auth=auth, progressbar=True)
    try:
        downloader(login.url, output_file, dataset)
    except requests.exceptions.HTTPError as error:
        if 'Unauthorized' in str(error):
            pooch.get_logger().error('Wrong username/password!')
        raise error


nsidc_url = 'https://daacdata.apps.nsidc.org/pub/DATASETS/'

measures_antarctica = pooch.create(
    path=pooch.os_cache('icepack'),
    base_url='https://n5eil01u.ecs.nsidc.org/MEASURES/NSIDC-0754.001/1996.01.01/',
    registry={
        'antarctic_ice_vel_phase_map_v01.nc':
        'fa0957618b8bd98099f4a419d7dc0e3a2c562d89e9791b4d0ed55e6017f52416'
    }
)

def fetch_measures_antarctica():
    return measures_antarctica.fetch('antarctic_ice_vel_phase_map_v01.nc',
                                     downloader=_earthdata_downloader)


measures_greenland = pooch.create(
    path=pooch.os_cache('icepack'),
    base_url=nsidc_url + 'NSIDC-0478.002/2015.0.01/',
github icepack / icepack / icepack / datasets.py View on Github external
path=pooch.os_cache('icepack'),
    base_url='https://n5eil01u.ecs.nsidc.org/MEASURES/NSIDC-0756.001/1970.01.01/',
    registry={
        'BedMachineAntarctica_2019-11-05_v01.nc':
        '06a01511a51bbc27d5080e4727a6523126659fe62402b03654a5335e25b614c0'
    }
)

def fetch_bedmachine_antarctica():
    return bedmachine_antarctica.fetch('BedMachineAntarctica_2019-11-05_v01.nc',
                                       downloader=_earthdata_downloader)


outlines_url = 'https://raw.githubusercontent.com/icepack/glacier-meshes/'
outlines_commit = 'a522188dadb9ba49d4848ba66cab8c90f9fda5d9'
larsen_outline = pooch.create(
    path=pooch.os_cache('icepack'),
    base_url=outlines_url + outlines_commit + '/glaciers/',
    registry={
        'larsen.geojson':
        'da77c1920191d415961347b43e18d5bc2ffd72ddb803c01fc24c68c5db0f3033'
    }
)

def fetch_larsen_outline():
    return larsen_outline.fetch(
        'larsen.geojson', downloader=pooch.HTTPDownloader(progressbar=True)
    )


moa = pooch.create(
    path=pooch.os_cache('icepack'),
github fatiando / rockhound / rockhound / registry.py View on Github external
"""
Create a dataset registry using Pooch and the rockhound/registry.txt file.
"""
import os

import pooch


REGISTRY = pooch.create(
    path=pooch.os_cache("rockhound"), base_url="", env="ROCKHOUND_DATA_DIR"
)
REGISTRY.load_registry(os.path.join(os.path.dirname(__file__), "registry.txt"))


def data_location():
    r"""
    The absolute path to the data storage location on disk.

    This is where the data sets are saved on your computer. The data location
    is dependent on the operating system. The folder locations are defined by
    the ``appdirs``  package (see the
    `appdirs documentation `__).
    It can also be overwritten by the ``ROCKHOUND_DATA_DIR`` environment
    variable.
github mathause / regionmask / regionmask / defined_regions / _ressources.py View on Github external
import geopandas as gp
import pooch

REMOTE_RESSOURCE = pooch.create(
    # Use the default cache folder for the OS
    path=pooch.os_cache("regionmask"),
    # The remote data is on Github
    base_url="https://github.com/mathause/regionmask/raw/master/data/",
    registry={
        "CMIP6_referenceRegions.zip": "d05cd29fb0d0f21e696f118efdb9e9d87815096844d52d989affd513e9f597d1",
        "CMIP6_referenceRegions_pre_revisions.zip": "8507cef52057785117cabc83d6e03414b5994745bf7f297c179eb50507f7ee89",
    },
)


def fetch_remote_shapefile(name):
    """
    uses pooch to cache files
    """
github fatiando / verde / verde / datasets / sample_data.py View on Github external
import pooch

try:
    import cartopy.feature as cfeature
    import cartopy.crs as ccrs
    from cartopy.mpl.ticker import LongitudeFormatter, LatitudeFormatter
except ImportError:
    pass

from ..version import full_version


# Otherwise, DeprecationWarning won't be shown, kind of defeating the purpose.
warnings.simplefilter("default")

POOCH = pooch.create(
    path=["~", ".verde", "data"],
    base_url="https://github.com/fatiando/verde/raw/{version}/data/",
    version=full_version,
    version_dev="master",
    env="VERDE_DATA_DIR",
)
POOCH.load_registry(os.path.join(os.path.dirname(__file__), "registry.txt"))


def _setup_map(
    ax, xticks, yticks, crs, region, land=None, ocean=None, borders=None, states=None
):
    """
    Setup a Cartopy map with land and ocean features and proper tick labels.
    """
github fatiando / harmonica / harmonica / datasets / sample_data.py View on Github external
"""
Functions to load sample datasets used in the Harmonica docs.
"""
import pkg_resources
import xarray as xr
import pandas as pd
import pooch

from ..version import full_version

REGISTRY = pooch.create(
    path=pooch.os_cache("harmonica"),
    base_url="https://github.com/fatiando/harmonica/raw/{version}/data/",
    version=full_version,
    version_dev="master",
    env="HARMONICA_DATA_DIR",
)
with pkg_resources.resource_stream(
    "harmonica.datasets", "registry.txt"
) as registry_file:
    REGISTRY.load_registry(registry_file)


def locate():
    r"""
    The absolute path to the sample data storage location on disk.
github Unidata / MetPy / src / metpy / cbook.py View on Github external
# Copyright (c) 2008,2015,2018,2019 MetPy Developers.
# Distributed under the terms of the BSD 3-Clause License.
# SPDX-License-Identifier: BSD-3-Clause
"""Collection of generally useful utility code from the cookbook."""

import os

import numpy as np
import pooch

from . import __version__

POOCH = pooch.create(
    path=pooch.os_cache('metpy'),
    base_url='https://github.com/Unidata/MetPy/raw/{version}/staticdata/',
    version='v' + __version__,
    version_dev='master')

# Check if we have the data available directly from a git checkout, either from the
# TEST_DATA_DIR variable, or looking relative to the path of this module's file. Use this
# to override Pooch's path.
dev_data_path = os.environ.get('TEST_DATA_DIR',
                               os.path.join(os.path.dirname(__file__),
                                            '..', '..', 'staticdata'))
if os.path.exists(dev_data_path):
    POOCH.path = dev_data_path

POOCH.load_registry(os.path.join(os.path.dirname(__file__), 'static-data-manifest.txt'))