xarray Objects for VS Code

Inspect xarray objects directly from Python notebooks in VS Code. The extension finds
DataArray, Dataset, and DataTree variables in Jupyter and marimo notebooks, adds
quick actions to notebook hovers, and provides an xarray Objects panel plus a rendered
xarray Detail view.

Notebook Workflow
Inspect xarray variables
Work in a notebook with ordinary xarray variables. The extension recognizes
DataArray, Dataset, and DataTree objects from the active kernel and keeps the
Objects panel in sync with the active notebook.
Use hover actions
Hover over an xarray variable name in a Python cell to see its object type, dimensions,
and quick actions.

Use Details to open the rendered xarray HTML representation, or Pin to keep an
important variable visible in the xarray Objects panel. When
erlab is available, DataArray hovers can also
show additional quick actions for connecting to erlab tools.
Browse the xarray Objects panel
The xarray Objects panel lists notebook variables by xarray type, including generic
DataArray, Dataset, and DataTree entries.

From the panel you can:
- Select an object to open it in the Detail view.
- Filter the list by xarray type.
- Pin important variables so they stay at the top.
- Jump back to the notebook definition for a variable.
- Refresh the object list after notebook state changes.
Open the xarray Detail view
The xarray Detail view renders the object's HTML representation inside VS Code, so you can
inspect dimensions, coordinates, data variables, and attributes without leaving the
notebook.

You can open Details from a hover, from the xarray Objects panel, or from the Jupyter
Variables view.
Optional ERLab Integration
The core xarray workflow works with any Python kernel that has xarray installed. If the
kernel also has erlab, additional DataArray tools
appear where they apply:
- Watch and Unwatch connect notebook DataArrays to the ImageTool Manager.
- ImageTool opens a DataArray in
erlab's ImageTool.
- More tools provides access to ktool, dtool, restool, meshtool, ftool, and goldtool.
- Reconnect Watches reconnects saved ImageTool Manager rows to matching notebook
variables.
Usage
- Open a Jupyter (
.ipynb) notebook or a marimo notebook with a Python kernel.
- Create or load xarray
DataArray, Dataset, or DataTree variables.
- Hover over variable names in Python cells for quick actions.
- Open the erlab panel and browse xarray Objects.
- Select an object, open Details, pin variables, filter by type, or jump to definitions.
Commands
erlab.openDetail - Open the xarray Detail view from the command palette or the
Jupyter Variables view.
erlab.showOutput - Show the extension output channel.
ERLab Commands
These commands appear when the active notebook kernel has the erlab package installed:
erlab.watch - Watch a DataArray, or show it if it is already watched.
erlab.unwatch - Stop watching a DataArray.
erlab.restoreWatches - Reconnect saved ImageTool Manager rows whose variables exist
in the active notebook.
erlab.itool - Open the DataArray in ImageTool.
erlab.ktool - Open the DataArray in ktool.
erlab.dtool - Open the DataArray in dtool.
erlab.restool - Open the DataArray in restool.
erlab.meshtool - Open the DataArray in meshtool.
erlab.ftool - Open the DataArray in ftool.
erlab.goldtool - Open the DataArray in goldtool.
erlab.xarray.otherTools - Show a picker for additional ERLab tools.
Settings
erlab.xarray.displayExpandAttrs (default: true) - Expand the attributes section in
xarray HTML representations.
erlab.xarray.displayExpandCoords (default: true) - Expand the coordinates section
in xarray HTML representations.
erlab.xarray.displayExpandData (default: false) - Expand the data section in xarray
HTML representations.
erlab.itool.useManager (default: true) - Open in the ImageTool Manager when it is
already running. Otherwise, open in a new ImageTool window bound to the current kernel.
If set to false, always open in the current kernel.
erlab.kernel.commandTimeoutMs (default: 10000) - Timeout in milliseconds for erlab
command executions. Set to 0 to disable the timeout.
Requirements
- VS Code or a compatible editor with notebook support.
- The Jupyter extension (
ms-toolsai.jupyter) for Jupyter notebooks, or the marimo
extension (marimo-team.vscode-marimo) for marimo notebooks.
- A Python kernel with
xarray >=2024.10.
- Optional:
erlab for ImageTool and related
interactive tools. A Qt backend, PyQt6 or PySide6, is required for erlab GUI tools.
Watch and unwatch require erlab>=3.20.0; reconnecting saved watched variables
requires erlab>=3.22.0.
Notes
- Hover, panel, and context actions query the active notebook kernel.
- You may be prompted to allow notebook code execution the first time the extension
inspects kernel variables.
- ERLab GUI tool commands can block if the kernel has not enabled Qt event-loop
integration. In IPython/Jupyter kernels, run
%gui qt before opening GUI tools.