计算卫星视距与地面目标区域重叠的时间

2024-05-16 06:01:19 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试编写一些python代码来计算国际空间站的地平线何时与地面上的目标区域重叠。就我而言,我选择了中国。我有一些代码可以工作,但我不确定我是否在数学上正确地处理问题,并可以做一些建议。你知道吗

我的代码使用shapely来定义一个粗糙的多边形使用极坐标为中国的国家边界。然后我用以弗所来计算国际空间站的地面坐标和高程。海拔是以米为单位的,所以我用它来计算从眼球到地平线的距离。你知道吗

下一步的想法是创建一个以国际空间站为中心的圆形多边形(.buffer(1)),简单地看一下它是否与中国的多边形相交,使用的是形状良好的内置函数。你知道吗

但这有点棘手,因为中国多边形是在极坐标系中,地平线距离是以米为单位的。所以,为了解释经线在赤道处宽而在两极处窄的事实,我必须做一个计算,首先计算出当前纬度处经线之间的距离,然后用它来计算圆在x和y方向上需要多少极度。然后用这些尺寸做一个椭圆,看看交点是否在那里。你知道吗

import time
import ephem
import math
from shapely.geometry import Polygon, Point
import shapely.affinity
import datetime

R = 6371 * 1000.0

dist_1_deg_long_equator = 111321
dist_1_deg_lat_equator = 111000

def get_dist_to_horizon(elevation_meters):
    eye = R + elevation_meters
    return R * math.acos(R / eye)

china = Polygon([
    (48.74, 87.17),
    (39.09, 74.05),
    (33.25, 79.13),
    (28.24, 86.44),
    (29.58, 95.74),
    (26.33, 98.82),
    (24.29, 97.89),
    (21.85, 100.82),
    (23.57, 105.32),
    (21.65, 108.14),
    (23.04, 116.23),
    (27.10, 120.31),
    (30.63, 122.08),
    (39.81, 124.09),
    (46.87, 133.90),
    (53.37, 121.73),
    (46.57, 119.57),
    (41.64, 105.26),
    (42.75, 96.28),
    (45.30, 90.76)])

name = "ISS (ZARYA)             "
line1 = "1 25544U 98067A   19094.21920345  .00002412  00000-0  46183-4 0  9994"
line2 = "2 25544  51.6444   8.9214 0002426 147.8175  11.8704 15.52483300163762"

iss = ephem.readtle(name, line1, line2)

while True:
    iss.compute()
    iss_horizon_radius = get_dist_to_horizon(iss.elevation)    

    dist_1_deg_long_current = math.cos(iss.sublat) * dist_1_deg_long_equator

    x_fact = iss_horizon_radius / dist_1_deg_long_current  # include more lines of longitude further from equator
    y_fact = iss_horizon_radius / dist_1_deg_lat_equator  # latitude lines are approx equal distant

    iss_horizon_circle = Point(math.degrees(iss.sublat), math.degrees(iss.sublong)).buffer(1)
    iss_horizon_ellipse = shapely.affinity.scale(iss_horizon_circle, x_fact, y_fact, origin='center')

    if iss_horizon_ellipse.intersects(china):
        print("ISS horizon is over China! %s" % datetime.datetime.utcnow())

    time.sleep(30)

有没有更好的办法?例如,把所有的东西都转换成笛卡尔坐标,然后把地平线变成一个完美的圆?任何建议都将不胜感激!提前谢谢


Tags: 代码importdistmath多边形空间站地平线long