Example #1
0
import networkx as nx
import matplotlib.pyplot as plt
from networkx import graphviz_layout
from pySPARROW import Network, Reach

path = "test.h5"
workspace = "/home/user/pysparrow-read-only/examples/testing_on_sample_sparrow_dataset/"
test_reach = '5012'

net = Network(workspace + 'test.h5')
G=net._g.subgraph(net.get_upstream_reaches(net.get_reach(test_reach)))

lab = {}
node_size =[]
node_color = []
i = 1
for r in G:
    lab[r] = r._ComID
    #print r._AreaHa
    #if r._AreaHa >= 1000.0: 
    node_size.append((net.get_instream_loss(r._ComID, test_reach)*500.0) ** 1.0 )
    node_color.append((net.get_instream_loss(r._ComID, test_reach)*500.0) ** 1.0 )
    #else:
    #    node_size.append(1.0)
    #    node_color.append(1.0)
    i+=1
    
pos=nx.graphviz_layout(G,prog='neato',args='')
plt.figure(figsize=(8,8))
nx.draw(G,pos, \
    node_size=node_size, \
Example #2
0
import networkx as nx
import matplotlib.pyplot as plt
from networkx import graphviz_layout
from pySPARROW import Network, Reach

workspace = "/home/user/pysparrow-read-only/examples/testing_on_sample_sparrow_dataset/"
test_reach = '5012'

net = Network(workspace + 'test.h5')
max2= 0
id2 = 0

#for i in net._g:
#    if len(net.get_upstream_reaches(i)) > 1000: 
#        print str(len(net.get_upstream_reaches(i))) + " " + str(i._ComID)

    
G=net._g.subgraph(net.get_upstream_reaches(net.get_reach(test_reach)))
pos=nx.graphviz_layout(G,prog='neato',args='')
plt.figure(figsize=(8,8))
lab = {}
node_size = []
node_color = []
for r in G:
    lab[r] = r._ComID
    #print r._AreaHa
    if r._AreaHa >= 1000.0: 
        node_size.append((r.get_tot_runoff() / r._AreaHa ) ** 2.0 )
        node_color.append((r.get_tot_runoff() / r._AreaHa ) ** 2.0 )
    else:
        node_size.append(1.0)
Example #3
0
import networkx as nx
import matplotlib.pyplot as plt
import numpy as np
from networkx import graphviz_layout
from pySPARROW import Network, Reach

path = "test.h5"
workspace = "/home/user/pysparrow-read-only/examples/testing_on_sample_sparrow_dataset/"
test_reach = '5012'

net = Network(workspace + 'test.h5')
G = net._g.subgraph(net.get_upstream_reaches(net.get_reach(test_reach)))
wb = net.get_waterbody(test_reach)
l_old = wb.get_fert_load()

wbs = ['5092', '5014', '5087', '5041', '5054', '5068', '5061']
l_new = []
for j in wbs:
    wb = net.get_waterbody(j)
    l_new.append(wb.get_tot_load() / 10**5)

N = 7
ind = np.arange(N)
plt.subplot(1, 1, 1)
plt.bar(ind, l_new, width=0.3, color="black")

increase = [1]
l_new2 = []
for i in increase:

    # update
Example #4
0
import networkx as nx
import matplotlib.pyplot as plt
import numpy as np
from networkx import graphviz_layout
from pySPARROW import Network, Reach

path = "test.h5"
workspace = "/home/user/pysparrow-read-only/examples/testing_on_sample_sparrow_dataset/"
test_reach = "5012"

net = Network(workspace + "test.h5")
G = net._g.subgraph(net.get_upstream_reaches(net.get_reach(test_reach)))
wb = net.get_waterbody(test_reach)
l_old = wb.get_fert_load()

wbs = ["5092", "5014", "5087", "5041", "5054", "5068", "5061"]
l_new = []
for j in wbs:
    wb = net.get_waterbody(j)
    l_new.append(wb.get_tot_load() / 10 ** 5)

N = 7
ind = np.arange(N)
plt.subplot(1, 1, 1)
plt.bar(ind, l_new, width=0.3, color="black")

increase = [1]
l_new2 = []
for i in increase:

    # update
Example #5
0
import networkx as nx
import matplotlib.pyplot as plt
from networkx import graphviz_layout
from pySPARROW import Network, Reach

workspace = "/home/user/pysparrow-read-only/examples/testing_on_sample_sparrow_dataset/"
test_reach = '5012'

net = Network(workspace + 'test.h5')
max2 = 0
id2 = 0

#for i in net._g:
#    if len(net.get_upstream_reaches(i)) > 1000:
#        print str(len(net.get_upstream_reaches(i))) + " " + str(i._ComID)

G = net._g.subgraph(net.get_upstream_reaches(net.get_reach(test_reach)))
pos = nx.graphviz_layout(G, prog='neato', args='')
plt.figure(figsize=(8, 8))
lab = {}
node_size = []
node_color = []
for r in G:
    lab[r] = r._ComID
    #print r._AreaHa
    if r._AreaHa >= 1000.0:
        node_size.append((r.get_tot_runoff() / r._AreaHa)**2.0)
        node_color.append((r.get_tot_runoff() / r._AreaHa)**2.0)
    else:
        node_size.append(1.0)
        node_color.append(1.0)