2

I'm looking to determine the alt/az of (un-famous) stars at given RA/Dec at specific times from Mauna Kea. I'm trying to compute these parameters using pyephem, but the resulting alt/az don't agree with other sources. Here's the calculation for HAT-P-32 from Keck:

import ephem
telescope = ephem.Observer()
telescope.lat =  '19.8210'
telescope.long = '-155.4683'
telescope.elevation = 4154
telescope.date = '2013/1/18 10:04:14'
star = ephem.FixedBody()
star._ra = ephem.degrees('02:04:10.278')
star._dec = ephem.degrees('+46:41:16.21')
star.compute(telescope)
print star.alt, star.az

which returns -28:43:54.0 73:22:55.3, though according to Stellarium, the proper alt/az should be: 62:26:03 349:15:13. What am I doing wrong?

EDIT: Corrected latitude and longitude, which were formerly reversed.

Brett Morris
  • 791
  • 1
  • 4
  • 13
  • Random note: if you are trying to view HAT-P-32, then I think the right ascension is `02:01:10`, not `02:04:10`? Or are you looking at another object in that vicinity and so your right ascension is correct after all? – Brandon Rhodes Feb 22 '13 at 23:04
  • I'm talking about HAT-P-32, I got the RA/dec from [SIMBAD](http://simbad.harvard.edu/simbad/sim-id?Ident=hat-p-32&NbIdent=1&Radius=2&Radius.unit=arcmin&submit=submit+id). Sub-arcminute precision isn't necessary for the calculations that I'm looking to do anyways. – Brett Morris Feb 23 '13 at 17:06

2 Answers2

1

First, you've got long and latitude backwards; second, you need to provide the strings in hexadecimal form; and third, you need to provide the RA as hours, not degrees:

import ephem
telescope = ephem.Observer()
# Reversed longitude and latitude for Mauna Kea
telescope.lat =    '19:49:28' # from Wikipedia
telescope.long = '-155:28:24'
telescope.elevation = 4154.
telescope.date = '2013/1/18 00:04:14'
star = ephem.FixedBody()
star._ra  = ephem.hours('02:04:10.278') # in hours for RA
star._dec = ephem.degrees('+46:41:16.21')
star.compute(telescope)

This way, you get:

>>> print star.alt, star.az
29:11:57.2 46:43:19.6
Brandon Rhodes
  • 83,755
  • 16
  • 106
  • 147
juandesant
  • 703
  • 8
  • 16
  • I've changed some of the parameters in the original post before you answered (note the time was changed to indicate UT). I'm getting the same result as you now, which still does not agree with Stellarium. Is it possible that Stellarium is completely wrong? – Brett Morris Feb 22 '13 at 15:56
  • I doubt Stellarium is wrong (but it might!). I know PyEphem is not wrong because I've double checked for other projects with IDL code and algorithms from NOAO. I would suspect the setup of the site in Stellarium, have you tested that? – juandesant Feb 22 '13 at 17:08
  • The Stellarium "Keck Observatory" preset seems to be accurate enough in terms of lat/long and elevation. – Brett Morris Feb 22 '13 at 18:01
  • The `lat` and `long` do not *have* to be in sexagesimal form — I think, if you will check the way @BrettMorris is setting them with decimal numbers, you will find that it stores the correct value. – Brandon Rhodes Feb 22 '13 at 22:53
  • Also: note that your sample code here changes the time from `10:04:14` to `00:04:14` which of course makes a large difference in the result :) – Brandon Rhodes Feb 22 '13 at 23:01
  • Oh, the time zone of Hawaii is 10 hours off UTC. Is that why you were adjusting his time by 10 hours? – Brandon Rhodes Feb 22 '13 at 23:08
  • Yes, that's why I was adjusting it. – Brett Morris Feb 23 '13 at 17:03
  • @BrandonRhodes: Yeap, you're right, I was distracted first by the weird results I was having when `lat` and `long` where switched. – juandesant Feb 25 '13 at 12:45
0

PyEphem always uses UTC for time, so that programs operate the same and give the same output wherever they are run. You simply need to convert the date you are using to UTC, instead of using your local time zone, and the results agree fairly closely with Stellarium; use:

telescope.date = '2013/1/18 05:04:14'

The result is this alt/az:

62:27:19.0 349:26:19.4

To know where the small remaining difference comes from, I would have to look into how the two programs handle each step of their computation; but does this get you close enough?

Brandon Rhodes
  • 83,755
  • 16
  • 106
  • 147
  • Yes, thanks Brandon! I guess Stellarium uses the system time's time zone? – Brett Morris Feb 23 '13 at 17:03
  • Yes, when I installed and ran Stellarium, it used my system's time zone (and not, as I had at first expected, the time zone of the observatory you choose as the observation point!). – Brandon Rhodes Feb 24 '13 at 22:30