ra_dec

ssapy.utils.ra_dec(r=None, v=None, x=None, y=None, z=None, vx=None, vy=None, vz=None, r_earth=array([0, 0, 0]), v_earth=array([0, 0, 0]), input_unit='si')[source][source]

Calculate the Right Ascension (RA) and Declination (Dec) of an object relative to Earth’s position.

This function computes the RA and Dec of an object based on its position and velocity vectors. The Earth’s position and velocity are subtracted from the input to determine the object’s coordinates relative to Earth. The RA is returned in radians within the range [0, 2π], and the Dec is returned in radians.

Parameters:

r (ndarray, optional): Position vector of the object in 3D space (shape: Nx3). Default is None. v (ndarray, optional): Velocity vector of the object in 3D space (shape: Nx3). Default is None. x (float, optional): X-coordinate of the object’s position. Default is None. y (float, optional): Y-coordinate of the object’s position. Default is None. z (float, optional): Z-coordinate of the object’s position. Default is None. vx (float, optional): X-component of the object’s velocity. Default is None. vy (float, optional): Y-component of the object’s velocity. Default is None. vz (float, optional): Z-component of the object’s velocity. Default is None. r_earth (ndarray, optional): Earth’s position vector in 3D space (shape: 3). Default is [0, 0, 0]. v_earth (ndarray, optional): Earth’s velocity vector in 3D space (shape: 3). Default is [0, 0, 0]. input_unit (str, optional): Unit of the input values (‘si’ for meters and seconds). Default is ‘si’.

Returns:

tuple:
  • ra (ndarray): Right Ascension of the object in radians (shape: N).

  • dec (ndarray): Declination of the object in radians (shape: N).

Raises:

ValueError: If neither r and v nor individual coordinates (x, y, z, vx, vy, vz) are provided.

Notes:

  • If r and v are not provided, the function expects individual position (x, y, z) and velocity (vx, vy, vz) components to construct the vectors.

  • The function assumes the existence of einsum_norm, which calculates the norm of vectors using Einstein summation notation.

  • The function assumes the existence of rad0to2pi, which ensures RA values are within the range [0, 2π].

Example:

ra_dec(x=1.0, y=2.0, z=3.0, vx=0.1, vy=0.2, vz=0.3) -> (array([1.10714872]), array([0.64052231]))