Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
philipc2 committed Dec 10, 2023
2 parents 7c951e7 + 1caa4f4 commit 424d619
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 58 deletions.
10 changes: 5 additions & 5 deletions notebooks/01-intro/01-unstructured-grid-overview.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,12 @@
"ax.set_global()\n",
"\n",
"# Plot world map lines with prominent gridlines\n",
"ax.coastlines()\n",
"ax.gridlines(draw_labels=True, dms=True, x_inline=False, y_inline=False, linewidth=0.5)\n",
"ax.coastlines(linewidth=0.5)\n",
"# ax.gridlines(draw_labels=True, dms=True, x_inline=False, y_inline=False, linewidth=0.5)\n",
"\n",
"# Plot unstructured mesh with bold lines\n",
"ax.triplot(\n",
" triang, \"ko-\", markersize=1, linewidth=2, alpha=0.5\n",
" triang, \"ko-\", markersize=0.1, linewidth=0.5, alpha=0.5\n",
") # Increase linewidth to see the triangles\n",
"\n",
"# Scatter plot with temperature data\n",
Expand Down Expand Up @@ -253,13 +253,13 @@
"\n",
"UXarray, which stands for \"Unstructured-Xarray\", is a Python package that provides Xarray-styled functionality for working with unstructured grids built around the UGRID conventions. UXarray can simplify working with unstructured grids because it:\n",
"\n",
"- Enables significant data analysis and visualization functionality to be executed dircetly on unstructured grids\n",
"- Enables significant data analysis and visualization functionality to be executed directly on unstructured grids\n",
"\n",
"- Inherits from Xarray, providing simplified data using familiar (Xarray-like) data structures and operations\n",
" \n",
"- Brings standardization to unstructured mesh support for climate data analysis and visualization\n",
"\n",
"- Adheres to the UGRID specification for compatibility across a variety of mesh formats\n",
"- Adheres to the UGRID specifications for compatibility across a variety of mesh formats\n",
"\n",
"- Builds on optimized data structures and algorithms for handling large and complex unstructured datasets\n",
"\n",
Expand Down
4 changes: 2 additions & 2 deletions notebooks/01-intro/02-data-structures.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,11 @@
"source": [
"## `UxDataset` & `UxDataArray` Data Structures\n",
"\n",
"UXarray inherits from Xarray's two core data structures `Dataset` & `DataArary` to provide a grid-informed implementation through the `UxDataset` & `UxDataArray` data structures. \n",
"UXarray inherits from Xarray's two core data structures `Dataset` & `DataArray` to provide a grid-informed implementation through the `UxDataset` & `UxDataArray` data structures. \n",
"\n",
"The major difference between them is that UXarray's implementation is paired with a `Grid` object, accessed through the `.uxgrid` property.\n",
"\n",
"UXarray also provides a overloaded `ux.open_dataset` method, which takes in both a Grid and Data file path to construct a `UxDataset`\n"
"UXarray also provides an overloaded `ux.open_dataset` method, which takes in both a Grid and Data file path to construct a `UxDataset`\n"
]
},
{
Expand Down
138 changes: 87 additions & 51 deletions notebooks/01-intro/03-data-mapping.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,41 @@
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"source": [
"When attempting to visualize a data variable that resides on an unstructured grid, it's important to identify what element it is mapped to, since that will dictate what visualization to choose.\n",
"\n",
"This notebook provides a quick over of how data is commonly mapped to unstructured grid elements."
],
"metadata": {
"collapsed": false
}
"This notebook provides a quick overview of how data is commonly mapped to unstructured grid elements."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
"import uxarray as ux"
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false,
"is_executing": true,
"jupyter": {
"outputs_hidden": false
}
},
"source": [
"## Sample Mesh\n",
"\n",
Expand All @@ -40,121 +53,144 @@
"Below is a basic example of an Unstructured Grid, containing 13 Nodes, 15 Edges, and 3 Faces.\n",
"\n",
"![Sample Mesh](../images/sample/sample_mesh.png)"
],
"metadata": {
"collapsed": false,
"is_executing": true
}
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"source": [
"## Face-Centered Data\n",
"\n",
"Face-Centered data is mapped to the area that each face covers. \n",
"\n",
"![Faces](../images/sample/faces.png)\n"
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"source": [
"## Node-Centered Data\n",
"\n",
"Node-Centered data is assigned to the corners of each face.\n",
"\n",
"\n",
"![Faces](../images/sample/nodes.png)"
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"source": [
"## Edge-Centered Data\n",
"\n",
"Edge-Centered data is assigned to the edge that connects each pair of modes.\n",
"\n",
"![Edges](../images/sample/edges.jpg)"
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"source": [
"## Identifying Data Mappings with UXarray\n",
"\n",
"We can identify what element a data variable is mapped to by looking at the final dimensions of a `UxDataArray` or `UxDataset`"
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
"file_dir = \"../../meshfiles/\""
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
"grid_filename_mpas = file_dir + \"oQU480.grid.nc\"\n",
"data_filename_mpas = file_dir + \"oQU480.data.nc\"\n",
"uxds_mpas = ux.open_dataset(grid_filename_mpas, data_filename_mpas)\n",
"\n",
"uxds_mpas[\"bottomDepth\"].dims"
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"source": [
"The variable ``bottomDepth`` has a dimension of ``n_face``, which means that it is mapped to faces."
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
"grid_filename_geoflow = file_dir + \"geoflow.grid.nc\"\n",
"data_filename_geoflow = file_dir + \"geoflow.data.nc\"\n",
"uxds_geoflow = ux.open_dataset(grid_filename_geoflow, data_filename_geoflow)\n",
"\n",
"uxds_geoflow[\"v1\"].dims"
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"source": [
"The variable ``v1`` has a final dimension of ``n_node``, which means that it is mapped to the corner nodes of each face. However, it also has additional dimensions, ``time`` and ``meshLayers``. These additional dimensions describe the dimensionality of the data outside the unstructured grid, representing the temporal and vertical dimensions."
],
"metadata": {
"collapsed": false
}
]
}
],
"metadata": {
Expand All @@ -173,7 +209,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.11"
"version": "3.11.6"
},
"nbdime-conflicts": {
"local_diff": [
Expand Down

0 comments on commit 424d619

Please sign in to comment.