Code Monkey home page Code Monkey logo

river-route's Introduction

River Route

river-route is a Python package for routing runoff through a river network. Routing calculations are vectorized with numpy and scipy which keeps the array computation times on par with faster compiled languages.

Output File Schemas

Discharge Data

Discharge data are given in a netCDF file. The file has 2 dimensions: time and river_id. The times given will exactly match the times given in the runoff data unless a different time interval was specified. The river_id dimension will exactly match the IDs given in the river_id column of the routing parameters file. Discharge values will be in a variable named "Q", in an array of shape (time, river_id), and dtype float.

Tips for efficient computations

Results will vary based on your system specifications, the size of the river network, and the length of the simulation. These tips may help you achieve faster results.

  1. Use fewer inflow files: File IO operations can be relatively slow and are a probable bottleneck on HPC systems when I/O operations depend on networked drives. You may achieve faster results by doing a single computation covering 2 weeks instead of 14 computations covering 1 day each. The trade-off is that larger arrays consume more memory which could eventually become too large if your river network is very large.
  2. Adjust the time step: Using a longer time step will reduce the number of computations and therefore take less time to compute. It also requires storing fewer intermediate results in memory yielding a modest reduction in memory usage. A longer time step can increase performance if it does not induce numerical instability in the outflows.

river-route's People

Contributors

rileyhales avatar

Watchers

 avatar

Forkers

rhuber6 xueyil9

river-route's Issues

Nonlinear routing

Allow routing with variable k (and/or x) values

On each iteration

  • check if k needs to be changed based on current Q vector
  • update k
  • recalculate muskingum coefficients
  • recalculate the LHS matrix
  • calculate the iteration's rhs or b vector (existing)
  • solve (existing)

Need to determine the data structure for determining k or x values based on q thresholds

  • equations? require recomputing every time. Or only if q is >5% different than the previous Q or Q the last time it was calculate?
  • tables? what are the thresholds for changing k? can they be known a priori or must you iteratively solve to reach an equilibrium state when the thresholds stop changing (e.g. return periods)?

Alternative options for reading runoff volume arrays

Allow options for alternative methods for reading the runoff volumes array.

Runoff volumes array incremental reader generator instead of in memory array

Do you want to read the entire array in memory up front and then route it or do you want to incrementally read from the array/file on disc?

To reduce memory consumption (but maybe be slower?) you can incrementally read from the array if the data are provided in a chunked format that is optimized for it.

Documentation

Recommend PETSc options
Describe config file options
Establish standard config file names

Start a docs site

  • config files
  • example usage
  • api docs
  • how to overwrite the function which writes arrays to disc with custom logic

Specify sequential time steps vs ensemble members

Sometimes you run simulations where the runoffs/volumes represent a sequential and continuous set of time steps. Sometimes its an ensemble of predictions all starting from the same time step. Add a flag which allows the user to specify the condition type.

Add QA checks

  • last time step of the previous file is ~1 time step ahead of the next time step
  • If ensemble, all runoff time series start at the same date

Current code runs in sequential mode. To switch to ensemble, do not overwrite the saved self.q_init property at the end of the routing computations.

Options for writing outputs to disc

Provide additional options for writing outputs to disc. A single netCDF per runoff file is not always the best option for writing outputs.

Either provide additional formats for writing to disc or else allow the user to give their own function that takes in the results as arguments and then they give their own code for saving.

Sources and Sinks

Create a way for sources and sinks to be created.

Perhaps specify a time series of flows in or out of a river segment.

Use those to create a vector to add (positive/negative flows for flow into or out of river).

Add that vector after each routing computation but before enforcing max/min Q.

Source/sink distinction is probably not necessary. Flows will be added or removed by the sign of the flow.

Option to enforce minimum (and maximum?) Q after iterations

Giving an option to force minimum flows to be >=0 should improve accuracy and improve calculation stability/convergence.

Giving option to enforce maximum flows limit to some arbitrary large number can guarantee that flows are not too large to write to disc if there is a convergence issue or miscalculated inflows. Maybe raise warnings if its not too slow to check for large values first.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.