How to use the pooch.os_cache 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 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'))
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
    """

    # the file will be downloaded automatically the first time this is run.
    return REMOTE_RESSOURCE.fetch(name)
github icepack / icepack / icepack / datasets.py View on Github external
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'),
    base_url=nsidc_url + 'nsidc0593_moa2009/geotiff/',
    registry={
        'moa750_2009_hp1_v01.1.tif.gz':
        '90d1718ea0971795ec102482c47f308ba08ba2b88383facb9fe210877e80282c'
    }
)

def fetch_mosaic_of_antarctica():
    return moa.fetch(
        'moa750_2009_hp1_v01.1.tif.gz',
        downloader=_earthdata_downloader,
        processor=pooch.Decompress()
    )
github icepack / icepack / icepack / datasets.py View on Github external
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/',
    registry={
        'greenland_vel_mosaic200_2015_2016_vx_v02.1.tif':
        '77b8eb65a4718da055bb048b75c35b48ca43d76b5bffb650932128d60ed28598',
        'greenland_vel_mosaic200_2015_2016_vy_v02.1.tif':
        'fb5dbc07d032de9b1bdb0b990ed02a384964d73a150529515038139efb1e3193',
        'greenland_vel_mosaic200_2015_2016_ex_v02.1.tif':
        '7e980fb7845fb8517f3791c9b3912ac62d3ce760938d062f1a4d575fad02ad89',
        'greenland_vel_mosaic200_2015_2016_ey_v02.1.tif':
        '9a43092b4c92ac767dbc4e6b7d42e55887420bec94eb654382d724d2a2ab6d9a'
    }
)

def fetch_measures_greenland():
    return [
        measures_greenland.fetch(
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.

    Returns
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.

    This is where the data are saved on your computer. The location is