Skip to content

Commit

Permalink
Add verbosity to tests (#116)
Browse files Browse the repository at this point in the history
* Add verbosity to tests

* Add minimal tweaks
  • Loading branch information
fmaussion committed Jul 24, 2018
1 parent b1b1a8c commit ce49490
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ install:
- pip install -e .

script:
- pytest salem $MPL --cov=salem --cov-report term-missing;
- pytest salem $MPL --verbose --cov=salem --cov-report term-missing;

after_success:
- coveralls
9 changes: 7 additions & 2 deletions salem/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,11 +377,16 @@ def __init__(self, file, grid=None, time=None, monthbegin=False):
self.variables = self._nc.variables
if grid is None:
grid = sio.grid_from_dataset(self._nc)
if grid is None:
raise RuntimeError('File grid not understood')
if time is None:
time = sio.netcdf_time(self._nc, monthbegin=monthbegin)
dn = self._nc.dimensions.keys()
self.x_dim = utils.str_in_list(dn, utils.valid_names['x_dim'])[0]
self.y_dim = utils.str_in_list(dn, utils.valid_names['y_dim'])[0]
try:
self.x_dim = utils.str_in_list(dn, utils.valid_names['x_dim'])[0]
self.y_dim = utils.str_in_list(dn, utils.valid_names['y_dim'])[0]
except IndexError:
raise RuntimeError('File coordinates not understood')
dim = utils.str_in_list(dn, utils.valid_names['t_dim'])
self.t_dim = dim[0] if dim else None
dim = utils.str_in_list(dn, utils.valid_names['z_dim'])
Expand Down
9 changes: 7 additions & 2 deletions salem/wrftools.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ def _ncl_slp(z, t, p, q):
return 0.01 * (p0 * np.exp((2.*g*z_half_lowest)/(r*(t_sea_level+t_surf))))


def geogrid_simulator(fpath, do_maps=True):
def geogrid_simulator(fpath, do_maps=True, map_kwargs=None):
"""Emulates geogrid.exe, which is useful when defining new WRF domains.
Parameters
Expand All @@ -605,6 +605,8 @@ def geogrid_simulator(fpath, do_maps=True):
path to a namelist.wps file
do_maps: bool
if you want the simulator to return you maps of the grids as well
map_kwargs: dict
kwargs to pass to salem.Map()
Returns
-------
Expand Down Expand Up @@ -718,9 +720,12 @@ def geogrid_simulator(fpath, do_maps=True):
from salem import Map
import shapely.geometry as shpg

if map_kwargs is None:
map_kwargs = {}

maps = []
for i, g in enumerate(out):
m = Map(g)
m = Map(g, **map_kwargs)

for j in range(i+1, len(out)):
cg = out[j]
Expand Down

0 comments on commit ce49490

Please sign in to comment.