# Converting between Helioprojective and AltAz Coordinate¶

How to find the Sun in the sky as viewed from a particular location.

```from astropy.coordinates import EarthLocation, AltAz, SkyCoord
from astropy.time import Time
from sunpy.coordinates import frames, sun
import astropy.units as u
```

We use `SkyCoord` to define the center of the Sun

```obstime = "2013-09-21 16:00:00"
c = SkyCoord(0 * u.arcsec, 0 * u.arcsec, obstime=obstime, frame=frames.Helioprojective)
```

Now we establish our location on the Earth, in this case let’s consider a high altitude balloon launched from Fort Sumner, NM.

```Fort_Sumner = EarthLocation(lat=34.4900*u.deg, lon=-104.221800*u.deg, height=40*u.km)
```

Now lets convert this to a local measurement of Altitude and Azimuth.

```frame_altaz = AltAz(obstime=Time(obstime), location=Fort_Sumner)
sun_altaz = c.transform_to(frame_altaz)
print('Altitude is {0} and Azimuth is {1}'.format(sun_altaz.T.alt, sun_altaz.T.az))
```

Out:

```/home/docs/checkouts/readthedocs.org/user_builds/sunpy/conda/stable/lib/python3.7/site-packages/astropy/utils/iers/iers.py:656: AstropyWarning: failed to download http://maia.usno.navy.mil/ser7/finals2000A.all and http://toshi.nofs.navy.mil/ser7/finals2000A.all, using local IERS-B: <urlopen error [Errno -2] Name or service not known>;HTTP Error 503: Service Unavailable
';'.join(err_list))))  # noqa
Altitude is 37.782959956075395 deg and Azimuth is 121.342173388297 deg
```

Next let’s check this calculation by converting it back to helioprojective. We should get our original input which was the center of the Sun. To go from Altitude/Azimuth to Helioprojective, you will need the distance to the Sun. solar distance. Define distance with SunPy’s almanac.

```distance = sun.earth_distance(obstime)
b = SkyCoord(az=sun_altaz.T.az, alt=sun_altaz.T.alt, distance=distance, frame=frame_altaz)
sun_helio = b.transform_to(frames.Helioprojective)
print('The helioprojective point is {0}, {1}'.format(sun_helio.T.Tx, sun_helio.T.Ty))
```

Out:

```The helioprojective point is -0.021860375301912427 arcsec, -0.007958025525083122 arcsec
```

Total running time of the script: ( 0 minutes 12.776 seconds)

Gallery generated by Sphinx-Gallery