Skip to content

Tag: python-xarray

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 prod…

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 posit…

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…