更改底图投影会导致海滩球/数据消失(obspy)

2024-07-04 16:41:07 发布

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

有一个与我的问题here非常相似的问题,但是本页推荐的解决方案在我的情况下不起作用。对于“cyl”投影,绘制海滩球。将此投影更改为“robin”(robinson)将创建不带数据的投影(沙滩球)。另一个类似问题的建议是:

x,y = map(lat, lon)

为了将坐标转换为适用的投影,但这也包含在我的代码中(见下文):

m = Basemap(projection='cyl', lon_0=0, resolution='c')
m.drawmapboundary(fill_color='cornflowerblue')
m.drawcountries()
m.fillcontinents(color='white',lake_color='cornflowerblue',
zorder=0)
m.drawcoastlines()
m.drawparallels(np.arange(-90.,120.,30.))
m.drawmeridians(np.arange(0.,420.,60.))

lats = [38.3215, -55.285, -56.241, -60.274]
lons = [142.36929, -31.877, -26.935, -46.401]

x, y = m(lons, lats)
focmecs = [[193, 9, 78], [301, 62, 84], [101, 69, -56], [190, 89, -140]]
eq_mw = [9.0, 7.4, 7.2, 7.7]

ax = plt.gca()
for i in range(len(focmecs)):
# Loop to set the tensor (beach ball) colors
eq = eq_mw[i]
if eq < 6:
    beachball_color = 'y'
elif 6 <= eq < 8:
    beachball_color = 'orange'
elif 8 <= eq:
    beachball_color = 'r'

b = beach(focmecs[i], facecolor=beachball_color, xy=(x[i], y[i]), width=10, linewidth=1, alpha=0.85)
b.set_zorder(10)
ax.add_collection(b)

Tags: npaxcolormweq投影lonarange

热门问题