polaris.ocean.viz.transect.horiz.find_spherical_transect_cells_and_weights
- polaris.ocean.viz.transect.horiz.find_spherical_transect_cells_and_weights(lon_transect, lat_transect, ds_tris, ds_mesh, tree, degrees=True, earth_radius=None, subdivision_res=10000.0)[source]
Find “nodes” where the transect intersects the edges of the triangles that make up MPAS cells.
- Parameters:
lon_transect (xarray.DataArray) – The longitude of segments making up the transect
lat_transect (xarray.DataArray) – The latitude of segments making up the transect
ds_tris (xarray.Dataset) – A dataset that defines triangles, the results of calling
polaris.ocean.viz.transect.horiz.mesh_to_triangles()
ds_mesh (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
polaris.ocean.viz.transect.horiz.make_triangle_tree()
degrees (bool, optional) – Whether
lon_transect
andlat_transect
are in degrees (as opposed to radians).subdivision_res (float, optional) – Resolution in m to use to subdivide the transect when looking for intersection candidates. Should be small enough that curvature is small.
earth_radius (float, optional) – The radius of the Earth in meters, taken from the sphere_radius global attribute if not provided
- Returns:
ds_out (xarray.Dataset) – A dataset that contains “nodes” where the transect intersects the edges of the triangles in
ds_tris
. The nodes also includes 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 Cartesian and lon/lat coordinates of these nodes arexCartNode
,yCartNode
,zCartNode
,lonNode
andlatNode
. The distance along the transect of each intersection isdNode
. The index of the triangle and the first triangle node inds_tris
associated with each intersection node are given byhorizTriangleIndices
andhorizTriangleNodeIndices
, respectively. The second node on the triangle for the edge associated with the intersection is given bynumpy.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 6interpHorizCellIndices
andinterpHorizCellWeights
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 associatedinterpHorizCellIndices
will be -1.Finally,
lonTransect
andlatTransect
are included in the dataset, along with Cartesian coordinatesxCartTransect
,yCartTransect
, zCartTransect`, anddTransect
, the great-circle 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 indicestransectIndicesOnHorizNode
and weightstransectWeightsOnHorizNode
are provided. The values at nodes are found by:nodeValues = ((transectValues[transectIndicesOnHorizNode] * transectWeightsOnHorizNode) + (transectValues[transectIndicesOnHorizNode+1] * (1.0 - transectWeightsOnHorizNode))