Skip to content
Advertisement

Getting error “unhashable type: ‘numpy.ndarray’ ” while trying to plot vectors from two different .nc files

I have read two files using open_mfdataset. What I’m trying to do is create a vector plot for the wind stress data for which the i and j components are stored in two different files.

JavaScript

This is the data description

This is the data description

But while trying to do the vector plotting using quiver I’m getting this unhashable typeerror.

JavaScript
JavaScript

Advertisement

Answer

You’re using matplotlib.pyplot.quiver, which expects arrays of numbers x, y, u, v. When you call the following:

JavaScript

X and Y are 2D string arrays:

JavaScript

Instead, I think you’re looking for something along the lines of

JavaScript

That said, you might try xarray.Dataset.plot.quiver which can work directly with xarray objects, and does accept string arguments referring to the dataset’s variable and coordinate names:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement