Skip to content

Commit 1fda481

Browse files
committed
DOC: add section about Xarray datasets
1 parent 84b9575 commit 1fda481

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

doc/code-cells.ipynb

+43
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,49 @@
478478
"df"
479479
]
480480
},
481+
{
482+
"cell_type": "markdown",
483+
"metadata": {},
484+
"source": [
485+
"### Xarray Datasets\n",
486+
"\n",
487+
"[Xarray datasets](https://docs.xarray.dev/en/stable/generated/xarray.Dataset.html)\n",
488+
"should also be shown in their beautiful HTML representation.\n",
489+
"LaTeX/PDF output will fall back to the plain text representation."
490+
]
491+
},
492+
{
493+
"cell_type": "code",
494+
"execution_count": null,
495+
"metadata": {},
496+
"outputs": [],
497+
"source": [
498+
"import xarray as xr"
499+
]
500+
},
501+
{
502+
"cell_type": "code",
503+
"execution_count": null,
504+
"metadata": {},
505+
"outputs": [],
506+
"source": [
507+
"a = {}\n",
508+
"for name in [\"t\", \"q\"]: \n",
509+
" da = xr.DataArray(\n",
510+
" [\n",
511+
" [[11, 12, 13], [21, 22, 23], [31, 32, 33]],\n",
512+
" [[14, 15, 16], [24, 25, 26], [34, 35, 36]],\n",
513+
" ],\n",
514+
" coords={\"level\": [\"500\", \"700\"], \"x\": [1, 2, 3], \"y\": [4, 5, 6]},\n",
515+
" name=name,\n",
516+
" attrs={\"param\": name}\n",
517+
" )\n",
518+
" a[name] = da\n",
519+
"\n",
520+
"ds = xr.Dataset(a, attrs={\"title\": \"Demo dataset\", \"year\": 2024})\n",
521+
"ds"
522+
]
523+
},
481524
{
482525
"cell_type": "markdown",
483526
"metadata": {},

doc/requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ numpy
33
matplotlib
44
ipympl
55
pandas
6+
xarray
67
# setuptools seems to be needed for pybtex, see
78
# https://github.com/mcmtroffaes/sphinxcontrib-bibtex/issues/345:
89
setuptools

0 commit comments

Comments
 (0)