Skip to content

Commit afde384

Browse files
author
Joe Hamman
authored
Merge pull request #83 from UW-Hydro/develop
RVIC 1.1.1
2 parents 622f45d + 40fc9a5 commit afde384

File tree

16 files changed

+95
-59
lines changed

16 files changed

+95
-59
lines changed

.travis.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ matrix:
99
- python: 2.7
1010
- python: 3.4
1111
- python: 3.5
12+
- python: 3.6
1213

1314
# Setup anaconda
1415
before_install:
@@ -23,13 +24,13 @@ before_install:
2324
- conda config --set always_yes yes --set changeps1 no
2425
- conda update -q conda
2526
- conda info -a
27+
2628
# Install packages
2729
install:
28-
- conda create --yes --name=test python=$TRAVIS_PYTHON_VERSION numpy scipy pandas netcdf4 matplotlib pytest
30+
- conda create --yes --name=test python=$TRAVIS_PYTHON_VERSION numpy scipy pandas netcdf4 matplotlib pytest -c conda-forge
2931
- source activate test
30-
# - conda install -c https://conda.anaconda.org/ioos cdo
31-
# - pip install cdo
3232
- python setup.py install
33+
3334
# Run test
3435
script:
3536
- py.test

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
# RVIC Streamflow Routing Model
22

3-
4-
53
| VIC Links & Badges | |
64
|------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
75
| VIC Documentation | [![Documentation Status](https://readthedocs.org/projects/rvic/badge/?version=latest)](https://readthedocs.org/projects/rvic/?badge=latest) |
86
| Travis Build | [![Build Status](https://travis-ci.org/UW-Hydro/RVIC.svg?branch=master)](https://travis-ci.org/UW-Hydro/RVIC) |
97
| Code Health | [![Code Health](https://landscape.io/github/UW-Hydro/RVIC/master/landscape.svg?style=flat)](https://landscape.io/github/UW-Hydro/RVIC/master) |
108
| License | [![GitHub license](https://img.shields.io/badge/license-GPLv3-blue.svg)](https://raw.githubusercontent.com/UW-Hydro/RVIC/master/LICENSE.txt) |
11-
| Current Release DOI | [![DOI](https://zenodo.org/badge/doi/10.5281/zenodo.32620.svg)](http://dx.doi.org/10.5281/zenodo.32620) |
12-
9+
| Current Release DOI | [![DOI](https://zenodo.org/badge/11590212.svg)](https://zenodo.org/badge/latestdoi/11590212) |
1310

1411
The RVIC streamflow routing model is an adapted version of the model the model typically used as a post-processor with the Variable Infiltration Capacity (VIC) hydrology model. The routing model is a source-to-sink model that solves a linearized version of the Saint-Venant equations. This model, developed by Lohmann et al. (1996, 1998a, 1998b), has been used in many offline studies at a variety of spatial scales. Furthermore, the development of the impulse response functions (IRFs) is done as a preprocessing step, which considerably reduces the computation time in subsequent routing steps.
1512

docs/development/whats_new.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
# What's New
22

3+
v1.1.1 (7 February 2017
4+
5+
This release contains a number of bug and compatibility fixes.
6+
7+
### Enhancements
8+
9+
- Ability to pass a dictionary to top level RVIC functions (instead of only a file path). This allows for the generation of large ensembles of RVIC simulations in an interactive environment ([GH78](https://github.com/UW-Hydro/RVIC/pull/78)).
10+
11+
### Bug Fixes
12+
13+
- Fixed bug that in `tools/fraction2domain.bash` by using a temporary variable name ([GH88](https://github.com/UW-Hydro/RVIC/pull/88)).
14+
- Fixed off-by-one error in `history.py` ([GH86](https://github.com/UW-Hydro/RVIC/pull/86)).
15+
316
v1.1.0 (25 October 2015)
417

518
This release contains a number of bug and compatibility fixes.

docs/user-guide/api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Almost all of RVIC is available via a public API.
66
import rvic
77
```
88

9+
`rvic.parameters.parameters` and `rvic.convolution.convolution` both support either a path (string) to an INI style configuration file or a dictionary including configuration options. This feature is quite useful when generating ensembles of RVIC simulations.
10+
911
Most of the internals of RVIC are stored int the `rvic.core` module:
1012

1113
```Python

mkdocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
site_name: RVIC
22
site_description: RVIC Streamflow Routing Model
33
site_author: UW Hydro | Computational Hydrology
4-
copyright: 'Copyright &copy; 2015, <a href="www.hydro.washington.edu/">University of Washington Computational Hydrology Group</a>.'
4+
copyright: 'Copyright &copy; 2017, <a href="http://uw-hydro.github.io/">University of Washington Computational Hydrology Group</a>.'
55
repo_url: https://github.com/UW-Hydro/RVIC
66
theme: readthedocs
77

rvic/convolution.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,26 +31,21 @@
3131

3232
# -------------------------------------------------------------------- #
3333
# Top Level Driver
34-
def convolution(config_file):
34+
def convolution(config):
3535
'''
3636
Top level driver for RVIC convolution model.
3737
3838
Parameters
3939
----------
40-
config_file : str
41-
Path to RVIC convolution configuration file.
40+
config : str or dict.
41+
Path to RVIC convolution configuration file or dictionary of
42+
configuration options.
4243
'''
4344

4445
# ---------------------------------------------------------------- #
4546
# Initilize
4647
hist_tapes, data_model, rout_var, \
47-
time_handle, directories = convolution_init(config_file)
48-
# ---------------------------------------------------------------- #
49-
50-
# ---------------------------------------------------------------- #
51-
# Setup the pool of processors
52-
# if numofproc > 1:
53-
# pool = LoggingPool(processes=numofproc)
48+
time_handle, directories = convolution_init(config)
5449
# ---------------------------------------------------------------- #
5550

5651
# ---------------------------------------------------------------- #
@@ -69,7 +64,7 @@ def convolution(config_file):
6964

7065
# -------------------------------------------------------------------- #
7166
# Initialize RVIC
72-
def convolution_init(config_file):
67+
def convolution_init(config):
7368
'''
7469
Initialize the RVIC convolution routine
7570
@@ -85,8 +80,9 @@ def convolution_init(config_file):
8580
8681
Parameters
8782
----------
88-
config_file : str
89-
Path to RVIC convolution configuration file.
83+
config : str or dict
84+
Path to RVIC convolution configuration file or dictionary of
85+
configuration options.
9086
9187
Returns
9288
----------
@@ -109,7 +105,10 @@ def convolution_init(config_file):
109105

110106
# ---------------------------------------------------------------- #
111107
# Read Configuration files
112-
config_dict = read_config(config_file)
108+
if isinstance(config, dict):
109+
config_dict = config
110+
else:
111+
config_dict = read_config(config)
113112
# ---------------------------------------------------------------- #
114113

115114
# ---------------------------------------------------------------- #

rvic/core/history.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ def __write_grid(self):
518518
f.createDimension('time', None)
519519

520520
time = f.createVariable('time', self._ncprec, ('time',))
521-
time[:] = self._out_times[:self._out_data_i + 1]
521+
time[:] = self._out_times[:self._out_data_i]
522522
for key, val in iteritems(share.time):
523523
if val:
524524
setattr(time, key, val.encode())
@@ -531,7 +531,7 @@ def __write_grid(self):
531531

532532
time_bnds = f.createVariable('time_bnds', self._ncprec,
533533
('time', 'nv',), **self.ncvaropts)
534-
time_bnds[:, :] = self._out_time_bnds[:self._out_data_i + 1]
534+
time_bnds[:, :] = self._out_time_bnds[:self._out_data_i]
535535
# ------------------------------------------------------------ #
536536

537537
# ------------------------------------------------------------ #
@@ -585,7 +585,7 @@ def __write_grid(self):
585585
for field in self._fincl:
586586
var = f.createVariable(field, self._ncprec, tcoords,
587587
**self.ncvaropts)
588-
var[:, :] = self._out_data[field][:self._out_data_i + 1]
588+
var[:, :] = self._out_data[field][:self._out_data_i]
589589

590590
for key, val in iteritems(getattr(share, field)):
591591
if val:

rvic/core/make_uh.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ def read_direction(fdr, dy, dx):
192192
'''
193193
log.debug('Reading direction input and finding target row/columns')
194194

195-
to_y = np.zeros_like(fdr, dtype=np.int16)
196-
to_x = np.zeros_like(fdr, dtype=np.int16)
195+
to_y = np.zeros_like(fdr, dtype=np.int32)
196+
to_x = np.zeros_like(fdr, dtype=np.int32)
197197

198198
valid_dirs = list(dy.keys())
199199

@@ -238,7 +238,7 @@ def search_catchment(to_y, to_x, pour_point, basin_ids, basin_id):
238238
# -1 - not in catchment
239239
# 0 - unknown
240240
# 1 - in catchment
241-
in_catch = np.zeros_like(to_x, dtype=np.int16) - 1
241+
in_catch = np.zeros_like(to_x, dtype=np.int32) - 1
242242
in_catch[byinds, bxinds] = 0 # set basin inds as 0
243243

244244
# temporary variables for tracking flow path

rvic/core/param_file.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def finish_params(outlets, dom_data, config_dict, directories):
7373
'SUBSET_DAYS<BASIN_FLOWDAYS')
7474
for key, outlet in iteritems(outlets):
7575
outlet.offset = np.zeros(outlet.unit_hydrograph.shape[1],
76-
dtype=np.int16)
76+
dtype=np.int32)
7777
full_time_length = outlet.unit_hydrograph.shape[0]
7878
subset_length = full_time_length
7979
# ---------------------------------------------------------------- #
@@ -125,6 +125,10 @@ def finish_params(outlets, dom_data, config_dict, directories):
125125
outlet_name = grouped_data['outlet_name']
126126
outlet_upstream_area = grouped_data['outlet_upstream_area']
127127
outlet_upstream_gridcells = grouped_data['outlet_upstream_gridcells']
128+
129+
# Make sure the inds are all greater than zero, ref: Github #79
130+
assert source_decomp_ind.min() >= 0, source_decomp_ind
131+
assert outlet_decomp_ind.min() >= 0, outlet_decomp_ind
128132
# ---------------------------------------------------------------- #
129133

130134
# ---------------------------------------------------------------- #
@@ -322,7 +326,7 @@ def subset(outlets, subset_length=None):
322326
axis=1)
323327

324328
outlet.offset = np.empty(outlet.unit_hydrograph.shape[1],
325-
dtype=np.int16)
329+
dtype=np.int32)
326330
out_uh = np.zeros((subset_length, outlet.unit_hydrograph.shape[1]),
327331
dtype=np.float64)
328332

@@ -402,23 +406,23 @@ def group(outlets, subset_length):
402406
gd['frac_sources'] = np.empty(n_sources, dtype=np.float64)
403407
gd['source_lon'] = np.empty(n_sources, dtype=np.float64)
404408
gd['source_lat'] = np.empty(n_sources, dtype=np.float64)
405-
gd['source_x_ind'] = np.empty(n_sources, dtype=np.int16)
406-
gd['source_y_ind'] = np.empty(n_sources, dtype=np.int16)
407-
gd['source_decomp_ind'] = np.empty(n_sources, dtype=np.int16)
408-
gd['source_time_offset'] = np.empty(n_sources, dtype=np.int16)
409-
gd['source2outlet_ind'] = np.empty(n_sources, dtype=np.int16)
409+
gd['source_x_ind'] = np.empty(n_sources, dtype=np.int32)
410+
gd['source_y_ind'] = np.empty(n_sources, dtype=np.int32)
411+
gd['source_decomp_ind'] = np.empty(n_sources, dtype=np.int32)
412+
gd['source_time_offset'] = np.empty(n_sources, dtype=np.int32)
413+
gd['source2outlet_ind'] = np.empty(n_sources, dtype=np.int32)
410414
# ---------------------------------------------------------------- #
411415

412416
# ---------------------------------------------------------------- #
413417
# outlet specific inputs
414418
gd['outlet_lon'] = np.empty(n_outlets, dtype=np.float64)
415419
gd['outlet_lat'] = np.empty(n_outlets, dtype=np.float64)
416-
gd['outlet_x_ind'] = np.empty(n_outlets, dtype=np.int16)
417-
gd['outlet_y_ind'] = np.empty(n_outlets, dtype=np.int16)
418-
gd['outlet_decomp_ind'] = np.empty(n_outlets, dtype=np.int16)
419-
gd['outlet_number'] = np.empty(n_outlets, dtype=np.int16)
420+
gd['outlet_x_ind'] = np.empty(n_outlets, dtype=np.int32)
421+
gd['outlet_y_ind'] = np.empty(n_outlets, dtype=np.int32)
422+
gd['outlet_decomp_ind'] = np.empty(n_outlets, dtype=np.int32)
423+
gd['outlet_number'] = np.empty(n_outlets, dtype=np.int32)
420424
gd['outlet_name'] = np.empty(n_outlets, dtype='S{0}'.format(MAX_NC_CHARS))
421-
gd['outlet_upstream_gridcells'] = np.empty(n_outlets, dtype=np.int16)
425+
gd['outlet_upstream_gridcells'] = np.empty(n_outlets, dtype=np.int32)
422426
gd['outlet_upstream_area'] = np.empty(n_outlets, dtype=np.float64)
423427
# ---------------------------------------------------------------- #
424428

rvic/core/plots.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def uhs(data, title, case_id, plot_dir):
4040
plt.xlabel('timesteps')
4141
plt.ylabel('unit-hydrograph')
4242
fig.savefig(pfname)
43-
43+
plt.close()
4444
return pfname
4545
# -------------------------------------------------------------------- #
4646

@@ -71,6 +71,7 @@ def _fractions_grid(data, dom_x, dom_y, title, case_id, plot_dir):
7171
plt.ylim([0, dom_y.shape[0]])
7272
plt.xlim([0, dom_x.shape[1]])
7373
fig.savefig(pfname)
74+
plt.close()
7475
# ---------------------------------------------------------------- #
7576
return pfname
7677
# -------------------------------------------------------------------- #
@@ -129,6 +130,7 @@ def _fractions_map(data, dom_x, dom_y, title, case_id, plot_dir):
129130
m.colorbar(cs, location='right', pad='5%')
130131
plt.title(title)
131132
fig.savefig(pfname)
133+
plt.close()
132134
# ---------------------------------------------------------------- #
133135
return pfname
134136
# -------------------------------------------------------------------- #

0 commit comments

Comments
 (0)