3
���hp � @ sD d Z ddlZddlmZ ddlmZ ej j
d�Zded fd
d�ZdS )
zR
Useful for:
* users learning xarray
* building tutorials in the documentation.
� N� )�open_dataset)�urlretrieve�~�.xarray_tutorial_dataTz%https://github.com/pydata/xarray-datac
K s� t jj|�}| d }t jj||f�}t jj|�sbt jj|�sFt j|� dj|dd|f�}t||� t |f|�j
� } |s�t j|� | S )ak
Load 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 netcdf file containing the dataset
ie. 'air_temperature'
cache_dir : string, optional
The directory in which to search for and write cached data.
cache : boolean, optional
If True, then cache data locally for use on subsequent calls
github_url : string
Github repository where the data is stored
kws : dict, optional
Passed to xarray.open_dataset
z.nc�/�rawZmaster)�_os�path�
expanduser�sep�join�exists�isdir�mkdir�_urlretrieve�
_open_dataset�load�remove)
�name�cache� cache_dirZ
github_url�kwsZlongdir�fullname� localfile�urlZds� r �//tmp/pip-build-5_djhm0z/xray/xarray/tutorial.py�load_dataset s
r )r r )
�__doc__�osr Zbackends.apir r Z
core.pycompatr r r r
Z_default_cache_dirr r r r r �<module> s |