Skip to content

Commit

Permalink
Merge pull request #56 from UW-Hydro/develop
Browse files Browse the repository at this point in the history
RVIC 1.1 release merge from develop
  • Loading branch information
Joe Hamman committed Oct 25, 2015
2 parents 1b220c8 + ea5e52d commit ef16e06
Show file tree
Hide file tree
Showing 70 changed files with 2,411 additions and 1,512 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.nc filter=lfs diff=lfs merge=lfs -text
*.csv filter=lfs diff=lfs merge=lfs -text
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ rvic.egg-info
# Configuration Files #
#######################
*cfg
samples/cases/*

# Packages #
############
Expand Down
48 changes: 26 additions & 22 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
language: python
sudo: false # use container based build
notifications:
email: false

matrix:
fast_finish: true
include:
- python: 2.7
- python: 3.4
- python: 3.5

python:
- "2.7"
# Setup anaconda
before_install:
- wget http://repo.continuum.io/miniconda/Miniconda-2.2.2-Linux-x86_64.sh -O miniconda.sh
- chmod +x miniconda.sh
- ./miniconda.sh -b
- export PATH=/home/travis/anaconda/bin:$PATH
# Update conda itself
- conda update --yes conda
# The next couple lines fix a crash with multiprocessing on Travis and are not specific to using Miniconda
- sudo rm -rf /dev/shm
- sudo ln -s /run/shm /dev/shm
- if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
wget http://repo.continuum.io/miniconda/Miniconda-3.16.0-Linux-x86_64.sh -O miniconda.sh;
else
wget http://repo.continuum.io/miniconda/Miniconda3-3.16.0-Linux-x86_64.sh -O miniconda.sh;
fi
- bash miniconda.sh -b -p $HOME/miniconda
- export PATH="$HOME/miniconda/bin:$PATH"
- hash -r
- conda config --set always_yes yes --set changeps1 no
- conda update -q conda
- conda info -a
# Install packages
install:
- conda create --yes --name=rvic_test_env python=$TRAVIS_PYTHON_VERSION --file=ci/requirements-2.7.txt
- source activate rvic_test_env
- conda create --yes --name=test python=$TRAVIS_PYTHON_VERSION numpy scipy pandas netcdf4 matplotlib pytest
- source activate test
# - conda install -c https://conda.anaconda.org/ioos cdo
# - pip install cdo
- python setup.py install
# Run test
script:
- which python
- python --version
- conda list
- pip freeze
- echo $PATH
- python -c 'import rvic; print rvic.__file__'
- cd tests
- pwd
- python run_tests.py unit
- py.test
7 changes: 0 additions & 7 deletions ci/requirements-2.7-dev.txt

This file was deleted.

6 changes: 0 additions & 6 deletions ci/requirements-2.7.txt

This file was deleted.

95 changes: 0 additions & 95 deletions config/rvic_convert_example.cfg

This file was deleted.

16 changes: 16 additions & 0 deletions docs/development/whats_new.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# What's New

v1.1.0 (25 October 2015)

This release contains a number of bug and compatibility fixes.

### Enhancements

- Compatibility with Python 3.4 and 3.5 ([GH38](https://github.com/UW-Hydro/RVIC/pull/38)).
- Simplified multiprocessing in `parameters` which should improve stability ([GH60](https://github.com/UW-Hydro/RVIC/pull/60)).

### Bug Fixes

- Fixed bug that caused `REMAP=False` to fail ([GH60](https://github.com/UW-Hydro/RVIC/pull/60)).
- Improvements were made to the `SEARCH_FOR_CHANNEL` option in `parameters`.
- Fixed bug where last timestep of history output was not populated ([GH71](https://github.com/UW-Hydro/RVIC/pull/71)).
4 changes: 2 additions & 2 deletions docs/support/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
At the moment, no. However, many of the pieces needed to support this feature are already included in RVIC. This is a feature that has been identified for a future version of RVIC.

### Can route flows to every grid cell in my domain using RVIC?
Yes, it is possible to route to every grid cell in the RVIC domain. That said, it may not be the most efficent way to use RVIC. RVIC is a source to sink routing model which means it doesn't track where streamflow is along its flow path. When you route to every grid cell in the domain, you are duplicating a lot of calculations. There are other routing models that route flow from grid cell to grid cell.
Yes, it is possible to route to every grid cell in the RVIC domain. That said, it may not be the most efficient way to use RVIC. RVIC is a source to sink routing model which means it doesn't track where streamflow is along its flow path. When you route to every grid cell in the domain, you are duplicating a lot of calculations. There are other routing models that route flow from grid cell to grid cell.

### Is there a C or Fortran Version of RVIC?
RVIC has been coupled in the Community Earth System Model (CESM) as the streamflow routing model. For that project, a Fortran version of the "convolution" step was written. At this time, there is not a C version of this routing model. In the future, a C binding may be created to coupled with the stand-alone VIC model version 5.
RVIC has been coupled in the Community Earth System Model (CESM) as the streamflow routing model. For that project, a Fortran version of the "convolution" step was written. Work is currently underway to couple RVIC to the stand-alone image driver in VIC 5.0 ([VIC231](https://github.com/UW-Hydro/VIC/pull/231)).
3 changes: 0 additions & 3 deletions docs/user-guide/convolution.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ The flux file(s) must be in netCDF format and have a `time` dimension as well as
3. **CASE_DIR**
- Description: case run directory
- Type: char
4. **RVIC_TAG**
- Description: RVIC Tag
- Type: char
5. **CASEID**
- Description: Case ID
- Type: char
Expand Down
25 changes: 20 additions & 5 deletions docs/user-guide/install.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
# Installing RVIC

## Dependencies
- [Python 2.7](http://www.python.org/)
- [Numpy](http://www.numpy.org)
- [Scipy](http://www.scipy.org/)
- [netcdf4-python](https://code.google.com/p/netcdf4-python/)
- [Python 2.7 or later including Python3](http://www.python.org)
- [NumPy](http://www.numpy.org)
- [SciPy](http://www.scipy.org)
- [netcdf4-python](https://code.google.com/p/netcdf4-python)
- [pandas](http://pandas.pydata.org)

If using `REMAP=True`:

- [cdo](https://code.zmaw.de/projects/cdo)
- [CDO](https://code.zmaw.de/projects/cdo)
- [cdo.py](https://github.com/Try2Code/cdo-bindings)

## Installing using a package manager

RVIC is available via [PyPi](https://pypi.python.org/pypi/rvic):

```
pip install rvic
```

or Anaconda via the UW-Hydro channel:

```
conda install --channel https://conda.anaconda.org/UW-Hydro rvic
```

## Building RVIC

### Option 1: Using Anaconda
Expand Down
2 changes: 2 additions & 0 deletions docs/user-guide/parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ For irregular grids, you need to come up with a netCDF file that contains these
- area (in m2 or rad2 or similar)
- coordinate vars (lon and lat or similar)

*Note: If `REMAP==False`, the resolution of the routing data grid and domain grid must be the same. Furthermore, the domain grid must be a subset of the routing grid. RVIC will raise an error if either of these conditions is not met.*

## Pour Points File
A pour points CSV is needed to develop the parameter file. This is simply a csv file containing a list of the pour point locations with 2 or 3 columns (required: lons, lats; optional: names/contributing area/etc). One header row is required.

Expand Down
1 change: 1 addition & 0 deletions rvic/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .version import short_version as __version__
32 changes: 16 additions & 16 deletions rvic/clib/rvic_convolution.c
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
#include <stdlib.h>

void convolve(const int nsources, /*scalar - number of sources*/
const int noutlets, /*scalar - length of subset*/
const int subset_length, /*scalar - length of subset*/
const int x_size,
const int* source2outlet_ind, /*1d array - source to outlet mapping*/
const int* source_y_ind, /*1d array - source y location*/
const int* source_x_ind, /*1d array - source x location*/
const int* source_time_offset, /*1d array - source time offset*/
const double* unit_hydrograph, /*2d array[times][sources] - unit hydrographs*/
const double* aggrunin, /*2d array[ysize][xsize] - vic runoff flux*/
double* ring) /*2d array[times][outlets] - convolution ring*/
void
convolve(const int nsources, /*scalar - number of sources*/
const int noutlets, /*scalar - length of subset*/
const int subset_length, /*scalar - length of subset*/
const int x_size,
const int *source2outlet_ind, /*1d array - source to outlet mapping*/
const int *source_y_ind, /*1d array - source y location*/
const int *source_x_ind, /*1d array - source x location*/
const int *source_time_offset, /*1d array - source time offset*/
const double *unit_hydrograph, /*2d array[times][sources] - unit hydrographs*/
const double *aggrunin, /*2d array[ysize][xsize] - vic runoff flux*/
double *ring) /*2d array[times][outlets] - convolution ring*/
{
int s, i, j; /*counters*/
int y, x, offset, outlet; /*2d indicies*/
int xyind, rind, uhind; /*1d indicies*/

/*Loop through all sources*/
for (s = 0; s < nsources; s++) {

outlet = source2outlet_ind[s];
y = source_y_ind[s];
x = source_x_ind[s];
offset = source_time_offset[s];

//1d index location
//2d-->1d indexing goes like this: ind = y*x_size + x
xyind = y*x_size + x;
// 1d index location
// 2d-->1d indexing goes like this: ind = y*x_size + x
xyind = y * x_size + x;

/* Do the convolution */
// i is the position in the unit hydrograph
// j is the position in the ring
for (i = 0; i < subset_length; i++) {
j = i + offset;

//1d index locations
// 1d index locations
rind = j * noutlets + outlet;
uhind = i * nsources + s;

Expand Down
Loading

0 comments on commit ef16e06

Please sign in to comment.