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 liketripcolor
andtricontourf
. Also, compute interpolation weights such that observations at points on the original transect and with vertical coordinatetransectZ
can be bilinearly interpolated to the nodes of the transect.- Parameters:
dsTransect (xarray.Dataset) – A dataset that defines nodes of the transect, the results of calling
mpas_tools.viz.transects.find_transect_cells_and_weights()
layerThickness (xarray.DataArray) – layer thicknesses on the MPAS mesh
bottomDepth (xarray.DataArray) – the (positive down) depth of the seafloor on the MPAS mesh
maxLevelCell (xarray.DataArray) – the vertical zero-based index of the bathymetry on the MPAS mesh
zTransect (xarray.DataArray, optional) – the z coordinate of the transect (1D or 2D). If 2D, it must have the same along-transect dimension as the lon and lat passed to
mpas_tools.viz.transects.find_transect_cells_and_weights()
- 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 withnTriangleNodes = 3
nodes, wherenTransectCells
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 onsegmentIndices: 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 notNone
, 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 withinterp_transect_grid_to_transect_triangle_nodes()
To visualize constant values on MPAS cells, a field can be sampled at indices
nCells=cellIndices
andnVertLevels=levelIndices
. If a smoother visualization is desired, bilinear interpolation can be performed by first sampling the field at indicesnCells=interpCellIndices
andnVertLevels=interpLevelIndices
and then multiplying byinterpCellWeights
and summing overnWeights
.