mpl_toolkits.basemap 是否在整个投影过程中一致地处理坐标?

问题描述 投票:0回答:0

最近,我一直在研究与地面上固定位置相交的轨道平面。我突然想到绘制这些交叉点可能会有所帮助。这样做时,我相信我在

mpl_toolkits.basemap
处理传递给
Basemap.plot()
的坐标方面遇到了不一致。当使用
ortho
nsper
投影时,它不会绘制与例如
moll
mill
相同的路径,它们都会产生预期的输出。

这是一个最小的工作示例:

import math
import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.basemap import Basemap

# Utilities:
RAD2DEG = 180 / math.pi
DEG2RAD = math.pi / 180

# Angles and coordinates:
i = 51.6390 * DEG2RAD  # Orbital inclination of approx. 51 degrees matching ISS in radians
observer_lat = 28.5728722 * DEG2RAD   # Latitude matching KSC in radians
observer_lon = -80.6489808 * DEG2RAD  # Longitude matching KSC in radians

plt.figure(figsize=(14,14))

offset = -math.acos(-1/(math.tan(i) * math.tan(math.pi/2 - observer_lat)))  # Offset for intersecting KSC

map = Basemap(projection='ortho', lat_0 = observer_lat * RAD2DEG, lon_0 = observer_lon * RAD2DEG)
map.drawcoastlines()
map.drawcountries()
map.fillcontinents(color = 'whitesmoke')
map.drawmapboundary()
map.drawmeridians(np.arange(0, 360, 30))
map.drawparallels(np.arange(-90, 90, 30))

def path(lon):  # Latitude as a function of longitude for the plane
    return math.atan(-1/(math.tan(i)*(math.cos(lon + offset)))) + math.pi/2  

lons = np.linspace(0, 2 * math.pi, 1000)
map.plot(lons * RAD2DEG, (np.vectorize(path)(lons) * RAD2DEG + 90) % 180 - 90, color='r', latlon=True)

map.plot(observer_lon * RAD2DEG, observer_lat * RAD2DEG, color='blue', marker='.', latlon=True)

plt.show()

以上产生this unexpected output。将 only 投影更改为

moll
会产生 this output。输入点没有改变——也没有任何其他改变——但输出不同。请注意 Mollweide 投影的红线如何与蓝点相交,而正交投影并没有接近相交。

我已经搜索了文档,但只能找到有关

latlon
标志的信息。我还尝试使用类似于此处的第二个示例的方法完全删除该标志。尽管如此,我始终在预测之间产生不匹配的输出。

我喜欢使用

ortho
nsper
投影正确地绘制。非常感谢任何帮助。

matplotlib matplotlib-basemap orthographic
© www.soinside.com 2019 - 2024. All rights reserved.