Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
philipc2 committed Dec 1, 2023
2 parents 2cf5430 + 8604a44 commit e6b622e
Show file tree
Hide file tree
Showing 3 changed files with 171 additions and 120 deletions.
12 changes: 6 additions & 6 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,22 @@ name: unstructured-grid-viz-cookbook-dev
channels:
- conda-forge
dependencies:
- jupyter-book
- jupyterlab
- jupyter_server
- pip
# - uxarray uncomment this and remove the below pip uxarray install if Grid.plot.mesh() etc get released
- cartopy
- dask
- datashader
- geoviews
- holoviews
- hvplot
- jupyter-book
- jupyterlab
- jupyter_server
- matplotlib-base
- netcdf4
- numba
- numpy
- pandas<2.1.0
- pathlib
- pip
- pre_commit
- pyarrow<13.0.0
- pytest
Expand All @@ -28,9 +27,10 @@ dependencies:
- scipy
- shapely
# - spatialpandas # uncomment this and remove below pip install if from_exterior_coords() gets released
# - uxarray uncomment this and remove the below pip uxarray install if Grid.plot.mesh() etc get released
- xarray
- pip:
- sphinx-pythia-theme
- antimeridian
- git+https://github.com/UXARRAY/uxarray.git@philipc2/point-viz
- git+https://github.com/holoviz/spatialpandas.git
- sphinx-pythia-theme
189 changes: 120 additions & 69 deletions notebooks/03-uxarray-vis/01-plot-api.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -14,181 +14,232 @@
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"source": [
"```{Note}\n",
"This notebook acts as an introduction into using the UXarray plotting API. The following notebooks in this section provide a detailed overview of visualuzation techniques.\n",
"```"
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
"import uxarray as ux"
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
"file_dir = \"../../meshfiles/\"\n",
"grid_filename = file_dir + \"oQU480.grid.nc\"\n",
"data_filename = file_dir + \"oQU480.data.nc\""
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
"grid = ux.open_grid(grid_filename)\n",
"uxds = ux.open_dataset(grid_filename, data_filename)"
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"source": [
"## `Grid` Plotting\n",
"\n",
"For visualizing the topology (i.e. geometry) of an unstructured grid, plotting is done through a `Grid` Instance"
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
"grid.plot(title=\"Default Grid Plot\")"
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"source": [
"You can call specific plotting routines through the `plot` accessor"
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
"grid.plot.nodes(title=\"Grid Node Plot\")"
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"source": [
"If you have a `UxDataset` or `UxDataArray`, you can access the `Grid` through the `uxgrid` attribute."
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
"uxds.uxgrid.(title=\"Default Grid Plot through uxgrid attribute\")"
],
"metadata": {
"collapsed": false
}
"uxds.uxgrid.plot(title=\"Default Grid Plot through uxgrid attribute\")"
]
},
{
"cell_type": "markdown",
"source": [],
"metadata": {
"collapsed": false
}
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"source": []
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"source": [
"## `UxDataset` & `UxDataArray` Plotting\n",
"\n",
"For visualizing data variables, plotting is done a `UxDataArray` instance."
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
"uxds[\"bottomDepth\"].plot(title=\"Default UxDataArray Plot\")"
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"source": [
"As was shown with a `Grid`, you can call specific plotting routines through the `plot` accessor"
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
"uxds[\"bottomDepth\"].plot.points(title=\"UxDataArray Point Plot\")"
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"source": [
"Plotting a `UxDataset` currently not supported"
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
"uxds.plot()"
],
"metadata": {
"collapsed": false
}
]
}
],
"metadata": {
Expand All @@ -207,7 +258,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.11"
"version": "3.11.6"
},
"nbdime-conflicts": {
"local_diff": [
Expand Down
Loading

0 comments on commit e6b622e

Please sign in to comment.