uxarray.Grid#

class uxarray.Grid(input_obj, **kwargs)#

Unstructured grid topology definition.

Can be used standalone to explore an unstructured grid topology, or can be seen as the property of uxarray.UxDataset and uxarray.DataArray to make them unstructured grid-aware data sets and arrays.

Parameters:
  • input_obj (xarray.Dataset, ndarray, list, tuple, required) – Input xarray.Dataset or vertex coordinates that form faces.

  • gridspec (bool, optional) – Specifies gridspec

  • islatlon (bool, optional) – Specify if the grid is lat/lon based

  • isconcave (bool, optional) – Specify if this grid has concave elements (internal checks for this are possible)

  • use_dual (bool, optional) – Specify whether to use the primal (use_dual=False) or dual (use_dual=True) mesh if the file type is mpas

Raises:

RuntimeError – If specified file not found or recognized

Examples

>>> import uxarray as ux
  1. Open a grid file with uxarray.open_grid():

>>> uxgrid = ux.open_grid("filename.g")

2. Open an unstructured grid dataset file with uxarray.open_dataset(), then access Grid info:

>>> uxds = ux.open_dataset("filename.g")
__init__(input_obj, **kwargs)#

Methods

__init__(input_obj, **kwargs)

calculate_total_face_area([quadrature_rule, ...])

Function to calculate the total surface area of all the faces in a mesh.

compute_face_areas([quadrature_rule, order])

Face areas calculation function for grid class, calculates area of all faces in the grid.

copy()

Returns a deep copy of this grid.

encode_as(grid_type)

Encodes the grid as a new xarray.Dataset per grid format supplied in the grid_type argument.

Attributes

Mesh2

UGRID Attribute Mesh2, which indicates the topology data of a 2D unstructured mesh.

Mesh2_edge_nodes

UGRID Connectivity Variable Mesh2_edge_nodes, which maps every edge to the two nodes that it connects.

Mesh2_face_edges

UGRID Connectivity Variable Mesh2_face_edges, which maps every face to its edges.

Mesh2_face_nodes

UGRID Connectivity Variable Mesh2_face_nodes, which maps each face to its corner nodes.

Mesh2_face_x

UGRID Coordinate Variable Mesh2_face_x, which contains the longitude of each face center.

Mesh2_face_y

UGRID Coordinate Variable Mesh2_face_y, which contains the latitude of each face center.

Mesh2_node_cart_x

Coordinate Variable Mesh2_node_cart_x, which contains the x location in meters.

Mesh2_node_cart_y

Coordinate Variable Mesh2_node_cart_y, which contains the y location in meters.

Mesh2_node_cart_z

Coordinate Variable Mesh2_node_cart_z, which contains the z location in meters.

Mesh2_node_x

UGRID Coordinate Variable Mesh2_node_x, which contains the longitude of each node in degrees.

Mesh2_node_y

UGRID Coordinate Variable Mesh2_node_y, which contains the latitude of each node.

face_areas

Declare face_areas as a property.

nMaxMesh2_face_edges

Dimension nMaxMesh2_face_edges, which represents the maximum number of edges per face.

nMaxMesh2_face_nodes

UGRID Dimension nMaxMesh2_face_nodes, which represents the maximum number of faces nodes that a face may contain.

nMesh2_edge

UGRID Dimension nMesh2_edge, which represents the total number of edges.

nMesh2_face

UGRID Dimension nMesh2_face, which represents the total number of faces.

nMesh2_node

UGRID Dimension nMesh2_node, which represents the total number of nodes.

nNodes_per_face

Dimension Variable nNodes_per_face, which contains the number of non-fill-value nodes per face.

parsed_attrs

Dictionary of parsed attributes from the source grid.