Quick Overview#

import uxarray as ux

base_path = "../../test/meshfiles/ugrid/outCSne30/"
grid_path = base_path + "outCSne30.ug"
data_path = base_path + "outCSne30_vortex.nc"

Loading Grid Files#

grid_path = "../../test/meshfiles/ugrid/outCSne30/outCSne30.ug"
uxgrid = ux.open_grid(grid_path)
uxgrid
<uxarray.Grid>
Original Grid Type: UGRID
Grid Dimensions:
  * n_node: 5402
  * n_face: 5400
  * n_max_face_nodes: 4
  * n_nodes_per_face: (5400,)
Grid Coordinates (Spherical):
  * node_lon: (5402,)
  * node_lat: (5402,)
Grid Coordinates (Cartesian):
Grid Connectivity Variables:
  * face_node_connectivity: (5400, 4)
Grid Descriptor Variables:
grid_path = "../../test/meshfiles/ugrid/outCSne30/outCSne30.ug"
data_path = "../../test/meshfiles/ugrid/outCSne30/outCSne30_vortex.nc"
uxds = ux.open_dataset(grid_path, data_path)
uxds
<xarray.UxDataset> Size: 43kB
Dimensions:  (n_face: 5400)
Dimensions without coordinates: n_face
Data variables:
    psi      (n_face) float64 43kB ...

Talk about accessor

uxds.uxgrid
<uxarray.Grid>
Original Grid Type: UGRID
Grid Dimensions:
  * n_node: 5402
  * n_face: 5400
  * n_max_face_nodes: 4
  * n_nodes_per_face: (5400,)
Grid Coordinates (Spherical):
  * node_lon: (5402,)
  * node_lat: (5402,)
Grid Coordinates (Cartesian):
Grid Connectivity Variables:
  * face_node_connectivity: (5400, 4)
Grid Descriptor Variables:

Accessing Grid Dimensions & Variables#

First, talk about how a grid can be accessed stand alone or through a dataset or data array

uxds.uxgrid.n_node, uxgrid.n_node
(5402, 5402)

Dimensions#

uxgrid.sizes
{'n_face': 5400, 'n_node': 5402, 'n_max_face_nodes': 4}
uxgrid.n_node, uxgrid.n_edge, uxgrid.n_face
(5402, 10800, 5400)

Coordinates#

uxgrid.node_lon
<xarray.DataArray 'node_lon' (n_node: 5402)> Size: 43kB
array([-45.        ,  45.        , 135.        , ..., 141.09968961,
       138.03317102, 135.        ])
Dimensions without coordinates: n_node
uxgrid.node_lat
<xarray.DataArray 'node_lat' (n_node: 5402)> Size: 43kB
[5402 values with dtype=float64]
Dimensions without coordinates: n_node
Attributes:
    standard_name:  latitude
    long_name:      latitude of 2D mesh nodes
    units:          degrees_north
uxgrid.node_x
<xarray.DataArray 'node_x' (n_node: 5402)> Size: 43kB
array([ 0.57735027,  0.57735027, -0.57735027, ..., -0.58878977,
       -0.57332232, -0.55611709])
Dimensions without coordinates: n_node
Attributes:
    standard_name:  x
    long name:      Cartesian x location of the corner nodes of each face
    units:          meters

Connectivity#

uxgrid.face_node_connectivity
<xarray.DataArray 'face_node_connectivity' (n_face: 5400, n_max_face_nodes: 4)> Size: 173kB
array([[   0,    8,  356,  124],
       [   8,    9,  357,  356],
       [   9,   10,  358,  357],
       ...,
       [5399, 5400,  299,  300],
       [5400, 5401,  298,  299],
       [5401,  297,    6,  298]])
Dimensions without coordinates: n_face, n_max_face_nodes
Attributes:
    cf_role:      face_node_connectivity
    start_index:  0
    _FillValue:   -9223372036854775808
uxgrid.face_edge_connectivity
<xarray.DataArray 'face_edge_connectivity' (n_face: 5400, n_max_face_edges: 4)> Size: 173kB
array([[    0,    25,   369,     2],
       [   24,    28,  1056,    25],
       [   27,    31,  1058,    28],
       ...,
       [10798,   889,   887,   892],
       [10799,   886,   884,   889],
       [  883,    19,    20,   886]])
Dimensions without coordinates: n_face, n_max_face_edges
Attributes:
    cf_role:      face_edge_connectivity
    long name:    Maps every face to its edges.
    start_index:  0
    _FillValue:   -9223372036854775808
    dtype:        <class 'numpy.int64'>

Plotting#

uxds["psi"].plot(width=600, height=300)