Single Bifurcation

[1]:
import pandas as pd
import networkx as nx
import matplotlib.pyplot as plt
import numpy as np
[2]:
from context import RiverNetwork
from RiverNetwork import RiverNetwork
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-2-34661278ac7e> in <module>
----> 1 from context import RiverNetwork
      2 from RiverNetwork import RiverNetwork

~/checkouts/readthedocs.org/user_builds/rna/checkouts/stable/docs/context.py in <module>
      5 sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
      6
----> 7 import RiverNetwork
      8 import fit_muskingum

ModuleNotFoundError: No module named 'RiverNetwork'

Loading network structure

[3]:
structure1 = RiverNetwork('../data/single-bifurcation.xlsx')
structure1.draw(figsize=(4,4))
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-3-efa603431af2> in <module>
----> 1 structure1 = RiverNetwork('../data/single-bifurcation.xlsx')
      2 structure1.draw(figsize=(4,4))

NameError: name 'RiverNetwork' is not defined

Here we see the network with a single bifurcation. Each reach after such bifurcation has another parameter: \(f\). This parameter determines the (volume) fraction of water flowing into each reach, which is considered static. In this case 40% to the left and 60% to the right. This can also be seen in the base loads.

[4]:
structure1.draw_base_loads(figsize=(7,2.5))
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-4-86d24af1fd1f> in <module>
----> 1 structure1.draw_base_loads(figsize=(7,2.5))

NameError: name 'structure1' is not defined

Setting the inflow

The same inflow is set to the single source node

[5]:
inflow = np.array(pd.read_excel('../data/example-inflow-karahan-adjusted.xlsx').Inflow)-22
---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-5-931a6ef8ac3f> in <module>
----> 1 inflow = np.array(pd.read_excel('../data/example-inflow-karahan-adjusted.xlsx').Inflow)-22

~/checkouts/readthedocs.org/user_builds/rna/envs/stable/lib/python3.7/site-packages/pandas/util/_decorators.py in wrapper(*args, **kwargs)
    206                 else:
    207                     kwargs[new_arg_name] = new_arg_value
--> 208             return func(*args, **kwargs)
    209
    210         return wrapper

~/checkouts/readthedocs.org/user_builds/rna/envs/stable/lib/python3.7/site-packages/pandas/io/excel/_base.py in read_excel(io, sheet_name, header, names, index_col, usecols, squeeze, dtype, engine, converters, true_values, false_values, skiprows, nrows, na_values, keep_default_na, verbose, parse_dates, date_parser, thousands, comment, skip_footer, skipfooter, convert_float, mangle_dupe_cols, **kwds)
    308
    309     if not isinstance(io, ExcelFile):
--> 310         io = ExcelFile(io, engine=engine)
    311     elif engine and engine != io.engine:
    312         raise ValueError(

~/checkouts/readthedocs.org/user_builds/rna/envs/stable/lib/python3.7/site-packages/pandas/io/excel/_base.py in __init__(self, io, engine)
    817         self._io = _stringify_path(io)
    818
--> 819         self._reader = self._engines[engine](self._io)
    820
    821     def __fspath__(self):

~/checkouts/readthedocs.org/user_builds/rna/envs/stable/lib/python3.7/site-packages/pandas/io/excel/_xlrd.py in __init__(self, filepath_or_buffer)
     19         err_msg = "Install xlrd >= 1.0.0 for Excel support"
     20         import_optional_dependency("xlrd", extra=err_msg)
---> 21         super().__init__(filepath_or_buffer)
     22
     23     @property

~/checkouts/readthedocs.org/user_builds/rna/envs/stable/lib/python3.7/site-packages/pandas/io/excel/_base.py in __init__(self, filepath_or_buffer)
    357             self.book = self.load_workbook(filepath_or_buffer)
    358         elif isinstance(filepath_or_buffer, str):
--> 359             self.book = self.load_workbook(filepath_or_buffer)
    360         else:
    361             raise ValueError(

~/checkouts/readthedocs.org/user_builds/rna/envs/stable/lib/python3.7/site-packages/pandas/io/excel/_xlrd.py in load_workbook(self, filepath_or_buffer)
     34             return open_workbook(file_contents=data)
     35         else:
---> 36             return open_workbook(filepath_or_buffer)
     37
     38     @property

~/checkouts/readthedocs.org/user_builds/rna/envs/stable/lib/python3.7/site-packages/xlrd/__init__.py in open_workbook(filename, logfile, verbosity, use_mmap, file_contents, encoding_override, formatting_info, on_demand, ragged_rows)
    109     else:
    110         filename = os.path.expanduser(filename)
--> 111         with open(filename, "rb") as f:
    112             peek = f.read(peeksz)
    113     if peek == b"PK\x03\x04": # a ZIP file

FileNotFoundError: [Errno 2] No such file or directory: '../data/example-inflow-karahan-adjusted.xlsx'
[6]:
structure1.set_shape('S.1',36,inflow)
structure1.draw_Qin(figsize=(7,2.5))
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-6-fde9623c0897> in <module>
----> 1 structure1.set_shape('S.1',36,inflow)
      2 structure1.draw_Qin(figsize=(7,2.5))

NameError: name 'structure1' is not defined

Calculating wave propagation

The same steps are repeated to see calculate the resulting flows

[7]:
structure1.calc_flow_propagation(36)
structure1.draw_Qin(figsize=(7,4))
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-7-938b17e2d1be> in <module>
----> 1 structure1.calc_flow_propagation(36)
      2 structure1.draw_Qin(figsize=(7,4))

NameError: name 'structure1' is not defined

A.1 is a single timestep shift from S.1 (\(x = 0.5\), \(k=1\)). For clarity S.1 is omitted from the figure:

[8]:
structure1.draw_Qin(figsize=(7,4),no='S.1')
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-8-b08ce15e9616> in <module>
----> 1 structure1.draw_Qin(figsize=(7,4),no='S.1')

NameError: name 'structure1' is not defined

Here we clearly see how the flow through A.1 is divided into two flows. Both flows have a different lag and attenuation. In the first few timesteps it is also clear that the distribution is 60-40.