Exemplo n.º 1
0
def _create_image_fetcher():
    try:
        import pooch
    except ImportError:
        # Without pooch, fallback on the standard data directory
        # which for now, includes a few limited data samples
        return None, legacy_data_dir

    pooch_version = __version__.replace(".dev", "+")
    url = "https://github.com/histolab/histolab/raw/{version}/histolab/"

    # Create a new friend to manage your sample data storage
    image_fetcher = pooch.create(
        # Pooch uses appdirs to select an appropriate directory for the cache
        # on each platform.
        # https://github.com/ActiveState/appdirs
        # On linux this converges to
        # '$HOME/.cache/histolab-image'
        # With a version qualifier
        path=pooch.os_cache("histolab-images"),
        base_url=url,
        version=pooch_version,
        env="HISTOLAB_DATADIR",
        registry=registry,
        urls=registry_urls,
    )

    data_dir = os.path.join(str(image_fetcher.abspath), "data")
    return image_fetcher, data_dir
Exemplo n.º 2
0
def create_image_fetcher():
    try:
        import pooch
    except ImportError:
        # Without pooch, fallback on the standard data directory
        # which for now, includes a few limited data samples
        return None, legacy_data_dir

    # Pooch expects a `+` to exist in development versions.
    # Since scikit-image doesn't follow that convention, we have to manually
    # remove `.dev` with a `+` if it exists.
    # This helps pooch understand that it should look in master
    # to find the required files
    pooch_version = __version__.replace('.dev', '+')
    url = "https://github.com/scikit-image/scikit-image/raw/{version}/skimage/"

    # Create a new friend to manage your sample data storage
    image_fetcher = pooch.create(
        # Pooch uses appdirs to select an appropriate directory for the cache
        # on each platform.
        # https://github.com/ActiveState/appdirs
        # On linux this converges to
        # '$HOME/.cache/scikit-image'
        # With a version qualifier
        path=pooch.os_cache("scikit-image"),
        base_url=url,
        version=pooch_version,
        env="SKIMAGE_DATADIR",
        registry=registry,
        urls=registry_urls,
    )

    data_dir = osp.join(str(image_fetcher.abspath), 'data')
    return image_fetcher, data_dir
Exemplo n.º 3
0
def create_image_fetcher():
    try:
        import pooch
        # older versions of Pooch don't have a __version__ attribute
        if not hasattr(pooch, '__version__'):
            retry = {}
        else:
            pooch_version = pooch.__version__.lstrip('v')
            retry = {'retry_if_failed': 3}
            # Keep version check in synch with
            # scikit-image/requirements/optional.txt
            if version.parse(pooch_version) < version.parse('1.3.0'):
                # we need a more recent version of pooch to retry
                retry = {}
    except ImportError:
        # Without pooch, fallback on the standard data directory
        # which for now, includes a few limited data samples
        return None, legacy_data_dir

    # Pooch expects a `+` to exist in development versions.
    # Since scikit-image doesn't follow that convention, we have to manually
    # remove `.dev` with a `+` if it exists.
    # This helps pooch understand that it should look in master
    # to find the required files
    if '+git' in __version__:
        skimage_version_for_pooch = __version__.replace('.dev0+git', '+git')
    else:
        skimage_version_for_pooch = __version__.replace('.dev', '+')

    if '+' in skimage_version_for_pooch:
        url = ("https://github.com/scikit-image/scikit-image/raw/"
               "{version}/skimage/")
    else:
        url = ("https://github.com/scikit-image/scikit-image/raw/"
               "v{version}/skimage/")

    # Create a new friend to manage your sample data storage
    image_fetcher = pooch.create(
        # Pooch uses appdirs to select an appropriate directory for the cache
        # on each platform.
        # https://github.com/ActiveState/appdirs
        # On linux this converges to
        # '$HOME/.cache/scikit-image'
        # With a version qualifier
        path=pooch.os_cache("scikit-image"),
        base_url=url,
        version=skimage_version_for_pooch,
        version_dev="main",
        env="SKIMAGE_DATADIR",
        registry=registry,
        urls=registry_urls,
        # Note: this should read `retry_if_failed=3,`, but we generate that
        # dynamically at import time above, in case installed pooch is a less
        # recent version
        **retry,
    )

    data_dir = osp.join(str(image_fetcher.abspath), 'data')
    return image_fetcher, data_dir
Exemplo n.º 4
0
def _construct_cache_dir(path):
    import pooch

    if isinstance(path, pathlib.Path):
        path = os.fspath(path)
    elif path is None:
        path = pooch.os_cache(_default_cache_dir_name)

    return path
Exemplo n.º 5
0
Arquivo: data.py Projeto: scipp/ess
def _make_pooch():
    import pooch
    return pooch.create(
        path=pooch.os_cache('ess/amor'),
        env='ESS_AMOR_DATA_DIR',
        base_url='https://public.esss.dk/groups/scipp/ess/amor/{version}/',
        version=_version,
        registry={
            "reference.nxs": "md5:56d493c8051e1c5c86fb7a95f8ec643b",
            "sample.nxs": "md5:4e07ccc87b5c6549e190bc372c298e83"
        })
Exemplo n.º 6
0
def test_pooch():
    goodboy = pooch.create(
        # Use the default cache folder for the OS
        path=pooch.os_cache("plumbus"),
        # The remote data is on Github
        base_url="https://raw.githubusercontent.com/cgre-aachen/gempy_data/master/data"
                 "/gempy_models/Tutorial_ch1-8_Onlap_relations/",
        # If this is a development version, get the data from the master branch
        version_dev="master",
        # We'll load it from a file later
        registry={
        "Tutorial_ch1-8_Onlap_relations_faults.csv": "19uheidhlkjdwhoiwuhc0uhcwljchw9ochwochw89dcgw9dcgwc"
    },
    )
    print(goodboy)
Exemplo n.º 7
0
 def __init__(self, cache_dir=None):
     import json
     import pooch
     import pkg_resources
     if cache_dir is None:
         if os.path.isdir(soxs_cfg.get("soxs", "soxs_data_dir")):
             cache_dir = soxs_cfg.get("soxs", "soxs_data_dir")
         else:
             cache_dir = pooch.os_cache("soxs")
             
     self._registry = json.load(
         pkg_resources.resource_stream("soxs", "file_hash_registry.json"))
     self.pooch_obj = pooch.create(
         path=cache_dir,
         registry=self._registry,
         env="SOXS_DATA_DIR",
         base_url="https://hea-www.cfa.harvard.edu/soxs/soxs_responses/"
     )
     self.dl = pooch.HTTPDownloader(progressbar=True)
Exemplo n.º 8
0
def _make_pooch():
    import pooch
    return pooch.create(
        path=pooch.os_cache('scippneutron'),
        env='SCIPPNEUTRON_DATA_DIR',
        retry_if_failed=3,
        base_url='https://public.esss.dk/groups/scipp/scippneutron/{version}/',
        version=_version,
        registry={
            'iris26176_graphite002_sqw.nxs':
            'md5:7ea63f9137602b7e9b604fe30f0c6ec2',
            'loki-at-larmor.hdf5': 'md5:7fc48639bb2c409adb9a1dedd53d1c83',
            'powder-event.h5': 'md5:f92ca1da4c2d42c3d8a5d1b1d79aa5a4',
            'mcstas_sans.h5': 'md5:a608255dd757905490882eb35e209d12',
            'CNCS_51936_event.nxs': 'md5:5ba401e489260a44374b5be12b780911',
            'GEM40979.raw': 'md5:6df0f1c2fc472af200eec43762e9a874',
            'PG3_4844_calibration.h5': 'md5:290f5108aa9ff0b1c5a2ac8dc2c1cb15',
            'PG3_4844_event.nxs': 'md5:d5ae38871d0a09a28ae01f85d969de1e',
            'PG3_4866_event.nxs': 'md5:3d543bc6a646e622b3f4542bc3435e7e',
            'PG3_4871_event.nxs': 'md5:a3d0edcb36ab8e9e3342cd8a4440b779',
            'WISH00016748.raw': 'md5:37ecc6f99662b57e405ed967bdc068af',
        })
Exemplo n.º 9
0
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={
        "IPCC-WGI-reference-regions-v4.zip":
        "c83881a18e74912385ad578282de721cc8e866b62cbbc75446e52e7041c81cff",
        "IPCC-WGI-reference-regions-v1.zip":
        "8507cef52057785117cabc83d6e03414b5994745bf7f297c179eb50507f7ee89",
    },
)


def fetch_remote_shapefile(name):
    """
    uses pooch to cache files
    """

    # the file will be downloaded automatically the first time this is run.
    return REMOTE_RESSOURCE.fetch(name)


def read_remote_shapefile(name):

    fname = fetch_remote_shapefile(name)

    return gp.read_file("zip://" + fname)
Exemplo n.º 10
0
import tempfile
from pathlib import Path
from typing import Union

import pooch
"""
Load sample data.
"""

POOCH = pooch.create(
    # Use the default cache folder for the OS
    path=pooch.os_cache("bed_reader"),
    # The remote data is on Github
    base_url="https://raw.githubusercontent.com/" +
    "fastlmm/bed-reader/master/bed_reader/tests/data/",
    # If this is a development version, get the data from the master branch
    version_dev="master",
    # The registry specifies the files that can be fetched
    env="BED_READER_DATA_DIR",
)

# Get registry file from package_data
registry_file = Path(__file__).parent / "tests/registry.txt"
# Load this registry file
POOCH.load_registry(registry_file)


def sample_file(filepath: Union[str, Path]) -> str:
    """
    Retrieve a sample .bed file. (Also retrieves associated .fam and .bim files).
Exemplo n.º 11
0
from . import __version__

try:
    string_type = basestring
except NameError:
    string_type = str


# TODO: This can go away when we remove Python 2
def is_string_like(s):
    """Check if an object is a string."""
    return isinstance(s, string_type)


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

# Check if we're running from a git clone and if so, bash the path attribute with the path
# to git's local data store (un-versioned)
# Look for the staticdata directory (i.e. this is a git checkout)
if os.path.exists(os.path.join(os.path.dirname(__file__), '..', 'staticdata')):
    POOCH.path = os.path.join(os.path.dirname(__file__), '..', 'staticdata')

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


def get_test_data(fname, as_file_obj=True):
Exemplo n.º 12
0
import logging
from pathlib import Path

import pooch

__all__ = ["example_filepath"]

pooch.get_logger().setLevel(logging.ERROR)

goodboy = pooch.create(
    path=pooch.os_cache("hmmer"),
    base_url="https://hmmer-py.s3.eu-west-2.amazonaws.com/",
    registry={
        "Pfam-A_24.hmm.gz": "32791a1b50837cbe1fca1376a3e1c45bc84b32dd4fe28c92fd276f3f2c3a15e3"
    },
)


def example_filepath(filename: str) -> Path:
    return Path(goodboy.fetch(filename + ".gz", processor=pooch.Decompress()))
Exemplo n.º 13
0
import json
from pathlib import Path

from pkg_resources import resource_filename
import pooch

from .exceptions import ParameterError
from .decorators import deprecated

__all__ = [
    'example_audio_file', 'find_files', 'example', 'ex', 'list_examples',
    'example_info'
]

# Instantiate the pooch
__data_path = os.environ.get('LIBROSA_DATA_DIR', pooch.os_cache('librosa'))
__GOODBOY = pooch.create(__data_path,
                         base_url="https://librosa.org/data/audio/",
                         registry=None)

__GOODBOY.load_registry(
    resource_filename(__name__, str(Path('example_data') / 'registry.txt')))

with open(
        resource_filename(__name__, str(Path('example_data') / 'index.json')),
        'r') as fdesc:
    __TRACKMAP = json.load(fdesc)


def example(key, hq=False):
    """Retrieve the example recording identified by 'key'.
Exemplo n.º 14
0
    def __init__(
        self,
        cache_path=None,
        registry=None,
        project_dir=None,
        check_hash=True,
        show_progress=True,
    ):
        """Class to download FARS data from the NHTSA FTP repository.

        Note that on first run, this will take a long time to fully download the data, as the repository is large.
        Expect first run to take 5-10+ minutes, depending on your setup.

        Parameters
        ----------
        cache_path: `os.path` or path-like, or str, optional
            The path to save the downloaded FARS files to.
            Default is `pooch.os_cache("fars")`, the default cache path as defined by the OS. See `pooch` and
            `appdirs` documentations.
            If `str`, and `project_dir` is not `None`, files will be downloaded to `project_dir/cache_path`
        registry:
            Path to registry file. Defaults to path for packaged `registry.txt` file. Override at your own risk.
        project_dir:
            Top level directory for your current project. If a path is provided, and `cache_path` is left as default,
            files will be downloaded to `project_dir/data/fars`. If `cache_path` is not the default, files will be
            downloaded to `project_dir/cache_path`.
        check_hash: bool
            Flag to enforce pooch download behavior. Defaults to True. When False, force download of FARS resources
            regardless of hash mismatch against the local registry version. Useful for when the FARS
            database is updated before the registry can be modified. Should normally be left to default (False).
        show_progress: bool
            Use pooch built-in feature to show progress bars during download. Default True.
        """
        if project_dir:
            self.project_dir = project_dir
            if cache_path:
                self.cache_path = Path(project_dir) / cache_path
            else:
                self.cache_path = Path(project_dir) / "data" / "fars"
            self.project_dir.mkdir(parents=True, exist_ok=True)
            self.cache_path.mkdir(parents=True, exist_ok=True)
        else:
            self.project_dir = None
            if cache_path:
                self.cache_path = Path(cache_path)
                self.cache_path.mkdir(parents=True, exist_ok=True)
            else:
                self.cache_path = pooch.os_cache("fars")

        if registry:
            self.registry = Path(registry)
        else:
            self.registry = os.path.join(os.path.dirname(__file__),
                                         "registry.txt")

        self.check_hash = check_hash
        self.show_progress = show_progress

        self.GOODBOY = pooch.create(
            path=self.cache_path,
            base_url="https://www.nhtsa.gov/filebrowser/download/",
            registry=None,
            allow_updates=self.check_hash,
        )

        self.GOODBOY.load_registry(self.registry)
Exemplo n.º 15
0
import logging
from pathlib import Path

import pooch

__all__ = ["get"]

pooch.get_logger().setLevel(logging.ERROR)

registry = {
    "minifam.hmm.gz": "md5:2f0d22cec2ae29af4755913652d205d4",
    "pfam24.hmm.gz": "md5:e927fd1fc25bd56d8f70a3fa97223304",
}

goodboy = pooch.create(
    path=pooch.os_cache("deciphon"),
    base_url="https://deciphon.s3.amazonaws.com/",
    registry=registry,
)


def get(filename: str) -> Path:
    return Path(
        goodboy.fetch(filename + ".gz",
                      processor=pooch.Decompress(name=filename)))
Exemplo n.º 16
0
        downloader = pooch.HTTPDownloader(auth=auth, progressbar=True)
        try:
            login = requests.get(url)
            downloader(login.url, output_file, dataset)
        except requests.exceptions.HTTPError as error:
            if "Unauthorized" in str(error):
                pooch.get_logger().error("Wrong username/password!")
                self._username = None
                self._password = None
            raise error


_earthdata_downloader = EarthDataDownloader()


nsidc_data = pooch.create(path=pooch.os_cache("icepack"), base_url="", registry=None)

registry_nsidc = pkg_resources.resource_stream("icepack", "registry-nsidc.txt")
nsidc_data.load_registry(registry_nsidc)


def fetch_measures_antarctica():
    r"""Fetch the MEaSUREs Antarctic velocity map"""
    return nsidc_data.fetch(
        "antarctic_ice_vel_phase_map_v01.nc", downloader=_earthdata_downloader
    )


def fetch_measures_greenland():
    r"""Fetch the MEaSUREs Greenland velocity map"""
    return [
Exemplo n.º 17
0
try:
    import igraph as ig
except ModuleNotFoundError:
    ig = None

__all__ = [
    "available_networks",
    "available_ground_truths",
    "fetch_network_data",
    "fetch_ground_truth_data",
    "fetch_network_ground_truth",
]

__networks = pooch.create(
    path=pooch.os_cache("cdlib"),
    base_url=
    "https://github.com/GiulioRossetti/cdlib_datasets/raw/main/networks/",
    version_dev="master",
    env="cdlib_data_dir",
    registry={
        "karate_club.csv.gz":
        "0bac1a017e59f505f073aef6dc1783c03826a3fd4f38ffc6a50fde582948e2f2",
        "dblp.csv.gz":
        "6b64a23e60083fa52d64320a2cd4366ff1b33d8a89ac4fa1b30f159e88c1730c",
        "amazon.csv.gz":
        "aea015386f62b21ba31e097553a298fb3df610ec8dc722addb06a1a59e646cd3",
        "youtube.csv.gz":
        "dad87a04c648b31565448e7bef62ace569157aa58f7d2a0bb435eb490d0bf33e",
        "LFR_N100000_ad5_mc50_mu0.1.csv.gz":
        "54eb36e619fa7f6ff2dcbb4e5a43ee9885c8f4d9634fd9e48cdef3de963581ae",
Exemplo n.º 18
0
def open_dataset(
    name,
    engine=None,
    cache=True,
    cache_dir=None,
    **kws,
):
    """
    Open a dataset from the online repository (requires internet).

    If a local copy is found then always use that to avoid network traffic.

    Parameters
    ----------
    name : str
        Name of the file containing the dataset.
        e.g. 'air_temperature'
    engine : str, optional
        The engine to use.
    cache_dir : path-like, optional
        The directory in which to search for and write cached data.
    cache : bool, optional
        If True, then cache data locally for use on subsequent calls
    kws : dict, optional
        Passed to xarray.open_dataset

    Notes
    -----
    Available datasets:

    * ``"air_temperature"``
    * ``"rasm"``
    * ``"ROMS_example"``
    * ``"tiny"``
    * ``"era5-2mt-2019-03-uk.grib"``
    * ``"RGB.byte"``: example rasterio file from https://github.com/mapbox/rasterio

    See Also
    --------
    xarray.open_dataset
    """
    try:
        import pooch
    except ImportError:
        raise ImportError("using the tutorial data requires pooch")

    if isinstance(cache_dir, pathlib.Path):
        cache_dir = os.fspath(cache_dir)
    elif cache_dir is None:
        cache_dir = pooch.os_cache(_default_cache_dir_name)

    if name in external_urls:
        engine_, url = external_urls[name]
        if engine is None:
            engine = engine_
    else:
        # process the name
        default_extension = ".nc"
        path = pathlib.Path(name)
        if not path.suffix:
            path = path.with_suffix(default_extension)

        url = f"{base_url}/raw/{version}/{path.name}"

    _open = overrides.get(engine, _open_dataset)
    # retrieve the file
    filepath = pooch.retrieve(url=url, known_hash=None, path=cache_dir)
    ds = _open(filepath, engine=engine, **kws)
    if not cache:
        ds = ds.load()
        pathlib.Path(filepath).unlink()

    return ds
Exemplo n.º 19
0
import pooch as ppooch

from kikuchipy.signals import EBSD, EBSDMasterPattern
from kikuchipy import load
from kikuchipy.release import version
from kikuchipy.data._registry import registry, registry_urls

__all__ = [
    "nickel_ebsd_small",
    "nickel_ebsd_large",
    "nickel_ebsd_master_pattern_small",
]

fetcher = ppooch.create(
    path=ppooch.os_cache("kikuchipy"),
    base_url="",
    version=version.replace(".dev", "+"),
    env="KIKUCHIPY_DATA_DIR",
    registry=registry,
    urls=registry_urls,
)
cache_data_path = fetcher.path.joinpath("data")
package_data_path = Path(os.path.abspath(os.path.dirname(__file__)))


def _has_hash(path, expected_hash):
    """Check if the provided path has the expected hash."""
    if not os.path.exists(path):
        return False
    else:
Exemplo n.º 20
0
import pkg_resources
import numpy as np
import pandas as pd
import pooch

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

from ..version import full_version

REGISTRY = pooch.create(
    path=pooch.os_cache("verde"),
    base_url="https://github.com/fatiando/verde/raw/{version}/data/",
    version=full_version,
    version_dev="master",
    env="VERDE_DATA_DIR",
)
with pkg_resources.resource_stream("verde.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.

    This is where the data are saved on your computer. The location is
Exemplo n.º 21
0
# 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
from pathlib import Path

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='main')

# 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 and disable downloading from GitHub.
dev_data_path = os.environ.get('TEST_DATA_DIR',
                               Path(__file__).parents[2] / 'staticdata')
if Path(dev_data_path).exists():
    POOCH.path = dev_data_path
    POOCH.base_url = 'NODOWNLOAD:'

POOCH.load_registry(Path(__file__).parent / 'static-data-manifest.txt')

Exemplo n.º 22
0
# Since scikit-image doesn't follow that convention, we have to manually
# remove `.dev` with a `+` if it exists.
# This helps pooch understand that it should look in master
# to find the required files
pooch_version = __version__.replace('.dev', '+')
url = "https://github.com/scikit-image/scikit-image/raw/{version}/skimage/"

# Create a new friend to manage your sample data storage
image_fetcher = pooch.create(
    # Pooch uses appdirs to select an appropriate directory for the cache
    # on each platform.
    # https://github.com/ActiveState/appdirs
    # On linux this converges to
    # '$HOME/.cache/scikit-image'
    # With a version qualifier
    path=pooch.os_cache("scikit-image"),
    base_url=url,
    version=pooch_version,
    env="SKIMAGE_DATADIR",
    registry=registry,
    urls=registry_urls,
)

data_dir = osp.join(str(image_fetcher.abspath), 'data')

os.makedirs(data_dir, exist_ok=True)
shutil.copy2(osp.join(skimage_distribution_dir, 'data', 'README.txt'),
             osp.join(data_dir, 'README.txt'))


def _has_hash(path, expected_hash):
Exemplo n.º 23
0
def test_init_fetcher_defaults():
    fetcher = FARSFetcher()
    assert fetcher.get_show_progress() == True
    assert fetcher.get_data_path() == pooch.os_cache("fars")
Exemplo n.º 24
0
import pooch

# Going to set this up a bit later...
from . import __version__

_registry = {
    "fullSoy_2-12a.ply":
    "e12f192188058851289f0531dc456c6df31b562405b77e382e0f9e4b1c899108"
}

PLANTS = pooch.create(
    path=pooch.os_cache("hothouse"),
    base_url="https://github.com/MatthewTurk/hothouse/raw/{version}/data/",
    version=__version__,
    version_dev="master",
    env="HOTHOUSE_DATA_DIR",
    registry=_registry,
)
Exemplo n.º 25
0
import os
from getpass import getpass
import subprocess
import requests
import pooch
import mesh

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


def _earthdata_downloader(url, output_file, dataset):
    username = os.environ.get('EARTHDATA_USERNAME')
    if username is None:
        username = input('EarthData username: '******'EARTHDATA_PASSWORD')
    if password is None:
        password = getpass('EarthData password: ')

    login = requests.get(url)
    downloader = pooch.HTTPDownloader(auth=(username, password))
    downloader(login.url, output_file, dataset)

Exemplo n.º 26
0
# SPDX-License-Identifier: BSD-3-Clause
#
# This code is part of the Fatiando a Terra project (https://www.fatiando.org)
#
"""
Functions to load sample datasets used in the Harmonica docs.
"""
import pandas as pd
import pkg_resources
import pooch
import xarray as xr

from .._version import __version__ as version

REGISTRY = pooch.create(
    path=pooch.os_cache("harmonica"),
    base_url="https://github.com/fatiando/harmonica/raw/{version}/data/",
    version=version,
    version_dev="main",
    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.

    This is where the data are saved on your computer. The location is
Exemplo n.º 27
0
"""
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 <https://github.com/ActiveState/appdirs>`__).
    It can also be overwritten by the ``ROCKHOUND_DATA_DIR`` environment variable.

    Returns
    -------
    path : str
        The local data storage location.

    """
    return str(REGISTRY.abspath)
Exemplo n.º 28
0
"""
Driver Module 
"""
import os
import pkg_resources
import pooch
import importlib

from . import version

__all__ = ["SPATIALPOOCH"]

SPATIALPOOCH = pooch.create(
    path=pooch.os_cache("spatial-pooch"),
    base_url="https://github.com/achapkowski/spatial-pooch/raw/master/data/",#{version} - use if I am going to version the data
    #version="",#version.version, - use if data versioning is needed 
    version_dev="master",
    env="SPATIODATA")
SPATIALPOOCH.load_registry(
    os.path.join(os.path.dirname(__file__), 'registery.txt')
)

Exemplo n.º 29
0
import pooch

from .exceptions import ParameterError


__all__ = [
    "find_files",
    "example",
    "ex",
    "list_examples",
    "example_info",
]


# Instantiate the pooch
__data_path = os.environ.get("LIBROSA_DATA_DIR", pooch.os_cache("librosa"))
__GOODBOY = pooch.create(
    __data_path, base_url="https://librosa.org/data/audio/", registry=None
)

__GOODBOY.load_registry(
    resource_filename(__name__, str(Path("example_data") / "registry.txt"))
)

with open(
    resource_filename(__name__, str(Path("example_data") / "index.json")), "r"
) as fdesc:
    __TRACKMAP = json.load(fdesc)


def example(key, *, hq=False):
Exemplo n.º 30
0
        auth = self._get_credentials()
        downloader = pooch.HTTPDownloader(auth=auth, progressbar=True)
        try:
            login = requests.get(url)
            downloader(login.url, output_file, dataset)
        except requests.exceptions.HTTPError as error:
            if 'Unauthorized' in str(error):
                pooch.get_logger().error('Wrong username/password!')
                self._username = None
                self._password = None
            raise error


_earthdata_downloader = EarthDataDownloader()

nsidc_data = pooch.create(path=pooch.os_cache('icepack'),
                          base_url='',
                          registry=None)

registry_file = pkg_resources.resource_stream('icepack', 'registry.txt')
nsidc_data.load_registry(registry_file)


def fetch_measures_antarctica():
    r"""Fetch the MEaSUREs Antarctic velocity map"""
    return nsidc_data.fetch('antarctic_ice_vel_phase_map_v01.nc',
                            downloader=_earthdata_downloader)


def fetch_measures_greenland():
    r"""Fetch the MEaSUREs Greenland velocity map"""
Exemplo n.º 31
0
import scipy.signal
import scipy.fftpack as fft
from scipy.stats import pearsonr
import pkg_resources
from .exceptions import ParameterError

import os
import json
from pathlib import Path
from pkg_resources import resource_filename
import pooch

from . import version

# Instantiate the pooch
__data_path = os.environ.get("CARAT_DATA_DIR", pooch.os_cache("carat"))
__GOODBOY = pooch.create(
    __data_path,
    base_url=
    f"https://github.com/mrocamora/carat/raw/{version.version}/examples/data/",
    registry=None)

__GOODBOY.load_registry(
    pkg_resources.resource_stream(__name__,
                                  str(Path("example_data") / "registry.txt")))

with open(
        resource_filename(__name__, str(Path("example_data") / "index.json")),
        "r") as fdesc:
    __TRACKMAP = json.load(fdesc)