2017-05-05 55 views
1

我想用立體投影繪製我的數據。然而,當我嘗試繪製時,除了大​​陸之外沒有任何東西被繪製出來。Python - 用pcolormesh和底圖繪製

要解釋一下,這是我的數據圖的數字爲:

plt.pcolormesh(longrid_t, latgrid_t,totvart_t) 

其中longrid_t是經度,latgrid_t是緯度和totvart_t是,我想繪製的數據。

這裏是圖中繪出僅與pcolormesh(無底圖)爲plt.pcolormesh(longrid_t, latgrid_t,totvart_t)

Figure plotted only with pcolormesh (without basemap : plt.pcolormesh(longrid_t, latgrid_t,totvart_t)

現在,我試圖用一個立體投影繪製這些數據:

map = Basemap(width=10000000,height=6000000, resolution='l',projection='stere', 
     lat_0=40.,lon_0=-40.) 
map.fillcontinents(color='darkgrey',lake_color='darkgrey') 
map.drawcoastlines() 
map.drawparallels(arange(-90, 91., 10.), labels=[1, 0, 0, 1], 
       dashes=[1, 1], linewidth=0.25, color='0.5') 
map.drawmeridians(arange(-180., 181., 10.), labels=[1, 0, 0, 1], 
       dashes=[1, 1], linewidth=0.25, color='0.5') 

map.pcolormesh(longrid_t, latgrid_t, totvart_t, cmap='jet') 
map.colorbar() 

然而,這個立體投影的結果並不是我所期望的:

stereographic projection

我也嘗試過與其他預測。並且還使用pcolor和contourf代替pcolormesh。但它給了我相同的結果。

你有什麼想法嗎?

+0

您是否在調用'map.pcolormesh'函數時使用'latlon = True' kwarg? – farenorth

回答

1

你必須轉換你的座標數據投影xy座標,然後與轉換的座標繪製:

map = Basemap(width=10000000,height=6000000, resolution='l',projection='stere', 
     lat_0=40.,lon_0=-40.) 
map.fillcontinents(color='darkgrey',lake_color='darkgrey') 
map.drawcoastlines() 
map.drawparallels(arange(-90, 91., 10.), labels=[1, 0, 0, 1], 
       dashes=[1, 1], linewidth=0.25, color='0.5') 
map.drawmeridians(arange(-180., 181., 10.), labels=[1, 0, 0, 1], 
       dashes=[1, 1], linewidth=0.25, color='0.5') 
# convert lat-lon to projection coordinate system 
xpt,ypt = m(longrid_t, latgrid_t) # convert to projection map 

map.pcolormesh(xpt, ypt, totvart_t, cmap='jet') 
map.colorbar() 
0

非常感謝您! 它只是在ymy調用map.pcolormesh時添加latlon = True kwarg