Package pylal :: Module sphericalutils
[hide private]
[frames] | no frames]

Module sphericalutils

source code

Utilities to perform operations on (polar, azimuthal) vectors.


Author: Nickolas Fotopoulos <nvf@gravity.phys.uwm.edu>

Functions [hide private]
 
rotate_euler(sph_coords, alpha, beta, gamma)
Take an Nx2 array of N (theta, phi) vectors on the unit sphere (that is, (polar, azimuthal) angles in radians) and apply rotations through the Euler angles alpha, beta, and gamma in radians, using the ZXZ convention.
source code
 
new_z_to_euler(new_z)
From the new Z axis expressed in (polar, azimuthal) angles of the initial coordinate system, return the (alpha, beta) Euler angles that rotate the old Z axis (0, 0) to the new Z axis.
source code
 
rotate_about_axis(x, axis, ang)
Return the result of rotating x about axis by ang (in radians).
source code
 
_abs_diff(c)
For some angular difference c = |a - b| in radians, find the magnitude of the difference, taking into account the wrap-around at 2*pi.
source code
 
_haversine(angle) source code
 
_archaversine(h)
Compute the inverse of the _haversine function, using clip as protection for the antipodes.
source code
 
angle_between_points(a, b)
Find the angle in radians between a and b, each expressed in (polar, azimuthal) angles in radians.
source code
 
fisher_rvs(mu, kappa, size=1)
Return a random (polar, azimuthal) angle drawn from the Fisher distribution.
source code
 
fisher_pdf(theta, kappa)
Return the PDF of theta, the opening angle of X with respect to mu where X is Fisher-distributed about mu.
source code
 
fisher_cdf(theta, kappa) source code
Function Details [hide private]

rotate_about_axis(x, axis, ang)

source code 

Return the result of rotating x about axis by ang (in radians). axis must be a unit vector.

angle_between_points(a, b)

source code 

Find the angle in radians between a and b, each expressed in (polar, azimuthal) angles in radians. If a and b are Nx2 arrays of vectors, then return the N pairwise angles between them.

This formula is the law of _haversines, which is derivable from the spherical law of cosines, but is more numerically stable about a == b. This technique is slightly unstable for antipodal a and b.

fisher_rvs(mu, kappa, size=1)

source code 

Return a random (polar, azimuthal) angle drawn from the Fisher
distribution. Assume that the concentration parameter (kappa) is large
so that we can use a Rayleigh distribution about the north pole and
rotate it to be centered at the (polar, azimuthal) coordinate mu.

Assume kappa = 1 / sigma**2

References:
  * http://en.wikipedia.org/wiki/Von_Mises-Fisher_distribution
  * http://arxiv.org/pdf/0902.0737v1 (states the Rayleigh limit)

fisher_pdf(theta, kappa)

source code 

Return the PDF of theta, the opening angle of X with respect to mu where X is Fisher-distributed about mu. See fisher_rvs for the definition of mu.