如何利用底图绘制地球观测卫星靠近两极时的视场?

2024-03-29 06:39:54 发布

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

我试图绘制卫星轨道上最大(理论)视场。我使用的是Basemap,我想在它上绘制轨道上不同的位置(带散射),我想使用tissot方法(或等效方法)添加整个视图字段。 下面的代码很好地工作到纬度达到大约75度北,在300公里的高空轨道。代码输出值错误的范围: “ValueError:未定义的反测地线(可能是反ODAL点)”

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

earth_radius = 6371000.  # m
fig = plt.figure(figsize=(8, 6), edgecolor='w')
m = Basemap(projection='cyl', resolution='l',
            llcrnrlat=-90, urcrnrlat=90,
            llcrnrlon=-180, urcrnrlon=180)

# draw the coastlines on the empty map
m.drawcoastlines(color='k')

# define the position of the satellite
position = [300000., 75., 0.]  # altitude, latitude, longitude

# radius needed by the tissot method
radius = math.degrees(math.acos(earth_radius / (earth_radius + position[0])))
m.tissot(position[2], position[1], radius, 100, facecolor='tab:blue', alpha=0.3)
m.scatter(position[2], position[1], marker='*', c='tab:red')

plt.show()

需要注意的是,该代码在南极(纬度低于-75)工作良好。我知道这是一个已知的bug,有没有已知的解决办法? 谢谢你的帮助!


Tags: the方法代码import绘制positionpltmath
1条回答
网友
1楼 · 发布于 2024-03-29 06:39:54

你发现了Basemap的一些局限性。现在我们换成卡通吧。工作代码会有所不同,但不会太多。在

import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import math

earth_radius = 6371000.
position = [300000., 75., 0.]   # altitude (m), lat, long
radius = math.degrees(math.acos(earth_radius / (earth_radius + position[0])))
print(radius)  # in subtended degrees??

fig = plt.figure(figsize=(12,8))

img_extent = [-180, 180, -90, 90]

# here, cartopy's' `PlateCarree` is equivalent with Basemap's `cyl` you use
ax = fig.add_subplot(1, 1, 1, projection = ccrs.PlateCarree(), extent = img_extent)

# for demo purposes, ...
# let's take 1 subtended degree = 112 km on earth surface (*** you set the value as needed ***)
ax.tissot(rad_km=radius*112, lons=position[2], lats=position[1], n_samples=64, \
             facecolor='red', edgecolor='black', linewidth=0.15, alpha = 0.3)

ax.coastlines(linewidth=0.15)
ax.gridlines(draw_labels=False, linewidth=1, color='blue', alpha=0.3, linestyle=' ')
plt.show()

使用上面的代码,结果图是:

enter image description here

现在,如果我们使用正交投影(用这个替换相关的代码行)

^{pr2}$

你得到这个情节:

enter image description here

相关问题 更多 >