我的数据集采用表格数据的形式。我正在尝试绘制通过仪器在特定路径上测量的风数据,该仪器的值和坐标在此表格数据中给出。数据头如下:
df.head()
>>Lat Lon Wind_direction Air_temp Water_temp Wind_speed
64.1513 -21.935475 106 11.13 11.98 4.8
64.1515 -21.935418 114 11.59 11.09 9.8
64.1596 -21.931857 114 11.78 11.58 10.8
64.1596 -21.931857 116 11.59 11.78 10.2
64.1596 -21.931860 120 11.60 11.82 9.5
我正在尝试按照示例of basemap-rotate vectors绘制数据,但是该绘制未生成任何倒钩并给出了空白图表。这是我的代码:
lats1, lons1 = np.array(df.Lat), np.array(df.Lon)
# creating a grid of data points
lats2, lons2 = np.meshgrid(lons1, lats1)
# N-S and E-W components of velocity
u = np.array(df['Wind_speed'] * np.sin(df['Wind_direction'] * np.pi / 180.0))
v = np.array(df['Wind_speed'] * np.cos(df['Wind_direction'] * np.pi / 180.0))
# We have to bring u and v also in the shape of lon and lat to be able to plot them??
u2 = np.ones(lons2.shape) * u
v2 = np.ones(lons2.shape) * v
#rotating the wind vectors
u2_rot, v2_rot, x2, y2 = map.rotate_vector(u2, v2, lons2, lats2, returnxy=True)
fig = plt.figure(figsize=(8,15), dpi=100)
# generating the map
m = Basemap(projection='lcc', resolution='l', llcrnrlat=63,
urcrnrlat=68,llcrnrlon=-30, urcrnrlon=-20, lat_0=65.25, lon_0=-29.2)
# plotting barbs
# zorder used so that continents don't overlay barbs
m.barbs(x2, y2, u2_rot, v2_rot, pivot='middle', barbcolor='#ff7777', zorder=100)
m.fillcontinents(color='coral',lake_color='aqua')
m.drawmapboundary(fill_color="#DDEEFF")
m.drawcoastlines()
我得到的只是地图上的大洲和海岸线。请指出在绘制它们时我犯了什么概念性错误。