将赤道转换为alt-az坐标非常慢

问题描述 投票:2回答:1

[我正在尝试(希望)在<5秒运行时或更理想的情况下,在<1秒运行时中将给定时间和位置的对象的赤道坐标转换为alt-az坐标。

astropy tutorial for coordinate transformations之后,我设置了以下代码:

from astropy import units as u
from astropy.coordinates import SkyCoord,EarthLocation, AltAz
from astropy.time import Time

target = SkyCoord(9.81625*u.deg, 0.88806*u.deg, frame='icrs')

location = EarthLocation(lat='31d57.5m', lon='-111d35.8m', height=0*u.m)
obs_time = Time('2010-12-21 1:00')

alt_az_frame = AltAz(location=location, obstime=obs_time)
target_alt_az = target.transform_to(alt_az_frame)

print(target_alt_az.alt, target_alt_az.az)

此代码需要20秒钟才能运行,几乎所有的代码都来自target.transform_to(alt_az_frame)行。

是否有使用transform_to函数来加快代码速度的更合适的方法,还是应该完全放弃使用astropy并从头开始编写代码?我了解SkyCoord对象中内置了许多额外功能,但我可能不需要其中的许多功能-使用预先构建的标准化代码很方便。

python astropy
1个回答
4
投票

经过一些调试后,似乎发生了这种情况,因为astropy.utils.iers.iersconf.iers_auto_url是错误的网址。这是我为您解决的简单方法。

from astropy.utils.iers.iers import conf
# The desired url may change in the future
conf.iers_auto_url = 'ftp://cddis.gsfc.nasa.gov/pub/products/iers/finals2000A.all'

# Run you code here

或者,您可以执行conf.remote_timeout = 0.1conf.auto_download = False(使用备份数据)。

我找不到与此问题直接相关的文档,但阅读this page可能会有帮助。讨论了该问题in the issue。我认为此问题仅在某些版本的库中发生,因此将库更新到最新版本可能是一个解决方案。

© www.soinside.com 2019 - 2024. All rights reserved.