# [AstroPy] Convert from AltAz to ICRS

keithmclaurin at gmail.com keithmclaurin at gmail.com
Tue Nov 26 00:06:54 EST 2019

```The RA and dec changes mostly due to precession is my understanding.

Sent from my iPhone

> On Nov 23, 2019, at 15:20, Eric Jensen <ejensen1 at swarthmore.edu> wrote:
>
> Hi Franco,
>
> You can use the same transform_to method that is given in the example docs, just in the other direction, e.g.
>
>
> Referring to the example here:
> https://docs.astropy.org/en/stable/generated/examples/coordinates/plot_obs-planning.html#sphx-glr-generated-examples-coordinates-plot-obs-planning-py
>
> Here is some code based on that example, that extends it to show a transformation back to RA and Dec:
>
> import astropy.units as u
> from astropy.time import Time
> from astropy.coordinates import SkyCoord, EarthLocation, AltAz
>
> # Get M33's coordinates
> m33 = SkyCoord.from_name('M33')
>
> # Define a location for observation:
> bear_mountain = EarthLocation(lat=41.3*u.deg, lon=-74*u.deg, height=390*u.m)
> utcoffset = -4*u.hour  # Eastern Daylight Time
> time = Time('2012-07-12 23:00:00') - utcoffset
>
> # Find the alt/az at that time:
> m33altaz = m33.transform_to(AltAz(obstime=time,location=bear_mountain))
> print("M33's Altitude = {0.alt:.2f}, Azimuth = {0.az:.1f}".format(m33altaz))
>
> # prints:  M33's Altitude = 0.13 deg, Azimuth = 47.3 deg
>
> # Look at the same alt/az,
> # but half a sidereal day later:
> new_altaz = SkyCoord(AltAz(obstime=time + 0.5*u.sday,
>                     az=m33altaz.az,
>                     alt=m33altaz.alt,
>                    location=bear_mountain))
>
> # Transform back to RA, Dec;
> # should get the same Dec as before but RA 12 hours different:
> print(m33.to_string('hmsdms'))
>
> # Prints
> # 01h33m50.904s +30d39m35.79s
> # 13h33m59.1873s +30d47m03.8071s
>
> Interestingly, the declination isn’t *exactly* the same and the RA doesn’t differ by exactly 12 hours - I wonder why?   But overall you can see the idea for doing what you want.
>
> Best,
>
> Eric
>
>
>> On Nov 23, 2019, at 2:00 PM, franco basti <franco.basti at gmail.com> wrote:
>>
>>
>> Can anyone help me converting from a alt az to ra,dec ?
>> all I can find are examples that convert from ra,dec to alt,az
>>
>> Thx
>> Franco
>>
>> _______________________________________________
>> AstroPy mailing list
>> AstroPy at python.org
>> https://mail.python.org/mailman/listinfo/astropy
>
> _______________________________________________
> AstroPy mailing list
> AstroPy at python.org
> https://mail.python.org/mailman/listinfo/astropy
```