PyEphem 上升和设定数百年的计算有多准确?

how accurate are PyEphem rise and set calculations over several hundred years?

计算每天的日照时间(日落-日出)并找到每年的最大值(通常在至日但并非总是如此),一个有趣的模式出现了。每个世纪损失大约 5 秒的阳光。

这是 PyEphem 中的错误因素吗?这是否准确,PyEphem 是否考虑了地球轨道的变化?其他原因?

import pandas as pd
import ephem

sun = ephem.Sun()
raleigh = ephem.Observer()
raleigh.lon, raleigh.lat = "-78.6382", '35.7796'
raleigh.horizon = '-0:34'  # USNO standard atmospheric diffraction
raleigh.pressure = 0       # atmospheric refraction parameters

def riseset(date, f):
    # compute passed function (sunrise or sunset)
    raleigh.date = date
    sun.compute(raleigh)
    sr = ephem.localtime(f(sun))
    return sr

def createdataframe(start, end):
    # create a dataframe index by daily dates, add columns for the
    # sunrise, sunset, and their delta
    df = pd.DataFrame(index=pd.date_range(start=start, end=end,  freq='D'))
    df['date'] = df.index.map(lambda d: d.strftime("%b %d"))
    df['sunrise'] = df.index.map(lambda d: riseset(d, raleigh.next_rising))
    df['sunset'] = df.index.map(lambda d: riseset(d, raleigh.next_setting))
    df['daylightdelta'] = df['sunset'] - df['sunrise']
    return df

def outputmax(df, year):
    i = df['daylightdelta'].idxmax()  # index of the day where the sun is visible above the horizon for the most time
    return "solstice: %s longest day sunrise: %s sunset: %s daylight: %s" % (
        ephem.localtime(ephem.next_solstice(str(year))).strftime("%Y %b %d %X"),
        df.loc[i]['sunrise'].strftime("%b %d %X"),
        df.loc[i]['sunset'].strftime("%T"),
        df.loc[i]['daylightdelta'])

if __name__ == "__main__":
    for year in range(1900,2201):
        # looping through 1900-2200, find the date with the most hours of sunlight
        start = '%d-01-01 04:00:00' % year # compensating for UTC which can throw off pandas columnar math
        end = '%d-12-31 23:59:00' % year
        print outputmax(createdataframe(start, end), year)

我猜 PyEphem 正在向您展示一个真实的现象。虽然我不是专家,无法列出所有影响诸如最长一天的长度等数字的众多旋转因素,但对我来说最突出的是地球磁极的倾斜度随着时间的推移而变化,目前正在减少:

https://en.wikipedia.org/wiki/Milankovitch_cycles#Axial_tilt_.28obliquity.29

让我们粗略地粗略猜测一下这种影响可能有多大。如果超过 41,000 年倾斜度从最大值到最小值再返回,那么当前从最大倾斜值回到最小值的半周期必须花费大约 20,500 年。虽然真正的调整当然是正弦曲线,在最大值附近缓慢变化,然后在极端之间的中间变化更快,但如果它只是线性的,作为一阶近似值呢?那么 20,500 年 = 205 个世纪的变化率大致为:

(24.5 - 22.1) 度 / 205 个世纪 ≅ 0.01 度

因此,地轴的倾斜度预计每年变化大约百分之一度。如果将轴倾斜度改变 0.01 度,罗利最长的一天会改变多少秒? PyEphem 不允许我们任意改变轴向倾斜,所以让我们调整 Raleigh 的位置。将程序的底部子句更改为:

if __name__ == "__main__":
    year = 2000
    start = '%d-01-01 04:00:00' % year # compensating for UTC which can throw off pandas columnar math
    end = '%d-12-31 23:59:00' % year

    raleigh.lat = '35.76'
    print outputmax(createdataframe(start, end), year)

    raleigh.lat = '35.77'
    print outputmax(createdataframe(start, end), year)

    raleigh.lat = '35.78'
    print outputmax(createdataframe(start, end), year)

作为输出你应该得到:

solstice: 2000 Jun 20 21:47:51 longest day sunrise: Dec 21 07:20:52 sunset: 17:04:27 daylight: 0 days 14:16:24.970989
solstice: 2000 Jun 20 21:47:51 longest day sunrise: Dec 21 07:20:54 sunset: 17:04:26 daylight: 0 days 14:16:28.206467
solstice: 2000 Jun 20 21:47:51 longest day sunrise: Dec 21 07:20:55 sunset: 17:04:24 daylight: 0 days 14:16:31.442902

大约每世纪三四秒,这大致是您所看到的效果的大小。那么,我的猜测是,您的程序正在揭示地球轴向倾斜度的逐渐减小,这逐渐使季节不那么极端,最长的白天和最长的夜晚也不那么极端。