Salem

Salem is a cat. Salem is also a small library to do some geoscientific data processing and plotting. It extends xarray to add geolocalised subsetting, masking, and plotting operations to xarray’s DataArray and DataSet structures.

Warning

Salem is at a very early development stage and is more a proof of feasibility than a library for “everything you’ll ever have to do with geoscientific data”. There are plenty of more mature tools out there (see What others tools should I know about?). Salem basically reinvents the wheel, but in the way I want the wheel to be. Some might still find it useful: as an addition to xarray, or if you use the WRF model for example.

Documentation

Examples

Subsetting and selecting data

Let’s open a WRF model output file:

In [1]: import salem

In [2]: from salem.utils import get_demo_file

In [3]: ds = salem.open_xr_dataset(get_demo_file('wrfout_d01.nc'))

Let’s take a time slice of the variable T2 for a start:

In [4]: t2 = ds.T2.isel(Time=2)

In [5]: t2.salem.quick_map()
Out[5]: <salem.graphics.Map at 0x7efe27aa3410>
_images/plot_wrf_t2.png

Although we are on a Lambert Conformal projection, it’s possible to subset the file using longitudes and latitudes:

In [6]: t2_sub = t2.salem.subset(corners=((77., 20.), (97., 35.)), crs=salem.wgs84)

In [7]: t2_sub.salem.quick_map()
Out[7]: <salem.graphics.Map at 0x7efe2715f710>
_images/plot_wrf_t2_corner_sub.png

It’s also possible to use geometries or shapefiles to subset your data:

In [8]: shdf = salem.read_shapefile(get_demo_file('world_borders.shp'))

In [9]: shdf = shdf.loc[shdf['CNTRY_NAME'].isin(['Nepal', 'Bhutan'])]  # GeoPandas' GeoDataFrame

In [10]: t2_sub = t2_sub.salem.subset(shape=shdf, margin=2)  # add 2 grid points

In [11]: t2_sub.salem.quick_map()
Out[11]: <salem.graphics.Map at 0x7efe286415d0>
_images/plot_wrf_t2_country_sub.png

Based on the same principle, one can mask out the useless grid points:

In [12]: t2_roi = t2_sub.salem.roi(shape=shdf)

In [13]: t2_roi.salem.quick_map()
Out[13]: <salem.graphics.Map at 0x7efe26f990d0>
_images/plot_wrf_t2_roi.png

Plotting

Maps can be pimped with topographical shading, points of interest, and more:

In [14]: smap = t2_roi.salem.get_map(data=t2_roi-273.15, cmap='RdYlBu_r', vmin=-14, vmax=18)

In [15]: _ = smap.set_topography(get_demo_file('himalaya.tif'))

In [16]: smap.set_shapefile(shape=shdf, color='grey', linewidth=3)

In [17]: smap.set_points(91.1, 29.6)

In [18]: smap.set_text(91.2, 29.7, 'Lhasa', fontsize=17)

In [19]: smap.visualize()
_images/plot_wrf_t2_topo.png

Maps are persistent, which is useful when you have many plots to do. Plotting further data on them is possible, as long as the geolocalisation information is shipped with the data (in that case, the DataArray’s attributes are lost in the conversion from Kelvins to degrees Celsius so we have to set it explicitly):

In [20]: smap.set_data(ds.T2.isel(Time=1)-273.15, crs=ds.salem.grid)

In [21]: smap.visualize(title='2m temp - large domain', cbar_title='C')
_images/plot_wrf_t2_transform.png

Reprojecting data

Salem can also transform data from one grid to another:

In [22]: dse = salem.open_xr_dataset(get_demo_file('era_interim_tibet.nc'))

In [23]: t2_era_reproj = ds.salem.transform(dse.t2m)

In [24]: assert t2_era_reproj.salem.grid == ds.salem.grid

In [25]: t2_era_reproj.isel(time=0).salem.quick_map()
Out[25]: <salem.graphics.Map at 0x7efe280ea850>
_images/plot_era_repr_nn.png
In [26]: t2_era_reproj = ds.salem.transform(dse.t2m, interp='spline')

In [27]: t2_era_reproj.isel(time=0).salem.quick_map()
Out[27]: <salem.graphics.Map at 0x7efe27d8da50>
_images/plot_era_repr_spline.png

Frequently Asked Questions

Is your library mature for production code?

No. The API is not always as clever as I wish it would, and it will probably change in the future. It is quite well tested though, at least for the cases I encounter in my daily work.

What others tools should I know about?

If you want to plot on maps, cartopy is probably one of the best tools you could pick. For reprojection workflows on large or numerous gridded files you probably want to use rasterio.

The python atmopsheric sciences community is a bit spread between iris and xarray for N-Dimensional data handling (I picked the later for it’s strong interaction with pandas). Several great libraries are available to meteorologists and climatologists, for example MetPy, windspharm, xgcm, and all the ones I forgot to mention.

But then, why developing Salem?

As an atmospheric scientist, I hate to have to take care about projections and maps. Salem was created to hide all these concerns. By the time I started, it seemed a good idea to provide map transformation tools without depending on GDAL (thanks to conda-forge GDAL is now much easier to install). It is still possible to do reprojection work in Salem using scipy and pyproj alone. It is al done in python and on memory, so don’t expect miracles on that side.

Furthermore, I use the atmospheric model WRF quite often in my work. Its output files are absolutely not compliant with the CF conventions. To my knowledge, there is no tool to plot and manipulate WRF data with Python, and Salem will be further developed with this model in mind.

Why aren’t you using Xarray/Cartopy for your maps?

This is actually a good question, and I think that there are no obstacle for Salem to use it’s geolocation information to plot gridded data on cartopy’s maps. I never really got to understand how cartopy really works, but I’m sure that salem’s Grid object would be able to provide the right info to cartopy with a little bit of coding. Contributions welcome!

On the other hand I kind of like how Salem’s Map output looks, and I find it nice and easy to use. But that, of course, might not be your opinion. Other advantages of Salem’s Maps are their persistence (usefull if you want to plot data on the same map several times), their internal optimisations based on disk cache, and the ability to add lon-lat orientation grids to virtually any map projection.

What’s this ”.salem_cache” directory in my home folder?

At the first import, Salem will create a hidden directory called .salem_cache in your home folder. It will be used to download Salem’s demo files and standard shapefiles. This directory is also used by joblib to store the result of slow operations such as reading and transforming shapefiles, or downloading google maps from the internet. The cache should not become too large, but if it does: simply delete it.

What’s New

v0.1.0 (22 October 2016)

Big refactoring (PR15), partly backwards incompatible (mostly renaming). Improved xarray accessors, WRF tools, merged Cleo into the codebase, added a first draft of documentation.

v0.0.9 (22 October 2016)

Initial release.

Installation

Salem is a pure python package, but it has several non-trivial dependencies.

Required dependencies

Optional dependencies

Because not using them is a bad idea
  • pandas: working with labeled data
  • xarray: pandas in N-dimensions
For vector and raster operations

(rasterio and geopandas require GDAL)

For plotting

Instructions

The very best (unique?) way to install Salem without too much hassle is to install its dependencies with conda and conda-forge:

conda config --add channels conda-forge
conda install <package-name>

Currently, Salem can only be installed via pip:

pip install salem

If you want to install the latest master:

pip install git+https://github.com/fmaussion/salem.git

Warning

At the first import, Salem will create a hidden directory called .salem_cache in your home folder. It will be used to download Salem’s demo files and standard shapefiles. This directory is also used by joblib to store the result of slow operations such as reading and transforming shapefiles, or downloading google maps from the internet. The cache should not become too large, but if it does: simply delete it.

Georeferencing

A point on earth can be defined unambiguously in two ways:

DATUM (lon, lat, datum)
longitudes and latitudes are angular coordinates of a point on an ellipsoid (datum)
PROJ (x, y, projection)
x (eastings) and y (northings) are cartesian coordinates of a point in a map projection (the unit of x, y is usually meter)

Salem adds a third coordinate reference system (crs) to this list:

GRID (i, j, Grid)
on a structured grid, the (x, y) coordinates are distant of a constant (dx, dy) step. The (x, y) coordinates are therefore equivalent to a new reference frame (i, j) proportional to the projection’s (x, y) frame.

Transformations between datums and projections is handled by several tools in the python ecosystem, for example GDAL or the more lightweight pyproj, which is the tool Salem is using internally [1].

The concept of Grid added by Salem is useful when transforming data between two structured datasets, or from an unstructured dataset to a structured one.

[1]Most datasets nowadays are defined in the WGS 84 datum, therefore the concepts of datum and projection are often interchangeable: (lon, lat) coordinates are equivalent to cartesian (x, y) coordinates in the plate carree projection.

Grids

A Grid is defined by a projection, a reference point in this projection, a grid spacing and a number of grid points:

In [1]: import numpy as np

In [2]: import salem

In [3]: from salem import wgs84

In [4]: grid = salem.Grid(nxny=(3, 2), dxdy=(1, 1), ll_corner=(0.5, 0.5), proj=wgs84)

In [5]: x, y = grid.xy_coordinates

In [6]: x
Out[6]: 
array([[ 0.5,  1.5,  2.5],
       [ 0.5,  1.5,  2.5]])

In [7]: y
Out[7]: 
array([[ 0.5,  0.5,  0.5],
       [ 1.5,  1.5,  1.5]])

The default in Salem is to define the grids according to the pixels center point:

In [8]: smap = salem.Map(grid)

In [9]: smap.set_data(np.arange(6).reshape((2, 3)))

In [10]: lon, lat = grid.ll_coordinates

In [11]: smap.set_points(lon.flatten(), lat.flatten())

In [12]: smap.visualize(addcbar=False)
_images/plot_example_grid.png

But with the pixel_ref keyword you can use another convention. For Salem, the two conventions are identical:

In [13]: grid_c = salem.Grid(nxny=(3, 2), dxdy=(1, 1), ll_corner=(0, 0), proj=wgs84, pixel_ref='corner')

In [14]: assert grid_c == grid

While it’s good to know how grids work, most of the time grids should be inferred directly from the data files (if not, we have to implement it!):

In [15]: ds = salem.open_xr_dataset(salem.get_demo_file('himalaya.tif'))

In [16]: grid = ds.salem.grid

In [17]: grid.proj.srs
Out[17]: '+units=m +init=epsg:4326 '

In [18]: grid.extent
Out[18]: 
[78.312513473116013,
 93.937514288103202,
 24.237496572347762,
 31.545830286884001]

Grids come with several convenience functions, for example for transforming a point onto the grid coordinates:

In [19]: grid.transform(85, 27, crs=salem.wgs84)
Out[19]: (801.99834136842378, 544.9996059728029)

Or for reprojecting structured data (the xarray accessors transform() method calls map_gridded_data() internally):

In [20]: dse = salem.open_xr_dataset(salem.get_demo_file('era_interim_tibet.nc'))

In [21]: t2_era_reproj = ds.salem.transform(dse.t2m.isel(time=0))

In [22]: t2_era_reproj.salem.quick_map()
Out[22]: <salem.graphics.Map at 0x7efe27d8e890>
_images/plot_reproj_grid.png

Plotting

Color handling with DataLevels

DataLevels is the base class for handling colors. It is there to ensure that there will never be a mismatch between data and assigned colors.

In [1]: from salem import DataLevels

In [2]: a = [-1., 0., 1.1, 1.9, 9.]

In [3]: dl = DataLevels(a)

In [4]: dl.visualize(orientation='horizontal', add_values=True)
_images/datalevels_01.png
Discrete levels
In [5]: dl.set_plot_params(nlevels=11)

In [6]: dl.visualize(orientation='horizontal', add_values=True)
_images/datalevels_02.png
vmin, vmax
In [7]: dl.set_plot_params(nlevels=9, vmax=3)

In [8]: dl.visualize(orientation='horizontal', add_values=True)
_images/datalevels_03.png
Out-of-bounds data
In [9]: dl.set_plot_params(levels=[0, 1, 2, 3])

In [10]: dl.visualize(orientation='horizontal', add_values=True)
_images/datalevels_04.png

Note that if the bounds are not exceeded, the colorbar extensions are gone:

In [11]: dl.set_data([0., 0.2, 0.4, 0.6, 0.8])

In [12]: dl.visualize(orientation='horizontal', add_values=True)
_images/datalevels_05.png

This might be undesirable, so you can set a keyword to force out-of-bounds levels:

In [13]: dl.set_plot_params(levels=[0, 1, 2, 3], extend='both')

In [14]: dl.visualize(orientation='horizontal', add_values=True)
_images/datalevels_06.png
Using DataLevels with matplotlib
Here with the example of a scatterplot:
In [15]: x, y = np.random.randn(1000), np.random.randn(1000)

In [16]: z = x**2 + y**2

In [17]: dl = DataLevels(z, cmap='RdYlBu_r', levels=np.arange(6))

In [18]: fig, ax = plt.subplots(1, figsize=(6, 4))

In [19]: ax.scatter(x, y, color=dl.to_rgb(), s=64);

In [20]: cbar = dl.append_colorbar(ax, "right")  # DataLevel draws the colorbar

In [21]: plt.show()
_images/datalevels_07.png

Maps

Map is a sublass of DataLevels, but adds the georeferencing aspects to the plot. A Map is initalised with a Grid:

In [22]: from salem import mercator_grid, Map, get_demo_file, open_xr_dataset

In [23]: grid = mercator_grid(center_ll=(10.76, 46.79), extent=(9e5, 4e5))

In [24]: emap = Map(grid)

In [25]: emap.visualize(addcbar=False)
_images/map_central_europe.png

The map image has it’s own pixel resolution (set with the keywords nx or ny), and the cartographic information is simply overlayed on it. When asked to plot data, the map will automatically transform it to the map projection:

In [26]: ds = open_xr_dataset(get_demo_file('histalp_avg_1961-1990.nc'))

In [27]: emap.set_data(ds.prcp)

In [28]: emap.visualize()
_images/map_histalp.png

Add topographical shading to a map

You can add topographical shading to a map with DEM files:

In [29]: grid = mercator_grid(center_ll=(10.76, 46.79), extent=(18000, 14000))

In [30]: smap = Map(grid, countries=False)

In [31]: smap.set_topography(get_demo_file('hef_srtm.tif'));

In [32]: smap.visualize(addcbar=False, title='Topographical shading')
_images/topo_shading_simple.png

Note that you can also use the topography data to make a colourful plot:

In [33]: z = smap.set_topography(get_demo_file('hef_srtm.tif'))

In [34]: smap.set_data(z)

In [35]: smap.set_cmap('topo')

In [36]: smap.visualize(title='Topography', cbar_title='m a.s.l.')
_images/topo_shading_color.png

WRF tools

Let’s open a WRF model output file with xarray first:

In [1]: import xarray as xr

In [2]: from salem.utils import get_demo_file

In [3]: ds = xr.open_dataset(get_demo_file('wrfout_d01.nc'))

WRF files are a bit messy:

In [4]: ds
Out[4]: 
<xarray.Dataset>
Dimensions:           (Time: 3, bottom_top: 27, bottom_top_stag: 28, south_north: 150, south_north_stag: 151, west_east: 150, west_east_stag: 151)
Coordinates:
    XLONG             (Time, south_north, west_east) float32 70.7231 70.9749 ...
    XLONG_U           (Time, south_north, west_east_stag) float32 70.5974 ...
    XLAT_U            (Time, south_north, west_east_stag) float32 7.76865 ...
    XLAT_V            (Time, south_north_stag, west_east) float32 7.66444 ...
    XLONG_V           (Time, south_north_stag, west_east) float32 70.7436 ...
    XLAT              (Time, south_north, west_east) float32 7.78907 7.82944 ...
  * Time              (Time) int64 0 1 2
  * south_north       (south_north) int64 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ...
  * west_east         (west_east) int64 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ...
  * bottom_top        (bottom_top) int64 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ...
  * west_east_stag    (west_east_stag) int64 0 1 2 3 4 5 6 7 8 9 10 11 12 13 ...
  * south_north_stag  (south_north_stag) int64 0 1 2 3 4 5 6 7 8 9 10 11 12 ...
  * bottom_top_stag   (bottom_top_stag) int64 0 1 2 3 4 5 6 7 8 9 10 11 12 ...
Data variables:
    Times             (Time) |S19 '2008-10-26_12:00:00' ...
    T2                (Time, south_north, west_east) float32 301.977 302.008 ...
    RAINC             (Time, south_north, west_east) float32 0.0 0.0 0.0 0.0 ...
    RAINNC            (Time, south_north, west_east) float32 0.0 0.0 0.0 0.0 ...
    U                 (Time, bottom_top, south_north, west_east_stag) float32 1.59375 ...
    V                 (Time, bottom_top, south_north_stag, west_east) float32 -2.07031 ...
    PH                (Time, bottom_top_stag, south_north, west_east) float32 0.0 ...
    PHB               (Time, bottom_top_stag, south_north, west_east) float32 0.0 ...
Attributes:
    note: Global attrs removed.

WRF files aren’t exactly CF compliant: you’ll need a special parser for the timestamp, the coordinate names are a bit exotic and do not correspond to the dimension names, they contain so-called staggered variables (and their correponding coordinates), etc.

Salem defines a special parser for these files:

In [5]: import salem

In [6]: ds = salem.open_wrf_dataset(get_demo_file('wrfout_d01.nc'))

This parser greatly simplifies the file structure:

In [7]: ds
Out[7]: 
<xarray.Dataset>
Dimensions:       (bottom_top: 27, south_north: 150, time: 3, west_east: 150)
Coordinates:
    lon           (time, south_north, west_east) float32 70.7231 70.9749 ...
    lat           (time, south_north, west_east) float32 7.78907 7.82944 ...
  * time          (time) datetime64[ns] 2008-10-26T12:00:00 ...
  * south_north   (south_north) float64 -2.235e+06 -2.205e+06 -2.175e+06 ...
  * west_east     (west_east) float64 -2.235e+06 -2.205e+06 -2.175e+06 ...
  * bottom_top    (bottom_top) int64 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ...
Data variables:
    T2            (time, south_north, west_east) float32 301.977 302.008 ...
    RAINC         (time, south_north, west_east) float32 0.0 0.0 0.0 0.0 0.0 ...
    RAINNC        (time, south_north, west_east) float32 0.0 0.0 0.0 0.0 0.0 ...
    U             (time, bottom_top, south_north, west_east) float32 1.73438 ...
    V             (time, bottom_top, south_north, west_east) float32 -2.125 ...
    PH            (time, bottom_top, south_north, west_east) float32 18.7031 ...
    PHB           (time, bottom_top, south_north, west_east) float32 277.504 ...
    T2C           (time, south_north, west_east) float32 28.8266 28.8578 ...
    PRCP          (time, south_north, west_east) float32 nan nan nan nan nan ...
    GEOPOTENTIAL  (time, bottom_top, south_north, west_east) float32 296.207 ...
    PRCP_NC       (time, south_north, west_east) float32 nan nan nan nan nan ...
    PRCP_C        (time, south_north, west_east) float32 nan nan nan nan nan ...
Attributes:
    note: Global attrs removed.

Note that some dimensions / coordinates have been renamed, new variables have been defined, and the staggered dimensions have disappeared.

Diagnostic variables

Salem adds a layer between xarray and the underlying NetCDF file. This layer computes new variables “on the fly” or, in the case of staggered variables, “unstaggers” them:

In [8]: ds.U
Out[8]: 
<xarray.DataArray 'U' (time: 3, bottom_top: 27, south_north: 150, west_east: 150)>
[1822500 values with dtype=float32]
Coordinates:
    lon          (time, south_north, west_east) float32 70.7231 70.9749 ...
    lat          (time, south_north, west_east) float32 7.78907 7.82944 ...
  * time         (time) datetime64[ns] 2008-10-26T12:00:00 ...
  * south_north  (south_north) float64 -2.235e+06 -2.205e+06 -2.175e+06 ...
  * west_east    (west_east) float64 -2.235e+06 -2.205e+06 -2.175e+06 ...
  * bottom_top   (bottom_top) int64 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ...
Attributes:
    FieldType: 104
    MemoryOrder: XYZ
    description: x-wind component
    units: m s-1
    stagger: X
    pyproj_srs: +units=m +proj=lcc +lat_1=29.0400009155 +lat_2=29.0400009155 +lat_0=29.0399971008 +lon_0=89.8000030518 +x_0=0 +y_0=0 +a=6370000 +b=6370000

This computation is done only on demand (just like a normal NetCDF variable), this new layer is therefore relatively cheap.

In addition to unstaggering, Salem adds a number of “diagnostic” variables to the dataset. Some are convenient (like T2C, temperature in Celsius instead of Kelvins), but others are more complex (e.g. SLP for sea-level pressure, or PRCP which computes step-wize total precipitation out of the accumulated fields). For a list of diagnostic variables (and TODOs!), refer to GH18.

In [9]: ds.PRCP.isel(time=-1).salem.quick_map(cmap='Purples', vmax=5)
Out[9]: <salem.graphics.Map at 0x7efe26c3afd0>
_images/plot_wrf_diag.png

Geogrid simulator

Salem provides a small tool which comes handy when defining new WRF domains. It parses the WPS configuration file (namelist.wps) and generates the grids and maps corresponding to each domain.

geogrid_simulator() will search for the &geogrid section of the file and parse it:

In [10]: fpath = get_demo_file('namelist_mercator.wps')

In [11]: with open(fpath, 'r') as f:  # this is just to show the file
   ....:     print(f.read())
   ....: 
&geogrid
 parent_id         =   1, 1, 2, 3,
 parent_grid_ratio =   1, 3, 5, 5,
 i_parent_start    =   1, 28, 54, 40,
 j_parent_start    =   1, 24, 97, 50,
 e_we              =  211, 178, 101, 136,
 e_sn              =  131, 220, 141, 136,
 dx = 30000,
 dy = 30000,
 map_proj = 'mercator',
 ref_lat   =  -8.0,
 ref_lon   =  -62.0,
 truelat1  =  -8.0,
/



In [12]: from salem import geogrid_simulator

In [13]: g, maps = geogrid_simulator(fpath)

In [14]: maps[0].set_rgb(natural_earth='lr')  # add a background image

In [15]: maps[0].visualize(title='Domains 1 to 4')
_images/plot_geo_simu.png

API reference

Here we will add the documentation for selected modules.

Grid

Grid A structured grid on a map projection.
Grid methods
Grid.extent_in_crs Get the extent of the grid in a desired crs.
Grid.ij_to_crs Converts local i, j to cartesian coordinates in a specified crs
Grid.map_gridded_data Reprojects any structured data onto the local grid.
Grid.region_of_interest Computes a region of interest (ROI).
Grid.regrid Make a copy of the grid with an updated spatial resolution.
Grid.transform Converts any coordinates into the local grid.

Georeferencing utils

check_crs Checks if the crs represents a valid grid, projection or ESPG string.
proj_is_same Checks is two pyproj projections are equal.
transform_proj Wrapper around the pyproj.transform function.
transform_geometry Reprojects a shapely geometry.
transform_geopandas Reprojects a geopandas dataframe.
mercator_grid Local transverse mercator map centered on a specified point.

Graphics

DataLevels Assigns the right color to your data.
Map Plotting georeferenced data.
get_cmap Get a colormap from mpl, and also those defined by Salem.
Map & DataLevels methods
DataLevels.append_colorbar Appends a colorbar to existing axes
DataLevels.colorbarbase Returns a ColorbarBase to add to the cax axis.
DataLevels.set_cmap Set a colormap.
DataLevels.set_data Any kind of data array (also masked).
DataLevels.set_plot_params Shortcut to all parameters related to the plot.
DataLevels.set_extend Colorbar extensions: ‘neither’ | ‘both’ | ‘min’ | ‘max’
DataLevels.set_levels Levels you define.
DataLevels.set_nlevels Automatic N levels.
DataLevels.set_vmax Maximum level value.
DataLevels.set_vmin Mininum level value.
DataLevels.visualize Quick plot, useful for debugging.
DataLevels.plot Add a kind of plot of the data to an axis.
Map methods
Map.set_data Adds data to the plot.
Map.set_contour Adds data to contour on the map.
Map.set_contourf Adds data to contourfill on the map.
Map.set_geometry Adds any Shapely geometry to the map.
Map.set_lonlat_contours Add longitude and latitude contours to the map.
Map.set_points Shortcut for set_geometry() accepting coordinates as input.
Map.set_rgb Manually force to a rgb img
Map.set_shapefile Add a shapefile to the plot.
Map.set_text Add a text to the map.
Map.set_topography Add topographical shading to the map.

Input/output

get_demo_file Returns the path to the desired demo file.
read_shapefile Reads a shapefile using geopandas.
read_shapefile_to_grid Same as read_shapefile but directly transformed to a grid.

Xarray

open_xr_dataset Thin wrapper around xarray’s open_dataset.
open_wrf_dataset Wrapper around xarray’s open_dataset to make WRF files a bit better.
DataArrayAccessor
DatasetAccessor
Xarray accessors

Salem adds accessors to xarray objects. They can be accessed via the .salem attribute and add the following methods (DataArray and Dataset methods are almost equivalent):

DatasetAccessor.get_map Make a salem.Map out of the dataset.
DatasetAccessor.quick_map Make a plot of a variable of the DataSet.
DatasetAccessor.roi Make a region of interest (ROI) for the dataset.
DatasetAccessor.subset Get a subset of the dataset.
DatasetAccessor.transform Reprojects an other Dataset or DataArray onto this grid.

Old-style datasets

Old-style Datasets (prior to xarray), kept for backwards compatibility reasons and because they are quite lightweight. They might be replaced by xarray’s datasets one day.

GeoDataset Interface for georeferenced datasets.
GeoTiff Geolocalised tiff images (needs rasterio).
GeoNetcdf NetCDF files with geolocalisation info.
WRF WRF proof-of-concept template.
GoogleCenterMap Google Static Maps (needs motionless).
GoogleVisibleMap Google Static Maps (needs motionless).

Other

geogrid_simulator Emulates geogrid.exe, which is useful when defining new WRF domains.

Get in touch

  • To ask questions or discuss Salem, send me an e-mail.
  • Report bugs, share your ideas or view the source code on GitHub.

License

Salem is available under the open source GNU GPLv3 license.

About

Status:

Experimental - in development

License:

GNU GPLv3

Authors:

Fabien Maussion

Funding:http://acinn.uibk.ac.at/sites/all/themes/imgi/images/acinn_logo.png