加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

python – 根据纬度和日出时间计算经度?

发布时间:2020-12-20 13:29:42 所属栏目:Python 来源:网络整理
导读:我正在计算当前太阳高度当前为~0.0的位置的经度.这是通过迭代一系列纬度来计算,计算日出时间(0.0,纬度)然后通过将时间差(小时数)乘以15(太阳“移动”的度数来计算经度)地球表面). 当从计算的坐标元组计算日出时间时,最低纬度显示具有最高纬度的几分钟的时间
我正在计算当前太阳高度当前为~0.0的位置的经度.这是通过迭代一系列纬度来计算,计算日出时间(0.0,纬度)然后通过将时间差(小时数)乘以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).代码在?秒下运行.

造成这种差异的原因是什么?

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

解决方法

我检查了 NOAA’s solar calculator列表中极端N和S点的日出时间.在纬度/长度和今天的日期喂食给出的日出时间与您发布的表格中的相同,条件是仅计算器将日出时间提供给最近的分钟.

不过,如果您的问题与我的代码有什么问题一致?答案很可能是什么都没有.

但是,如果你的问题确实是什么我对日出时间和位置和日期的变化我没有理解?然后你的问题严重偏离了主题.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读