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

时间:2016-10-18 11:38:57

标签: python matplotlib-basemap

我的问题here存在一个非常类似的问题,但此页面上推荐的解决方案在我的案例中不起作用。对于投影'圆柱体,绘制了沙滩球。将此预测更改为“知更鸟”#39; (鲁宾逊)创建没有数据的投影(沙滩球)。对其他类似问题的建议是使用:

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)

1 个答案:

答案 0 :(得分:0)

问题在于投影和轴或数据坐标转换。当宽度从10更改为1000000时,这解决了问题:

b = beach(focmecs[i], facecolor=beachball_color, xy=(x[i], y[i]), width=1000000, linewidth=1, alpha=0.85)