|
26 | 26 | "- Scipy is required to define lognormal fragility curves\n", |
27 | 27 | "- NetworkX is used to calculate topographic metrics\n", |
28 | 28 | "- 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" |
30 | 31 | ] |
31 | 32 | }, |
32 | 33 | { |
|
40 | 41 | "import networkx as nx\n", |
41 | 42 | "import geopandas as gpd\n", |
42 | 43 | "import matplotlib.pylab as plt\n", |
| 44 | + "import warnings\n", |
43 | 45 | "import wntr" |
44 | 46 | ] |
45 | 47 | }, |
| 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 | + }, |
46 | 62 | { |
47 | 63 | "cell_type": "markdown", |
48 | 64 | "metadata": {}, |
|
780 | 796 | "# Split pipe 123 \n", |
781 | 797 | "wn = wntr.morph.split_pipe(wn, pipe_name_to_split='123', new_pipe_name='123_B', new_junction_name='123_node')\n", |
782 | 798 | "# 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", |
783 | 800 | "leak_node = wn.get_node('123_node')\n", |
784 | 801 | "leak_node.add_leak(wn, area=0.05, start_time=2*3600, end_time=12*3600)" |
785 | 802 | ] |
|
958 | 975 | "wntr.network.write_geojson(wn, 'Net3')\n", |
959 | 976 | "\n", |
960 | 977 | "# Create a WaterNetworkModel from GeoJSON files\n", |
961 | | - "# The following code will produce UserWarnings: 'crs' was not provided\n", |
962 | 978 | "# Check project folder to verify that files were written\n", |
963 | 979 | "geojson_files = {'junctions': 'Net3_junctions.geojson',\n", |
964 | 980 | " 'tanks': 'Net3_tanks.geojson',\n", |
|
986 | 1002 | "outputs": [], |
987 | 1003 | "source": [ |
988 | 1004 | "# 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", |
990 | 1005 | "wntr.network.write_shapefile(wn, 'Net3')\n", |
991 | 1006 | "\n", |
992 | 1007 | "# Create a WaterNetworkModel from Shapefiles\n", |
|
1490 | 1505 | "outputs": [], |
1491 | 1506 | "source": [ |
1492 | 1507 | "# 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", |
1494 | 1509 | "epicenter = (32000,15000) # x,y location\n", |
1495 | 1510 | "magnitude = 6.5 # Richter scale\n", |
1496 | 1511 | "depth = 10000 # m, shallow depth\n", |
1497 | 1512 | "# Model the magnitude 6.5 earthquake scenario\n", |
1498 | 1513 | "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", |
1500 | 1515 | "# Get peak ground accelerations (PGAs) from earthquake scenario\n", |
1501 | 1516 | "pga = earthquake.pga_attenuation_model(distance)\n", |
1502 | 1517 | "# 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)')" |
1504 | 1519 | ] |
1505 | 1520 | }, |
1506 | 1521 | { |
|
1707 | 1722 | "# Geospatial capabilities\n", |
1708 | 1723 | "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", |
1709 | 1724 | "\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.**" |
1711 | 1726 | ] |
1712 | 1727 | }, |
1713 | 1728 | { |
|
1755 | 1770 | "metadata": {}, |
1756 | 1771 | "source": [ |
1757 | 1772 | "## 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." |
1759 | 1774 | ] |
1760 | 1775 | }, |
1761 | 1776 | { |
|
0 commit comments