Salem
Salem is a python library developed by Fabien Maussion, a researcher and lecturer at the Institute of Atmospheric and Cryospheric Sciences, at the University of Innsbruck.
It extends xarray and adds notably geolocalised subsetting (via shapefiles), masking, and geographical mapping operations to xarray’s DataArray DataSet datasetdata structures.
It is still ayoung project, but has already proven extremely useful to me in a number of occasions, and I think it's the perfect illustration of how one can build clever and useful extensions build on the very powerful xarray data structures. I hope to be able to contribute to this project, and this post is intended to be a shoutout and acknowledgment of Fabien Maussion's work.
If you work in climate / ocean science and are already using (as you should !) xarray, Salem is definitely worth a try
installation¶
Salem has a number of hard dependencies: what worked for me (MacOS Sierra) is to create a specific environment following the instructions available here, then installing Salem in this environment using pip and development version of Salem, via:
```
pip install git+https://github.com/fmaussion/salem.git
```
%matplotlib inline
from matplotlib import pyplot as plt
import numpy as np
import xarray as xr
import salem
from salem.utils import get_demo_file
ds = salem.open_xr_dataset(get_demo_file('wrfout_d01.nc'))
t2 = ds.T2.isel(Time=2)
shdf = salem.read_shapefile(get_demo_file('world_borders.shp'))
t2.salem.quick_map(cmap=plt.cm.autumn_r)