mpas_tools.viz.transects.find_planar_transect_cells_and_weights

mpas_tools.viz.transects.find_planar_transect_cells_and_weights(xTransect, yTransect, dsTris, dsMesh, tree, subdivisionRes=10000.0)[source]

Find “nodes” where the transect intersects the edges of the triangles that make up MPAS cells.

Parameters
  • xTransect (xarray.DataArray) – The x and y points defining segments making up the transect

  • yTransect (xarray.DataArray) – The x and y points defining segments making up the transect

  • dsTris (xarray.Dataset) – A dataset that defines triangles, the results of calling mesh_to_triangles()

  • dsMesh (xarray.Dataset) – A data set with the full MPAS mesh.

  • tree (scipy.spatial.cKDTree) – A tree of edge centers from triangles making up an MPAS mesh, the return value from make_triangle_tree()

  • subdivisionRes (float, optional) – Resolution in m to use to subdivide the transect when looking for intersection candidates. Should be small enough that curvature is small.

Returns

dsOut (xarray.Dataset) – A dataset that contains “nodes” where the transect intersects the edges of the triangles in dsTris. The nodes also include the two end points of the transect, which typically lie within triangles. Each internal node (that is, not including the end points) is purposefully repeated twice, once for each triangle that node touches. This allows for discontinuous fields between triangles (e.g. if one wishes to plot constant values on each MPAS cell). The planar coordinates of these nodes are xNode and yNode. The distance along the transect of each intersection is dNode. The index of the triangle and the first triangle node in dsTris associated with each intersection node are given by horizTriangleIndices and horizTriangleNodeIndices, respectively. The second node on the triangle for the edge associated with the intersection is given by numpy.mod(horizTriangleNodeIndices + 1, 3).

The MPAS cell that a given node belongs to is given by horizCellIndices. Each node also has an associated set of 6 interpHorizCellIndices and interpHorizCellWeights that can be used to interpolate from MPAS cell centers to nodes first with area-weighted averaging to MPAS vertices and then linear interpolation along triangle edges. Some of the weights may be zero, in which case the associated interpHorizCellIndices will be -1.

Finally, xTransect and yTransect are included in the dataset, along with dTransect, the distance along the transect of each original transect point. In order to interpolate values (e.g. observations) from the original transect points to the intersection nodes, linear interpolation indices transectIndicesOnHorizNode and weights transectWeightsOnHorizNode are provided. The values at nodes are found by:

nodeValues = ((transectValues[transectIndicesOnHorizNode] *
               transectWeightsOnHorizNode)
              + (transectValues[transectIndicesOnHorizNode+1] *
                 (1.0 - transectWeightsOnHorizNode))