我如何用pyephem计算距离?

我如何用pyephem计算距离?,pyephem,Pyephem,嗨,我需要一些帮助,如果你们中有人知道如何计算坐标和卫星投影的距离,我的意思是,当我预测卫星的路径时,我需要知道未来路径和我放置的坐标之间的距离。这样,当卫星接近坐标时,就会发出一条信息通知我 这是我正在使用的代码,任何人都可以帮助我,这将是伟大的 from mpl_toolkits.basemap import Basemap from geopy.distance import great_circle from matplotlib import colors from pyorbital

嗨,我需要一些帮助,如果你们中有人知道如何计算坐标和卫星投影的距离,我的意思是,当我预测卫星的路径时,我需要知道未来路径和我放置的坐标之间的距离。这样,当卫星接近坐标时,就会发出一条信息通知我

这是我正在使用的代码,任何人都可以帮助我,这将是伟大的

from mpl_toolkits.basemap import Basemap
from geopy.distance import great_circle
from matplotlib import colors
from pyorbital import tlefile
import matplotlib.pyplot as plt
import numpy as np
import math
import ephem
from datetime import datetime


tlefile.TLE_URLS = (    'http://celestrak.com/NORAD/elements/resource.txt',)
sat_tle = tlefile.read('NUSAT 1 (FRESCO)')
sat = ephem.readtle("NUSAT 1 (FRESCO)", sat_tle.line1, sat_tle.line2)
obs = ephem.Observer()
# location for tge coordinates
print("Latitud ")
sat_lat = input()
print("Longitud suggested point")
sat_lon = input()
obs.lat = str(sat_lat)
obs.long = str(sat_lon)
# programar proyeccion del mapa
map = Basemap(projection='ortho', lat_0=sat_lat, lon_0=sat_lon, resolution='l')
# draw coastlines, country boundaries, fill continents.
map.drawcoastlines(linewidth=0.25)
map.drawcountries(linewidth=0.25)
map.fillcontinents(color='coral',lake_color='aqua')
# draw the edge of the map projection region (the projection limb)
map.drawmapboundary(fill_color='aqua')
# grid in latitud and longitud every 30 sec.
map.drawmeridians(np.arange(0,360,30))
map.drawparallels(np.arange(-90,90,30))



# plot
passes = 4
for p in range(passes):
    coords = []
    dists = []
    tr, azr, tt, altt, ts, azs = obs.next_pass(sat)
    print """Date/Time (UTC)       Alt/Azim   Lat/Long  Elev"""
    print """====================================================="""
    while tr < ts:
        obs.date = tr
        sat.compute(obs)
    print "%s | %4.1f %5.1f | %4.1f %+6.1f | %5.1f" % \
    (tr, math.degrees(sat.alt), math.degrees(sat.az), math.degrees(sat.sublat),              math.degrees(sat.sublong), sat.elevation/1000.)    
        sat_lat = math.degrees(sat.sublat)
        sat_lon = math.degrees(sat.sublong)
        dist = great_circle((sat_lat, sat_lon), (sat_lat, sat_lon)).miles
        coords.append([sat_lon, sat_lat])
        dists.append(dist)
        tr = ephem.Date(tr + 30.0 * ephem.second)
    md = min(dists)
    imd = 1 - (float(md) / 1400)
    hue = float(240) / float(360)
    clr = colors.hsv_to_rgb([hue, imd, 1])
    map.drawgreatcircle(coords[0][0], coords[0][1], coords[-1][0], coords[-1][1], linewidth=2, color=clr)
    obs.date = tr + ephem.minute
# map with UTC 
date = datetime.utcnow()
cs=map.nightshade(date)



plt.title('next '+ str(passes)+ ' passes of the satellite')
plt.show()
从mpl_toolkits.basemap导入basemap
从geopy.distance导入大圆
从matplotlib导入颜色
从pyorbital导入文件
将matplotlib.pyplot作为plt导入
将numpy作为np导入
输入数学
进口以弗所
从日期时间导入日期时间
tlefile.TLE_URL=('http://celestrak.com/NORAD/elements/resource.txt',)
sat_tle=tlefile.read('NUSAT 1(湿壁画)'
sat=以弗所Readle(“NUSAT 1(壁画)”,sat_tle.line1,sat_tle.line2)
obs=以弗所观察者()
#tge坐标的位置
打印(“纬度”)
sat_lat=输入()
打印(“纵向建议点”)
sat_lon=输入()
obs.lat=str(sat_lat)
obs.long=str(卫星)
#mapa计划项目
地图=底图(投影='ortho',纬度0=卫星纬度,经度0=卫星纬度,分辨率='l')
#绘制海岸线,国家边界,填充大陆。
地图绘制海岸线(线宽=0.25)
地图绘制国家(线宽=0.25)
地图。填充大陆(颜色为珊瑚色,湖泊颜色为水色)
#绘制地图投影区域的边(投影肢体)
map.drawmapboundary(填充颜色为aqua)
#每30秒以横向和纵向进行网格划分。
绘制子午线图(北阿兰奇(0360,30))
拉丝平行线地图(np.arange(-90,90,30))
#密谋
通行证=4
对于范围内的p(通过):
coords=[]
dists=[]
tr、azr、tt、altt、ts、azs=下一个通行证(sat)
打印“日期/时间(UTC)Alt/Azim Lat/Long Elev”
打印“”“”=======================================================================================================================================================================================================================================================================================
而tr
您可能想看看它在哪里描述函数
ephem.separation()
。您可以使用两个经纬度坐标对来调用它,它将告诉您它们之间的距离:

ephem.separation((lon1, lat1), (lon2, lat2))
因此,如果将卫星的经度和纬度作为一个坐标对传递,将感兴趣的位置的经度和纬度作为另一个传递,则可以观察间隔何时变得非常小