Skip to content

Commit

Permalink
DOC: add section about Xarray datasets
Browse files Browse the repository at this point in the history
  • Loading branch information
mgeier committed Oct 1, 2024
1 parent 84b9575 commit 1fda481
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
43 changes: 43 additions & 0 deletions doc/code-cells.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,49 @@
"df"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Xarray Datasets\n",
"\n",
"[Xarray datasets](https://docs.xarray.dev/en/stable/generated/xarray.Dataset.html)\n",
"should also be shown in their beautiful HTML representation.\n",
"LaTeX/PDF output will fall back to the plain text representation."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import xarray as xr"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"a = {}\n",
"for name in [\"t\", \"q\"]: \n",
" da = xr.DataArray(\n",
" [\n",
" [[11, 12, 13], [21, 22, 23], [31, 32, 33]],\n",
" [[14, 15, 16], [24, 25, 26], [34, 35, 36]],\n",
" ],\n",
" coords={\"level\": [\"500\", \"700\"], \"x\": [1, 2, 3], \"y\": [4, 5, 6]},\n",
" name=name,\n",
" attrs={\"param\": name}\n",
" )\n",
" a[name] = da\n",
"\n",
"ds = xr.Dataset(a, attrs={\"title\": \"Demo dataset\", \"year\": 2024})\n",
"ds"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down
1 change: 1 addition & 0 deletions doc/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ numpy
matplotlib
ipympl
pandas
xarray
# setuptools seems to be needed for pybtex, see
# https://github.com/mcmtroffaes/sphinxcontrib-bibtex/issues/345:
setuptools
Expand Down

0 comments on commit 1fda481

Please sign in to comment.