# [AstroPy] calculating Hour Angle to obtain Parallactic angle

Orfeo Colebatch orfeo.colebatch at utoronto.ca
Tue Sep 10 14:14:25 EDT 2013

```Hi All,

We have a alt/az sun tracker whose coding requires the calculation of the parallactic angle in order to do some coordinate transformations between the alt/az mount and a camera monitoring the image it produces.

I have found Ian's Astro Python code (http://www.mpia-hd.mpg.de/homes/ianc/python/_modules/spec.html#parangle) which works when i use it conjunction with the coordinates output by this site (http://www.jgiesen.de/astro/suncalc/) when the Hour Angle is converted to decimal hours.

I have tried to calculate the same hour angle using coordinates.angles.RA.hour_angle (among other codes) bu have not been able to reproduce that Hour Angle (HA) from the above site.

E.g for 21st June 2013, 13:00 UTC (9:00 GMT-4), 43.66 deg latitude, -79.4 W longitude I get a HA of -64.73 degreees  (or +295 degrees)

By doing the following in python with ephem and astropy i get the following

In : import ephem

In : from astropy import coordinates as coord

In : from astropy.time import Time

In : from astropy import units as u

In : obs = ephem.Observer()

In : from datetime import datetime as dt

In : time = dt.strptime('2013/6/21' +' ' + '09:00:00', '%Y/%m/%d %H:%M:%S')

In : obs.date = time

In : obs.lon =-79.4

In : obs.lat = 43.66

In : obs.elevation = 174.0

In : sun = ephem.Sun()

In : sun.compute(obs)

In : ra = sun.g_ra

In : ra
Out: 1.573768747713852

In : coord.ICRSCoordinates(ra=ra, dec = sun.dec, unit=(u.radian, u.radian))
Out: <ICRSCoordinates RA=90.17031 deg, Dec=23.43624 deg>

In : c= coord.ICRSCoordinates(ra=ra, dec = sun.dec, unit=(u.radian, u.radian
))

In : c
Out: <ICRSCoordinates RA=90.17031 deg, Dec=23.43624 deg>

In : c.ra
Out: <RA 90.17031 deg>

In : sun.ra
Out: 1.573725506944724

In [21: c.ra * ephem.pi/180
Out: <Angle 1.57377 deg>

In : c.ra
Out: <RA 90.17031 deg>

In : coord.angles.RA.hour_angle(c.ra,t)
Out: <Angle 277.95469 deg>

In : t.lat = 43.66

In : t.lon =-79.4

In : coord.angles.RA.hour_angle(c.ra,t)
Out: <Angle 277.95469 deg>

As you can see the angle is off by 20 degrees. I know this must be a unit problem, but i'm not sure what as of yet. If anyone has any idea's i'd be interested. Perhaps i should be calculating RA inside astropy? and not switching between ephem and astropy?

I do have access to this IDL code (http://idlastro.gsfc.nasa.gov/) and the code for the above sun web page( http://www.esrl.noaa.gov/gmd/grad/solcalc/calcdetails.html) but i would like to avoid coding that all up in python.

If anyone has any advise i'm all ears.

kind regards

Orfeo

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/astropy/attachments/20130910/f8754f16/attachment.html>
```

More information about the AstroPy mailing list