mpas_tools.ocean.transects.find_transect_levels_and_weights

mpas_tools.ocean.transects.find_transect_levels_and_weights(dsTransect, layerThickness, bottomDepth, maxLevelCell, zTransect=None)[source]

Construct a vertical coordinate for a transect produced by mpas_tools.viz.transects.find_transect_cells_and_weights(), then break each resulting quadrilateral into 2 triangles that can later be visualized with functions like tripcolor and tricontourf. Also, compute interpolation weights such that observations at points on the original transect and with vertical coordinate transectZ can be bilinearly interpolated to the nodes of the transect.

Parameters:
Returns:

dsTransectTriangles (xarray.Dataset) – A dataset that contains nodes and triangles that make up a 2D transect. For convenience in visualization, the quadrilaterals of each cell making up the transect have been divided into an upper and lower triangle. The nodes of the triangles are completely independent of one another, allowing for potential jumps in fields values between nodes of different triangles that are at the same location. This is convenient, for example, when visualizing data with constant values within each MPAS cell.

There are nTransectTriangles = 2*nTransectCells triangles, each with nTriangleNodes = 3 nodes, where nTransectCells is the number of valid transect cells (quadrilaterals) that are above the MPAS-Ocean bathymetry.

In addition to the variables and coordinates in dsTransect, the output dataset contains:

  • nodeHorizBoundsIndices: which of the nHorizBounds = 2 bounds of a horizontal transect segment a given node is on

  • segmentIndices: the transect segment of a given triangle

  • cellIndices: the MPAS-Ocean cell of a given triangle

  • levelIndices: the MPAS-Ocean vertical level of a given triangle

  • zTransectNode: the vertical height of each triangle node

  • ssh, zSeaFloor: the sea-surface height and sea-floor height at each node of each transect segment

  • interpCellIndices, interpLevelIndices: the MPAS-Ocean cells and levels from which the value at a given triangle node are interpolated. This can involve up to nWeights = 12 different cells and levels.

  • interpCellWeights: the weight to multiply each field value by to perform interpolation to a triangle node.

  • transectInterpVertIndices, transectInterpVertWeights - if zTransect is not None, vertical indices and weights for interpolating from the original transect grid to MPAS-Ocean transect nodes.

Interpolation of a DataArray from MPAS cells and levels to transect triangle nodes can be performed with interp_mpas_to_transect_triangle_nodes(). Similarly, interpolation of a DataArray (e.g. an observation) from the original transect grid to transect triangle nodes can be performed with interp_transect_grid_to_transect_triangle_nodes()

To visualize constant values on MPAS cells, a field can be sampled at indices nCells=cellIndices and nVertLevels=levelIndices. If a smoother visualization is desired, bilinear interpolation can be performed by first sampling the field at indices nCells=interpCellIndices and nVertLevels=interpLevelIndices and then multiplying by interpCellWeights and summing over nWeights.