Skip to content

Commit

Permalink
update interactive notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
philipc2 committed Dec 8, 2023
1 parent 295d6f2 commit 1cacaef
Showing 1 changed file with 4 additions and 170 deletions.
174 changes: 4 additions & 170 deletions notebooks/03-uxarray-vis/07-animations.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,183 +11,17 @@
},
"id": "766ae3323db40ec2"
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"import warnings\n",
"\n",
"import holoviews as hv\n",
"import uxarray as ux\n",
"\n",
"warnings.filterwarnings(\"ignore\")\n",
"\n",
"hv.extension(\"bokeh\")\n",
"\n",
"file_dir = \"../../meshfiles/\""
],
"metadata": {
"collapsed": false
},
"id": "e6d8966f381f6a14"
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"grid_filename_geoflow = file_dir + \"geoflow.grid.nc\"\n",
"data_filename_geoflow = file_dir + \"geoflow.data.nc\"\n",
"uxds = ux.open_dataset(grid_filename_geoflow, data_filename_geoflow)\n",
"\n",
"v1 = uxds[\"v1\"].nodal_average()"
],
"metadata": {
"collapsed": false
},
"id": "fabacde78c2027ca"
},
{
"cell_type": "markdown",
"source": [
"## Interactivity \n",
"\n",
"### Dynamic Rendering\n",
"\n",
"By setting the \"dynamic\" parameter to True, the resulting plot will dynamically re-rasterize whenever you zoom."
],
"metadata": {
"collapsed": false
},
"id": "11d050fd83cfc049"
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"v1[0][0].plot.rasterize(method=\"polygon\", dynamic=True)"
],
"metadata": {
"collapsed": false
},
"id": "4c1e60b1f35ee6a3"
},
{
"cell_type": "markdown",
"source": [
"### Tools"
],
"metadata": {
"collapsed": false
},
"id": "36dd246ddcfc2220"
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"v1[0][0].plot.polygons().opts(tools=[\"hover\"], width=900, height=400)"
],
"metadata": {
"collapsed": false
},
"id": "572417f981cbebcf"
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"v1[0][0].plot.polygons().opts(tools=[\"hover\"], width=900, height=400)"
":::{note}\n",
"This notebook is currently under development! Please refer to the [Interactive HoloViz Visualization](https://projectpythia.org/advanced-viz-cookbook/notebooks/interactive-holoviz-mpas.html#interactive-holoviz-plots) notebook in the Advanced Visualization Cookbook.\n",
":::"
],
"metadata": {
"collapsed": false
},
"id": "dfe8e8cc3966db84"
},
{
"cell_type": "markdown",
"source": [
"An additional tool that can be selected is the 'lasso_select` tool, which similar to the `box_select` tool can be used to interactively select points."
],
"metadata": {
"collapsed": false
},
"id": "3d53a4b99cc1ec9a"
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"v1[0][0].plot.points().opts(tools=[\"hover\", \"lasso_select\"], width=900, height=400)"
],
"metadata": {
"collapsed": false
},
"id": "200640779a5ebfdd"
},
{
"cell_type": "markdown",
"source": [
"### HoloMaps"
],
"metadata": {
"collapsed": false
},
"id": "bac833698a730d2a"
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"%%capture\n",
"hmap = hv.HoloMap(\n",
" {\n",
" i: v1[0][i].plot.rasterize(\n",
" method=\"polygon\",\n",
" exclude_antimeridian=False,\n",
" cmap=\"coolwarm\",\n",
" title=f\"v1: Mesh Layer {i}\",\n",
" width=700,\n",
" height=350,\n",
" clim=(-10, 10),\n",
" )\n",
" for i in range(5)\n",
" },\n",
" kdims=\"Mesh Layer\",\n",
")"
],
"metadata": {
"collapsed": false
},
"id": "5a00d5599c34648b"
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"hmap"
],
"metadata": {
"collapsed": false
},
"id": "b66ceaad4c6f552e"
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [],
"metadata": {
"collapsed": false
},
"id": "433a5e65413f567a"
"id": "135881e235d90c09"
}
],
"metadata": {
Expand Down

0 comments on commit 1cacaef

Please sign in to comment.