Coordinate Transforms#

Coordinate conversions between Cartesian, lat/lon, and theta/phi.

sphedron.transform.rotate_senders_by_receivers(receivers_xyz: ndarray[tuple[Any, ...], dtype[_ScalarT]], senders_xyz: ndarray[tuple[Any, ...], dtype[_ScalarT]], zero_latitude: bool = False, zero_longitude: bool = False)[source]#

Apply rotation that zeroes out receivers’ latitude and/or longitude to Cartesian senders’ coordinates.

Parameters:
  • receivers_xyz – An NDArray representing the coordinates of the receivers in Cartesian format, shape (N,3)

  • senders_xyz – An NDArray representing the coordinates of the senders in Cartesian format, shape (N,3)

  • zero_latitude – A boolean flag indicating whether to zero out the latitude of the receivers. Defaults to False.

  • zero_longitude – A boolean flag indicating whether to zero out the longitude of the receivers. Defaults to False.

Returns:

NDArray for shape (N,3) of the senders’ rotated coordinates

sphedron.transform.sender2receiver_edge_coords(sender_nodes: ndarray[tuple[Any, ...], dtype[_ScalarT]], receiver_nodes: ndarray[tuple[Any, ...], dtype[_ScalarT]], sender2receiver_edges: ndarray[tuple[Any, ...], dtype[_ScalarT]], zero_latitude: bool = True, zero_longitude: bool = True)[source]#

Rotates the nodes so that the receivers have 0 latitude and longitude and computes the difference between the receivers and their senders coords

Parameters:
  • sender_nodes – An array of the nodes of the sender mesh, (N,3)

  • receiver_nodes – An array of the nodes of receiver mesh, (M,3)

  • sender2receiver_edges – An array representing edges from senders to receivers, (E, 2)

  • zero_latitude – If True, adjusts the latitude of receivers to 0.

  • zero_longitude – If True, adjusts the longitude of receivers to 0.

Returns:

An array of coordinates representing the differences between the receivers and their corresponding senders, shaped (E, 3)

sphedron.transform.rotate_nodes(nodes_xyz: ndarray[tuple[Any, ...], dtype[_ScalarT]], axis: str, angles: float | List[float]) ndarray[tuple[Any, ...], dtype[_ScalarT]][source]#

Rotate the mesh nodes around a specified axis by a given angle.

Parameters:
  • nodes_xyz – Cartesian coordinates of the nodes, shape (N, 3)

  • axis – axis around which to rotate the nodes, scipy’s Euler rotation.

  • angles – The angle (radian) by which to rotate the nodes.

Returns:

The rotated nodes of shape (num_nodes, 3).

sphedron.transform.xyz_to_thetaphi(xyz: ndarray[tuple[Any, ...], dtype[_ScalarT]]) ndarray[tuple[Any, ...], dtype[_ScalarT]][source]#

Convert Cartesian coordinates to spherical

sphedron.transform.thetaphi_to_xyz(thetaphi: ndarray[tuple[Any, ...], dtype[_ScalarT]])[source]#

Convert spherical coordinates on the sphere (r=1) to Cartesian

sphedron.transform.latlong_to_thetaphi(latlong: ndarray[tuple[Any, ...], dtype[_ScalarT]]) ndarray[tuple[Any, ...], dtype[_ScalarT]][source]#

Convert latitude-longitude to spherical (theta, phi) where theta is the inclination (angle from positive z-axis) and phi the azimuth (z-axis rotation).

sphedron.transform.thetaphi_to_latlong(thetaphi: ndarray[tuple[Any, ...], dtype[_ScalarT]])[source]#

Convert spherical to latitude/longitude

sphedron.transform.xyz_to_latlong(xyz: ndarray[tuple[Any, ...], dtype[_ScalarT]]) ndarray[tuple[Any, ...], dtype[_ScalarT]][source]#

Cartesian coordinates on the unit sphere to latitude,longitude

sphedron.transform.latlong_to_xyz(latlong: ndarray[tuple[Any, ...], dtype[_ScalarT]]) ndarray[tuple[Any, ...], dtype[_ScalarT]][source]#

latitude,longitude to Cartesian coordinates on the unit sphere