Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ env:
# Maximum cache period (in weeks) before forcing a new cache upload.
CACHE_PERIOD: "2"
# Increment the build number to force new cartopy cache upload.
CARTOPY_CACHE_BUILD: "0"
CARTOPY_CACHE_BUILD: "1"
Comment thread
jamesp marked this conversation as resolved.
Outdated
# Increment the build number to force new conda cache upload.
CONDA_CACHE_BUILD: "0"
# Increment the build number to force new nox cache upload.
Expand Down Expand Up @@ -72,6 +72,12 @@ linux_task_template: &LINUX_TASK_TEMPLATE
fingerprint_script:
- echo "${CIRRUS_OS}"
- echo "$(date +%Y).$(expr $(date +%U) / ${CACHE_PERIOD}):${CARTOPY_CACHE_BUILD}"
populate_script:
- conda create --quiet --name cartopy-cache cartopy
- source ${HOME}/miniconda/etc/profile.d/conda.sh >/dev/null 2>&1
- conda activate cartopy-cache >/dev/null 2>&1
- python tools/cartopy_feature_download.py --output ${HOME}/.local/share/cartopy --nowarn
- conda deactivate >/dev/null 2>&1
Comment thread
bjlittle marked this conversation as resolved.
nox_cache:
folder: ${CIRRUS_WORKING_DIR}/.nox
reupload_on_changes: true
Expand Down
4 changes: 2 additions & 2 deletions docs/src/whatsnew/1.3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ Loading ABF/ABL Files
---------------------

Support for the ABF and ABL file formats (as
`defined <http://cliveg.bu.edu/modismisr/lai3g-fpar3g.html>`_ by the
climate and vegetation research group of Boston University), is
`defined <https://nasanex.s3.amazonaws.com/AVHRR/GIMMS/LAI3G/00README_V01.pdf>`_
by the climate and vegetation research group of Boston University), is
currently provided under the "experimental" system. As such, ABF/ABL
file detection is not automatically enabled.

Expand Down
2 changes: 1 addition & 1 deletion lib/iris/fileformats/abf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
Including this module adds ABF and ABL loading to the session's capabilities.

The documentation for this file format can be found
`here <http://cliveg.bu.edu/modismisr/lai3g-fpar3g.html>`_.
`here <https://nasanex.s3.amazonaws.com/AVHRR/GIMMS/LAI3G/00README_V01.pdf>`_.

"""

Expand Down
2 changes: 1 addition & 1 deletion lib/iris/fileformats/netcdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"""
Module to support the loading of a NetCDF file into an Iris cube.

See also: `netCDF4 python <http://code.google.com/p/netcdf4-python/>`_.
See also: `netCDF4 python <https://github.com/Unidata/netcdf4-python>`_

Also refer to document 'NetCDF Climate and Forecast (CF) Metadata Conventions'.

Expand Down
95 changes: 95 additions & 0 deletions tools/cartopy_feature_download.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Copyright Iris contributors
#
# This file is part of Iris and is released under the LGPL license.
# See COPYING and COPYING.LESSER in the root of the repository for full
# licensing details.
"""
A command line utility for downloading cartopy resources e.g.,

> python cartopy_feature_download.py --help


"""

import argparse
import os
import pathlib
import sys
import tempfile
import urllib.request

import cartopy
from cartopy import config

FEATURE_DOWNLOAD_URL = f"https://raw.githubusercontent.com/SciTools/cartopy/v{cartopy.__version__}/tools/feature_download.py"
# This will be the (more stable) cartopy resource endpoint from v0.19.0.post1+
URL_TEMPLATE = "https://naturalearth.s3.amazonaws.com/{resolution}_{category}/ne_{resolution}_{name}.zip"
SHP_NE_SPEC = ("shapefiles", "natural_earth")


def main(target_dir, features, dry_run):
target_dir = pathlib.Path(target_dir).expanduser().resolve()
target_dir.mkdir(parents=True, exist_ok=True)

with tempfile.TemporaryDirectory() as tmpdir:
cwd = pathlib.Path.cwd()
os.chdir(tmpdir)

# Download cartopy feature_download tool, which is not bundled
# within a cartopy package, and make it importable.
urllib.request.urlretrieve(FEATURE_DOWNLOAD_URL, "feature_download.py")
with open("__init__.py", "w"):
pass
sys.path.append(tmpdir)

from feature_download import download_features

# Configure the cartopy resource cache.
config["pre_existing_data_dir"] = str(target_dir)
config["data_dir"] = str(target_dir)
config["repo_data_dir"] = str(target_dir)
config["downloaders"][SHP_NE_SPEC].url_template = URL_TEMPLATE

# Perform download, or dry-run.
download_features(features, dry_run=dry_run)
os.chdir(cwd)


if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="Download cartopy data for caching."
)
parser.add_argument(
"--dryrun",
"-d",
action="store_true",
help="perform a dry-run of the download",
)
parser.add_argument(
"--feature",
"-f",
nargs="+",
default=["physical"],
help="list of one or more features to download",
)
parser.add_argument(
"--nowarn",
"-n",
action="store_true",
help="ignore cartopy DownloadWarning warnings",
)
parser.add_argument(
"--output",
"-o",
required=True,
help="save datasets in the specified directory",
)

args = parser.parse_args()

if args.nowarn:
import warnings

warnings.filterwarnings("ignore", category=cartopy.io.DownloadWarning)

main(args.output, args.feature, args.dryrun)