How to compute (alt, az) for given Galactic coordinate (GLON, GLAT) with PyEphem?

一个人想着一个人 提交于 2019-12-10 17:44:11

问题


For a given observer (lon, lat, time) on Earth and a given Galactic coordinate (GLON, GLAT), how can I compute the corresponding (alt, az) point in the sky with PyEphem?


回答1:


Given the way that PyEphem currently works, there are two steps to answering your question. First, you have to convert a pair of galactic coordinates into an equatorial RA/dec pair of coordinates instead.

import ephem

# Convert a Galactic coordinate to RA and dec                          

galactic_center = ephem.Galactic(0, 0)
eq = ephem.Equatorial(galactic_center)
print 'RA:', eq.ra, 'dec:', eq.dec

→ RA: 17:45:37.20 dec: -28:56:10.2

Those coordinates are pretty close to the ones that the Wikipedia gives for the galactic center.

Now that we have a normal RA/dec coordinate, we just need to figure out where it is in the sky right now. Since PyEphem is built atop a library that knows only about celestial “bodies” like stars and planets, we simply need to create a fake “star” at that location and ask its azimuth and altitude.

# So where is that RA and dec above Boston?
# Pretend that a star or other fixed body is there.

body = ephem.FixedBody()
body._ra = eq.ra
body._dec = eq.dec
body._epoch = eq.epoch

obs = ephem.city('Boston')
obs.date = '2012/6/24 02:00' # 10pm EDT
body.compute(obs)
print 'Az:', body.az, 'Alt:', body.alt

→ Az: 149:07:25.6 Alt: 11:48:43.0

And we can check that this answer is reasonable by looking at a sky chart for Boston late that evening: Sagittarius — the location of the Galactic Center — is just rising over the southeastern rim of the sky, which makes perfect sense of a southeast azimuth like 149°, and for an as-yet low altitude like 11°.



来源:https://stackoverflow.com/questions/11169523/how-to-compute-alt-az-for-given-galactic-coordinate-glon-glat-with-pyephem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!