Skip to content

Commit 5b7d0cb

Browse files
committed
Tutorials update
Updates to the tutorial files based upon EPA internal technical peer review comments. Revisions include simplifying coding commands, adding more detailed comments, and suppressing warning messages.
1 parent eef598d commit 5b7d0cb

File tree

5 files changed

+268
-132
lines changed

5 files changed

+268
-132
lines changed

examples/basics_tutorial.ipynb

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
"- Scipy is required to define lognormal fragility curves\n",
2727
"- NetworkX is used to calculate topographic metrics\n",
2828
"- Geopandas is used to load geospatial data\n",
29-
"- Matplotlib is used to create graphics"
29+
"- Matplotlib is used to create graphics\n",
30+
"- Warnings is used to suppress warning messages for features that will be addressed in future WNTR releases"
3031
]
3132
},
3233
{
@@ -40,9 +41,24 @@
4041
"import networkx as nx\n",
4142
"import geopandas as gpd\n",
4243
"import matplotlib.pylab as plt\n",
44+
"import warnings\n",
4345
"import wntr"
4446
]
4547
},
48+
{
49+
"cell_type": "code",
50+
"execution_count": null,
51+
"metadata": {},
52+
"outputs": [],
53+
"source": [
54+
"# Suppress warning messages that will be addressed in future WNTR releases\n",
55+
"warnings.filterwarnings(\"ignore\", message=\"Column names longer than 10 characters will be truncated when saved to \"\n",
56+
" \"ESRI Shapefile.\")\n",
57+
"warnings.filterwarnings(\"ignore\", message=\"'crs' was not provided. The output dataset will not have projection information defined and may not be usable in other systems.\")\n",
58+
"warnings.filterwarnings(\"ignore\", message=\"Normalized/laundered field name:\")\n",
59+
"warnings.filterwarnings(\"ignore\", message=\"Geometry is in a geographic CRS.\")"
60+
]
61+
},
4662
{
4763
"cell_type": "markdown",
4864
"metadata": {},
@@ -780,6 +796,7 @@
780796
"# Split pipe 123 \n",
781797
"wn = wntr.morph.split_pipe(wn, pipe_name_to_split='123', new_pipe_name='123_B', new_junction_name='123_node')\n",
782798
"# Add a leak to the new node which starts at hour 2 and ends at hour 12\n",
799+
"# Note add_leak is only included in the hydraulic simulation when using the WNTRSimulator\n",
783800
"leak_node = wn.get_node('123_node')\n",
784801
"leak_node.add_leak(wn, area=0.05, start_time=2*3600, end_time=12*3600)"
785802
]
@@ -958,7 +975,6 @@
958975
"wntr.network.write_geojson(wn, 'Net3')\n",
959976
"\n",
960977
"# Create a WaterNetworkModel from GeoJSON files\n",
961-
"# The following code will produce UserWarnings: 'crs' was not provided\n",
962978
"# Check project folder to verify that files were written\n",
963979
"geojson_files = {'junctions': 'Net3_junctions.geojson',\n",
964980
" 'tanks': 'Net3_tanks.geojson',\n",
@@ -986,7 +1002,6 @@
9861002
"outputs": [],
9871003
"source": [
9881004
"# Create Shapefiles from the WaterNetworkModel\n",
989-
"# The following code will produce UserWarnings: \"Column names longer than 10 characters will be truncated when saved to ESRI Shapefile.\"\n",
9901005
"wntr.network.write_shapefile(wn, 'Net3')\n",
9911006
"\n",
9921007
"# Create a WaterNetworkModel from Shapefiles\n",
@@ -1490,17 +1505,17 @@
14901505
"outputs": [],
14911506
"source": [
14921507
"# Define an earthquake scenario\n",
1493-
"wn = wntr.morph.scale_node_coordinates(wn, 1000)\n",
1508+
"wn1 = wntr.morph.scale_node_coordinates(wn, 1000)\n",
14941509
"epicenter = (32000,15000) # x,y location\n",
14951510
"magnitude = 6.5 # Richter scale\n",
14961511
"depth = 10000 # m, shallow depth\n",
14971512
"# Model the magnitude 6.5 earthquake scenario\n",
14981513
"earthquake = wntr.scenario.Earthquake(epicenter, magnitude, depth)\n",
1499-
"distance = earthquake.distance_to_epicenter(wn, element_type=wntr.network.Pipe)\n",
1514+
"distance = earthquake.distance_to_epicenter(wn1, element_type=wntr.network.Pipe)\n",
15001515
"# Get peak ground accelerations (PGAs) from earthquake scenario\n",
15011516
"pga = earthquake.pga_attenuation_model(distance)\n",
15021517
"# Plot the PGA for each link on the network\n",
1503-
"ax = wntr.graphics.plot_network(wn, link_attribute=pga, node_size=0, link_width=2, title=\"Peak ground acceleration\", link_colorbar_label='PGA (g)')"
1518+
"ax = wntr.graphics.plot_network(wn1, link_attribute=pga, node_size=0, link_width=2, title=\"Peak ground acceleration\", link_colorbar_label='PGA (g)')"
15041519
]
15051520
},
15061521
{
@@ -1707,7 +1722,7 @@
17071722
"# Geospatial capabilities\n",
17081723
"Geospatial data can be used within WNTR to build a WaterNetworkModel, associate geospatial data with nodes and links, and save simulation results to GIS compatible files.\n",
17091724
"\n",
1710-
"**Note, this example assumes the coordinate reference system (CRS) for the WaterNetworkModel and GIS data are in EPSG:4326 (lat/long). Geographic CRS are not suitable for measuring distance and the example will result in UserWarnings. The example will be updated to use a projected CRS at a later date.**"
1725+
"**Note, this example assumes the coordinate reference system (CRS) for the WaterNetworkModel and GIS data are in EPSG:4326 (lat/long). Geographic CRS are not suitable for measuring distance. The example will be updated to use a projected CRS at a later date.**"
17111726
]
17121727
},
17131728
{
@@ -1755,7 +1770,7 @@
17551770
"metadata": {},
17561771
"source": [
17571772
"## Snap data\n",
1758-
"The `snap` function is used to find the nearest point or line to a set of points. "
1773+
"The `snap` function is used to find the nearest point or line to a set of points."
17591774
]
17601775
},
17611776
{

0 commit comments

Comments
 (0)