4.6.14. pde.tools.spherical module¶
Module collecting functions for handling spherical geometry
The coordinate systems use the following convention for polar coordinates \((r, \phi)\), where \(r\) is the radial coordinate and \(\phi\) is the polar angle:
Similarly, for spherical coordinates \((r, \theta, \phi)\), where \(r\) is the radial coordinate, \(\theta\) is the azimuthal angle, and \(\phi\) is the polar angle, we use
The module also provides functions for handling spherical harmonics. These spherical harmonics are described by the degree \(l\) and the order \(m\) or, alternatively, by the mode \(k\). The relation between these values is
and
We will use these indices interchangeably, although the mode \(k\) is preferred internally. Note that we also consider axisymmetric spherical harmonics, where the order is always zero and the degree \(l\) and the mode \(k\) are thus identical.
Return the radius of a sphere with a given volume |
|
Return the volume of a sphere with a given radius |
|
Return the surface area of a sphere with a given radius |
|
returns the mode k from the degree degree and order order |
|
returns the degree l and the order m from the mode k |
|
return the number of modes for all indices <= l |
|
checks whether the modes captures all orders for maximal degree |
|
axisymmetric spherical harmonics with degree degree, so m=0. |
|
real spherical harmonics of degree l and order m |
|
real spherical harmonics described by mode k |
- class PointsOnSphere(points)[source]¶
Bases:
object
class representing points on an n-dimensional unit sphere
- Parameters
points (
ndarray
) – The list of points on the unit sphere
- get_area_weights(balance_axes: bool = True)[source]¶
return the weight of each point associated with the unit cell size
- get_distance_matrix()[source]¶
calculate the (spherical) distances between each point
- Returns
the distance of each point to each other
- Return type
- classmethod make_uniform(dim: int, num_points: int = None)[source]¶
create uniformly distributed points on a sphere
- get_spherical_polygon_area(vertices: numpy.ndarray, radius: float = 1) float [source]¶
Calculate the surface area of a polygon on the surface of a sphere. Based on equation provided here: http://mathworld.wolfram.com/LHuiliersTheorem.html Decompose into triangles, calculate excess for each
Adapted from https://github.com/tylerjereddy/spherical-SA-docker-demo Licensed under MIT License (see copy in root of this project)
- haversine_distance(point1: numpy.ndarray, point2: numpy.ndarray) numpy.ndarray [source]¶
Calculate the haversine-based distance between two points on the surface of a sphere. Should be more accurate than the arc cosine strategy. See, for example: https://en.wikipedia.org/wiki/Haversine_formula
Adapted from https://github.com/tylerjereddy/spherical-SA-docker-demo Licensed under MIT License (see copy in root of this project)
- make_radius_from_volume_compiled(dim: int) Callable[[TNumArr], TNumArr] [source]¶
Return a function calculating the radius of a sphere with a given volume
- Parameters
dim (int) – Dimension of the space
- Returns
A function that takes a volume and returns the radius
- Return type
function
- make_surface_from_radius_compiled(dim: int) Callable[[TNumArr], TNumArr] [source]¶
Return a function calculating the surface area of a sphere
- Parameters
dim (int) – Dimension of the space
- Returns
A function that takes a radius and returns the surface area
- Return type
function
- make_volume_from_radius_compiled(dim: int) Callable[[TNumArr], TNumArr] [source]¶
Return a function calculating the volume of a sphere with a given radius
- Parameters
dim (int) – Dimension of the space
- Returns
A function that takes a radius and returns the volume
- Return type
function
- points_cartesian_to_spherical(points: numpy.ndarray) numpy.ndarray [source]¶
Convert points from Cartesian to spherical coordinates
- points_spherical_to_cartesian(points: numpy.ndarray) numpy.ndarray [source]¶
Convert points from spherical to Cartesian coordinates
- radius_from_surface(surface: TNumArr, dim: int) TNumArr [source]¶
Return the radius of a sphere with a given surface area
- radius_from_volume(volume: TNumArr, dim: int) TNumArr [source]¶
Return the radius of a sphere with a given volume
- spherical_harmonic_real(degree: int, order: int, θ: float, φ: float) float [source]¶
real spherical harmonics of degree l and order m
- Parameters
- Returns
The value of the spherical harmonics
- Return type
- spherical_harmonic_real_k(k: int, θ: float, φ: float) float [source]¶
real spherical harmonics described by mode k
- Parameters
- Returns
The value of the spherical harmonics
- Return type
- spherical_harmonic_symmetric(degree: int, θ: float) float [source]¶
axisymmetric spherical harmonics with degree degree, so m=0.
- spherical_index_count(l: int) int [source]¶
return the number of modes for all indices <= l
The returned value is one less than the maximal mode k required.
- spherical_index_count_optimal(k_count: int) bool [source]¶
checks whether the modes captures all orders for maximal degree
- Parameters
k_count (int) – The number of modes considered
- spherical_index_k(degree: int, order: int = 0) int [source]¶
returns the mode k from the degree degree and order order
- Parameters
- Raises
ValueError – if order < -degree or order > degree
- Returns
a combined index k
- Return type
- spherical_index_lm(k: int) Tuple[int, int] [source]¶
returns the degree l and the order m from the mode k