Skip to content

Commit

Permalink
Fix plot bug with integer data (#197)
Browse files Browse the repository at this point in the history
  • Loading branch information
fmaussion committed Mar 24, 2021
1 parent 9012e92 commit 0a0a930
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
9 changes: 5 additions & 4 deletions salem/graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,10 +452,6 @@ def _check_data(self, data=None, crs=None, interp='nearest',
except:
pass

# We convert to float for img resizing
if data.dtype not in [np.float32, np.float64]:
data = data.astype(np.float64)

data = np.ma.fix_invalid(np.squeeze(data))
shp = data.shape
if len(shp) != 2:
Expand All @@ -469,6 +465,11 @@ def _check_data(self, data=None, crs=None, interp='nearest',

# need to resize if not same
if not ((shp[0] == self.grid.ny) and (shp[1] == self.grid.nx)):

# We convert to float for img resizing
if data.dtype not in [np.float32, np.float64]:
data = data.astype(np.float64)

if interp.lower() == 'nearest':
interp = 0
elif interp.lower() == 'linear':
Expand Down
11 changes: 9 additions & 2 deletions salem/sio.py
Original file line number Diff line number Diff line change
Expand Up @@ -1173,8 +1173,15 @@ def open_mf_wrf_dataset(paths, chunks=None, compat='no_conflicts', lock=None,

if lock is None:
lock = NETCDF4_PYTHON_LOCK
datasets = [open_wrf_dataset(p, chunks=chunks or {}, lock=lock)
for p in paths]
try:
datasets = [open_wrf_dataset(p, chunks=chunks or {}, lock=lock)
for p in paths]
except TypeError as err:
if 'lock' not in str(err):
raise
# New xarray backends
datasets = [open_wrf_dataset(p, chunks=chunks or {}) for p in paths]

orig_datasets = datasets

def ds_closer():
Expand Down

0 comments on commit 0a0a930

Please sign in to comment.