Useful xarray commands for Satellite data

15 Dec 2022

The Xarray libray is an open source project and Python package that introduces labels in the form of dimensions, coordinates, and attributes on top of raw NumPy-like arrays,which allows for more intuitive, more concise, and less error-prone user experience. I personally consider it like a Pandas designed for geosciences, with very powerful tools to easily manipulate 3D large datasets. In this code, I make some computation in a huge dataset (daily global maps from 1993 to 2019 of geostrophic velocity obtained by altimeters) and plot the results.

The computations includes slicing data for a specific region (the South Brazil), compute a 60-day running mean and then obtain spatial derivates, to compute the horizontal shear production and the gradient of the total vorticity, after that, I group these variables by months and seasons. These calculations are done with few lines of commands and would require much more effort (and time) if I decide to work with 3D arrays only instead of xarray built-in functions.