From d77432a93a8aa14b9da01a37e9aa6ae032fca7d9 Mon Sep 17 00:00:00 2001 From: Rajeev Jain Date: Tue, 14 May 2024 22:49:29 -0500 Subject: [PATCH 01/10] o Move area calc notebook to users guide --- docs/gallery.yml | 6 +++--- .../003-area-calc.ipynb => user-guide/area_calc.ipynb} | 0 docs/userguide.rst | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) rename docs/{examples/003-area-calc.ipynb => user-guide/area_calc.ipynb} (100%) diff --git a/docs/gallery.yml b/docs/gallery.yml index 735760d3a..22c556aae 100644 --- a/docs/gallery.yml +++ b/docs/gallery.yml @@ -1,6 +1,6 @@ -- title: Face Area Calculations - path: examples/003-area-calc.ipynb - thumbnail: _static/thumbnails/default.svg +# - title: Face Area Calculations +# path: examples/003-area-calc.ipynb +# thumbnail: _static/thumbnails/default.svg - title: Working with MPAS Grids path: examples/004-working-with-mpas-grids.ipynb diff --git a/docs/examples/003-area-calc.ipynb b/docs/user-guide/area_calc.ipynb similarity index 100% rename from docs/examples/003-area-calc.ipynb rename to docs/user-guide/area_calc.ipynb diff --git a/docs/userguide.rst b/docs/userguide.rst index 19c2a9a03..e703298ee 100644 --- a/docs/userguide.rst +++ b/docs/userguide.rst @@ -15,3 +15,4 @@ common tasks that you can accomplish with UXarray. user-guide/representation.rst user-guide/grid-formats.rst user-guide/data-structures.ipynb + user-guide/area-calc.ipynb From cf864251c4e6d6c156d9b475564cde997abd6e64 Mon Sep 17 00:00:00 2001 From: Philip Chmielowiec <67855069+philipc2@users.noreply.github.com> Date: Tue, 14 May 2024 23:04:25 -0500 Subject: [PATCH 02/10] make a change to prompt ReviewNB bot --- docs/user-guide/area_calc.ipynb | 3 --- 1 file changed, 3 deletions(-) diff --git a/docs/user-guide/area_calc.ipynb b/docs/user-guide/area_calc.ipynb index cee9ecf8c..4d7d40d70 100644 --- a/docs/user-guide/area_calc.ipynb +++ b/docs/user-guide/area_calc.ipynb @@ -6,9 +6,6 @@ "source": [ "# Face Area Calculations\n", "\n", - "Authors: [Rajeev Jain](https://github.com/rajeeja)\n", - "\n", - "\n", "## Overview\n", "\n", "This notebook will showcase the different area calculation options provided by `uxarray`\n", From 36e6d5de719c943ca8707ab7ab59cd13c2ec537f Mon Sep 17 00:00:00 2001 From: Rajeev Jain Date: Tue, 14 May 2024 23:29:20 -0500 Subject: [PATCH 03/10] o Fix links and address review comments --- docs/user-guide/area_calc.ipynb | 69 ++------------------------------- docs/userguide.rst | 1 + 2 files changed, 4 insertions(+), 66 deletions(-) diff --git a/docs/user-guide/area_calc.ipynb b/docs/user-guide/area_calc.ipynb index 4d7d40d70..a6a4e5a5a 100644 --- a/docs/user-guide/area_calc.ipynb +++ b/docs/user-guide/area_calc.ipynb @@ -10,15 +10,12 @@ "\n", "This notebook will showcase the different area calculation options provided by `uxarray`\n", "\n", - "For more details on how to load in data, check out our [previous usage example](https://uxarray.readthedocs.io/en/latest/examples/001-read-grid-data.html)\n", - "\n", "**This notebook has the following sections:**\n", "1. Calculate Total Face Area\n", "2. Options for `Grid.calculate_total_face_area` Function\n", "3. Getting Area of Individual Faces\n", "4. Calculate Area of a Single Triangle in Cartesian Coordinates\n", - "5. Calculate Area from Multiple Faces in Spherical Coordinates\n", - "6. Area Calculation without Grid Object\n" + "5. Calculate Area from Multiple Faces in Spherical Coordinates" ] }, { @@ -67,7 +64,7 @@ "metadata": {}, "source": [ "## 1. Calculate Total Face Area\n", - "We can calculate the total face area by calling the function `Grid.calculate_total_face_area()`. Since our dataset lies on the unit sphere, our expected area is 4*pi, which is approximately 12.56" + "We can calculate the total face area by calling the function `Grid.calculate_total_face_area()`. Since our dataset lies on the unit sphere, our expected area is $4\\pi$, which is approximately 12.56" ] }, { @@ -118,7 +115,7 @@ "\n", "Using a lower order is faster, but at the sacrifice of accuracy.\n", "\n", - "Generally, gaussian quadrature rule is more accurate than the triangular quadrature rule. Additionally, a higher order comes at the cost of computation time, but produces a more accurate result. See `uxarray/get_quadratureDG.py` file for details on quadrature points and weights." + "Generally, gaussian quadrature rule is more accurate than the triangular quadrature rule. Additionally, a higher order comes at the cost of computation time, but produces a more accurate result. See `uxarray/grid/area.py` file and function `get_gauss_quadratureDG` for details on quadrature points and weights." ] }, { @@ -249,11 +246,6 @@ }, "outputs": [], "source": [ - "# # Set correct units for the x and y coordinates\n", - "# vgrid.Mesh2_node_x.attrs[\"units\"] = \"km\"\n", - "# vgrid.Mesh2_node_y.attrs[\"units\"] = \"km\"\n", - "# vgrid.Mesh2_node_z.attrs[\"units\"] = \"km\" # This is just a placeholder, UXarray does not support 3D meshes\n", - "\n", "# Calculate the area of the triangle\n", "area_gaussian = vgrid.calculate_total_face_area(quadrature_rule=\"gaussian\", order=5)\n", "area_gaussian" @@ -348,61 +340,6 @@ "area, jacobian = verts_grid.compute_face_areas()\n", "area" ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 6. Area Calculation without Grid Object\n", - "\n", - "If you want to compute the face area without using the `Grid` object, many of the functions for computing the face are can be accessed through `uxarray.helpers`\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "from uxarray.grid.area import calculate_face_area" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "`Grid.calculate_face_area` takes in three coordinate variables (x, y, z) in the form of numpy arrays and the coordinate type (either spherical or artesian) and computes the face area from the set of points" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "cart_x = np.array(\n", - " [0.577340924821405, 0.577340924821405, 0.577340924821405, 0.577340924821405]\n", - ")\n", - "cart_y = np.array(\n", - " [0.577343045516932, 0.577343045516932, -0.577343045516932, -0.577343045516932]\n", - ")\n", - "cart_z = np.array(\n", - " [0.577366836872017, -0.577366836872017, 0.577366836872017, -0.577366836872017]\n", - ")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "area, jacobian = calculate_face_area(cart_x, cart_y, cart_z, coords_type=\"cartesian\")\n", - "# both area and jacobian are reported for each face\n", - "area, jacobian" - ] } ], "metadata": { diff --git a/docs/userguide.rst b/docs/userguide.rst index e703298ee..469c61dc5 100644 --- a/docs/userguide.rst +++ b/docs/userguide.rst @@ -16,3 +16,4 @@ common tasks that you can accomplish with UXarray. user-guide/grid-formats.rst user-guide/data-structures.ipynb user-guide/area-calc.ipynb + From 4343cf5feacc6ce455b670c669279abbc652f6bb Mon Sep 17 00:00:00 2001 From: Rajeev Jain Date: Tue, 14 May 2024 23:32:08 -0500 Subject: [PATCH 04/10] o pre-commit fix --- docs/userguide.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/userguide.rst b/docs/userguide.rst index 469c61dc5..e703298ee 100644 --- a/docs/userguide.rst +++ b/docs/userguide.rst @@ -16,4 +16,3 @@ common tasks that you can accomplish with UXarray. user-guide/grid-formats.rst user-guide/data-structures.ipynb user-guide/area-calc.ipynb - From 8d036e4ab1567313f90d1ea3487048c437e6bf23 Mon Sep 17 00:00:00 2001 From: Rajeev Jain Date: Tue, 14 May 2024 23:56:17 -0500 Subject: [PATCH 05/10] Update docs/userguide.rst Co-authored-by: Philip Chmielowiec <67855069+philipc2@users.noreply.github.com> --- docs/userguide.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/userguide.rst b/docs/userguide.rst index e703298ee..3a848b16f 100644 --- a/docs/userguide.rst +++ b/docs/userguide.rst @@ -15,4 +15,4 @@ common tasks that you can accomplish with UXarray. user-guide/representation.rst user-guide/grid-formats.rst user-guide/data-structures.ipynb - user-guide/area-calc.ipynb + user-guide/area_calc.ipynb From edd917807633ffd9535fdae64d40affa6c79db1a Mon Sep 17 00:00:00 2001 From: Rajeev Jain Date: Tue, 14 May 2024 23:56:49 -0500 Subject: [PATCH 06/10] o Remove comments --- docs/gallery.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/docs/gallery.yml b/docs/gallery.yml index 22c556aae..db257db37 100644 --- a/docs/gallery.yml +++ b/docs/gallery.yml @@ -1,7 +1,3 @@ -# - title: Face Area Calculations -# path: examples/003-area-calc.ipynb -# thumbnail: _static/thumbnails/default.svg - - title: Working with MPAS Grids path: examples/004-working-with-mpas-grids.ipynb thumbnail: _static/thumbnails/004-thumbnail.png From ef0b43b07a96f7ca83400a1109967ef102738d46 Mon Sep 17 00:00:00 2001 From: Philip Chmielowiec <67855069+philipc2@users.noreply.github.com> Date: Wed, 15 May 2024 00:41:06 -0500 Subject: [PATCH 07/10] update face areas notebook --- docs/user-guide/area_calc.ipynb | 52 ++++++++++++++++----------------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/docs/user-guide/area_calc.ipynb b/docs/user-guide/area_calc.ipynb index a6a4e5a5a..992fa48a5 100644 --- a/docs/user-guide/area_calc.ipynb +++ b/docs/user-guide/area_calc.ipynb @@ -1,16 +1,33 @@ { "cells": [ + { + "cell_type": "markdown", + "source": [ + "# Face Area Calculations" + ], + "metadata": { + "collapsed": false + } + }, + { + "cell_type": "code", + "execution_count": null, + "outputs": [], + "source": [ + "import uxarray as ux\n", + "import numpy as np\n", + "import xarray as xr" + ], + "metadata": { + "collapsed": false + } + }, { "cell_type": "markdown", "metadata": {}, "source": [ - "# Face Area Calculations\n", + "Computing and working with face areas is important for analysis unstructured grids, with many algorithms and workflows requiring them. This section will showcase the different face area calculation options provided with UXarray:\n", "\n", - "## Overview\n", - "\n", - "This notebook will showcase the different area calculation options provided by `uxarray`\n", - "\n", - "**This notebook has the following sections:**\n", "1. Calculate Total Face Area\n", "2. Options for `Grid.calculate_total_face_area` Function\n", "3. Getting Area of Individual Faces\n", @@ -33,29 +50,10 @@ }, "outputs": [], "source": [ - "import uxarray as ux\n", - "import numpy as np\n", - "import xarray as xr" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "# Base data path\n", "base_path = \"../../test/meshfiles/\"\n", + "grid_path = base_path + \"/ugrid/outCSne30/outCSne30.ug\"\n", "\n", - "# Path to Grid files\n", - "ugrid_path = base_path + \"/ugrid/outCSne30/outCSne30.ug\"\n", - "\n", - "# Load grid files and create UXarray Grid objects\n", - "ugrid_ds = xr.open_dataset(ugrid_path)\n", - "\n", - "ugrid = ux.open_grid(ugrid_ds)\n", + "ugrid = ux.open_grid(grid_path)\n", "ugrid" ] }, From 327d49ac4fee4ce07896f300f9b5c307984240eb Mon Sep 17 00:00:00 2001 From: Philip Chmielowiec <67855069+philipc2@users.noreply.github.com> Date: Wed, 15 May 2024 00:43:45 -0500 Subject: [PATCH 08/10] update notebook --- docs/user-guide/area_calc.ipynb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/user-guide/area_calc.ipynb b/docs/user-guide/area_calc.ipynb index 992fa48a5..fe16e1780 100644 --- a/docs/user-guide/area_calc.ipynb +++ b/docs/user-guide/area_calc.ipynb @@ -15,8 +15,7 @@ "outputs": [], "source": [ "import uxarray as ux\n", - "import numpy as np\n", - "import xarray as xr" + "import numpy as np" ], "metadata": { "collapsed": false @@ -26,7 +25,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Computing and working with face areas is important for analysis unstructured grids, with many algorithms and workflows requiring them. This section will showcase the different face area calculation options provided with UXarray:\n", + "Computing and working with face areas is important for the analysis of unstructured grids, with many algorithms and workflows requiring them. This section will showcase the different face area calculation options provided with UXarray:\n", "\n", "1. Calculate Total Face Area\n", "2. Options for `Grid.calculate_total_face_area` Function\n", From ff0f37e93844cb588dd9a187b2a14b94d8d4c3dc Mon Sep 17 00:00:00 2001 From: Philip Chmielowiec <67855069+philipc2@users.noreply.github.com> Date: Wed, 15 May 2024 00:57:13 -0500 Subject: [PATCH 09/10] update 4pi --- docs/user-guide/area_calc.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide/area_calc.ipynb b/docs/user-guide/area_calc.ipynb index fe16e1780..67a2de018 100644 --- a/docs/user-guide/area_calc.ipynb +++ b/docs/user-guide/area_calc.ipynb @@ -61,7 +61,7 @@ "metadata": {}, "source": [ "## 1. Calculate Total Face Area\n", - "We can calculate the total face area by calling the function `Grid.calculate_total_face_area()`. Since our dataset lies on the unit sphere, our expected area is $4\\pi$, which is approximately 12.56" + "We can calculate the total face area by calling the function `Grid.calculate_total_face_area()`. Since our dataset lies on the unit sphere, our expected area is :math:`4\\pi`, which is approximately 12.56" ] }, { From 8572cecfedc1e9900a3f74487917e703aee2219b Mon Sep 17 00:00:00 2001 From: Philip Chmielowiec <67855069+philipc2@users.noreply.github.com> Date: Wed, 15 May 2024 01:20:40 -0500 Subject: [PATCH 10/10] update latex --- docs/user-guide/area_calc.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide/area_calc.ipynb b/docs/user-guide/area_calc.ipynb index 67a2de018..d3925cb9c 100644 --- a/docs/user-guide/area_calc.ipynb +++ b/docs/user-guide/area_calc.ipynb @@ -61,7 +61,7 @@ "metadata": {}, "source": [ "## 1. Calculate Total Face Area\n", - "We can calculate the total face area by calling the function `Grid.calculate_total_face_area()`. Since our dataset lies on the unit sphere, our expected area is :math:`4\\pi`, which is approximately 12.56" + "We can calculate the total face area by calling the function `Grid.calculate_total_face_area()`. Since our dataset lies on the unit sphere, our expected area is 4π, which is approximately 12.56" ] }, {