Skip to content
Advertisement

Tag: python-xarray

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. This is the data description But while trying to do the vector plotting using quiver I’m getting this unhashable typeerror. Answer You’re using matplotlib.pyplot.quiver, which

extract extreme values from xarray dataarray

I have a rather large dataset, and need to find in that dataset extreme values, including coordinates. The real dataset is much larger, but let’s take this one for testing: I want to find in this dataarray all values larger than 2. I found on here this solution: but even in this small example, this produces a lot more nans

1D netcdf to 2D lat lon using xarray and Dask

I have a large netcdf dataset which has two dimensions – ‘time’ and a single spatial dimension ‘x’. There is also a ‘lat’ and ‘lon’ coord for each ‘x’. This needs to be mapped onto a global half degree 2D grid, such that the dimensions are ‘time’, ‘lat and ‘lon’. Not all the points on the global half degree grid

Multiply xarray variables with a numpy array

I have an xarray.DataArray: and I want ro multiply each mode with an element of the array array([68.8005905 , 17.8959575 , 8.46729004]). Any idea how to do that? Answer This is exactly what xarray is intended to help with you’re on the right track! Unlike numpy, which relies on dimension order and positional indices to align arrays, xarray relies on

compute mean from several years using xarray

I want to compute the mean for an xarray dataset that contains daily temperature data from 2015-2020. Here is what I am doing currently: ds.groupby(‘time.year’).mean(‘time’) However, this gives me annual mean for each year separately, whereas I want the mean for all the years. How do I fix this? Answer If you’re looking for the mean across the entire time

Advertisement