xarray Computation Practice

xarray Computation Practice#

Part 1#

Computation#

Filtering or masking values#

worksheet? dimensions can still be awkward, even if they aren’t as bad in xarray as they are in numpy.

Getting a bunch of dates with .sel or .isel

Part 2#

Look again at the .max() documentation. We see that the dim argument can take either a single string or a sequence of strings. The sequence object we have used most is a List.

Try giving a list as an input to the .max() function to take the max over 2 dimensions of the array.

sst.max(dim=[‘lat’, ‘lon’]) sst.max(dim=[‘lat’, ‘time’]) sst.max(dim=[‘time’, ‘lon’])

Notice that the conditional doesn’t have to be data from the original dataset - it could be one of its coordinates, or even a totally different dataset of the same shape.

(from the lesson)

two dataset of the same shape, but where the conditional depends on another array. (A Dar group example?)

.rolling()?

https://docs.xarray.dev/en/latest/user-guide/groupby.html#apply using a custom .map() function for aggregation.