From 83ff4fcf55148c11de5b0ee1337d61a94f926b76 Mon Sep 17 00:00:00 2001 From: tomvothecoder Date: Thu, 3 Oct 2024 11:42:33 -0700 Subject: [PATCH] Add `xc.tutorial.load_dataset()` API --- conda-env/dev.yml | 1 + xcdat/__init__.py | 1 + xcdat/tutorial.py | 11 +++++++++++ 3 files changed, 13 insertions(+) create mode 100644 xcdat/tutorial.py diff --git a/conda-env/dev.yml b/conda-env/dev.yml index eca2f9cf..5c7f1e6e 100644 --- a/conda-env/dev.yml +++ b/conda-env/dev.yml @@ -32,6 +32,7 @@ dependencies: - pandoc - ipython # Required for nbsphinx syntax highlighting - gsw-xarray # Required for vertical regridding example + - pooch # Required for xarray tutorial data # Quality Assurance # ================== - types-python-dateutil diff --git a/xcdat/__init__.py b/xcdat/__init__.py index cae99097..0af6d9ef 100644 --- a/xcdat/__init__.py +++ b/xcdat/__init__.py @@ -19,6 +19,7 @@ ) from xcdat.spatial import SpatialAccessor # noqa: F401 from xcdat.temporal import TemporalAccessor # noqa: F401 +from xcdat.tutorial import load_dataset # noqa: F401 from xcdat.utils import compare_datasets # noqa: F401 __version__ = "0.7.2" diff --git a/xcdat/tutorial.py b/xcdat/tutorial.py new file mode 100644 index 00000000..43c923e4 --- /dev/null +++ b/xcdat/tutorial.py @@ -0,0 +1,11 @@ +import xarray as xr +from xarray.tutorial import load_dataset as xr_load_dataset + +import xcdat.bounds # noqa: F401 + + +def load_dataset(name: str) -> xr.Dataset: + ds = xr_load_dataset(name) + ds = ds.bounds.add_missing_bounds(axes=["X", "Y", "T"]) + + return ds