Skip to content

Commit

Permalink
Preserve encoding while making ROI (#111)
Browse files Browse the repository at this point in the history
* Preserve encoding while making ROI

* Fix for DataArrays
  • Loading branch information
jlandmann authored and fmaussion committed Jul 24, 2018
1 parent d9de663 commit 53b43ce
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion salem/sio.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,8 +508,12 @@ def roi(self, ds=None, **kwargs):

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

# keep attrs
# keep attrs and encoding
out.attrs = self._obj.attrs
out.encoding = self._obj.encoding
if isinstance(out, xr.Dataset):
for v in self._obj.variables.keys():
out[v].encoding = self._obj[v].encoding
if isinstance(out, xr.DataArray):
out.name = self._obj.name

Expand Down

0 comments on commit 53b43ce

Please sign in to comment.