Salem

  |   Source

a quick look at the salem library

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
    ```
In [1]:
%matplotlib inline
In [2]:
from matplotlib import pyplot as plt
In [3]:
import numpy as np
import xarray as xr
In [4]:
import salem

from salem.utils import get_demo_file

ds = salem.open_xr_dataset(get_demo_file('wrfout_d01.nc'))
In [5]:
t2 = ds.T2.isel(Time=2)
In [6]:
shdf = salem.read_shapefile(get_demo_file('world_borders.shp'))
In [7]:
t2.salem.quick_map(cmap=plt.cm.autumn_r)
Out[7]:
<salem.graphics.Map at 0x119187a58>
In [ ]:
 
Comments powered by Disqus
    Share