【发布时间】:2012-08-16 18:48:54
【问题描述】:
我正在计算当前太阳高度当前约为 0.0 的位置的经度。这是通过迭代一系列纬度来完成的,计算(0.0, latitude) 的日出时间,然后通过将时间差(分数小时)乘以 15(太阳在地球表面“移动”的度数)来计算经度)。
从计算的坐标元组计算日出时间时,最低纬度与最高纬度显示几分钟的时间差。如何解释这种差异?
在:
points=walk_the_earth()
输出:
[-66.53673944994807, -65.0] 2012-08-21 12:07:04.748893
[-67.13184367865324, -64.5] 2012-08-21 12:07:05.666852
[-67.70314011722803, -64.0] 2012-08-21 12:07:06.541521
...
[-119.24775995314121, 64.0] 2012-08-21 12:08:45.536679
[-119.93103107437491, 64.5] 2012-08-21 12:08:47.770382
[-120.64480075612664, 65.0] 2012-08-21 12:08:50.152224
(时间以 UTC 为单位)。代码在 ~second 下运行。
造成这种差异的原因是什么?
代码
import math
import xephem
def longitude_from_latitude(lat):
"""
Calculate the longitude at which Sun altitude is ~0.0.
Args:
lat: A float indicating the latitude to calculate longitude
for.
Returns:
float
"""
now = xephem.julianday.now()
meridian = xephem.Observer(now.midnight.dublin, 0.0, lat)
sun = xephem.Sun.fromobserver(meridian)
transit = sun.transit(-1)
# Calculate time difference between sun position and local time.
delta_t = ((now - transit['rs_risetm']) * 24.0) * 15.0
return delta_t
def walk_the_earth(resolution=0.5, minlat=-65.0, maxlat=65.0):
"""
Calculate the coordinate at which Sun altitude is ~0.0 for
a given range of latitudes.
Args:
resolution: A float indicating the number of points to
return for the specified range of latitudes. 1.0 means
that 1 longitude will be calculated for each real
latitude, 0.5 means 2, etc.
minlat: A float indicating the lowest latitude to start
calculating.
maxlat: A float indicating the highest latitude to
calculate up to.
Returns:
list of longitude, latitude, xephem.Sun tuples.
"""
now = xephem.julianday.now()
lat = minlat
points = []
while True:
if lat > maxlat:
break
lng = longitude_from_latitude(lat)
# Create an Observer for longitude and latitude
obs = xephem.Observer(now.dublin, lng, lat)
sun = xephem.Sun.fromobserver(obs)
points.append([lng, lat, sun])
# sun.transit() calculates the rising, transit and setting times
# of the sun at Observers location. The -1 argument specifies
# that we consider sunrise to occur when the upper limb touches
# the horizon (0 indicates center, 1 indicates lower limb).
print points[-1], sun.transit(-1)['rs_risetm'].datetime()
lat += resolution
return points
【问题讨论】:
-
我认为您对问题的编辑可能已经改变了输出,但是......您所描述的问题(太阳位于高度 0 的点)本质上是关于追踪地球上的终结者(光变暗的点)。只有当地轴垂直于地球-太阳矢量或在春分点时,这一切都在一个纬度上。例如,可视化终结者在至日的位置。
-
你能展示你所期望的吗?你给出的输出来自哪里?
-
与什么相比有几分钟的差异?另外,这两个函数是如何调用的?他们似乎没有互相调用,所以我假设某处有一个 main 函数调用它们。
-
我已经编辑了问题以澄清,并更正了代码中的错字。
标签: python math astronomy xephem