Skip to content

Commit

Permalink
What's new and small tweak to previous PR (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
fmaussion committed Apr 5, 2018
1 parent 1c15b0c commit 61e95e4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions docs/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ Enhancements
- each salem version is now pinned to a certain commit of the sample-data
repository. This is more robust and will avoid future tests to fail
for the wrong reasons.
- accessor's ``roi`` method now accepts an ``other`` kwarg to fill masked
values with something else than Nan (:pull:`96`).
By `Schlump <https://github.com/Schlump>`_


Bug fixes
Expand All @@ -39,6 +42,8 @@ Bug fixes
- Corrected a bug in `proj_to_cartopy` where the spherical parameters were
silently ignored. Cartopy maps on WRF domains are now perfect!
- ``Grid.ij_to_crs`` should now handle non numpy arrays too
- Corrected an internal bug with latest xarray version (:pull:`97`). Users
will have to update to latest xarray version (v0.10+).


v0.2.1 (07 February 2017)
Expand Down
8 changes: 5 additions & 3 deletions salem/sio.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from xarray.backends.netCDF4_ import NetCDF4DataStore
from xarray.core.pycompat import basestring
from xarray.backends.api import _MultiFileCloser, _default_lock
from xarray.core import dtypes
has_xarray = True
except ImportError:
has_xarray = False
Expand Down Expand Up @@ -490,10 +491,11 @@ def roi(self, ds=None, **kwargs):
that all grid cells which are clipped by the shapefile defining
the region of interest should be included (default=False)
other : scalar, DataArray or Dataset, optional
Value to use for locations in this object where cond is False. By default, these locations filled with NA.
Value to use for locations in this object where cond is False. By
default, these locations filled with NA.
As in http://xarray.pydata.org/en/stable/generated/xarray.DataArray.where.html
"""
other = kwargs.pop('other', None)
other = kwargs.pop('other', dtypes.NA)
if ds is not None:
grid = ds.salem.grid
kwargs.setdefault('grid', grid)
Expand All @@ -503,7 +505,7 @@ def roi(self, ds=None, **kwargs):
self.x_dim: self._obj[self.x_dim].values}
mask = xr.DataArray(mask, coords=coords,
dims=(self.y_dim, self.x_dim))

out = self._obj.where(mask, other=other)

# keep attrs
Expand Down

0 comments on commit 61e95e4

Please sign in to comment.