Skip to content

Commit

Permalink
Merge pull request #427 from kaklise/demos
Browse files Browse the repository at this point in the history
Updates to the basic and geospatial demos
  • Loading branch information
kaklise authored Jun 10, 2024
2 parents 0b098de + ffb58c1 commit 1222cb0
Show file tree
Hide file tree
Showing 4 changed files with 3,523 additions and 726 deletions.
1,459 changes: 1,048 additions & 411 deletions examples/demos/basic_demo.ipynb

Large diffs are not rendered by default.

2,773 changes: 2,467 additions & 306 deletions examples/demos/geospatial_demo.ipynb

Large diffs are not rendered by default.

13 changes: 6 additions & 7 deletions examples/getting_started.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
"""
The following example demonstrates how to import WNTR, generate a water network
model from an INP file, simulate hydraulics, and plot simulation results on the network.
The following example demonstrates how to import WNTR, create a water
network model from an EPANET INP file, simulate hydraulics, and plot
simulation results on the network.
"""
# Import WNTR
import wntr

# Create a water network model
inp_file = 'networks/Net3.inp'
wn = wntr.network.WaterNetworkModel(inp_file)

# Graph the network
wntr.graphics.plot_network(wn, title=wn.name)

# Simulate hydraulics
sim = wntr.sim.EpanetSimulator(wn)
results = sim.run_sim()

# Plot results on the network
pressure_at_5hr = results.node['pressure'].loc[5*3600, :]
wntr.graphics.plot_network(wn, node_attribute=pressure_at_5hr, node_size=30,
title='Pressure at 5 hours')
wntr.graphics.plot_network(wn, node_attribute=pressure_at_5hr,
node_size=30, title='Pressure at 5 hours')
4 changes: 2 additions & 2 deletions wntr/gis/geospatial.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,9 @@ def intersect(A, B, B_value=None, include_background=False, background_value=0):
weighted_mean = True

if weighted_mean and B_value is not None:
stats['weighted_mean'] = 0
stats['weighted_mean'] = 0.0
A_length = A.length
covered_length = pd.Series(0, index = A.index)
covered_length = pd.Series(0.0, index = A.index)

for i in B.index:
B_geom = gpd.GeoDataFrame(B.loc[[i],:], crs=B.crs)
Expand Down

0 comments on commit 1222cb0

Please sign in to comment.