Skip to content

Commit

Permalink
Units of WRF variable PRESSURE (#87)
Browse files Browse the repository at this point in the history
* Units of WRF variable PRESSURE

* update for dask scheduler
  • Loading branch information
fmaussion committed Dec 4, 2017
1 parent 36d608e commit d78e44c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Bug fixes
- the cache directory is also updated when the ``pandas`` version changes
(:issue:`74`)
- small bugfixes in the projections and warning handling
- PRESSURE variable was given in Pa, not hPa. This is corrected now.


v0.2.1 (07 February 2017)
Expand Down
7 changes: 6 additions & 1 deletion salem/sio.py
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,12 @@ def open_mf_wrf_dataset(paths, chunks=None, compat='no_conflicts', lock=None,
raise IOError('no files to open')

# TODO: current workaround to dask thread problems
dask.set_options(get=dask.async.get_sync)
try:
# dask < 0.16
get = dask.async.get_sync
except AttributeError:
get = dask.get
dask.set_options(get=get)

if lock is None:
lock = _default_lock(paths[0], 'netcdf4')
Expand Down
7 changes: 6 additions & 1 deletion salem/wrftools.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,12 @@ def can_do(nc):
return np.all([n in nc.variables for n in ['P', 'PB']])

def __getitem__(self, item):
return self.nc.variables['P'][item] + self.nc.variables['PB'][item]
res = self.nc.variables['P'][item] + self.nc.variables['PB'][item]
if self.nc.variables['P'].units == 'Pa':
res /= 100
elif self.nc.variables['P'].units == 'hPa':
pass
return res


class GEOPOTENTIAL(FakeVariable):
Expand Down

0 comments on commit d78e44c

Please sign in to comment.