Skip to content

Minor updates to support newer version of pandas etc #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -13,10 +13,11 @@ When using the GisToSWMM5 tool, please refer to the following publications which
Other studies involving GisToSWMM5 include:
- Aarnio, K., 2016. Pintamittauksen hyödyntämismahdollisuudet viemäriverkosto-mallin kalibroinnissa (Utilizing possibilities of level measurement in the calibration of a sewerage model). Master’s Thesis. Aalto University, Espoo, Finland. 94 p. <http://urn.fi/URN:NBN:fi:aalto-201612085848> (In Finnish)
- Bangura, E.K., Yang, X., Zaman, M.N., 2018. Application and assessment of an automated subcatchment generator for SWMM (Study project Report). Technische Universität Dresden: Institute of Urban Water Management, Dresden, Germany. 43 p.
- Kokkonen, T., Warsta, L., Niemi, T.J., Taka, M., Sillanpää, N., Pusa, M., Kesäniemi, O., Salo H. & Koivusalo, H. 2019, Impact of alternative land cover descriptions on urban hydrological model simulations, *Urban Water Journal*, 16 (2): 103-113, <https://doi.org/10.1080/1573062X.2019.1634742>.
- Niemi, T.J., Krebs, G. & Kokkonen, T., 2019, Automated Approach for Rainfall-Runoff Model Generation. in G Mannina (ed.), New Trends in Urban Drainage Modelling: UDM 2018. Green Energy and Technology, International Conference on Urban Drainage Modelling, Palermo, Italy, 23-26.9.2018. <https://doi.org/10.1007/978-3-319-99867-1_103>
- Niemi, T.J., Warsta, L., Taka, M., Hickman, B., Pulkkinen, S., Krebs, G., Moisseev, D.N., Koivusalo, H., Kokkonen, T., 2017. Applicability of open rainfall data to event-scale urban rainfall-runoff modelling. J. Hydrol. 547, 143–155. <https://doi.org/10.1016/j.jhydrol.2017.01.056>
- Niemi, T.J., Warsta, L., Taka, M., Hickman, B., Pulkkinen, S., Krebs, G., Moisseev, D.N., Koivusalo, H., Kokkonen, T., 2017. Applicability of open rainfall data to event-scale urban rainfall-runoff modelling. *Journal of Hydrology*. 547: 143–155. <https://doi.org/10.1016/j.jhydrol.2017.01.056>
- Rautiainen, M., 2016. Hulevesimallinnus ja tulvariskin arviointi Turun sataman valuma-alueella (Storm water modelling and flood risk assessment in Turku harbor catchment). Master’s Thesis. Aalto University, Espoo, Finland. 51 p. <http://urn.fi/URN:NBN:fi:aalto-201611025308> (In Finnish)
- Taka, M., Kokkonen, T., Kuoppamäki, K., Niemi, T., Sillanpää, N., Valtanen, M., Warsta, L., Setälä, H., 2017. Spatio-temporal patterns of major ions in urban stormwater under cold climate. Hydrol. Process. 31, 1564–1577. <https://doi.org/10.1002/hyp.11126>
- Taka, M., Kokkonen, T., Kuoppamäki, K., Niemi, T., Sillanpää, N., Valtanen, M., Warsta, L., Setälä, H., 2017. Spatio-temporal patterns of major ions in urban stormwater under cold climate. *Hydrological Processes*. 31: 1564–1577. <https://doi.org/10.1002/hyp.11126>

### Using GisToSWMM5

Binary file modified bin/GisToSWMM5
Binary file not shown.
28 changes: 14 additions & 14 deletions demo_catchment/data/table_conduits.csv
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
x0,y0,x1,y1,name,elev_in,elev_out,length,junc_in,junc_out,roughness,elev_in_of,elev_ou_of
63.5599999987,200.3439999986,74.620000001,173.3359999992,c1,26.725,26.225,29.18414059,j4,j3,0.015,0,0.03
102.5700000003,107.8089999994,121.2600000016,58.5659999987,c2,24.765,24.685,52.67030014,j1,j5,0.015,0,0
74.620000001,173.3359999992,92.2600000016,132.0899999989,c3,26.195,25.095,44.86166364,j3,j2,0.015,0,0.07
92.2600000016,132.0899999989,102.5700000003,107.8089999994,c4,25.025,24.815,26.37889134,j2,j1,0.015,0,0.05
63.1000000015,11.2499999991,45.0599999987,-20.1870000008,c5,24.505,24.4516479,14.87498223,j7,o1,0.015,0,0
85.9600000009,38.0549999988,63.1000000015,11.2499999991,c6,24.535,24.505,35.22842261,j6,j7,0.015,0,0
121.2600000016,58.5659999987,85.9600000009,38.0549999988,c7,24.685,24.535,40.83075865,j5,j6,0.015,0,0
86.4899999984,44.6329999994,85.9600000009,38.0549999988,c8,24.568,24.535,6.599756519,j8,j6,0.015,0,0
90.4499999993,40.2409999995,85.9600000009,38.0549999988,c9,24.56,24.535,4.995472217,j9,j6,0.015,0,0
126.1900000013,68.0589999994,121.2600000016,58.5659999987,c10,24.7385,24.685,10.69564785,j10,j5,0.015,0,0
131.4400000013,63.1499999994,121.2600000016,58.5659999987,c11,24.7408,24.685,11.16611395,j11,j5,0.015,0,0
90.4899999984,127.2689999994,92.2600000016,132.0899999989,c12,25.1207,25.095,5.135353998,j12,j2,0.015,0,0.07
94.7100000009,129.2929999987,92.2600000016,132.0899999989,c13,25.1136,25.095,3.718270045,j13,j2,0.015,0,0.07
x0,y0,x1,y1,name,elev_in,elev_out,length,junc_in,junc_out,roughness,elev_in_of,elev_ou_of
63.5599999987,200.3439999986,74.620000001,173.3359999992,c1,26.725,26.225,29.18414059,j4,j3,0.015,0,0.03
102.5700000003,107.8089999994,121.2600000016,58.5659999987,c2,24.765,24.685,52.67030014,j1,j5,0.015,0,0
74.620000001,173.3359999992,92.2600000016,132.0899999989,c3,26.195,25.095,44.86166364,j3,j2,0.015,0,0.07
92.2600000016,132.0899999989,102.5700000003,107.8089999994,c4,25.025,24.815,26.37889134,j2,j1,0.015,0,0.05
63.1000000015,11.2499999991,45.0599999987,-20.1870000008,c5,24.505,24.4516479,14.87498223,j7,o1,0.015,0,0
85.9600000009,38.0549999988,63.1000000015,11.2499999991,c6,24.535,24.505,35.22842261,j6,j7,0.015,0,0
121.2600000016,58.5659999987,85.9600000009,38.0549999988,c7,24.685,24.535,40.83075865,j5,j6,0.015,0,0
86.4899999984,44.6329999994,85.9600000009,38.0549999988,c8,24.568,24.535,6.599756519,j8,j6,0.015,0,0
90.4499999993,40.2409999995,85.9600000009,38.0549999988,c9,24.56,24.535,4.995472217,j9,j6,0.015,0,0
126.1900000013,68.0589999994,121.2600000016,58.5659999987,c10,24.7385,24.685,10.69564785,j10,j5,0.015,0,0
131.4400000013,63.1499999994,121.2600000016,58.5659999987,c11,24.7408,24.685,11.16611395,j11,j5,0.015,0,0
90.4899999984,127.2689999994,92.2600000016,132.0899999989,c12,25.1207,25.095,5.135353998,j12,j2,0.015,0,0.07
94.7100000009,129.2929999987,92.2600000016,132.0899999989,c13,25.1136,25.095,3.718270045,j13,j2,0.015,0,0.07
28 changes: 14 additions & 14 deletions demo_catchment/data/table_junctions.csv
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
x0,y0,name,elevation,inv_elev,max_depth,open,InitDepth,SurDepth,Aponded,routing
102.5700000003,107.8089999994,j1,26.819,24.765,2.054,0,0,0,1,1
92.2600000016,132.0899999989,j2,26.865,25.025,1.84,0,0,0,1,1
74.620000001,173.3359999992,j3,27.967,26.195,1.772,0,0,0,1,1
63.5599999987,200.3439999986,j4,28.51,26.725,1.785,0,0,0,1,1
121.2600000016,58.5659999987,j5,27.349,24.685,2.664,0,0,0,1,1
85.9600000009,38.0549999988,j6,27.141,24.535,2.606,0,0,0,1,1
63.1000000015,11.2499999991,j7,27.338,24.505,2.833,0,0,0,1,1
86.4899999984,44.6329999994,j8,27.058,24.568,2.49,1,0,0,1,1
90.4499999993,40.2409999995,j9,27.104,24.56,2.544,1,0,0,1,1
126.1900000013,68.0589999994,j10,27.079,24.7385,2.3405,1,0,0,1,1
131.4400000013,63.1499999994,j11,27.314,24.7408,2.5732,1,0,0,1,1
90.4899999984,127.2689999994,j12,26.798,25.1207,1.6773,1,0,0,1,1
94.7100000009,129.2929999987,j13,26.647,25.1136,1.5334,1,0,0,1,1
x0,y0,name,elevation,inv_elev,max_depth,open,InitDepth,SurDepth,Aponded,routing
102.5700000003,107.8089999994,j1,26.819,24.765,2.054,0,0,0,1,1
92.2600000016,132.0899999989,j2,26.865,25.025,1.84,0,0,0,1,1
74.620000001,173.3359999992,j3,27.967,26.195,1.772,0,0,0,1,1
63.5599999987,200.3439999986,j4,28.51,26.725,1.785,0,0,0,1,1
121.2600000016,58.5659999987,j5,27.349,24.685,2.664,0,0,0,1,1
85.9600000009,38.0549999988,j6,27.141,24.535,2.606,0,0,0,1,1
63.1000000015,11.2499999991,j7,27.338,24.505,2.833,0,0,0,1,1
86.4899999984,44.6329999994,j8,27.058,24.568,2.49,1,0,0,1,1
90.4499999993,40.2409999995,j9,27.104,24.56,2.544,1,0,0,1,1
126.1900000013,68.0589999994,j10,27.079,24.7385,2.3405,1,0,0,1,1
131.4400000013,63.1499999994,j11,27.314,24.7408,2.5732,1,0,0,1,1
90.4899999984,127.2689999994,j12,26.798,25.1207,1.6773,1,0,0,1,1
94.7100000009,129.2929999987,j13,26.647,25.1136,1.5334,1,0,0,1,1
2 changes: 1 addition & 1 deletion demo_catchment/data/table_losses.csv
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Link,Kentry,Kexit,Kavg,Flap Gate,Seepage
Link,Kentry,Kexit,Kavg,Flap Gate,Seepage
2 changes: 1 addition & 1 deletion demo_catchment/data/table_raingages.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Gage,Format,Interval,SCF,Source ,Path,Station name,Units
STA01,VOLUME,00:01,1,FILE,"../../GisToSWMM5/demo_catchment/data/prec_mm.DAT",STA01,MM
STA01,VOLUME,00:01,1,FILE,"../../data/prec_mm.DAT",STA01,MM
2 changes: 1 addition & 1 deletion demo_catchment/data/table_temperature.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Temp/Wind/Snow,Source/Data, , , , , , , , , ,
FILE,"../../GisToSWMM5/demo_catchment/data/climate.DAT", , , , , , , , , ,
FILE,"../../data/climate.DAT", , , , , , , , , ,
WINDSPEED,FILE, , , , , , , , , ,
SNOWMELT,0.952966,0.45,0.66,15.1,60.243222,0, , , , ,
ADC IMPERVIOUS,1,1,1,1,1,1,1,1,1,1
8,125 changes: 4,063 additions & 4,062 deletions demo_catchment/out/SWMM_in/demo_catchment_adap.inp

Large diffs are not rendered by default.

190,531 changes: 95,266 additions & 95,265 deletions demo_catchment/out/SWMM_in/demo_catchment_rect.inp

Large diffs are not rendered by default.

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
PROJCS["ETRS89_GK25FIN",GEOGCS["GCS_ETRS_1989",DATUM["D_ETRS_1989",SPHEROID["GRS_1980",6378137,298.257222101]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",25],PARAMETER["scale_factor",1],PARAMETER["false_easting",25500000],PARAMETER["false_northing",0],UNIT["Meter",1]]
PROJCS["ETRS_1989_GK25FIN",GEOGCS["GCS_ETRS_1989",DATUM["D_ETRS_1989",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",25500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",25.0],PARAMETER["Scale_Factor",1.0],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
PROJCS["ETRS89_GK25FIN",GEOGCS["GCS_ETRS_1989",DATUM["D_ETRS_1989",SPHEROID["GRS_1980",6378137,298.257222101]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",25],PARAMETER["scale_factor",1],PARAMETER["false_easting",25500000],PARAMETER["false_northing",0],UNIT["Meter",1]]
PROJCS["ETRS_1989_GK25FIN",GEOGCS["GCS_ETRS_1989",DATUM["D_ETRS_1989",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",25500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",25.0],PARAMETER["Scale_Factor",1.0],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
PROJCS["ETRS89_GK25FIN",GEOGCS["GCS_ETRS_1989",DATUM["D_ETRS_1989",SPHEROID["GRS_1980",6378137,298.257222101]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",25],PARAMETER["scale_factor",1],PARAMETER["false_easting",25500000],PARAMETER["false_northing",0],UNIT["Meter",1]]
PROJCS["ETRS_1989_GK25FIN",GEOGCS["GCS_ETRS_1989",DATUM["D_ETRS_1989",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",25500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",25.0],PARAMETER["Scale_Factor",1.0],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
PROJCS["ETRS89_GK25FIN",GEOGCS["GCS_ETRS_1989",DATUM["D_ETRS_1989",SPHEROID["GRS_1980",6378137,298.257222101]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",25],PARAMETER["scale_factor",1],PARAMETER["false_easting",25500000],PARAMETER["false_northing",0],UNIT["Meter",1]]
PROJCS["ETRS_1989_GK25FIN",GEOGCS["GCS_ETRS_1989",DATUM["D_ETRS_1989",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",25500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",25.0],PARAMETER["Scale_Factor",1.0],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]
Binary file not shown.
20,221 changes: 10,114 additions & 10,107 deletions demo_catchment/out/SWMM_out/demo_catchment_adap.rpt

Large diffs are not rendered by default.

42,076 changes: 0 additions & 42,076 deletions demo_catchment/out/SWMM_out/demo_catchment_rect.rpt

Large diffs are not rendered by default.

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
PROJCS["ETRS89_GK25FIN",GEOGCS["GCS_ETRS_1989",DATUM["D_ETRS_1989",SPHEROID["GRS_1980",6378137,298.257222101]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",25],PARAMETER["scale_factor",1],PARAMETER["false_easting",25500000],PARAMETER["false_northing",0],UNIT["Meter",1]]
PROJCS["ETRS_1989_GK25FIN",GEOGCS["GCS_ETRS_1989",DATUM["D_ETRS_1989",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",25500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",25.0],PARAMETER["Scale_Factor",1.0],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]
Binary file not shown.
Binary file not shown.
17 changes: 17 additions & 0 deletions run_scripts/run_SWMM5
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/bash

# Test SWMM5 simulation
# This is an example script to run SWMM5 from command line
# Syntax:
# [PATH TO runswmm5] [PATH TO SWMM5 INPUT FILE (*.inp)] [PATH TO SWMM5 OUTPUT SUMMARY FILE (*.rpt)] [(OPTIONAL) PATH TO SWMM5 OUTPUT BINARY FILE (*.out)]


# Save only the summary (text) output file (*.rpt) with given time series at the end of the file
../../swmm/build/runswmm ../demo_catchment/out/SWMM_in/demo_catchment_adap.inp ../demo_catchment/out/SWMM_out/demo_catchment_adap.rpt

# Save the summary (text) output file (*.rpt) and the binary file (*.out) with detailed simulation results only in the binary file
../../swmm/build/runswmm ../demo_catchment/out/SWMM_in/demo_catchment_rect.inp ../demo_catchment/out/SWMM_out/demo_catchment_rect.rpt ../demo_catchment/out/SWMM_out/demo_catchment_rect.out




10 changes: 10 additions & 0 deletions run_scripts/run_inp2gis
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

# Extract subcatchment geometries and attributes from SWMM input (*.inp) file
# and save into shapefile.
# Syntax:
# python inp2gis.py [PATH TO *.inp FILE] 'EPSG:[XXXX]'

# Example of running inp2gis.py
python ../utils/inp2gis.py ../demo_catchment/out/SWMM_in/demo_catchment_rect.inp EPSG:3879

2 changes: 1 addition & 1 deletion utils/ExtractSubcatchmentResults.py
Original file line number Diff line number Diff line change
@@ -50,7 +50,7 @@
if idx == 4: # Read second line of column headers
subcatchment_headers_2 = row.split()
if idx == 5: # Read column units
subcatchment_units = re.split('\s{2,}', row.strip())
subcatchment_units = re.split(r'\s{2,}', row.strip())
if idx < 7: # Skip extra lines after header
continue
if row.isspace(): # Stop looking after empty line
8 changes: 4 additions & 4 deletions utils/adap2shp.py
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@
from rasterio.features import shapes
import sys

crs = {'init': 'epsg:4326'} # Default Coordinate Reference System
crs = 'epsg:4326' # Default Coordinate Reference System
# Check input parameters
if (len(sys.argv) < 4 or len(sys.argv) > 5):
print("Usage:\n"
@@ -50,7 +50,7 @@
""".shp FILE] 'EPSG:[XXXX]'""")
sys.exit(1)
else:
crs = {'init': sys.argv[4].lower()} # Custom CRS
crs = sys.argv[4].lower() # Custom CRS
print('Using ' + sys.argv[4].upper() +
' as Coordinate Reference System.')

@@ -68,12 +68,12 @@

# Create a GeoDataFrame from polygonized data
gdf = gpd.GeoDataFrame.from_features(geoms)
gdf.crs = crs
gdf = gdf.set_crs(crs)
gdf['id'] = gdf['id'].astype(int)
gdf = gdf[gdf['id'] > 0]

# Read in the attribute data
attr = pd.read_csv(sys.argv[2], ';')
attr = pd.read_csv(sys.argv[2], sep=';')
attr = attr.drop('wkt', axis=1)

# Join attribute tables
3 changes: 2 additions & 1 deletion utils/environment.yml
Original file line number Diff line number Diff line change
@@ -4,8 +4,9 @@ channels:
- conda-forge
- defaults
dependencies:
- python=3
- python>=3
- pandas
- geopandas
- shapely
- rasterio
- pyarrow
4 changes: 2 additions & 2 deletions utils/inp2gis.py
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@
import shapely.wkt


crs = {'init': 'epsg:4326'} # Default Coordinate Reference System
crs = 'epsg:4326' # Default Coordinate Reference System
# Check input parameters
if (len(sys.argv) < 2 or len(sys.argv) > 3):
print("Usage:\n"
@@ -39,7 +39,7 @@
"""$ python inp2gis.py [PATH TO *.inp FILE] 'EPSG:[XXXX]'""")
sys.exit()
else:
crs = {'init': sys.argv[2].lower()} # Custom CRS
crs = sys.argv[2].lower() # Custom CRS

subcatchment_data = []
landuse_data = []