Python PyEphem方位角和高度的计算 [英] Python PyEphem calculation of Azimuth and Altitude

查看:744
本文介绍了Python PyEphem方位角和高度的计算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是PyEphem的新手,我试图弄清楚它可以做什么以及如何工作.由于我不想将其用作黑匣子并盲目相信我得到的任何数字,因此我想重新创建一个示例,该示例说明了此处.

I am new to PyEphem and I am trying to figure out what it can do and how it works. As I do not want to use it as a black box and blindly trust whatever figure I get, I wanted to recreate an example that is explained here.

该示例在1998年8月10日世界标准时间23:10为给定的观察者计算对象的方位角和高度.给出以下参数:

The example calculates the azimuth and altitude of an object for a given observer on the 10th August 1998 at 23:10 UT. The following parameters are given:

RA = 16小时41.7分钟,DEC = 36 d 28分钟

RA = 16 h 41.7 min, DEC = 36 d 28 min

观察者的纬度是北纬52 d 30分钟,西经1 d 55分钟.

The observer's latitude is 52 d 30 min North and longitude 1 d 55 min West.

根据示例(我可以在Excel中重新创建)的正确答案是AZ = 269.14634度和ALT = 49.169122度.

The correct answer according to the example (which I can recreate in Excel) is AZ = 269.14634 degrees and ALT = 49.169122 degrees.

我使用pyephem编写了以下代码,以尝试达到相同的结果:

I wrote the following code using pyephem to try to achieve the same result:

day = '1998/8/10 23:10:00'
longitude = ephem.degrees('-1.91667')
latitude = ephem.degrees('52.5')

star = ephem.FixedBody()
star._ra = '16:41:42.0'
star._dec = '36:28:00.0'

observer = ephem.Observer()
observer.date = day
observer.lon = longitude
observer.lat = latitude

star.compute(observer)

print 'Observer', observer
print 'RA', star.ra, 'DEC', star.dec
print 'AZ', star.az, 'ALT', star.alt

运行程序会得到以下输出结果:

Running the program gives me this output:

>>> 
Observer <ephem.Observer date='1998/8/10 23:10:00' epoch='2000/1/1 12:00:00' lon=-1:55:00.0 lat=52:30:00.0 elevation=0.0m horizon=0:00:00.0 temp=15.0C pressure=1010.0mBar>
RA 16:41:39.23 DEC 36:28:33.5
AZ 269:09:54.9 ALT 49:10:57.7

对于AZ + ALT的结果显然是该示例的依据,但相差甚远.与我输入的内容相比,RA和DEC在打印输出中略有修改的事实也令我感到困惑.

The results for AZ + ALT are obviously ballpark to the example but far from identical. I am also puzzled by the fact that RA and DEC are slightly modified in the print out compared to what I entered.

如果有人可以帮助我阐明为什么结果有所不同以及我可以或应该做什么来复制结果,我将不胜感激.谢谢.

If anyone can help me shed some light to why the results differ and what I can or should do to replicate the results, I would greatly appreciate it. Thanks.

编辑:更正了以下答案中指出的错字.这个问题仍然有效.

EDIT: Corrected a typo pointed out in answer below. The question is still valid.

EDIT2 :好的,我已经阅读(并有些理解)为什么PyEphem从此

EDIT2: OK, I have read (and sort of understood) why the right ascension and declination is adjusted by PyEphem from this link. What I do not understand is if there is any way to get PyEphem to ignore adjusting for relativistic deflection, nutation and aberration of light the same way that you can make it ignore atmospheric refraction? I am assuming that the difference in Azimuth is due to the adjustment of RA and DEC but it would be nice to confirm.

推荐答案

PyEphem底层的C库没有任何方法可以关闭偏斜,像差或章动现象-也许是因为Nature不允许我们也关闭这些效果,但我不确定!我会注意到,它不会对绕地球运行的卫星进行这些计算,但是我想不出一种简单的方法来将卫星放置在精确的RA并下降到高于您的位置的位置,以便您可以向PyEphem询问它的位置.

The C library underlying PyEphem does not have any way to turn off deflection, aberration, or nutation — maybe because Nature does not let us turn those effects off either, but I am not sure! It does not, I will note, do those calculations for an earth-orbiting satellite, but I can't think of an easy way for you to put a satellite at an exact RA and dec above your position so that you can ask PyEphem about its location.

我实际上本周在DjangoCon上度过了关于API的话题,并思考有一天PyEphem如何使它的内部工作更易于从Python访问,而不是将所有这些有趣的步骤都锁定在C代码内部.但是,在我准备好替代方法之前,完成所需操作的唯一方法是打开源文件circum.c并注释掉以下几行:

I am actually spending this week at DjangoCon going to talks about APIs, and thinking about how PyEphem might someday make its inner workings easier to access from Python, instead of leaving all of these interesting steps locked inside of the C code. But, until I have an alternative ready, the only way to accomplish what you want would be to open the source file circum.c and comment out these lines:

/* allow for relativistic light bending near the sun */
deflect (mjed, lam, bet, lsn, rsn, 1e10, &ra, &dec);

/* TODO: correction for annual parallax would go here */

/* correct EOD equatoreal for nutation/aberation to form apparent 
 * geocentric
 */
nut_eq(mjed, &ra, &dec);
ab_eq(mjed, lsn, &ra, &dec);

如果注释掉了从第263行开始的这三个调用-deflect()nut_eq()ab_eq(),那么您可能会得到一个与本文产生的答案更接近的答案.您可以通过以下方式应用这些更改:

If those three calls — deflect(), nut_eq(), and ab_eq() starting at line 263 — are commented out, then you might get an answer much closer to the one produced in this article. You would apply these changes by:

  • 下载PyEphem的.tar.gz.
  • 提取存档以生成文件.
  • 进行我上面建议的编辑.
  • 运行python setup.py install以安装您的自定义版本的软件.
  • 尝试一下!
  • Downloading the .tar.gz for PyEphem.
  • Extract the archive to produce files.
  • Make the edit that I suggest above.
  • Run python setup.py install to install your custom version of the software.
  • Try it out!

如果进动在某种程度上起作用,则可能会遇到另一个障碍-在这种情况下,您可能需要将star对象的时期完全设置为'1998/8/10 23:10:00'-但尝试先关闭三个光效果调用看看是否可以拉近你!

There might be another obstacle, if precession is somehow coming into play — you might need to set the epoch of your star object to exactly '1998/8/10 23:10:00' in that case — but try turning off the three light-effect calls first and see if that gets you closer!

这篇关于Python PyEphem方位角和高度的计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆