This repository has been archived by the owner on Oct 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add antarctic_ice_shelves_polys to download (#7)
* Bump the version number to 0.2.3 * Add antarctic_ice_shelves_polys to download This merge switches to using a python script to do the downloading. This let us get the version number more easily from cartopy, as well as add features that are not downloaded by default. I have kind of cheated by downloading the python file we want and then importing it as a module. If a better way exists, I'm eager to hear it!
- Loading branch information
Showing
3 changed files
with
55 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/usr/bin/env python | ||
import argparse | ||
import os | ||
import urllib.request | ||
import tempfile | ||
import cartopy | ||
from cartopy import config | ||
import sys | ||
|
||
|
||
def main(target_dir): | ||
try: | ||
os.makedirs(target_dir) | ||
except OSError: | ||
pass | ||
|
||
version = cartopy.__version__ | ||
|
||
with tempfile.TemporaryDirectory() as tmpdirname: | ||
target_dir = os.path.abspath(target_dir) | ||
owd = os.getcwd() | ||
os.chdir(tmpdirname) | ||
urllib.request.urlretrieve( | ||
'https://raw.githubusercontent.com/SciTools/cartopy/v{}/tools/feature_download.py'.format(version), | ||
'feature_download.py') | ||
|
||
file = open('__init__.py', 'w') | ||
file.close() | ||
|
||
sys.path.append(tmpdirname) | ||
|
||
from feature_download import FEATURE_DEFN_GROUPS, download_features | ||
|
||
# add Antarctic ice shelves | ||
FEATURE_DEFN_GROUPS['physical'] = \ | ||
FEATURE_DEFN_GROUPS['physical'] + \ | ||
(('physical', 'antarctic_ice_shelves_polys', ('50m', '10m')),) | ||
|
||
config['pre_existing_data_dir'] = target_dir | ||
config['data_dir'] = target_dir | ||
config['repo_data_dir'] = target_dir | ||
download_features( | ||
['cultural-extra', 'cultural', 'gshhs', 'physical'], dry_run=False) | ||
os.chdir(owd) | ||
|
||
|
||
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser( | ||
description='Download cartopy data for caching.') | ||
parser.add_argument('--output', '-o', required=True, | ||
help='save datasets in the specified directory') | ||
args = parser.parse_args() | ||
main(args.output) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
from setuptools import setup | ||
|
||
setup(name='cartopy_offlinedata', | ||
version='0.2.2', | ||
version='0.2.3', | ||
description='Add shared data path to cartopy config', | ||
url='https://github.com/willirath/cartopy_offlinedata', | ||
author='Willi Rath', | ||
author_email='[email protected]', | ||
license='MIT', | ||
packages=['cartopy_userconfig'], | ||
scripts=['bin/download_cartopy_data.sh'], | ||
scripts=['bin/download_cartopy_data.py'], | ||
zip_safe=False) |