Data Structures
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.
uxarray.Grid
: Stores the grid representation (i.e. coordinates, connectivity information, etc.)
uxarray.UxDataset
: One or more data variable that resided on a grid.
uxarray.UxDataArray
: A single data variable that resides on a grid
Grid and Data Files
When working with unstructured grid datasets, the grid definition is typically stored separately from any data variables.
For example, the dataset used in this example is made up of two files: a single grid definition and a single data file.
quad-hexagon
│ grid.nc
│ data.nc
Additionally, there may be multiple data files that are mapped to the same unstructured grid (such as the case with climate model output). Using our sample dataset, this may look something like this:
quad-hexagon
│ grid.nc
│ data1.nc
| data2.nc
| data3.nc
We can store these paths as a list (in this case we simply repeat the original data file to imitate having 4 separate data files)
Grid
The Grid
class is used for storing variables associated with an unstructured grid’s topology. This includes dimensions, coordinates, and connectivity variables.
Creating a Grid
The recommended way to construct a Grid
is by using the ux.open_grid()
method, which takes in a grid file path, detects the input grid format, and parses and encodes the provided coordinates and connectivity into the UGRID conventions. Details on supported grid formats and what variables are parsed can be found in other parts of this user guide.
<uxarray.Grid>
Original Grid Type: UGRID
Grid Dimensions:
* n_node: 16
* n_edge: 19
* n_face: 4
* n_max_face_nodes: 6
* n_nodes_per_face: (4,)
Grid Coordinates (Spherical):
* node_lon: (16,)
* node_lat: (16,)
* edge_lon: (19,)
* edge_lat: (19,)
* face_lon: (4,)
* face_lat: (4,)
Grid Coordinates (Cartesian):
Grid Connectivity Variables:
* face_node_connectivity: (4, 6)
Grid Descriptor Variables:
* n_nodes_per_face: (4,)
Dimensions: n_node : 16n_face : 4n_edge : 19n_max_face_nodes : 6
Spherical Coordinates: (6)
node_lon
(n_node)
float32
-0.03841 -0.1864 ... 0.2352 0.2439
standard_name : longitude long_name : longitude of mesh nodes units : degrees_east array([-0.038411, -0.186448, -0.181994, -0.047552, 0.100399, 0.096181,
0.105031, 0.239774, -0.177116, -0.325237, 0.378854, 0.382835,
-0.042753, -0.320659, 0.235225, 0.243879], dtype=float32) node_lat
(n_node)
float32
...
standard_name : latitude long_name : latitude of mesh nodes units : degrees_north [16 values with dtype=float32] edge_lon
(n_edge)
float32
-0.1149 0.02647 ... 0.03119 0.1723
standard_name : longitude long name : Longitude of the center of each edge units : degrees_east array([-0.114868, 0.026474, 0.167755, 0.309082, -0.184204, 0.098297,
0.380844, -0.253662, -0.112366, 0.028824, 0.17009 , 0.311295,
-0.322998, -0.040649, 0.241837, -0.251099, -0.109985, 0.031189,
0.172333], dtype=float32) edge_lat
(n_edge)
float32
...
standard_name : latitude long_name : latitude of edge centers units : degrees_north [19 values with dtype=float32] face_lon
(n_face)
float32
-0.04297 0.1006 -0.1818 0.2396
standard_name : longitude long name : Longitude of the center of each face units : degrees_east array([-0.042969, 0.100616, -0.181763, 0.239563], dtype=float32) face_lat
(n_face)
float32
...
standard_name : latitude long_name : latitude of center nodes units : degrees_north [4 values with dtype=float32] Cartesian Coordinates: (0)
Connectivity: (1)
Descriptors: (1)
Attributes: (54)
model_name : mpas core_name : init_atmosphere source : MPAS Conventions : MPAS git_version : v6.0-dirty on_a_sphere : YES sphere_radius : 6371229.0 is_periodic : NO x_period : 0.0 y_period : 0.0 history : Mon Aug 16 12:09:52 2021: ncks -v latVertex,lonVertex,latCell,lonCell,latEdge,lonEdge,cellsOnVertex,verticesOnCell,verticesOnEdge,edgesOnVertex,edgesOnCell,nEdgesOnCell,angleEdge x1.655362.init.nc foo.nc
mpirun -n 18 ./init_atmosphere_model parent_id : 0hhmjs26t0
mesh_spec : 0.0 config_init_case : 7 config_calendar_type : gregorian config_start_time : 2016-08-01_00:00:00 config_stop_time : 2016-09-10_00:00:00 config_theta_adv_order : 3 config_coef_3rd_order : 0.25 config_num_halos : 2 config_nvertlevels : 75 config_nsoillevels : 4 config_nfglevels : 38 config_nfgsoillevels : 4 config_months : 12 config_geog_data_path : /glade/p/work/wrfhelp/WPS_GEOG/ config_met_prefix : FILE config_sfc_prefix : SST config_fg_interval : 86400 config_landuse_data : USGS config_topo_data : GMTED2010 config_use_spechumd : NO config_ztop : 40000.0 config_nsmterrain : 1 config_smooth_surfaces : YES config_dzmin : 0.3 config_nsm : 30 config_tc_vertical_grid : YES config_extrap_airtemp : linear config_static_interp : NO config_native_gwd_static : NO config_gwd_cell_scaling : 1.0 config_vertical_grid : YES config_met_interp : YES config_input_sst : NO config_frac_seaice : YES config_pio_num_iotasks : 0 config_pio_stride : 1 config_block_decomp_file_prefix : x1.655362.graph.info.part. config_number_of_blocks : 0 config_explicit_proc_decomp : NO config_proc_decomp_file_prefix : graph.info.part. file_id : ytj0fh0qmd NCO : netCDF Operators version 4.9.5 (Homepage = http://nco.sf.net, Code = http://github.com/nco/nco)
Accessing Variables
As we saw above when printing out Grid instance, there are many variables that are associated with a single grid. In addition to the general repr, we can obtain the stored dimensions, coordinates, and connectivity variables through the following attributes.
{'n_edge', 'n_face', 'n_max_face_nodes', 'n_node'}
{'n_edge': 19, 'n_max_face_nodes': 6, 'n_face': 4, 'n_node': 16}
{'edge_lat', 'edge_lon', 'face_lat', 'face_lon', 'node_lat', 'node_lon'}
{'face_node_connectivity'}
We can access any desired quantity by either calling an attribute by the same name or by indexing a Grid
like a dictionary.
<xarray.DataArray 'node_lon' (n_node: 16)> Size: 64B
array([-0.038411, -0.186448, -0.181994, -0.047552, 0.100399, 0.096181,
0.105031, 0.239774, -0.177116, -0.325237, 0.378854, 0.382835,
-0.042753, -0.320659, 0.235225, 0.243879], dtype=float32)
Dimensions without coordinates: n_node
Attributes:
standard_name: longitude
long_name: longitude of mesh nodes
units: degrees_east -0.03841 -0.1864 -0.182 -0.04755 ... -0.04275 -0.3207 0.2352 0.2439
array([-0.038411, -0.186448, -0.181994, -0.047552, 0.100399, 0.096181,
0.105031, 0.239774, -0.177116, -0.325237, 0.378854, 0.382835,
-0.042753, -0.320659, 0.235225, 0.243879], dtype=float32) Coordinates: (0)
Indexes: (0)
Attributes: (3)
standard_name : longitude long_name : longitude of mesh nodes units : degrees_east
<xarray.DataArray 'node_lon' (n_node: 16)> Size: 64B
array([-0.038411, -0.186448, -0.181994, -0.047552, 0.100399, 0.096181,
0.105031, 0.239774, -0.177116, -0.325237, 0.378854, 0.382835,
-0.042753, -0.320659, 0.235225, 0.243879], dtype=float32)
Dimensions without coordinates: n_node
Attributes:
standard_name: longitude
long_name: longitude of mesh nodes
units: degrees_east -0.03841 -0.1864 -0.182 -0.04755 ... -0.04275 -0.3207 0.2352 0.2439
array([-0.038411, -0.186448, -0.181994, -0.047552, 0.100399, 0.096181,
0.105031, 0.239774, -0.177116, -0.325237, 0.378854, 0.382835,
-0.042753, -0.320659, 0.235225, 0.243879], dtype=float32) Coordinates: (0)
Indexes: (0)
Attributes: (3)
standard_name : longitude long_name : longitude of mesh nodes units : degrees_east
Constructing Additional Variables
Looking at Grid.connectivity
one more time, we can see that there are only two available variables.
{'face_node_connectivity'}
These variables are the ones that were able to be parsed and encoded in the UGRID conventions from the inputted grid file.
In addition to parsing variables, we can construct additional variables by calling the attribute or indexing the Grid with the desired name. For example, if we wanted to construct the face_edge_connectivity
, we would do the following:
<xarray.DataArray 'face_edge_connectivity' (n_face: 4, n_max_face_edges: 6)> Size: 192B
array([[ 0, 3, 5, 6, 7, 1],
[12, 10, 11, 2, 1, 9],
[ 2, 14, 13, 15, 4, 0],
[ 8, 18, 16, 17, 9, 7]])
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 0 3 5 6 7 1 12 10 11 2 1 9 2 14 13 15 4 0 8 18 16 17 9 7
array([[ 0, 3, 5, 6, 7, 1],
[12, 10, 11, 2, 1, 9],
[ 2, 14, 13, 15, 4, 0],
[ 8, 18, 16, 17, 9, 7]]) Coordinates: (0)
Indexes: (0)
Attributes: (4)
cf_role : face_edge_connectivity long name : Maps every face to its edges. start_index : 0 _FillValue : -9223372036854775808
Now if we look at our Grid.connectivity
, we can see that it now contains our new connectivity variable.
{'edge_node_connectivity', 'face_edge_connectivity', 'face_node_connectivity'}
All grid variables can be accessed using an attribute. At the time the user calls the attribute (in the above example uxgrid.face_edge_connectivity
), there is code in place to check whether the variable is present within the Grid
. If it’s available, it is directly returned to the user, otherwise it is constructed. Below shows off how this works internally.
@property
def face_edge_connectivity ( self ) -> xr . DataArray :
"""Indices of the edges that surround each face.
Dimensions: ``(n_face, n_max_face_edges)``
"""
if "face_edge_connectivity" not in self . _ds :
_populate_face_edge_connectivity ( self )
return self . _ds [ "face_edge_connectivity" ]
UxDataset
Up to this point, we’ve exclusively looked at the unstructured grid without any data variables mapped to it. Working with a standalone Grid
has its applications, such as grid debugging and analysis, however more commonly an unstructured grid is paired with data variables that are mapped to it.
The UxDataset
class is used for pairing one or more data variables with an unstructured grid. It operates similarly to a xarrary.Dataset
, with the addition of unstructured-grid specific functionality and is linked to an instance of a Grid
.
Opening a Single Data File
We can load a pair of grid and data files using the ux.open_dataset()
method.
<xarray.UxDataset> Size: 16B
Dimensions: (n_face: 4)
Dimensions without coordinates: n_face
Data variables:
t2m (n_face) float32 16B ...
<xarray.UxDataset> Size: 16B
Dimensions: (n_face: 4)
Dimensions without coordinates: n_face
Data variables:
t2m (n_face) float32 16B ... Show Grid Information
<uxarray.Grid>
Original Grid Type: UGRID
Grid Dimensions:
* n_node: 16
* n_edge: 19
* n_face: 4
* n_max_face_nodes: 6
* n_nodes_per_face: (4,)
Grid Coordinates (Spherical):
* node_lon: (16,)
* node_lat: (16,)
* edge_lon: (19,)
* edge_lat: (19,)
* face_lon: (4,)
* face_lat: (4,)
Grid Coordinates (Cartesian):
Grid Connectivity Variables:
* face_node_connectivity: (4, 6)
Grid Descriptor Variables:
* n_nodes_per_face: (4,)
Dimensions: n_node : 16n_face : 4n_edge : 19n_max_face_nodes : 6
Spherical Coordinates: (6)
node_lon
(n_node)
float32
-0.03841 -0.1864 ... 0.2352 0.2439
standard_name : longitude long_name : longitude of mesh nodes units : degrees_east array([-0.038411, -0.186448, -0.181994, -0.047552, 0.100399, 0.096181,
0.105031, 0.239774, -0.177116, -0.325237, 0.378854, 0.382835,
-0.042753, -0.320659, 0.235225, 0.243879], dtype=float32) node_lat
(n_node)
float32
...
standard_name : latitude long_name : latitude of mesh nodes units : degrees_north [16 values with dtype=float32] edge_lon
(n_edge)
float32
-0.1149 0.02647 ... 0.03119 0.1723
standard_name : longitude long name : Longitude of the center of each edge units : degrees_east array([-0.114868, 0.026474, 0.167755, 0.309082, -0.184204, 0.098297,
0.380844, -0.253662, -0.112366, 0.028824, 0.17009 , 0.311295,
-0.322998, -0.040649, 0.241837, -0.251099, -0.109985, 0.031189,
0.172333], dtype=float32) edge_lat
(n_edge)
float32
...
standard_name : latitude long_name : latitude of edge centers units : degrees_north [19 values with dtype=float32] face_lon
(n_face)
float32
-0.04297 0.1006 -0.1818 0.2396
standard_name : longitude long name : Longitude of the center of each face units : degrees_east array([-0.042969, 0.100616, -0.181763, 0.239563], dtype=float32) face_lat
(n_face)
float32
...
standard_name : latitude long_name : latitude of center nodes units : degrees_north [4 values with dtype=float32] Cartesian Coordinates: (0)
Connectivity: (1)
Descriptors: (1)
Attributes: (54)
model_name : mpas core_name : init_atmosphere source : MPAS Conventions : MPAS git_version : v6.0-dirty on_a_sphere : YES sphere_radius : 6371229.0 is_periodic : NO x_period : 0.0 y_period : 0.0 history : Mon Aug 16 12:09:52 2021: ncks -v latVertex,lonVertex,latCell,lonCell,latEdge,lonEdge,cellsOnVertex,verticesOnCell,verticesOnEdge,edgesOnVertex,edgesOnCell,nEdgesOnCell,angleEdge x1.655362.init.nc foo.nc
mpirun -n 18 ./init_atmosphere_model parent_id : 0hhmjs26t0
mesh_spec : 0.0 config_init_case : 7 config_calendar_type : gregorian config_start_time : 2016-08-01_00:00:00 config_stop_time : 2016-09-10_00:00:00 config_theta_adv_order : 3 config_coef_3rd_order : 0.25 config_num_halos : 2 config_nvertlevels : 75 config_nsoillevels : 4 config_nfglevels : 38 config_nfgsoillevels : 4 config_months : 12 config_geog_data_path : /glade/p/work/wrfhelp/WPS_GEOG/ config_met_prefix : FILE config_sfc_prefix : SST config_fg_interval : 86400 config_landuse_data : USGS config_topo_data : GMTED2010 config_use_spechumd : NO config_ztop : 40000.0 config_nsmterrain : 1 config_smooth_surfaces : YES config_dzmin : 0.3 config_nsm : 30 config_tc_vertical_grid : YES config_extrap_airtemp : linear config_static_interp : NO config_native_gwd_static : NO config_gwd_cell_scaling : 1.0 config_vertical_grid : YES config_met_interp : YES config_input_sst : NO config_frac_seaice : YES config_pio_num_iotasks : 0 config_pio_stride : 1 config_block_decomp_file_prefix : x1.655362.graph.info.part. config_number_of_blocks : 0 config_explicit_proc_decomp : NO config_proc_decomp_file_prefix : graph.info.part. file_id : ytj0fh0qmd NCO : netCDF Operators version 4.9.5 (Homepage = http://nco.sf.net, Code = http://github.com/nco/nco)
Opening Multiple Data Files
When working with multiple data paths, we can open them using the ux.open_mfdataset()
method.
<xarray.UxDataset> Size: 48B
Dimensions: (time: 3, n_face: 4)
Dimensions without coordinates: time, n_face
Data variables:
t2m (time, n_face) float32 48B dask.array<chunksize=(1, 4), meta=np.ndarray>
<xarray.UxDataset> Size: 48B
Dimensions: (time: 3, n_face: 4)
Dimensions without coordinates: time, n_face
Data variables:
t2m (time, n_face) float32 48B dask.array<chunksize=(1, 4), meta=np.ndarray> Show Grid Information
<uxarray.Grid>
Original Grid Type: UGRID
Grid Dimensions:
* n_node: 16
* n_edge: 19
* n_face: 4
* n_max_face_nodes: 6
* n_nodes_per_face: (4,)
Grid Coordinates (Spherical):
* node_lon: (16,)
* node_lat: (16,)
* edge_lon: (19,)
* edge_lat: (19,)
* face_lon: (4,)
* face_lat: (4,)
Grid Coordinates (Cartesian):
Grid Connectivity Variables:
* face_node_connectivity: (4, 6)
Grid Descriptor Variables:
* n_nodes_per_face: (4,)
Dimensions: n_node : 16n_face : 4n_edge : 19n_max_face_nodes : 6
Spherical Coordinates: (6)
node_lon
(n_node)
float32
-0.03841 -0.1864 ... 0.2352 0.2439
standard_name : longitude long_name : longitude of mesh nodes units : degrees_east array([-0.038411, -0.186448, -0.181994, -0.047552, 0.100399, 0.096181,
0.105031, 0.239774, -0.177116, -0.325237, 0.378854, 0.382835,
-0.042753, -0.320659, 0.235225, 0.243879], dtype=float32) node_lat
(n_node)
float32
...
standard_name : latitude long_name : latitude of mesh nodes units : degrees_north [16 values with dtype=float32] edge_lon
(n_edge)
float32
-0.1149 0.02647 ... 0.03119 0.1723
standard_name : longitude long name : Longitude of the center of each edge units : degrees_east array([-0.114868, 0.026474, 0.167755, 0.309082, -0.184204, 0.098297,
0.380844, -0.253662, -0.112366, 0.028824, 0.17009 , 0.311295,
-0.322998, -0.040649, 0.241837, -0.251099, -0.109985, 0.031189,
0.172333], dtype=float32) edge_lat
(n_edge)
float32
...
standard_name : latitude long_name : latitude of edge centers units : degrees_north [19 values with dtype=float32] face_lon
(n_face)
float32
-0.04297 0.1006 -0.1818 0.2396
standard_name : longitude long name : Longitude of the center of each face units : degrees_east array([-0.042969, 0.100616, -0.181763, 0.239563], dtype=float32) face_lat
(n_face)
float32
...
standard_name : latitude long_name : latitude of center nodes units : degrees_north [4 values with dtype=float32] Cartesian Coordinates: (0)
Connectivity: (1)
Descriptors: (1)
Attributes: (54)
model_name : mpas core_name : init_atmosphere source : MPAS Conventions : MPAS git_version : v6.0-dirty on_a_sphere : YES sphere_radius : 6371229.0 is_periodic : NO x_period : 0.0 y_period : 0.0 history : Mon Aug 16 12:09:52 2021: ncks -v latVertex,lonVertex,latCell,lonCell,latEdge,lonEdge,cellsOnVertex,verticesOnCell,verticesOnEdge,edgesOnVertex,edgesOnCell,nEdgesOnCell,angleEdge x1.655362.init.nc foo.nc
mpirun -n 18 ./init_atmosphere_model parent_id : 0hhmjs26t0
mesh_spec : 0.0 config_init_case : 7 config_calendar_type : gregorian config_start_time : 2016-08-01_00:00:00 config_stop_time : 2016-09-10_00:00:00 config_theta_adv_order : 3 config_coef_3rd_order : 0.25 config_num_halos : 2 config_nvertlevels : 75 config_nsoillevels : 4 config_nfglevels : 38 config_nfgsoillevels : 4 config_months : 12 config_geog_data_path : /glade/p/work/wrfhelp/WPS_GEOG/ config_met_prefix : FILE config_sfc_prefix : SST config_fg_interval : 86400 config_landuse_data : USGS config_topo_data : GMTED2010 config_use_spechumd : NO config_ztop : 40000.0 config_nsmterrain : 1 config_smooth_surfaces : YES config_dzmin : 0.3 config_nsm : 30 config_tc_vertical_grid : YES config_extrap_airtemp : linear config_static_interp : NO config_native_gwd_static : NO config_gwd_cell_scaling : 1.0 config_vertical_grid : YES config_met_interp : YES config_input_sst : NO config_frac_seaice : YES config_pio_num_iotasks : 0 config_pio_stride : 1 config_block_decomp_file_prefix : x1.655362.graph.info.part. config_number_of_blocks : 0 config_explicit_proc_decomp : NO config_proc_decomp_file_prefix : graph.info.part. file_id : ytj0fh0qmd NCO : netCDF Operators version 4.9.5 (Homepage = http://nco.sf.net, Code = http://github.com/nco/nco)
Grid Accessor
Each UxDataset
(and in the next section UxDataArray
) is linked to a Grid
instance, which contain the unstructured grid information.
<uxarray.Grid>
Original Grid Type: UGRID
Grid Dimensions:
* n_node: 16
* n_edge: 19
* n_face: 4
* n_max_face_nodes: 6
* n_nodes_per_face: (4,)
Grid Coordinates (Spherical):
* node_lon: (16,)
* node_lat: (16,)
* edge_lon: (19,)
* edge_lat: (19,)
* face_lon: (4,)
* face_lat: (4,)
Grid Coordinates (Cartesian):
Grid Connectivity Variables:
* face_node_connectivity: (4, 6)
Grid Descriptor Variables:
* n_nodes_per_face: (4,)
Dimensions: n_node : 16n_face : 4n_edge : 19n_max_face_nodes : 6
Spherical Coordinates: (6)
node_lon
(n_node)
float32
-0.03841 -0.1864 ... 0.2352 0.2439
standard_name : longitude long_name : longitude of mesh nodes units : degrees_east array([-0.038411, -0.186448, -0.181994, -0.047552, 0.100399, 0.096181,
0.105031, 0.239774, -0.177116, -0.325237, 0.378854, 0.382835,
-0.042753, -0.320659, 0.235225, 0.243879], dtype=float32) node_lat
(n_node)
float32
...
standard_name : latitude long_name : latitude of mesh nodes units : degrees_north [16 values with dtype=float32] edge_lon
(n_edge)
float32
-0.1149 0.02647 ... 0.03119 0.1723
standard_name : longitude long name : Longitude of the center of each edge units : degrees_east array([-0.114868, 0.026474, 0.167755, 0.309082, -0.184204, 0.098297,
0.380844, -0.253662, -0.112366, 0.028824, 0.17009 , 0.311295,
-0.322998, -0.040649, 0.241837, -0.251099, -0.109985, 0.031189,
0.172333], dtype=float32) edge_lat
(n_edge)
float32
...
standard_name : latitude long_name : latitude of edge centers units : degrees_north [19 values with dtype=float32] face_lon
(n_face)
float32
-0.04297 0.1006 -0.1818 0.2396
standard_name : longitude long name : Longitude of the center of each face units : degrees_east array([-0.042969, 0.100616, -0.181763, 0.239563], dtype=float32) face_lat
(n_face)
float32
...
standard_name : latitude long_name : latitude of center nodes units : degrees_north [4 values with dtype=float32] Cartesian Coordinates: (0)
Connectivity: (1)
Descriptors: (1)
Attributes: (54)
model_name : mpas core_name : init_atmosphere source : MPAS Conventions : MPAS git_version : v6.0-dirty on_a_sphere : YES sphere_radius : 6371229.0 is_periodic : NO x_period : 0.0 y_period : 0.0 history : Mon Aug 16 12:09:52 2021: ncks -v latVertex,lonVertex,latCell,lonCell,latEdge,lonEdge,cellsOnVertex,verticesOnCell,verticesOnEdge,edgesOnVertex,edgesOnCell,nEdgesOnCell,angleEdge x1.655362.init.nc foo.nc
mpirun -n 18 ./init_atmosphere_model parent_id : 0hhmjs26t0
mesh_spec : 0.0 config_init_case : 7 config_calendar_type : gregorian config_start_time : 2016-08-01_00:00:00 config_stop_time : 2016-09-10_00:00:00 config_theta_adv_order : 3 config_coef_3rd_order : 0.25 config_num_halos : 2 config_nvertlevels : 75 config_nsoillevels : 4 config_nfglevels : 38 config_nfgsoillevels : 4 config_months : 12 config_geog_data_path : /glade/p/work/wrfhelp/WPS_GEOG/ config_met_prefix : FILE config_sfc_prefix : SST config_fg_interval : 86400 config_landuse_data : USGS config_topo_data : GMTED2010 config_use_spechumd : NO config_ztop : 40000.0 config_nsmterrain : 1 config_smooth_surfaces : YES config_dzmin : 0.3 config_nsm : 30 config_tc_vertical_grid : YES config_extrap_airtemp : linear config_static_interp : NO config_native_gwd_static : NO config_gwd_cell_scaling : 1.0 config_vertical_grid : YES config_met_interp : YES config_input_sst : NO config_frac_seaice : YES config_pio_num_iotasks : 0 config_pio_stride : 1 config_block_decomp_file_prefix : x1.655362.graph.info.part. config_number_of_blocks : 0 config_explicit_proc_decomp : NO config_proc_decomp_file_prefix : graph.info.part. file_id : ytj0fh0qmd NCO : netCDF Operators version 4.9.5 (Homepage = http://nco.sf.net, Code = http://github.com/nco/nco)
All the same functionality can be performed using the uxgrid
attribute as was discussed in the Grid
sections above.
{'n_edge', 'n_face', 'n_max_face_nodes', 'n_node'}
UxDataArray
While a UxDataset
represents one or more data variables linked to some unstructured grid, a UxDataArray
represent a single data variable. Alternatively, one can think of a UxDataset
as a collection of one or more UxDataArray
instances.
In our sample dataset, we have a variable called t2m
, which can be used to index our UxDataset
<xarray.UxDataArray 't2m' (n_face: 4)> Size: 16B
[4 values with dtype=float32]
Dimensions without coordinates: n_face
Attributes:
units: K
long_name: 2-meter temperature
<xarray.UxDataArray 't2m' (n_face: 4)> Size: 16B
[4 values with dtype=float32]
Dimensions without coordinates: n_face
Attributes:
units: K
long_name: 2-meter temperature Show Grid Information
<uxarray.Grid>
Original Grid Type: UGRID
Grid Dimensions:
* n_node: 16
* n_edge: 19
* n_face: 4
* n_max_face_nodes: 6
* n_nodes_per_face: (4,)
Grid Coordinates (Spherical):
* node_lon: (16,)
* node_lat: (16,)
* edge_lon: (19,)
* edge_lat: (19,)
* face_lon: (4,)
* face_lat: (4,)
Grid Coordinates (Cartesian):
Grid Connectivity Variables:
* face_node_connectivity: (4, 6)
Grid Descriptor Variables:
* n_nodes_per_face: (4,)
Dimensions: n_node : 16n_face : 4n_edge : 19n_max_face_nodes : 6
Spherical Coordinates: (6)
node_lon
(n_node)
float32
-0.03841 -0.1864 ... 0.2352 0.2439
standard_name : longitude long_name : longitude of mesh nodes units : degrees_east array([-0.038411, -0.186448, -0.181994, -0.047552, 0.100399, 0.096181,
0.105031, 0.239774, -0.177116, -0.325237, 0.378854, 0.382835,
-0.042753, -0.320659, 0.235225, 0.243879], dtype=float32) node_lat
(n_node)
float32
...
standard_name : latitude long_name : latitude of mesh nodes units : degrees_north [16 values with dtype=float32] edge_lon
(n_edge)
float32
-0.1149 0.02647 ... 0.03119 0.1723
standard_name : longitude long name : Longitude of the center of each edge units : degrees_east array([-0.114868, 0.026474, 0.167755, 0.309082, -0.184204, 0.098297,
0.380844, -0.253662, -0.112366, 0.028824, 0.17009 , 0.311295,
-0.322998, -0.040649, 0.241837, -0.251099, -0.109985, 0.031189,
0.172333], dtype=float32) edge_lat
(n_edge)
float32
...
standard_name : latitude long_name : latitude of edge centers units : degrees_north [19 values with dtype=float32] face_lon
(n_face)
float32
-0.04297 0.1006 -0.1818 0.2396
standard_name : longitude long name : Longitude of the center of each face units : degrees_east array([-0.042969, 0.100616, -0.181763, 0.239563], dtype=float32) face_lat
(n_face)
float32
...
standard_name : latitude long_name : latitude of center nodes units : degrees_north [4 values with dtype=float32] Cartesian Coordinates: (0)
Connectivity: (1)
Descriptors: (1)
Attributes: (54)
model_name : mpas core_name : init_atmosphere source : MPAS Conventions : MPAS git_version : v6.0-dirty on_a_sphere : YES sphere_radius : 6371229.0 is_periodic : NO x_period : 0.0 y_period : 0.0 history : Mon Aug 16 12:09:52 2021: ncks -v latVertex,lonVertex,latCell,lonCell,latEdge,lonEdge,cellsOnVertex,verticesOnCell,verticesOnEdge,edgesOnVertex,edgesOnCell,nEdgesOnCell,angleEdge x1.655362.init.nc foo.nc
mpirun -n 18 ./init_atmosphere_model parent_id : 0hhmjs26t0
mesh_spec : 0.0 config_init_case : 7 config_calendar_type : gregorian config_start_time : 2016-08-01_00:00:00 config_stop_time : 2016-09-10_00:00:00 config_theta_adv_order : 3 config_coef_3rd_order : 0.25 config_num_halos : 2 config_nvertlevels : 75 config_nsoillevels : 4 config_nfglevels : 38 config_nfgsoillevels : 4 config_months : 12 config_geog_data_path : /glade/p/work/wrfhelp/WPS_GEOG/ config_met_prefix : FILE config_sfc_prefix : SST config_fg_interval : 86400 config_landuse_data : USGS config_topo_data : GMTED2010 config_use_spechumd : NO config_ztop : 40000.0 config_nsmterrain : 1 config_smooth_surfaces : YES config_dzmin : 0.3 config_nsm : 30 config_tc_vertical_grid : YES config_extrap_airtemp : linear config_static_interp : NO config_native_gwd_static : NO config_gwd_cell_scaling : 1.0 config_vertical_grid : YES config_met_interp : YES config_input_sst : NO config_frac_seaice : YES config_pio_num_iotasks : 0 config_pio_stride : 1 config_block_decomp_file_prefix : x1.655362.graph.info.part. config_number_of_blocks : 0 config_explicit_proc_decomp : NO config_proc_decomp_file_prefix : graph.info.part. file_id : ytj0fh0qmd NCO : netCDF Operators version 4.9.5 (Homepage = http://nco.sf.net, Code = http://github.com/nco/nco)
We can see the relationship between a UxDataset
and UxDataArray
by checking the type.
(uxarray.core.dataset.UxDataset, uxarray.core.dataarray.UxDataArray)
As mentioned before, each UxDataArray
is linked to a Grid
instance.
<uxarray.Grid>
Original Grid Type: UGRID
Grid Dimensions:
* n_node: 16
* n_edge: 19
* n_face: 4
* n_max_face_nodes: 6
* n_nodes_per_face: (4,)
Grid Coordinates (Spherical):
* node_lon: (16,)
* node_lat: (16,)
* edge_lon: (19,)
* edge_lat: (19,)
* face_lon: (4,)
* face_lat: (4,)
Grid Coordinates (Cartesian):
Grid Connectivity Variables:
* face_node_connectivity: (4, 6)
Grid Descriptor Variables:
* n_nodes_per_face: (4,)
Dimensions: n_node : 16n_face : 4n_edge : 19n_max_face_nodes : 6
Spherical Coordinates: (6)
node_lon
(n_node)
float32
-0.03841 -0.1864 ... 0.2352 0.2439
standard_name : longitude long_name : longitude of mesh nodes units : degrees_east array([-0.038411, -0.186448, -0.181994, -0.047552, 0.100399, 0.096181,
0.105031, 0.239774, -0.177116, -0.325237, 0.378854, 0.382835,
-0.042753, -0.320659, 0.235225, 0.243879], dtype=float32) node_lat
(n_node)
float32
...
standard_name : latitude long_name : latitude of mesh nodes units : degrees_north [16 values with dtype=float32] edge_lon
(n_edge)
float32
-0.1149 0.02647 ... 0.03119 0.1723
standard_name : longitude long name : Longitude of the center of each edge units : degrees_east array([-0.114868, 0.026474, 0.167755, 0.309082, -0.184204, 0.098297,
0.380844, -0.253662, -0.112366, 0.028824, 0.17009 , 0.311295,
-0.322998, -0.040649, 0.241837, -0.251099, -0.109985, 0.031189,
0.172333], dtype=float32) edge_lat
(n_edge)
float32
...
standard_name : latitude long_name : latitude of edge centers units : degrees_north [19 values with dtype=float32] face_lon
(n_face)
float32
-0.04297 0.1006 -0.1818 0.2396
standard_name : longitude long name : Longitude of the center of each face units : degrees_east array([-0.042969, 0.100616, -0.181763, 0.239563], dtype=float32) face_lat
(n_face)
float32
...
standard_name : latitude long_name : latitude of center nodes units : degrees_north [4 values with dtype=float32] Cartesian Coordinates: (0)
Connectivity: (1)
Descriptors: (1)
Attributes: (54)
model_name : mpas core_name : init_atmosphere source : MPAS Conventions : MPAS git_version : v6.0-dirty on_a_sphere : YES sphere_radius : 6371229.0 is_periodic : NO x_period : 0.0 y_period : 0.0 history : Mon Aug 16 12:09:52 2021: ncks -v latVertex,lonVertex,latCell,lonCell,latEdge,lonEdge,cellsOnVertex,verticesOnCell,verticesOnEdge,edgesOnVertex,edgesOnCell,nEdgesOnCell,angleEdge x1.655362.init.nc foo.nc
mpirun -n 18 ./init_atmosphere_model parent_id : 0hhmjs26t0
mesh_spec : 0.0 config_init_case : 7 config_calendar_type : gregorian config_start_time : 2016-08-01_00:00:00 config_stop_time : 2016-09-10_00:00:00 config_theta_adv_order : 3 config_coef_3rd_order : 0.25 config_num_halos : 2 config_nvertlevels : 75 config_nsoillevels : 4 config_nfglevels : 38 config_nfgsoillevels : 4 config_months : 12 config_geog_data_path : /glade/p/work/wrfhelp/WPS_GEOG/ config_met_prefix : FILE config_sfc_prefix : SST config_fg_interval : 86400 config_landuse_data : USGS config_topo_data : GMTED2010 config_use_spechumd : NO config_ztop : 40000.0 config_nsmterrain : 1 config_smooth_surfaces : YES config_dzmin : 0.3 config_nsm : 30 config_tc_vertical_grid : YES config_extrap_airtemp : linear config_static_interp : NO config_native_gwd_static : NO config_gwd_cell_scaling : 1.0 config_vertical_grid : YES config_met_interp : YES config_input_sst : NO config_frac_seaice : YES config_pio_num_iotasks : 0 config_pio_stride : 1 config_block_decomp_file_prefix : x1.655362.graph.info.part. config_number_of_blocks : 0 config_explicit_proc_decomp : NO config_proc_decomp_file_prefix : graph.info.part. file_id : ytj0fh0qmd NCO : netCDF Operators version 4.9.5 (Homepage = http://nco.sf.net, Code = http://github.com/nco/nco)
This Grid is identical to the one linked to the UxDataset
. Regardless of the number of data variables present in the UxDataset
, they all share a single Grid
instance.
Functionality
Just like with Xarray, we can perform various operations on our data variable.
<xarray.UxDataArray 't2m' ()> Size: 4B
array(297.25037, dtype=float32)
<xarray.UxDataArray 't2m' ()> Size: 4B
array(297.25037, dtype=float32) Show Grid Information
<uxarray.Grid>
Original Grid Type: UGRID
Grid Dimensions:
* n_node: 16
* n_edge: 19
* n_face: 4
* n_max_face_nodes: 6
* n_nodes_per_face: (4,)
Grid Coordinates (Spherical):
* node_lon: (16,)
* node_lat: (16,)
* edge_lon: (19,)
* edge_lat: (19,)
* face_lon: (4,)
* face_lat: (4,)
Grid Coordinates (Cartesian):
Grid Connectivity Variables:
* face_node_connectivity: (4, 6)
Grid Descriptor Variables:
* n_nodes_per_face: (4,)
Dimensions: n_node : 16n_face : 4n_edge : 19n_max_face_nodes : 6
Spherical Coordinates: (6)
node_lon
(n_node)
float32
-0.03841 -0.1864 ... 0.2352 0.2439
standard_name : longitude long_name : longitude of mesh nodes units : degrees_east array([-0.038411, -0.186448, -0.181994, -0.047552, 0.100399, 0.096181,
0.105031, 0.239774, -0.177116, -0.325237, 0.378854, 0.382835,
-0.042753, -0.320659, 0.235225, 0.243879], dtype=float32) node_lat
(n_node)
float32
...
standard_name : latitude long_name : latitude of mesh nodes units : degrees_north [16 values with dtype=float32] edge_lon
(n_edge)
float32
-0.1149 0.02647 ... 0.03119 0.1723
standard_name : longitude long name : Longitude of the center of each edge units : degrees_east array([-0.114868, 0.026474, 0.167755, 0.309082, -0.184204, 0.098297,
0.380844, -0.253662, -0.112366, 0.028824, 0.17009 , 0.311295,
-0.322998, -0.040649, 0.241837, -0.251099, -0.109985, 0.031189,
0.172333], dtype=float32) edge_lat
(n_edge)
float32
...
standard_name : latitude long_name : latitude of edge centers units : degrees_north [19 values with dtype=float32] face_lon
(n_face)
float32
-0.04297 0.1006 -0.1818 0.2396
standard_name : longitude long name : Longitude of the center of each face units : degrees_east array([-0.042969, 0.100616, -0.181763, 0.239563], dtype=float32) face_lat
(n_face)
float32
...
standard_name : latitude long_name : latitude of center nodes units : degrees_north [4 values with dtype=float32] Cartesian Coordinates: (0)
Connectivity: (1)
Descriptors: (1)
Attributes: (54)
model_name : mpas core_name : init_atmosphere source : MPAS Conventions : MPAS git_version : v6.0-dirty on_a_sphere : YES sphere_radius : 6371229.0 is_periodic : NO x_period : 0.0 y_period : 0.0 history : Mon Aug 16 12:09:52 2021: ncks -v latVertex,lonVertex,latCell,lonCell,latEdge,lonEdge,cellsOnVertex,verticesOnCell,verticesOnEdge,edgesOnVertex,edgesOnCell,nEdgesOnCell,angleEdge x1.655362.init.nc foo.nc
mpirun -n 18 ./init_atmosphere_model parent_id : 0hhmjs26t0
mesh_spec : 0.0 config_init_case : 7 config_calendar_type : gregorian config_start_time : 2016-08-01_00:00:00 config_stop_time : 2016-09-10_00:00:00 config_theta_adv_order : 3 config_coef_3rd_order : 0.25 config_num_halos : 2 config_nvertlevels : 75 config_nsoillevels : 4 config_nfglevels : 38 config_nfgsoillevels : 4 config_months : 12 config_geog_data_path : /glade/p/work/wrfhelp/WPS_GEOG/ config_met_prefix : FILE config_sfc_prefix : SST config_fg_interval : 86400 config_landuse_data : USGS config_topo_data : GMTED2010 config_use_spechumd : NO config_ztop : 40000.0 config_nsmterrain : 1 config_smooth_surfaces : YES config_dzmin : 0.3 config_nsm : 30 config_tc_vertical_grid : YES config_extrap_airtemp : linear config_static_interp : NO config_native_gwd_static : NO config_gwd_cell_scaling : 1.0 config_vertical_grid : YES config_met_interp : YES config_input_sst : NO config_frac_seaice : YES config_pio_num_iotasks : 0 config_pio_stride : 1 config_block_decomp_file_prefix : x1.655362.graph.info.part. config_number_of_blocks : 0 config_explicit_proc_decomp : NO config_proc_decomp_file_prefix : graph.info.part. file_id : ytj0fh0qmd NCO : netCDF Operators version 4.9.5 (Homepage = http://nco.sf.net, Code = http://github.com/nco/nco)
<xarray.UxDataArray 't2m' ()> Size: 4B
array(297.54895, dtype=float32)
<xarray.UxDataArray 't2m' ()> Size: 4B
array(297.54895, dtype=float32) Show Grid Information
<uxarray.Grid>
Original Grid Type: UGRID
Grid Dimensions:
* n_node: 16
* n_edge: 19
* n_face: 4
* n_max_face_nodes: 6
* n_nodes_per_face: (4,)
Grid Coordinates (Spherical):
* node_lon: (16,)
* node_lat: (16,)
* edge_lon: (19,)
* edge_lat: (19,)
* face_lon: (4,)
* face_lat: (4,)
Grid Coordinates (Cartesian):
Grid Connectivity Variables:
* face_node_connectivity: (4, 6)
Grid Descriptor Variables:
* n_nodes_per_face: (4,)
Dimensions: n_node : 16n_face : 4n_edge : 19n_max_face_nodes : 6
Spherical Coordinates: (6)
node_lon
(n_node)
float32
-0.03841 -0.1864 ... 0.2352 0.2439
standard_name : longitude long_name : longitude of mesh nodes units : degrees_east array([-0.038411, -0.186448, -0.181994, -0.047552, 0.100399, 0.096181,
0.105031, 0.239774, -0.177116, -0.325237, 0.378854, 0.382835,
-0.042753, -0.320659, 0.235225, 0.243879], dtype=float32) node_lat
(n_node)
float32
...
standard_name : latitude long_name : latitude of mesh nodes units : degrees_north [16 values with dtype=float32] edge_lon
(n_edge)
float32
-0.1149 0.02647 ... 0.03119 0.1723
standard_name : longitude long name : Longitude of the center of each edge units : degrees_east array([-0.114868, 0.026474, 0.167755, 0.309082, -0.184204, 0.098297,
0.380844, -0.253662, -0.112366, 0.028824, 0.17009 , 0.311295,
-0.322998, -0.040649, 0.241837, -0.251099, -0.109985, 0.031189,
0.172333], dtype=float32) edge_lat
(n_edge)
float32
...
standard_name : latitude long_name : latitude of edge centers units : degrees_north [19 values with dtype=float32] face_lon
(n_face)
float32
-0.04297 0.1006 -0.1818 0.2396
standard_name : longitude long name : Longitude of the center of each face units : degrees_east array([-0.042969, 0.100616, -0.181763, 0.239563], dtype=float32) face_lat
(n_face)
float32
...
standard_name : latitude long_name : latitude of center nodes units : degrees_north [4 values with dtype=float32] Cartesian Coordinates: (0)
Connectivity: (1)
Descriptors: (1)
Attributes: (54)
model_name : mpas core_name : init_atmosphere source : MPAS Conventions : MPAS git_version : v6.0-dirty on_a_sphere : YES sphere_radius : 6371229.0 is_periodic : NO x_period : 0.0 y_period : 0.0 history : Mon Aug 16 12:09:52 2021: ncks -v latVertex,lonVertex,latCell,lonCell,latEdge,lonEdge,cellsOnVertex,verticesOnCell,verticesOnEdge,edgesOnVertex,edgesOnCell,nEdgesOnCell,angleEdge x1.655362.init.nc foo.nc
mpirun -n 18 ./init_atmosphere_model parent_id : 0hhmjs26t0
mesh_spec : 0.0 config_init_case : 7 config_calendar_type : gregorian config_start_time : 2016-08-01_00:00:00 config_stop_time : 2016-09-10_00:00:00 config_theta_adv_order : 3 config_coef_3rd_order : 0.25 config_num_halos : 2 config_nvertlevels : 75 config_nsoillevels : 4 config_nfglevels : 38 config_nfgsoillevels : 4 config_months : 12 config_geog_data_path : /glade/p/work/wrfhelp/WPS_GEOG/ config_met_prefix : FILE config_sfc_prefix : SST config_fg_interval : 86400 config_landuse_data : USGS config_topo_data : GMTED2010 config_use_spechumd : NO config_ztop : 40000.0 config_nsmterrain : 1 config_smooth_surfaces : YES config_dzmin : 0.3 config_nsm : 30 config_tc_vertical_grid : YES config_extrap_airtemp : linear config_static_interp : NO config_native_gwd_static : NO config_gwd_cell_scaling : 1.0 config_vertical_grid : YES config_met_interp : YES config_input_sst : NO config_frac_seaice : YES config_pio_num_iotasks : 0 config_pio_stride : 1 config_block_decomp_file_prefix : x1.655362.graph.info.part. config_number_of_blocks : 0 config_explicit_proc_decomp : NO config_proc_decomp_file_prefix : graph.info.part. file_id : ytj0fh0qmd NCO : netCDF Operators version 4.9.5 (Homepage = http://nco.sf.net, Code = http://github.com/nco/nco)
UXarray also provides custom data analysis operators which are explored in further sections of this user guide.
<xarray.UxDataArray 't2m_grad' (n_edge: 19)> Size: 152B
array([28.00277097, 20.66935101, 29.23128307, 0. , 0. ,
0. , 0. , 60.59822029, 0. , 86.32623052,
0. , 0. , 0. , 0. , 0. ,
0. , 0. , 0. , 0. ])
Dimensions without coordinates: n_edge
<xarray.UxDataArray 't2m_grad' (n_edge: 19)> Size: 152B
array([28.00277097, 20.66935101, 29.23128307, 0. , 0. ,
0. , 0. , 60.59822029, 0. , 86.32623052,
0. , 0. , 0. , 0. , 0. ,
0. , 0. , 0. , 0. ])
Dimensions without coordinates: n_edge 28.0 20.67 29.23 0.0 0.0 0.0 0.0 60.6 ... 0.0 0.0 0.0 0.0 0.0 0.0 0.0
array([28.00277097, 20.66935101, 29.23128307, 0. , 0. ,
0. , 0. , 60.59822029, 0. , 86.32623052,
0. , 0. , 0. , 0. , 0. ,
0. , 0. , 0. , 0. ]) Coordinates: (0)
Indexes: (0)
Attributes: (0)
Show Grid Information
<uxarray.Grid>
Original Grid Type: UGRID
Grid Dimensions:
* n_node: 16
* n_edge: 19
* n_face: 4
* n_max_face_nodes: 6
* n_max_face_edges: 6
* two: 2
* n_nodes_per_face: (4,)
Grid Coordinates (Spherical):
* node_lon: (16,)
* node_lat: (16,)
* edge_lon: (19,)
* edge_lat: (19,)
* face_lon: (4,)
* face_lat: (4,)
Grid Coordinates (Cartesian):
Grid Connectivity Variables:
* face_node_connectivity: (4, 6)
* face_edge_connectivity: (4, 6)
* edge_node_connectivity: (19, 2)
* edge_face_connectivity: (19, 2)
Grid Descriptor Variables:
* n_nodes_per_face: (4,)
* edge_face_distances: (19,)
Dimensions: n_node : 16n_face : 4n_edge : 19n_max_face_nodes : 6two : 2n_max_face_edges : 6
Spherical Coordinates: (6)
node_lon
(n_node)
float32
-0.03841 -0.1864 ... 0.2352 0.2439
standard_name : longitude long_name : longitude of mesh nodes units : degrees_east array([-0.038411, -0.186448, -0.181994, -0.047552, 0.100399, 0.096181,
0.105031, 0.239774, -0.177116, -0.325237, 0.378854, 0.382835,
-0.042753, -0.320659, 0.235225, 0.243879], dtype=float32) node_lat
(n_node)
float32
0.04606 -0.0459 ... -0.2608 0.05458
standard_name : latitude long_name : latitude of mesh nodes units : degrees_north array([ 0.046064, -0.0459 , -0.186066, -0.269315, -0.177301, -0.037181,
0.278242, 0.195007, 0.269507, 0.177593, -0.028934, -0.169011,
0.186535, 0.037078, -0.260818, 0.054577], dtype=float32) edge_lon
(n_edge)
float32
-0.1149 0.02647 ... 0.03119 0.1723
standard_name : longitude long name : Longitude of the center of each edge units : degrees_east array([-0.114868, 0.026474, 0.167755, 0.309082, -0.184204, 0.098297,
0.380844, -0.253662, -0.112366, 0.028824, 0.17009 , 0.311295,
-0.322998, -0.040649, 0.241837, -0.251099, -0.109985, 0.031189,
0.172333], dtype=float32) edge_lat
(n_edge)
float32
...
standard_name : latitude long_name : latitude of edge centers units : degrees_north [19 values with dtype=float32] face_lon
(n_face)
float32
-0.04297 0.1006 -0.1818 0.2396
standard_name : longitude long name : Longitude of the center of each face units : degrees_east array([-0.042969, 0.100616, -0.181763, 0.239563], dtype=float32) face_lat
(n_face)
float32
...
standard_name : latitude long_name : latitude of center nodes units : degrees_north [4 values with dtype=float32] Cartesian Coordinates: (0)
Connectivity: (4)
face_edge_connectivity
(n_face, n_max_face_edges)
int64
0 3 5 6 7 1 12 ... 0 8 18 16 17 9 7
cf_role : face_edge_connectivity long name : Maps every face to its edges. start_index : 0 _FillValue : -9223372036854775808 array([[ 0, 3, 5, 6, 7, 1],
[12, 10, 11, 2, 1, 9],
[ 2, 14, 13, 15, 4, 0],
[ 8, 18, 16, 17, 9, 7]]) edge_node_connectivity
(n_edge, two)
int64
0 1 0 5 0 12 ... 10 11 10 15 11 14
cf_role : edge_node_connectivity long name : Maps every edge to the two nodes that it connects. start_index : 0 inverse_indices : [ 0 3 5 6 7 1 12 10 11 2 1 9 2 14 13 15 4 0 8 18 16 17 9 7] fill_value_mask : [False False False False False False False False False False False False
False False False False False False False] array([[ 0, 1],
[ 0, 5],
[ 0, 12],
[ 1, 2],
[ 1, 13],
[ 2, 3],
[ 3, 4],
[ 4, 5],
[ 4, 14],
[ 5, 15],
[ 6, 7],
[ 6, 12],
[ 7, 15],
[ 8, 9],
[ 8, 12],
[ 9, 13],
[10, 11],
[10, 15],
[11, 14]]) edge_face_connectivity
(n_edge, two)
int64
0 2 0 ... 3 -9223372036854775808
cf_role : edge_face_connectivity long name : Faces that neighbor each edge start_index : 0 _FillValue : -9223372036854775808 array([[ 0, 2],
[ 0, 1],
[ 1, 2],
[ 0, -9223372036854775808],
[ 2, -9223372036854775808],
[ 0, -9223372036854775808],
[ 0, -9223372036854775808],
[ 0, 3],
[ 3, -9223372036854775808],
[ 1, 3],
[ 1, -9223372036854775808],
[ 1, -9223372036854775808],
[ 1, -9223372036854775808],
[ 2, -9223372036854775808],
[ 2, -9223372036854775808],
[ 2, -9223372036854775808],
[ 3, -9223372036854775808],
[ 3, -9223372036854775808],
[ 3, -9223372036854775808]]) face_node_connectivity
(n_face, n_max_face_nodes)
int64
0 1 2 3 4 5 15 ... 4 14 11 10 15 5
cf_role : face_node_connectivity long name : Maps every face to its corner nodes. start_index : 0 _FillValue : -9223372036854775808 array([[ 0, 1, 2, 3, 4, 5],
[15, 7, 6, 12, 0, 5],
[ 0, 12, 8, 9, 13, 1],
[ 4, 14, 11, 10, 15, 5]]) Descriptors: (2)
Attributes: (54)
model_name : mpas core_name : init_atmosphere source : MPAS Conventions : MPAS git_version : v6.0-dirty on_a_sphere : YES sphere_radius : 6371229.0 is_periodic : NO x_period : 0.0 y_period : 0.0 history : Mon Aug 16 12:09:52 2021: ncks -v latVertex,lonVertex,latCell,lonCell,latEdge,lonEdge,cellsOnVertex,verticesOnCell,verticesOnEdge,edgesOnVertex,edgesOnCell,nEdgesOnCell,angleEdge x1.655362.init.nc foo.nc
mpirun -n 18 ./init_atmosphere_model parent_id : 0hhmjs26t0
mesh_spec : 0.0 config_init_case : 7 config_calendar_type : gregorian config_start_time : 2016-08-01_00:00:00 config_stop_time : 2016-09-10_00:00:00 config_theta_adv_order : 3 config_coef_3rd_order : 0.25 config_num_halos : 2 config_nvertlevels : 75 config_nsoillevels : 4 config_nfglevels : 38 config_nfgsoillevels : 4 config_months : 12 config_geog_data_path : /glade/p/work/wrfhelp/WPS_GEOG/ config_met_prefix : FILE config_sfc_prefix : SST config_fg_interval : 86400 config_landuse_data : USGS config_topo_data : GMTED2010 config_use_spechumd : NO config_ztop : 40000.0 config_nsmterrain : 1 config_smooth_surfaces : YES config_dzmin : 0.3 config_nsm : 30 config_tc_vertical_grid : YES config_extrap_airtemp : linear config_static_interp : NO config_native_gwd_static : NO config_gwd_cell_scaling : 1.0 config_vertical_grid : YES config_met_interp : YES config_input_sst : NO config_frac_seaice : YES config_pio_num_iotasks : 0 config_pio_stride : 1 config_block_decomp_file_prefix : x1.655362.graph.info.part. config_number_of_blocks : 0 config_explicit_proc_decomp : NO config_proc_decomp_file_prefix : graph.info.part. file_id : ytj0fh0qmd NCO : netCDF Operators version 4.9.5 (Homepage = http://nco.sf.net, Code = http://github.com/nco/nco)
Inheritance from Xarray
For those that are familiar with Xarray, the naming of the methods and data structures looks familiar. UXarray aims to provide a familiar experience to Xarray by inheriting the xr.Dataset
and xr.DataArray
objects and linking them to an instance of a Grid
class to provide grid-aware implementations.
We can observe this inheritance by checking for subclassing.
Overloaded Methods
With subclassing, all methods are directly inherited from the parent class (xr.Dataset
). Most Xarray functionality works directly on UXarray’s data structures, however certain methods have been overloaded to make them unstructured-grid aware.
One example of this is the plotting functionality of a ux.UxDataArray
, which was re-implemented to support visualuzations of unstructured grids. A detailed overview of plotting functionality can be found in the next sections.