我在计算当前太阳高度为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(时间在协调时)。代码运行在~秒以下。
造成这种差异的原因是什么?
代码
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发布于 2012-08-21 14:12:45
我检查了NOAA太阳计算器列表中的极端N点和S点的日出时间。在lat/long和今天的日期上喂食的日出时间与您发布的表中的时间相同,但计算器只给出了日出时间的最近一分钟。
尽管如此,如果您的问题大致是这样的话,那么我的代码有什么问题呢?答案很可能是什么都没有。
但如果你的问题是,我到底有什么不了解的变化在日出时间,wrt的位置和日期?那么你的问题就严重偏离主题了。
发布于 2012-08-21 19:42:49
我认为一个更直接的方法会对你有用,这将避免每小时15度的修正。毕竟你有一个星历,所以你可以利用它。
对你想要的每一个纬度都这样做。
为了检查事情是否有效,在春分处做计算,你计算的经度应该几乎完全相等(确保你明白为什么)。在任何一个冬至再做一次,经度应该会有很大的变化,当你到达北纬或南纬约67度时,算法就会失败(你知道为什么吗?)
发布于 2014-10-20 18:42:50
太阳在天空中的位置不均匀。12月份的当地表观中午可能比当地的平均中午提前几分钟,而6月的局地表观中午可能会“迟到”几分钟。这种“摆动”是通过时间方程来预测的,如果我正确地理解了这一点,就会在离赤道更远的地方产生更明显的影响。
https://stackoverflow.com/questions/12054613
复制相似问题