# API/Reference

## Index

`SkyCoords.AbstractSkyCoords`

`SkyCoords.FK5Coords`

`SkyCoords.GalCoords`

`SkyCoords.ICRSCoords`

`SkyCoords.offset`

`SkyCoords.position_angle`

`SkyCoords.separation`

## Types

`SkyCoords.AbstractSkyCoords`

— TypeThe supertype for all sky coordinate systems.

`SkyCoords.ICRSCoords`

— Type`ICRSCoords(ra, dec)`

International Celestial Reference System

This is the current standard adopted by the International Astronomical Union notably due to its high level of accuracy compared to standard equatorial coordinate systems. What sets this apart from `FK5Coords`

is that it is completely defined using extragalactic radio sources rather than a geocentric frame, which means the reference frame will not change due to Earth's motion.

**Coordinates**

`ra`

- Right ascension in radians (0, 2π)`dec`

- Declination in radians (-π/2, π/2)

`SkyCoords.GalCoords`

— Type`GalCoords(l, b)`

This coordinate system is defined based on the projection of the Milky Way galaxy onto our celestial sphere, with (0, 0) being approximately the center of our galaxy.

**Coordinates**

`l`

- Galactic longitude in radians (-π, π)`b`

- Galactic latitude in radians (-π/2, π/2)

`SkyCoords.FK5Coords`

— Type`FK5Coords{equinox}(ra, dec)`

This coordinate system maps the celestial sphere based on a geocentric observer. Historically the oldest, this coordinate system has been shown to be inaccurate due to its definitions based on the Earth, which has long-scale precession causing the reference frame to change. Because of this, an equinox must be provided (typically 2000, commonly known as J2000) which defines the reference frame.

**Coordinates**

`ra`

- Right ascension in radians (0, 2π)`dec`

- Declination in radians (-π/2, π/2)

## Conversion

To convert between types, there are three (equivalent) methods of doing so.

```
julia> c1 = ICRSCoords(0., 0.)
ICRSCoords{Float64}(0.0, 0.0)
```

- using
`convert`

```
julia> convert(GalCoords, c1)
GalCoords{Float64}(1.6814027872278692, -1.0504884034813007)
```

- using constructors

```
julia> GalCoords(c1)
GalCoords{Float64}(1.6814027872278692, -1.0504884034813007)
```

- using
`|>`

```
julia> c1 |> GalCoords
GalCoords{Float64}(1.6814027872278692, -1.0504884034813007)
```

## Functions

`SkyCoords.separation`

— Function`separation(c1::AbstractSkyCoords, c2::AbstractSkyCoords) -> distance`

Return angular separation between two sky coordinates, in radians.

The angular separation is calculated using the Vincenty formula, which is slightly more complex and computationally expensive than some alternatives, but is stable at at all distances, including the poles and antipodes.

`SkyCoords.position_angle`

— Function`position_angle(c1::AbstractSkyCoords, c2::AbstractSkyCoords) -> angle`

Return position angle between two sky coordinates, in positive radians.

**Examples**

```
julia> c1 = ICRSCoords(0, 0); c2 = ICRSCoords(deg2rad(1), 0);
julia> position_angle(c1, c2) |> rad2deg
90.0
```

`SkyCoords.offset`

— Function`offset(::AbstractSkyCoords, separation, pa) -> coordinate`

Offset a coordinate by a given angular separation, `separation`

, in radians and position angle, `pa`

, in radians.

Uses the sine and cosine rules in spherical coordinates with corrections for the antipodes. Returns a sky coordinate of the same type as input.

**Examples**

```
julia> c1 = ICRSCoords(0, 0);
julia> c2 = offset(c1, deg2rad(1), deg2rad(90))
ICRSCoords{Float64}(0.017453292519943295, 1.0686516840418957e-18)
julia> offset(c1, c2) .|> rad2deg
(1.0, 90.0)
```

**See Also**

`offset(::AbstractSkyCoords, AbstractSkyCoords) -> angle, angle`

Return the separation and position angle in radians between two sky coordinates.

**Examples**

```
julia> c1 = ICRSCoords(0, 0); c2 = ICRSCoords(deg2rad(1), 0);
julia> offset(c1, c2) .|> rad2deg
(1.0, 90.0)
```

**See Also**