# Astronomy: Transform coordinates from horizon to equatorial

I'm using Mathematica 10. Giving a longitude & latitude on Earth, giving a local time, how can I transform Horizon Coordinte (az , alt) to Equatorial Coordinate (RA , DEC). Use function so I can change longitude, latitude & time when I call it.

## 1 Answer

Given the local sidereal time (LST) and local latitude you can convert (az,alt) to (ra,dec) with the following function (Input and Output are in degree (not radians!)):

AzElToRADec[{azimuth_, elevation_}, lattitude_, LST_] :=
Module[{sinDec, cosLHA, sinLHA, Dec, RA, LHA},
sinDec = Sin[elevation Degree] Sin[lattitude Degree] +
Cos[elevation Degree] Cos[lattitude Degree] Cos[azimuth Degree];
Dec = ArcSin[sinDec]/Degree;
sinLHA = -((Sin[azimuth Degree] Cos[elevation Degree])/Cos[Dec Degree]);
cosLHA = (Sin[elevation Degree] - Sin[lattitude Degree] Sin[Dec Degree])/(Cos[Dec Degree] Cos[lattitude Degree]);
LHA = ArcTan[cosLHA, sinLHA]/Degree;
RA = Mod[LST - LHA, 360];
{RA, Dec}]


To get the LST, see this post. The conversion is explained here.

Example:

Plot[AzElToRADec[{0, 30}, 0, x*15], {x, 0, 48},  AxesLabel -> {"LST (hrs)", "angle"}] • Sidereal time can now be computed with the SiderealTime function in version 10. – kale Dec 19 '14 at 15:23
• I am a new comer here. I want to thank Markus Roellig & kale. Thanks for your help. – iStar Jan 3 '15 at 12:18