Skip to content

Commit

Permalink
Merge pull request #152 from Kitware/viewers-xarray-accessor
Browse files Browse the repository at this point in the history
Viewers xarray accessor
  • Loading branch information
jourdain authored Dec 20, 2024
2 parents c1520e2 + c8510f8 commit 6aec7bb
Show file tree
Hide file tree
Showing 11 changed files with 708 additions and 158 deletions.
105 changes: 105 additions & 0 deletions examples/jupyter/xarray-globe.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "d3e629af-a060-4f1e-b821-34114a7694b2",
"metadata": {},
"source": [
"## Load XArray data"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "0a67097d-b562-444a-8c2c-ea383d46fa48",
"metadata": {},
"outputs": [],
"source": [
"import xarray as xr\n",
"\n",
"ds = xr.tutorial.load_dataset(\"air_temperature\")"
]
},
{
"cell_type": "markdown",
"id": "2bb6f93d-0005-4734-9af1-3db0ace2533b",
"metadata": {},
"source": [
"## Show data using Pan3d slicer"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "9a0c47e0-a635-4c95-8bac-382c4e9ab264",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "13609393ee3f4604984a3bb6b11ae634",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HTML(value='<iframe id=\"pan3d_accessor_1_trame__template_main\" src=\"http://localhost:65515/index.html?ui=main&…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"ds.pan3d.globe"
]
},
{
"cell_type": "markdown",
"id": "4f65f61f-a4ff-4664-bfc4-3758603b7a1b",
"metadata": {},
"source": [
"### Access to VTK source"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c848393f-0022-41c7-b82a-46789b9acc78",
"metadata": {},
"outputs": [],
"source": [
"print(\"Extents:\", ds.pan3d.globe.source.slice_extents)\n",
"print(\"Slice:\", ds.pan3d.globe.source.slices)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1d0b2248-047b-426b-8a9c-13f83d3915cd",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.15"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
115 changes: 115 additions & 0 deletions examples/jupyter/xarray-preview.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "0939199e-4fd4-4dec-8cf9-837e62dcfbe2",
"metadata": {},
"source": [
"## Load XArray data"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "87e682c0-d2d0-4991-8302-f876b310e982",
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"import xarray as xr\n",
"\n",
"ds = xr.tutorial.load_dataset(\"eraint_uvz\")"
]
},
{
"cell_type": "markdown",
"id": "ec636d74-f99f-4a50-b209-fa7f411dda3e",
"metadata": {},
"source": [
"## Show data using Pan3d preview"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ce12be13-2544-4dd8-90e3-ff076604dadb",
"metadata": {},
"outputs": [],
"source": [
"ds.pan3d.preview"
]
},
{
"cell_type": "markdown",
"id": "c5d8c7ac-9287-4e0e-bf78-65028b15a23f",
"metadata": {},
"source": [
"### Access to VTK source"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6ff48739-b9a2-435d-83bf-379a2d4d392d",
"metadata": {},
"outputs": [],
"source": [
"print(ds.pan3d.preview.source.slice_extents)\n",
"print(ds.pan3d.preview.source.slices)"
]
},
{
"cell_type": "markdown",
"id": "58002dba-7b9c-44ec-9e58-a5065267b6c9",
"metadata": {},
"source": [
"# Create Viewer by hand"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c4688d5b-333a-4138-a4c1-774eaab2202b",
"metadata": {},
"outputs": [],
"source": [
"from pan3d.viewers.preview import XArrayViewer\n",
"\n",
"viewer = XArrayViewer(xarray=ds, server=\"preview\")\n",
"await viewer.ui.ready\n",
"\n",
"viewer.ui"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "64c27303-0f5c-4224-8215-7299c05df23d",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.15"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
90 changes: 90 additions & 0 deletions examples/jupyter/xarray-slicer.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "d3e629af-a060-4f1e-b821-34114a7694b2",
"metadata": {},
"source": [
"## Load XArray data"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0a67097d-b562-444a-8c2c-ea383d46fa48",
"metadata": {},
"outputs": [],
"source": [
"import xarray as xr\n",
"\n",
"ds = xr.tutorial.load_dataset(\"eraint_uvz\")"
]
},
{
"cell_type": "markdown",
"id": "2bb6f93d-0005-4734-9af1-3db0ace2533b",
"metadata": {},
"source": [
"## Show data using Pan3d slicer"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9a0c47e0-a635-4c95-8bac-382c4e9ab264",
"metadata": {},
"outputs": [],
"source": [
"ds.pan3d.slicer"
]
},
{
"cell_type": "markdown",
"id": "4f65f61f-a4ff-4664-bfc4-3758603b7a1b",
"metadata": {},
"source": [
"### Access to VTK source"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c848393f-0022-41c7-b82a-46789b9acc78",
"metadata": {},
"outputs": [],
"source": [
"print(\"Extents:\", ds.pan3d.slicer.source.slice_extents)\n",
"print(\"Slice:\", ds.pan3d.slicer.source.slices)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1d0b2248-047b-426b-8a9c-13f83d3915cd",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.15"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading

0 comments on commit 6aec7bb

Please sign in to comment.