Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace OPeNDAP datasets with Xarray tutorial datasets in docs #705

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions conda-env/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Below is a list of top-level API functions that are available in ``xcdat``.
create_grid
create_uniform_grid
create_zonal_grid
tutorial.open_dataset

Accessors
---------
Expand Down
Binary file removed docs/examples/temporal-average-yearly.gif
Binary file not shown.
3,842 changes: 1,246 additions & 2,596 deletions docs/examples/temporal-average.ipynb

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions xcdat/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Top-level package for xcdat."""

from xcdat import tutorial # noqa: F401
from xcdat.axis import ( # noqa: F401
center_times,
get_dim_coords,
Expand Down
60 changes: 60 additions & 0 deletions xcdat/tutorial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
from __future__ import annotations

from typing import TYPE_CHECKING

import xarray as xr
from xarray.tutorial import open_dataset as xr_open_dataset

import xcdat.bounds # noqa: F401

if TYPE_CHECKING:
import os

from xarray.backends.api import T_Engine


def open_dataset(
name: str,
cache: bool = True,
cache_dir: None | str | os.PathLike = None,
*,
engine: T_Engine = None,
**kws,
) -> xr.Dataset:
"""Open a dataset from the online repository (requires internet).

This function is a wrapper around ``xarray.tutorial.open_dataset`` that
adds missing bounds to the dataset. If a local copy of the dataset file is
found then always use that to avoid network traffic.

Available datasets:

* ``"air_temperature"``: NCEP reanalysis subset
* ``"air_temperature_gradient"``: NCEP reanalysis subset with approximate x,y gradients
* ``"basin_mask"``: Dataset with ocean basins marked using integers
* ``"ASE_ice_velocity"``: MEaSUREs InSAR-Based Ice Velocity of the Amundsen Sea Embayment, Antarctica, Version 1
* ``"rasm"``: Output of the Regional Arctic System Model (RASM)
* ``"ROMS_example"``: Regional Ocean Model System (ROMS) output
* ``"tiny"``: small synthetic dataset with a 1D data variable
* ``"era5-2mt-2019-03-uk.grib"``: ERA5 temperature data over the UK
* ``"eraint_uvz"``: data from ERA-Interim reanalysis, monthly averages of upper level data
* ``"ersstv5"``: NOAA's Extended Reconstructed Sea Surface Temperature monthly averages

Parameters
----------
name : str
Name of the file containing the dataset.
e.g. 'air_temperature'
cache_dir : path-like, optional
The directory in which to search for and write cached data.
cache : bool, optional
If True, then cache data locally for use on subsequent calls
**kws : dict, optional
Passed to xarray.open_dataset
"""
ds = xr_open_dataset(
name=name, cache=cache, cache_dir=cache_dir, engine=engine, **kws
)
ds = ds.bounds.add_missing_bounds(axes=["X", "Y", "T"])

return ds
Loading