radec_to_unit

giant.catalogues.utilities:

giant.catalogues.utilities.radec_to_unit(ra, dec)[source]

This utility converts (a) right ascension and declination pair(s) expressed in units of radians into (an) unit vector(s).

The conversion to a unit vector is given by:

\[\begin{split}\hat{\mathbf{x}}=\left[\begin{array}{c}\text{cos}(\delta)\text{cos}(\alpha)\\ \text{cos}(\delta)\text{sin}(\alpha)\\ \text{sin}(\delta)\end{array}\right]\end{split}\]

where \(\alpha\) is the right ascension, \(\delta\) is the declination, and \(\hat{\mathbf{x}}\) is the resulting unit vector.

This method is vectorized, therefore multiple unit vectors can be created from multiple ra, dec pairs at the same time. When multiple conversions are performed, each unit vector is specified as a column in the array.

This function performs broadcast rules using numpy conventions, therefore you can provide inputs with different shapes, so long as they are able to be broadcast (you could add them together and numpy wouldn’t complain). If you provide >1D arrays then they will be raveled using c convention.

Parameters:
  • ra (Sequence | ndarray | Real) – The right ascension(s) to convert to unit vector(s) in units of radians

  • dec (Sequence | ndarray | Real) – The declination(s) to convert to unit vector(s) in units of radians

Returns:

A 3xn array of unit vectors corresponding to the right ascension, declination pair(s)

Return type:

ndarray