xarray
xarray: N-D labeled arrays and datasets in Python
Xarray was inspired by and borrows heavily from pandas, the popular data analysis package focused on labelled tabular data.
It is particularly tailored to working with netCDF files, which were the source of xarray’s data model, and integrates tightly with dask for parallel computing.
http://xarray.pydata.org/en/stable/
Official documents
Interpolating data
Examples
Xarray related projects
Xarray Tutorial
What's New
Makeing dataarray
code:python
data = xr.DataArray(np.random.randn(2, 3), dims=("x", "y"), coords={"x": 10, 20})
Tutorials
MetPy Mondays
#53 - XArray Basics : Unidata Developer's Blog
`#164 - MetPy 1.0 XArray Basics with the GFS : Unidata Developer's Blog
https://www.unidata.ucar.edu/blogs/developer/entry/metpy-mondays-164-metpy-1
#Siphon
`#165 - Using XArray to Subset in Lat/Lon and Map the GFS : Unidata Developer's Blog
https://www.unidata.ucar.edu/blogs/developer/entry/metpy-mondays-165-using-xarray
subsetting, plotting
`#166 - Getting Familiar with XArray : Unidata Developer's Blog
https://www.unidata.ucar.edu/blogs/developer/entry/metpy-mondays-166-getting-familiar
dataset, dataarray, dimension, coordinate
`#167 - Building with XArray from Scratch : Unidata Developer's Blog
https://www.unidata.ucar.edu/blogs/developer/entry/metpy-mondays-167-building-with
`#168 - Complex XArrays and Selecting : Unidata Developer's Blog
https://www.unidata.ucar.edu/blogs/developer/entry/metpy-mondays-168-complex-xarrays
Handling NetCDF Files using XArray for Absolute Beginners
https://towardsdatascience.com/handling-netcdf-files-using-xarray-for-absolute-beginners-111a8ab4463f
Siphon
Xarray Tutorial — NCAR-ESDS
https://ncar.github.io/esds/posts/xarray-tutorial/
Examples
PyVideo.org · Efficient Atmospheric Analogue Selection with Xarray and Dask | SciPy 2019 | Tyler Wixstrom
https://pyvideo.org/scipy-2019/efficient-atmospheric-analogue-selection-with-xarray-and-dask-scipy-2019-tyler-wixstrom.html
Tips
Area weighted mean
Compare weighted and unweighted mean temperature
https://xarray.pydata.org/en/stable/examples/area_weighted_temperature.html
code:python
weights = np.cos(np.deg2rad(air.lat))
air_weighted = air.weighted(weights)
weighted_mean = air_weighted.mean(("lon", "lat"))
Weighted array reductions
https://xarray.pydata.org/en/stable/user-guide/computation.html#weighted-array-reductions
select beyond date line
python - xarray slicing across the antimeridian - Geographic Information Systems Stack Exchange
https://gis.stackexchange.com/questions/205871/xarray-slicing-across-the-antimeridian
lazy
code:python
ds.sel(lon=(ds.lon < -80) | (ds.lon > 40))
not lazy
code:python
ds_rolled = ds.assign_coords(lon=(ds.lon % 360)).roll(lon=(ds.dims'lon' // 2))
subpages
xarray time series
xarray.apply_ufunc
xarray netcdf
xarray dask
Related packages
xESMF
xgcm
MetPy
xarray with MetPy Tutorial
https://unidata.github.io/MetPy/latest/tutorials/xarray_tutorial.html#sphx-glr-tutorials-xarray-tutorial-py
MetPy interpolation
regionmask: create masks of geographical regions
xagg: A package to aggregate gridded data in xarray to polygons in geopandas
xclim: Library of derived climate variables, ie climate indicators, based on xarray.
xreshaper: PyReshaper-like operation with Xarray
xarray-clim: wrapper functions for xarray to perform common tasks in analyzing gridded climate and weather data
xr-scipy: thin wrapper of scipy for xarray eco-system.
xskillscore: Metrics for verifying forecasts
xarray-leaflet: xarray extension for tiled map plotting
Xarray-spatial: Raster-based Spatial Analytics for Python
xtrude: an xarray extension for 3D terrain visualization
Xscale: Xscale a library of multi-dimensional signal processing tools using parallel computing
xmovie: A simple way of creating beautiful movies from xarray objects.
Xoak: Xoak is an Xarray extension that allows point-wise selection of irregular, n-dimensional data encoded in coordinates with an arbitrary number of dimensions.
xoa: intended to help reading and manipulating observed and simulated ocean data.
Xarray-Beam: Xarray-Beam is a Python library for building Apache Beam pipelines with Xarray datasets.