HI,

I was looking for an example using pygmt plotting ocean current vectors over the speed which is filled in the background from a NetCDF file. For example the HYCOM current vectors available from the below location which can be loaded to python memory using the below commands. And normal quiver plot can be made . But I wanted to use pygmt for this purpose, please direct me to an implemented example if possible.

from netCDF4 import Dataset as nc

nf=nc(“https://tds.hycom.org/thredds/dodsC/GLBv0.08/expt_56.3”)

lat=nf.variables[‘lat’][:]

lon=nf.variables[‘lon’][:]

#nf.variables[‘water_u’].shape

idx1 = (np.abs(lat - 0)).argmin()

idx2 = (np.abs(lat - 25)).argmin()

idx3=(np.abs(lon-65)).argmin()

idx4=(np.abs(lon-90)).argmin()

[lat[idx1],lat[idx2],lon[idx3],lon[idx4]]

uvel=nf.variables[‘water_u’][1,0,idx1:idx2,idx3:idx4]

vvel=nf.variables[‘water_v’][1,0,idx1:idx2,idx3:idx4]

lat1=nf.variables[‘lat’][idx1:idx2]

lon1=nf.variables[‘lon’][idx3:idx4]

spd=np.sqrt(np.square(uvel)+np.square(vvel))

x,y=np.meshgrid(lon1,lat1)

plt.contourf(x,y,spd,50)

plt.quiver(x,y,uvel,vvel,scale=20)