Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified docs/_static/examples/grids/cam_se.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/examples/grids/face_node_edge.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/examples/grids/iso_grid.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_static/examples/grids/lat_lon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/examples/grids/ocean.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/examples/grids/structured_grid.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/examples/grids/unstructured_grid.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
124 changes: 124 additions & 0 deletions docs/getting-started/unstructured-grids.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
.. currentmodule:: uxarray

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about moving this file from "Getting Started" to the first place of "User Guide" because the former is designed as a quick reference for getting the user to get going with UXarray, e.g. install & run it?


================================
Structured vs Unstructured Grids
================================

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this section and others in the rest of this file, you may want to check out this section from our UXarray Cookbook: https://projectpythia.org/unstructured-grid-viz-cookbook/notebooks/foundations/unstructured-grids/#structured-vs-unstructured-grids since a lot of text there can be reused here. However, it touched code etc. which may not be needed here.


UXarray's ability to work on such a large variety of datasets and file formats
comes from its support for unstructured grids. Unstructured grids differ from

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first sentence feels a bit off-placed in this section. Maybe it can be replaced with something else that starts the actual subject of structured vs unstructured comparison?

For example, this is how the referenced cookbook above begins with: "Before diving into unstructured grids, it is helpful to understand the basic differences between structured and unstructured grids"

structured grids in how they are designed, navigated, and used in modeling functions.


Structured Grids - How They're Designed
=======================================

Structured grids are matrix-like in structure. Just as we can navigate a 2D
plane using simple coordinates like (2, 2) to (2, 3), a structured grid can be
navigated predictably because it follows a repeatable pattern.

Example
-------

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already a small section, maybe get rid of the "Example" title and just continue to the text and figure?


A cell with a center at (20°N, 20°E) always has four neighboring cells:
(21°N, 20°E), (19°N, 20°E), (20°N, 21°E), and (20°N, 19°E).

.. image:: ../_static/examples/grids/structured_grid.png
:width: 300
:align: center
:alt: A structured grid with a regular, matrix-like arrangement of cells

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While it is technically not false/impossible to define cells being centered on a particular (lon,lat) pair, grid cells in structured grids are defined with their boundary longitudes and latitudes as follows:

Image

So, rather than identifying cell centers with lon, lat pairs, maybe draw a diagram similar to the above but with only nine cells, tag the constant lon and lat lines instead of cell centers, and rephrase the text in this section accordingly?

Moving along a structured grid has predictable outcomes and observations.
There are many assumptions you can make about a different cell that is 1 degree East.
It will have a predictable center, number of sides, and predictable neighboring cells
of the same characteristics.

Unstructured Grids - How They're Designed
=========================================

Unstructured grids do not follow a repeated, predictable pattern, and instead
can vary in shape and organization. Because of this, unstructured grids are
built like network graphs.

.. image:: ../_static/examples/grids/face_node_edge.png
:width: 300
:align: center
:alt: A visual of the components of a grid
Comment on lines +41 to +45

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd recommend to:

  • remove this figure (and corresponding text) from here, and
  • use a modification of unstructured_grid.png below where the geometric elements are visualized in the corresponding section in user_guide/terminology


Each grid face will be made of nodes and edges. Those nodes and edges can be shared with
other faces to make connected faces. All the connected faces together make up the grid.

Example
-------

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise, get rid of the "Example" title and provide the text directly?


Here we have a grid made from hexagons. While it appears to be a repeated
pattern, it is harder to make assumptions about what the neighboring faces may
be or what characteristics they may have. Holes can exist in the grid, different
shapes like hexagons and pentagons can exist on the same grid, and more.

.. image:: ../_static/examples/grids/unstructured_grid.png
:width: 300
:align: center
:alt: An unstructured grid made from hexagons

When you move one degree on a grid like the one above, you may end up in a hole,
a face of a different shape, or something entirely unexpected. That's why
the data is traversed by looking at its neighbors from connected edges.

Use Cases
=========

Many kinds of unstructured grids can exist because of these features.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A main reason for unstructured grids is to avoid the singularity at the poles in a lat-lon grid.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great point. I'll definitely include that. Thank you!


Some grids use hexagons rather than a rectilinear structure:

.. image:: ../_static/examples/grids/iso_grid.png
:width: 300
:align: center
:alt: An unstructured grid built from hexagonal cells

Others are allowed to have holes that cut out regions that aren't of interest in order to improve efficiency:

.. image:: ../_static/examples/grids/ocean.png
:width: 300
:align: center
:alt: An unstructured ocean grid with holes cut out over land regions

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This image is being rendered too small in the doc:

Image


Here a grid changes the size and shape of its cells to provide higher
resolution in a region of interest and coarser resolution elsewhere:

.. image:: ../_static/examples/grids/cam_se.png
:width: 300
:align: center
:alt: A CAM-SE grid with variable-resolution cells refined over a region of interest

.. note::

More info about each of the models currently supported can be seen on the `Supported Models & Grid Formats <https://uxarray.readthedocs.io/en/latest/user-guide/grid-formats.html>`__ page

Specialization & Efficiency
===========================

Structured grids face scalability limits due to several reasons such as global refinement, polar singularity,
land-ocean boundary fitting, etc. For instance, as the grid resolution scales, a global lat-lon rectilinear grid
creates too many cells near the poles, wasting massive storage/memory and compute resources for both model generation
and post-processing & analysis.

Models focused on the equator, like tropical cyclone models, will have a much higher density of cells near the poles
where they don't need data from, and a much lower density of cells near the equator, due to how the lat-lon grid scales.

On the other hand, models focused on the polar region tend to want more uniform shapes in this region, like the icosahedral
grid, which is an unstructured grid that contains hexagons of similar size uniformly across the whole grid.

Some of the value of unstructured grids comes from researchers being able to build or adopt
models that are tailored to their use case. For example, a researcher studying
measurements made across the planet's many oceans does not want to consider
cells on land. They can use a model that has no cells on land,
which creates large holes that structured grids could not run calculations on.

In a traditional lat/lon grid, ~30% of the grid cells in the previous example would be
unused, meaning the data footprint could be roughly 30% smaller. Many
calculations will likely require noticeably fewer resources, and less time will be required to
compute. Many nodes, edges, and faces are eliminated by the removal of the
land, and even the cells over the sea have fewer connected faces, nodes,
and edges as a result. These efficiency improvements matter a lot in
geospatial models, which tend to already be very resource intensive.
1 change: 1 addition & 0 deletions docs/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ and Usage Example sections.
getting-started/overview.rst
getting-started/installation.rst
getting-started/quick-overview.ipynb
getting-started/unstructured-grids.rst
getting-started/freq-asked-questions.rst
4 changes: 3 additions & 1 deletion docs/tutorials.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ Tutorials & Videos

Tutorials
---------
* `Project Pythia Unstructured Grid Visualization Cookbook <https://projectpythia.org/unstructured-grid-viz-cookbook>`_
* `Project Pythia Unstructured Grid Visualization Cookbook <https://projectpythia.org/unstructured-grid-viz-cookbook>`_ - A series of guides in the form of Jupyter notebooks. Shows code, examples, visualizations for various uses of ``uxarray``.
* `UXarray Tutorial at ESDS 2024 <https://www.youtube.com/watch?v=sOCMSLZrwQs>`_ - A YouTube video presentation by one of the lead UXarray developers on the motivation of UXarray, its origins, and uses.
* `UXarray Presentation at SciPy 2023 <https://www.youtube.com/watch?v=qwqJeOO8m6A>`_ - A second YouTube video presentation by another one of the lead UXarray developers on UXarray at SciPy 2023.
9 changes: 6 additions & 3 deletions docs/user-guide/data-structures.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"The core functionality of UXarray revolves around three data structures, which are used for interacting with unstructured grids and the data variables that reside on them.\n",
"\n",
"1. **[`uxarray.Grid`](https://uxarray.readthedocs.io/en/latest/generated/uxarray.UxDataArray.html)**: Stores the grid representation (i.e. coordinates, connectivity information, etc.)\n",
"2. **[`uxarray.UxDataset`](https://uxarray.readthedocs.io/en/latest/api.html#uxdataset)**: One or more data variable that resided on a grid.\n",
"3. **[`uxarray.UxDataArray`](https://uxarray.readthedocs.io/en/latest/api.html#uxdataarray)**: A single data variable that resides on a grid\n"
"2. **[`uxarray.UxDataset`](https://uxarray.readthedocs.io/en/latest/api.html#uxdataset)**: One or more data variables that resided on a grid. Each variable is stored in a UxDataArray.\n",
"3. **[`uxarray.UxDataArray`](https://uxarray.readthedocs.io/en/latest/api.html#uxdataarray)**: A single data variable that resides on a grid.\n"
]
},
{
Expand Down Expand Up @@ -486,7 +486,10 @@
}
},
"outputs": [],
"source": "uxds = ux.open_dataset(grid_path, data_path)\nuxds"
"source": [
"uxds = ux.open_dataset(grid_path, data_path)\n",
"uxds"
]
},
{
"cell_type": "markdown",
Expand Down
4 changes: 2 additions & 2 deletions docs/user-guide/grid-formats.rst
Original file line number Diff line number Diff line change
Expand Up @@ -242,13 +242,13 @@ Coordinates

<style>
.yes-cell {
background-color: green;
background-color: #6aa84f; /* Light green color */
color: white;
text-align: center;
}

.no-cell {
background-color: red;
background-color: #e06666; /* Light red color */
color: white;
text-align: center;
}
Expand Down