Auxiliary code¶
Helpers functions necessary to the core code and plotting functions.
frame_transformations.py¶
File frame_transformations.py Contains functions that for frame transformations and rotations
Authors: | mdelvallevaro, LucaZampieri (2018) |
---|
Note
In this file, when there is a reference, unless explicitly stated otherwise, it refers to Lindegren main article: “The astronometric core solution for the Gaia mission - overview of models, algorithms, and software implementation” by L. Lindegren, U. Lammer, D. Hobbs, W. O’Mullane, U. Bastian, and J.Hernandez The reference is usually made in the following way: Ref. Paper [LUDW2011] eq. [1]
-
frame_transformations.
adp_to_cartesian
(alpha, delta, parallax)[source]¶ Convert coordinates from (alpha, delta, parallax) format into the (x, y, z) format.
Parameters: - azimuth – [rad]
- altitude – [rad]
- parallax – [mas]
Returns: [parsec](x, y, z) array in parsecs.
-
frame_transformations.
compute_ljk
(epsilon)[source]¶ - Ref. [Lind2001] (Lindegren, SAG-LL-35, Eq.1)Calculates ecliptic triad vectors with respect to BCRS-frame.
Parameters: epsilon – obliquity of the equator. Returns: - np.array, np.array, np.array of the ecliptic triad:
- l: is a unit vector toward (alpha, delta) = (0,0)`)
- n: is a unit vector towards delta = 90°
- m = n x l
-
frame_transformations.
compute_pqr
(alpha, delta)[source]¶ -
Parameters: - alpha – [rad] astronomic parameter alpha
- delta – [rad] astronomic parameter alpha
Returns: p, q, r
-
frame_transformations.
lmn_to_xyz
(attitude, vector)[source]¶ Ref. Paper [LUDW2011] eq. [9] Goes from the non-rotating (lmn) CoMRS frame to the rotating (xyz) SRS frame
Note
The attitude Quaternion q(t) gives the rotation from (lmn) to (xyz) (lmn) being the CoMRS (C), and (xyz) the SRS (S). The relation between the two frames is given by: {S’v,0} = q^-1 {C’v,0} q for an any vector v
Parameters: - attitude – Quaternion object
- vector – array of 3D
Returns: the coordinates in XYZ-frame of the input vector.
-
frame_transformations.
polar_to_direction
(alpha, delta)[source]¶ Convert polar angles to unit direction vector
Parameters: - alpha – [rad]
- delta – [rad]
Returns: 3D np.array unit vector
-
frame_transformations.
quat_to_vector
(quat)[source]¶ Parameters: quat – [quaternion] Quaternion to transform into vector Returns: 3D array made with x,y,z components of the quaternion
-
frame_transformations.
rotate_by_quaternion
(quaternion, vector)[source]¶ Ref. Paper [LUDW2011] eq. [9] rotate vector by quaternion
-
frame_transformations.
transform_twoPi_into_halfPi
(deltas)[source]¶ Tranforms an angle in range [0-2*pi] to range [-pi/2, pi/2] by substracting 2pi to any angle greater than pi.
Warning
The input angles have to be defined between [0,pi/2] and [3pi/2, 2pi]
Parameters: delta – input angles Returns: modified angles
-
frame_transformations.
vector_to_alpha_delta
(vector, two_pi=False)[source]¶ Ref. Paper [LUDW2011] eq. [96] Convert carthesian coordinates of a vector into its corresponding polar coordinates (0 - 2*pi)
Parameters: - vector – [array] X,Y,Z coordinates in CoMRS frame (non-rotating)
- two_pi – [bool] if True return delta in [0,2pi] instead of [-pi/2,pi/2]
Returns: [rad][rad] alpha, delta
-
frame_transformations.
vector_to_quat
(vector)[source]¶ Transform vector to quaternion by setting x,y,z components of the quaternion with x,y,z components of the vector.
Parameters: vector – vector to transform to quaternion Returns: quaternion created from vector
-
frame_transformations.
xyz_to_lmn
(attitude, vector)[source]¶ Ref. Paper [LUDW2011] eq. [9] Go from the rotating (xyz) SRS frame to the non-rotating (lmn) CoMRS frame
Note
The attitude Quaternion q(t) gives the rotation from (lmn) to (xyz) (lmn) being the CoMRS (C), and (xyz) the SRS (S). The relation between the two frames is given by: {C’v,0} = q {S’v,0} q^-1 for an any vector v
Parameters: - attitude – Quaternion object
- vector – array of 3D
Returns: the coordinates in LMN-frame of the input vector.
-
frame_transformations.
zero_to_two_pi_to_minus_pi_pi
(angle, unit='radians')[source]¶ Tranforms an angle in range [0-2*pi] to range [-pi, pi] by substracting 2pi to any angle greater than pi.
Info: Can be used with numpy arrays
Parameters: - angle – [rad] angle or array of angles in [0-2*pi] format
- unit – [str] specify if the input data is in radians or degrees
Returns: angle in the [-pi, pi] format
helpers.py¶
File helpers.py
Helper functions for the analytic scanner
- Contains: (at least)
- compute_intersection
- compute_angle
Author: | LucaZampieri (2018) |
---|
-
helpers.
check_symmetry
(a, tol=1e-12)[source]¶ Check the symmetry of array a. True if symmetric up to tolerance
-
helpers.
compute_angle
(v1, v2)[source]¶ Computes the angle between two Vectors :param vi: vector between which you want to compute the angle for each i=1:2 :returns: [float] [deg] angle between the vectors
-
helpers.
compute_intersection
(x1, y1, x2, y2, x3, y3, x4, y4, segment=True)[source]¶ Return intersection of two lines (or segments) if it exists, raise an error otherwise. :param xi: x-coordinate of segment i for i=1:4 :param yi: y-coordinate of segment i for i=1:4 :param segment: [bool]
Returns: - (x, y) tuple with x and y coordinartes of the intersection point
- [list] error_msg list
-
helpers.
get_rotation_matrix
(v1, v2)[source]¶ Get the rotation matrix necessary to go from v1 to v2 :param vi: 3D vector as np.array To rotate vector v1 into v2 then do r@v1
-
helpers.
get_sparse_diagonal_matrix_from_half_band
(half_band)[source]¶ it assumes we have the upper hal of the band, i.e. we some zeros at the bottom of band for column index greater than 0