Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 0 additions & 2 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ build:
tools:
python: "miniforge3-25.11"
jobs:
post_create_environment:
- mamba install --quiet --name ${READTHEDOCS_VERSION} -c conda-forge "python>=3.12,<3.13" "psy-maps>=1.5.0"
pre_build:
- env SPHINX_APIDOC_OPTIONS="members,undoc-members,show-inheritance,no-index" sphinx-apidoc -o docs/apidoc/ --private --module-first clisops

Expand Down
49 changes: 30 additions & 19 deletions docs/notebooks/regrid.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,23 @@
"# Initialize the testing data\n",
"import clisops.utils.testing as clite\n",
"\n",
"cache_dir = Path(clite.ESGF_TEST_DATA_CACHE_DIR or clite.default_esgf_test_data_cache)\n",
"cache_dir.mkdir(parents=True, exist_ok=True)\n",
"\n",
"Stratus = clite.stratus(\n",
" repo=clite.ESGF_TEST_DATA_REPO_URL, branch=clite.ESGF_TEST_DATA_VERSION, cache_dir=clite.ESGF_TEST_DATA_CACHE_DIR\n",
" repo=clite.ESGF_TEST_DATA_REPO_URL,\n",
" branch=clite.ESGF_TEST_DATA_VERSION,\n",
" cache_dir=cache_dir,\n",
")\n",
"\n",
"mini_esgf_data = (\n",
" clite.get_esgf_file_paths(Stratus.path) or clite.get_esgf_glob_paths(Stratus.path) or clite.get_kerchunk_datasets()\n",
")"
" clite.get_esgf_file_paths(Stratus.path) | clite.get_esgf_glob_paths(Stratus.path) | clite.get_kerchunk_datasets()\n",
")\n",
"\n",
"\n",
"def fetch(key):\n",
" \"\"\"Download the test file for key on demand and return its local path.\"\"\"\n",
" return Stratus.fetch(Path(mini_esgf_data[key]).relative_to(Stratus.path).as_posix())"
Comment thread
Zeitsperre marked this conversation as resolved.
]
},
{
Expand All @@ -80,19 +90,19 @@
"One-line remapping with `clisops.ops.regrid`:\n",
"\n",
"```python\n",
"\n",
"def regrid(\n",
" ds: Union[xr.Dataset, str, Path],\n",
" ds: xr.Dataset | str | Path,\n",
" *,\n",
" method: Optional[str] = \"nearest_s2d\",\n",
" adaptive_masking_threshold: Optional[Union[int, float]] = 0.5,\n",
" grid: Optional[Union[xr.Dataset, xr.DataArray, int, float, tuple, str]] = \"adaptive\",\n",
" output_dir: Optional[Union[str, Path]] = None,\n",
" output_type: Optional[str] = \"netcdf\",\n",
" split_method: Optional[str] = \"time:auto\",\n",
" file_namer: Optional[str] = \"standard\",\n",
" keep_attrs: Optional[Union[bool, str]] = True,\n",
") -> List[Union[xr.Dataset, str]]:\n",
" method: str | None = \"nearest_s2d\",\n",
" adaptive_masking_threshold: int | float | None = 0.5,\n",
" grid: None | (xr.Dataset | xr.DataArray | int | float | tuple | str) = \"adaptive\",\n",
" mask: str | None = None,\n",
" output_dir: str | Path | None = None,\n",
" output_type: str | None = \"netcdf\",\n",
" split_method: str | None = \"time:auto\",\n",
" file_namer: str | None = \"standard\",\n",
" keep_attrs: bool | str | None = True,\n",
") -> list[xr.Dataset | str]:\n",
" pass\n",
"```\n",
"\n",
Expand Down Expand Up @@ -120,7 +130,7 @@
"metadata": {},
"outputs": [],
"source": [
"ds_vert = xr.open_dataset(mini_esgf_data[\"CMIP6_ATM_VERT_ONE_TIMESTEP\"])\n",
"ds_vert = xr.open_dataset(fetch(\"CMIP6_ATM_VERT_ONE_TIMESTEP\"))\n",
"ds_vert"
]
},
Expand Down Expand Up @@ -219,7 +229,7 @@
"metadata": {},
"outputs": [],
"source": [
"ds_cordex = xr.open_dataset(mini_esgf_data[\"CORDEX_TAS_ONE_TIMESTEP\"])\n",
"ds_cordex = xr.open_dataset(fetch(\"CORDEX_TAS_ONE_TIMESTEP\"))\n",
"ds_cordex"
]
},
Expand Down Expand Up @@ -309,7 +319,7 @@
"metadata": {},
"outputs": [],
"source": [
"ds_icono = xr.open_dataset(mini_esgf_data[\"CMIP6_UNSTR_VERT_ICON_O\"])\n",
"ds_icono = xr.open_dataset(fetch(\"CMIP6_UNSTR_VERT_ICON_O\"))\n",
"ds_icono"
]
},
Expand Down Expand Up @@ -486,7 +496,7 @@
"metadata": {},
"outputs": [],
"source": [
"dso = xr.open_dataset(mini_esgf_data[\"CMIP6_TOS_ONE_TIME_STEP\"])\n",
"dso = xr.open_dataset(fetch(\"CMIP6_TOS_ONE_TIME_STEP\"))\n",
"dso"
]
},
Expand Down Expand Up @@ -767,7 +777,7 @@
"metadata": {},
"outputs": [],
"source": [
"ds_vert = xr.open_dataset(mini_esgf_data[\"CMIP6_ATM_VERT_ONE_TIMESTEP\"])\n",
"ds_vert = xr.open_dataset(fetch(\"CMIP6_ATM_VERT_ONE_TIMESTEP\"))\n",
"ds_vert"
]
},
Expand Down Expand Up @@ -987,6 +997,7 @@
" * `False` : The resulting `xarray.Dataset` will have no attributes despite attributes generated by the regridding process.\n",
" * `\"target\"` : The resulting `xarray.Dataset` will have all attributes of `grid_out.ds.attrs`, despite attributes generated by the regridding process. Not recommended.\n",
"\n",
"\n",
"### In the following an example showing the function application and the effect of the adaptive masking."
]
},
Expand Down