geoclide.advancedvecope module#
Conversions between angles and direction vectors.
This module converts a direction described by the polar and azimuthal angles (theta, phi) into a direction described by a Vector, and conversely, in a direct orthogonal coordinate system where z is pointing upwards. Both single directions and sets of directions are supported, with an optional diagonal calculation mode where the i-th direction uses theta(i) and phi(i).
- geoclide.advancedvecope.ang2vec(theta: float | ndarray, phi: float | ndarray, vec_view: str = 'zenith', diag_calc: bool = False) Vector[source]#
Convert a direction/directions described by 2 angles/set of 2 angles into a direction/directions described by a vector/vectors
direct orthogonal coordinate system where z is pointing upwards
- Parameters:
- thetafloat or ndarray
The polar angle(s) in degrees, starting at z+ in the zx plane and going in the trigonometric direction around the y axis. In case of an ndarray, it must be 1-D
- phifloat or ndarray
The azimuthal angle(s) in degrees, starting at x+ in the xy plane and going in the trigonometric direction around the z axis. In case of an ndarray, it must be 1-D
- vec_viewstr, optional
Two choices (concerning initial direction at theta=phi=0): ‘zenith’ (i.e. pointing above) or ‘nadir’ (i.e. pointing below)
- diag_calcbool, optional
Perform diagonal calculations, v(i) is calculated using theta(i) and phi(i)
- Returns:
- Vector
The direction(s) described by a vector
Notes
In case both theta and phi are 1-D ndarrays, the vectors are ordered in phi-major order
Examples
>>> import geoclide as gc >>> th = 30. >>> ph = 0. >>> v1 = gc.ang2vec(theta=th, phi=ph, vec_view='zenith') >>> v1 Vector(0.49999999999999994, 0.0, 0.8660254037844387) >>> v2 = gc.ang2vec(theta=th, phi=ph, vec_view='nadir') >>> v2 Vector(-0.49999999999999994, 0.0, -0.8660254037844387)
- geoclide.advancedvecope.vec2ang(v: Vector, vec_view: str = 'zenith', acc: float = 1e-06) tuple[float | ndarray, float | ndarray][source]#
Convert a direction/directions described by a vector/vectors into a direction/directions described by 2 angles/set of 2 angles
direct orthogonal coordinate system where z is pointing upwards
- Parameters:
- vVector
The direction(s) described by a vector
- vec_viewstr, optional
Two choices (concerning initial direction at theta=phi=0): ‘zenith’ (i.e. pointing above) or ‘nadir’ (i.e. pointing below)
- accfloat, optional
The tolerance for numerical errors. Default is 1e-6.
- Returns:
- thetafloat or ndarray
The polar angle(s) in degrees, starting at z+ in the zx plane and going in the trigonometric direction around the y axis. In case of an ndarray, it is 1-D
- phifloat or ndarray
The azimuthal angle(s) in degrees, starting at x+ in the xy plane and going in the trigonometric direction around the z axis. In case of an ndarray, it is 1-D
Examples
>>> import geoclide as gc >>> th = 30. >>> ph = 0. >>> v1 = gc.ang2vec(theta=th, phi=ph, vec_view='zenith') >>> v1 Vector(0.49999999999999994, 0.0, 0.8660254037844387) >>> theta, phi = gc.vec2ang(v1, vec_view='zenith') >>> theta, phi (29.999999999999993, 0.0) >>> v2 = gc.ang2vec(theta=th, phi=ph, vec_view='nadir') >>> v2 Vector(-0.49999999999999994, 0.0, -0.8660254037844387) >>> theta, phi = gc.vec2ang(v2, vec_view='nadir') >>> theta, phi (29.999999999999993, 0.0)