简体   繁体   English

Python PyEphem方位角和高度的计算

[英]Python PyEphem calculation of Azimuth and Altitude

I am new to PyEphem and I am trying to figure out what it can do and how it works. 我是PyEphem的新手,我试图弄清楚它可以做什么以及如何工作。 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 . 因为我不想把它作为一个黑盒子,盲目信任任何数字,我得到,我想重新被解释的例子在这里

The example calculates the azimuth and altitude of an object for a given observer on the 10th August 1998 at 23:10 UT. 该示例在1998年8月10日世界标准时间23:10为给定的观察者计算对象的方位角和高度。 The following parameters are given: 给出以下参数:

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

The observer's latitude is 52 d 30 min North and longitude 1 d 55 min West. 观察者的纬度是北纬52 d 30分钟,西经1 d 55分钟。

The correct answer according to the example (which I can recreate in Excel) is AZ = 269.14634 degrees and ALT = 49.169122 degrees. 根据示例(我可以在Excel中重新创建)的正确答案是AZ = 269.14634度和ALT = 49.169122度。

I wrote the following code using pyephem to try to achieve the same result: 我使用pyephem编写了以下代码,以尝试达到相同的结果:

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

The results for AZ + ALT are obviously ballpark to the example but far from identical. AZ + ALT的结果显然是该示例的标准,但相差甚远。 I am also puzzled by the fact that RA and DEC are slightly modified in the print out compared to what I entered. 我也感到困惑的是,与我输入的内容相比,RA和DEC在打印输出中稍作修改。

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 : OK, I have read (and sort of understood) why the right ascension and declination is adjusted by PyEphem from this link . EDIT2 :好的,我已经阅读(并从某种程度上理解了)为什么PyEphem从此链接调整了正确的上升和下降。 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 ? 我不明白的是,是否有任何方法可以让PyEphem忽略对相对论的偏转章动像差进行调整,就像可以使它忽略大气折射一样 I am assuming that the difference in Azimuth is due to the adjustment of RA and DEC but it would be nice to confirm. 我假设方位角上的差异是由于RA和DEC的调整引起的,但可以很好地确认。

The fact that observer includes "temp=15.0C pressure=1010.0mBar" implies that the calculation will include refraction. 观察者包括“温度= 15.0℃压力= 1010.0mBar”的事实意味着计算将包括折射。 You want to turn off refraction 您要关闭折射

as described in the help : 帮助中所述:

These apparent positions include an adjustment to simulate atmospheric refraction for the observer's temp and presure; 这些明显的位置包括为观察者的温度和压力模拟大气折射的调整; set the observer's pressure to zero to ignore refraction. 将观察者的压力设为零以忽略折射。

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

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

/* 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);

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. 如果从第263行开始的这三个调用( deflect()nut_eq()ab_eq()被注释掉了,那么您可能会得到一个与本文产生的答案更接近的答案。 You would apply these changes by: 您可以通过以下方式应用这些更改:

  • Downloading the .tar.gz for PyEphem. 为PyEphem下载.tar.gz
  • 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. 运行python setup.py install以安装您的自定义版本的软件。
  • Try it out! 试试看!

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! 如果进动在某种程度上起作用,则可能还会有另一个障碍-在这种情况下,您可能需要将star的时代精确地设置为'1998/8/10 23:10:00'但请尝试关闭三盏灯-effect首先拨打电话,看看是否可以拉近您!

You wanted to enter : RA = 16 h 41.7 min 您想输入:RA = 16小时41.7分钟

but you entered: star._ra = '16:41.42.0' 但您输入了:star._ra = '16:41.42.0'

instead of star._ra = '16:41:42.0' 而不是star._ra = '16:41:42.0'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM