Skip to content

Commit

Permalink
add downloader
Browse files Browse the repository at this point in the history
  • Loading branch information
RondeauG committed Nov 20, 2024
1 parent 623ce86 commit 4448bfa
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions docs/notebooks/4_ensembles.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,25 @@
"metadata": {},
"outputs": [],
"source": [
"# from xclim.testing.utils import nimbus\n",
"from pathlib import Path\n",
"from urllib.parse import urljoin\n",
"# from pathlib import Path\n",
"# from urllib.parse import urljoin\n",
"\n",
"import pooch\n",
"from xclim.testing.utils import load_registry\n",
"# import pooch\n",
"# from xclim.testing.utils import load_registry\n",
"\n",
"\n",
"def nimbus():\n",
" repo = \"https://raw.githubusercontent.com/Ouranosinc/xclim-testdata/\"\n",
" branch = \"v2024.8.23\"\n",
" remote = urljoin(urljoin(repo, branch), \"data\")\n",
" return pooch.create(\n",
" path=Path(pooch.os_cache(\"xclim-testdata\")),\n",
" base_url=remote,\n",
" version=branch,\n",
" version_dev=branch,\n",
" allow_updates=True,\n",
" registry=load_registry(branch=branch, repo=repo),\n",
" )"
"# def nimbus():\n",
"# repo = \"https://raw.githubusercontent.com/Ouranosinc/xclim-testdata/\"\n",
"# branch = \"v2024.8.23\"\n",
"# remote = urljoin(urljoin(repo, branch), \"data\")\n",
"# return pooch.create(\n",
"# path=Path(pooch.os_cache(\"xclim-testdata\")),\n",
"# base_url=remote,\n",
"# version=branch,\n",
"# version_dev=branch,\n",
"# allow_updates=True,\n",
"# registry=load_registry(branch=branch, repo=repo),\n",
"# )"
]
},
{
Expand All @@ -69,9 +68,12 @@
"outputs": [],
"source": [
"import xarray as xr\n",
"from xclim.testing.utils import nimbus\n",
"\n",
"import xscen as xs\n",
"\n",
"downloader = pooch.HTTPDownloader(headers={\"User-Agent\": \"agent\"})\n",
"\n",
"datasets = {\n",
" \"ACCESS\": \"EnsembleStats/BCCAQv2+ANUSPLIN300_ACCESS1-0_historical+rcp45_r1i1p1_1950-2100_tg_mean_YS.nc\",\n",
" \"BNU-ESM\": \"EnsembleStats/BCCAQv2+ANUSPLIN300_BNU-ESM_historical+rcp45_r1i1p1_1950-2100_tg_mean_YS.nc\",\n",
Expand All @@ -81,7 +83,7 @@
"}\n",
"\n",
"for d in datasets:\n",
" file = nimbus().fetch(datasets[d])\n",
" file = nimbus().fetch(datasets[d], downloader=downloader)\n",
" ds = xr.open_dataset(file).isel(lon=slice(0, 4), lat=slice(0, 4))\n",
" ds = xs.climatological_op(\n",
" ds,\n",
Expand Down

0 comments on commit 4448bfa

Please sign in to comment.