swmmio Core Objects¶
-
class
swmmio.core.
Model
(in_file_path, crs=None, include_rpt=True)[source]¶ Bases:
object
Class representing a complete SWMM model incorporating its INP and RPT files and data
initialize a swmmio.Model object by pointing it to a directory containing a single INP (and optionally an RPT file with matching filename) or by pointing it directly to an .inp file.
>>> # initialize a model object by passing the path to an INP file >>> from swmmio.tests.data import MODEL_FULL_FEATURES_XY >>> m = Model(MODEL_FULL_FEATURES_XY) >>> # access sections of inp via the Model.inp object >>> m.inp.junctions InvertElev MaxDepth InitDepth SurchargeDepth PondedArea Name J3 6.547 15 0 0 0 1 17.000 0 0 0 0 2 17.000 0 0 0 0 3 16.500 0 0 0 0 4 16.000 0 0 0 0 5 15.000 0 0 0 0 J2 13.000 15 0 0 0 >>> m.inp.coordinates X Y Name J3 2748073.306 1117746.087 1 2746913.127 1118559.809 2 2747728.148 1118449.164 3 2747242.131 1118656.381 4 2747345.325 1118499.807 5 2747386.555 1118362.817 J2 2747514.212 1118016.207 J4 2748515.571 1117763.466 J1 2747402.678 1118092.704
Access composite sections of the model that merge together sensible sections of the inp into one dataframe. The Model.links.dataframe section, for example, returns a dataframe containing PUMPS, CONDUITS, WEIRS, and ORIFICES joined with XSECTIONS, COORDINATES and the Link Flow Summary (if there is an rpt file found).
>>> m.links.dataframe[['InletNode', 'OutletNode', 'Length', 'Roughness', 'Geom1']] InletNode OutletNode Length Roughness Geom1 Name C1:C2 J1 J2 244.63 0.01 1.0 C2.1 J2 J3 666.00 0.01 1.0 1:4 1 4 400.00 0.01 1.0 4:5 4 5 400.00 0.01 1.0 5:J1 5 J1 400.00 0.01 1.0 3:4 3 4 400.00 0.01 1.0 2:5 2 5 400.00 0.01 1.0 C3 J3 J4 NaN NaN 5.0 C2 J2 J3 NaN NaN NaN >>> # return all conduits (drop coords for clarity) >>> from swmmio.examples import jersey >>> jersey.nodes.dataframe[['InvertElev', 'MaxDepth', 'InitDepth', 'SurchargeDepth', 'PondedArea']] InvertElev MaxDepth InitDepth SurchargeDepth PondedArea Name J3 6.547 15.0 0.0 0.0 0.0 1 17.000 0.0 0.0 0.0 0.0 2 17.000 0.0 0.0 0.0 0.0 3 16.500 0.0 0.0 0.0 0.0 4 16.000 0.0 0.0 0.0 0.0 5 15.000 0.0 0.0 0.0 0.0 J2 13.000 15.0 0.0 0.0 0.0 J4 0.000 NaN NaN NaN NaN J1 13.392 NaN 0.0 NaN 0.0
-
conduits
()[source]¶ collect all useful and available data related model conduits and organize in one dataframe.
-
export_to_shapefile
(shpdir, prj=None)[source]¶ export the model data into a shapefile. element_type dictates which type of data will be included.
default projection is PA State Plane - untested on other cases
-
property
links
¶ Create a DataFrame containing all link objects in the model including conduits, pumps, weirs, and orifices.
- Returns:
dataframe containing all link objects in the model
- Return type:
pd.DataFrame
>>> from swmmio.examples import philly >>> philly.links.dataframe.loc['J1-025.1'] InletNode J1-025 OutletNode J1-026 Length 309.456216 Roughness 0.014 InOffset 0 OutOffset 0.0 InitFlow 0 MaxFlow 0 Shape CIRCULAR Geom1 1.25 Geom2 0 Geom3 0 Geom4 0 Barrels 1 coords [(2746229.223, 1118867.764), (2746461.473, 1118663.257)] Name: J1-025.1, dtype: object
-
property
network
¶ Networkx MultiDiGraph representation of the model
- Returns:
Networkx MultiDiGraph representation of model
- Return type:
networkx.MultiDiGraph
-
property
nodes
¶ Collect all useful and available data related model nodes and organize in one dataframe.
- Returns:
dataframe containing all node objects in the model
- Return type:
pd.DataFrame
>>> from swmmio.examples import jersey >>> jersey.nodes.dataframe['InvertElev'] Name J3 6.547 1 17.000 2 17.000 3 16.500 4 16.000 5 15.000 J2 13.000 J4 0.000 J1 13.392 Name: InvertElev, dtype: float64
-
property
orifices
¶ collect all useful and available data related model orifices and organize in one dataframe.
-
property
pumps
¶ Collect all useful and available data related model pumps and organize in one dataframe.
- Returns:
dataframe containing all pumps objects in the model
- Return type:
pd.DataFrame
>>> import swmmio >>> from swmmio.tests.data import MODEL_FULL_FEATURES_XY >>> model = swmmio.Model(MODEL_FULL_FEATURES_XY) >>> pumps = model.pumps.dataframe >>> pumps[['PumpCurve', 'InitStatus']] PumpCurve InitStatus Name C2 P1_Curve ON
-
rpt_is_valid
(verbose=False)[source]¶ Return true if the .rpt file exists and has a revision date more recent than the .inp file. If the inp has an modified date later than the rpt, assume that the rpt should be regenerated
-
property
subcatchments
¶ collect all useful and available data related subcatchments and organize in one dataframe.
-
property
summary
¶
-
to_crs
(*args, **kwargs)[source]¶ Convert coordinate reference system of the model coordinates
- Parameters:
target_crs – coordinate reference system to reproject
- Returns:
True
>>> import swmmio >>> m = swmmio.Model(MODEL_FULL_FEATURES_XY, crs="EPSG:2272") >>> m.to_crs("EPSG:4326") # convert to WGS84 web mercator >>> m.inp.coordinates.round(5) X Y Name J3 -74.86642 42.36596 1 -74.87061 42.36829 2 -74.86762 42.36792 3 -74.86939 42.36853 4 -74.86902 42.36809 5 -74.86889 42.36771 J2 -74.86846 42.36675 J4 -74.86479 42.36597 J1 -74.86886 42.36697 >>> m.inp.vertices.round(5) X Y Name C1:C2 -74.86870 42.36683 C2.1 -74.86803 42.36627 C2.1 -74.86731 42.36597
-
to_geojson
(target_path=None)[source]¶ Return a GeoJSON representation of the entire model :param target_path: target path of geojson (optional) :return: GeoJSON representation of model
-
property
weirs
¶ collect all useful and available data related model weirs and organize in one dataframe.
-
-
class
swmmio.core.
inp
(file_path)[source]¶ Bases:
swmmio.core.SWMMIOFile
-
property
aquifers
¶ Get/set the aquifers section of the INP file.
>>> from swmmio.examples import groundwater >>> groundwater.inp.aquifers.loc['1'] Por 0.500 WP 0.150 FC 0.300 Ksat 0.100 Kslope 12.000 Tslope 15.000 ETu 0.350 ETs 14.000 Seep 0.002 Ebot 0.000 Egw 3.500 Umc 0.400 Name: 1, dtype: float64
-
property
buildup
¶ Get/set buildup section of the INP file.
Examples:
>>> from swmmio.examples import walnut >>> walnut.inp.buildup[['Pollutant', 'Function', 'Normalizer']] Pollutant Function Normalizer LandUse Residential Lead NONE AREA Residential TSS SAT AREA Undeveloped Lead NONE AREA Undeveloped TSS SAT AREA
-
property
conduits
¶ Get/set conduits section of the INP file.
- Returns:
Conduits section of the INP file
- Return type:
pandas.DataFrame
Examples:
>>> import swmmio >>> from swmmio.tests.data import MODEL_FULL_FEATURES__NET_PATH >>> model = swmmio.Model(MODEL_FULL_FEATURES__NET_PATH) >>> model.inp.conduits[['InletNode', 'OutletNode', 'Length', 'Roughness']] InletNode OutletNode Length Roughness Name C1:C2 J1 J2 244.63 0.01 C2.1 J2 J3 666.00 0.01 1 1 4 400.00 0.01 2 4 5 400.00 0.01 3 5 J1 400.00 0.01 4 3 4 400.00 0.01 5 2 5 400.00 0.01
-
property
coordinates
¶ Get/set coordinates section of model :return: dataframe of model coordinates
-
property
coverages
¶ Get/set coverages section of the INP file.
Examples:
>>> from swmmio.examples import walnut >>> walnut.inp.coverages LandUse Percent Subcatchment 1 Residential 100.0 2 Residential 50.0 2 Undeveloped 50.0 3 Residential 100.0 4 Residential 50.0 4 Undeveloped 50.0 5 Residential 100.0 6 Undeveloped 100.0 7 Undeveloped 100.0 8 Undeveloped 100.0
-
property
curves
¶ get/set curves section of model :return: multi-index dataframe of model curves
-
property
dividers
¶ Get/set dividers section of the INP file.
- Returns:
dividers section of the INP file
- Return type:
pandas.DataFrame
>>> from swmmio.examples import spruce >>> spruce.inp.dividers Elevation Diverted Link Type Parameters Name NODE5 3.0 C6 CUTOFF 1.0
-
property
dwf
¶ Get/set DWF section of model :return: dataframe of model DWF section
-
property
evaporation
¶ get/set evaporation section of model
- Returns:
dataframe of evaporation section in inp file
Examples:
>>> from swmmio.examples import walnut >>> walnut.inp.evaporation Value Key CONSTANT 0.0 DRY_ONLY NO
-
property
files
¶ Get/set files section of the INP file.
- Returns:
files section of the INP file
- Return type:
pandas.DataFrame
-
property
groundwater
¶ Get/set the groundwater section of the INP file.
>>> from swmmio.examples import groundwater >>> groundwater.inp.groundwater.loc['1'] Aquifer 1.0 Node 2.0 Esurf 6.0 A1 0.1 B1 1.0 A2 0.0 B2 0.0 A3 0.0 Dsw 0.0 Egwt 4.0 Name: 1, dtype: float64
-
property
headers
¶ Return all headers and associated column names found in the INP file.
-
property
hydrographs
¶ Get/set hydrographs section of the INP file.
Examples:
>>> from swmmio.examples import walnut >>> walnut.inp.hydrographs RainGage/Month Hydrograph Hydrograph1 TS1
-
property
infiltration
¶ Get/set infiltration section of the INP file.
>>> import swmmio >>> from swmmio.tests.data import MODEL_FULL_FEATURES__NET_PATH >>> m = swmmio.Model(MODEL_FULL_FEATURES__NET_PATH) >>> m.inp.infiltration MaxRate MinRate Decay DryTime MaxInfil Subcatchment S1 3.0 0.5 4 7 0 S2 3.0 0.5 4 7 0 S3 3.0 0.5 4 7 0 S4 3.0 0.5 4 7 0
-
property
inflows
¶ Get/set inflows section of model
- Returns:
dataframe of nodes with inflows
>>> from swmmio.examples import jersey >>> jersey.inp.inflows[['Constituent', 'Mfactor', 'Baseline']] Constituent Mfactor Baseline Node J3 Flow 1.0 1 J2 FLOW 1.0 1 J1 FLOW 1.0 1
-
property
inlet_usage
¶ Get/set inlet usage section of the INP file.
pandas.DataFrame
Access the inlet usage section of the inp file
>>> from swmmio.examples import streets >>> streets.inp.inlet_usage[['Inlet', 'Node', 'Number', '%Clogged']] Inlet Node Number %Clogged Link Street1 ComboInlet J1 1 50 Street3 ComboInlet J2a 1 0 Street4 ComboInlet J2 1 0 Street5 ComboInlet J11 2 0
-
property
inlets
¶ Get/set inlets section of the INP file.
pandas.DataFrame
Access the inlets section of the inp file
>>> from swmmio.examples import streets >>> streets.inp.inlets Type Param1 Param2 Param3 Name ComboInlet GRATE 2 2.0 P_BAR-50 ComboInlet CURB 2 0.5 HORIZONTAL
-
property
junctions
¶ Get/set junctions section of the INP file.
- Returns:
junctions section of the INP file
- Return type:
pandas.DataFrame
Examples:
>>> import swmmio >>> from swmmio.tests.data import MODEL_FULL_FEATURES__NET_PATH >>> model = swmmio.Model(MODEL_FULL_FEATURES__NET_PATH) >>> model.inp.junctions InvertElev MaxDepth InitDepth SurchargeDepth PondedArea Name J3 6.547 15 0 0 0 1 17.000 0 0 0 0 2 17.000 0 0 0 0 3 16.500 0 0 0 0 4 16.000 0 0 0 0 5 15.000 0 0 0 0 J2 13.000 15 0 0 0
-
property
landuses
¶ Get/set landuses section of the INP file.
Examples:
>>> from swmmio.examples import walnut >>> walnut.inp.landuses CleaningInterval FractionAvailable LastCleaned Name Residential 0 0 0 Undeveloped 0 0 0
-
property
lid_usage
¶ Get/set LID_USAGE section of the INP file.
-
property
loadings
¶ Get/set loadings section of the INP file.
-
property
losses
¶ get/set losses section of model
- Returns:
dataframe of evaporation section in inp file
>>> from swmmio.examples import spruce >>> spruce.inp.losses Inlet Outlet Average Flap Gate SeepageRate Link C1:C2 0 0 0 YES 0 C2.1 0 0 0 YES 0
-
property
options
¶ Get/set options section of the INP file.
- Returns:
options section of the INP file
- Return type:
pandas.DataFrame
>>> import swmmio >>> from swmmio.tests.data import MODEL_FULL_FEATURES_XY >>> model = swmmio.Model(MODEL_FULL_FEATURES_XY) >>> model.inp.options.loc['INFILTRATION'] Value HORTON Name: INFILTRATION, dtype: object >>> model.inp.headers['[INFILTRATION]'] ['Subcatchment', 'MaxRate', 'MinRate', 'Decay', 'DryTime', 'MaxInfil'] >>> model.inp.options.loc['INFILTRATION', 'Value'] = 'GREEN_AMPT' >>> model.inp.headers['[INFILTRATION]'] ['Subcatchment', 'Suction', 'HydCon', 'IMDmax', 'Param4', 'Param5']
-
property
orifices
¶ Get/set orifices section of the INP file.
-
property
outfalls
¶ Get/set outfalls section of the INP file.
- Returns:
outfalls section of the INP file
- Return type:
pandas.DataFrame
Examples:
>>> import swmmio >>> from swmmio.tests.data import MODEL_FULL_FEATURES__NET_PATH >>> model = swmmio.Model(MODEL_FULL_FEATURES__NET_PATH) >>> model.inp.outfalls InvertElev OutfallType StageOrTimeseries Name J4 0 FREE NO
-
property
pollutants
¶ get/set pollutants section of model
- Returns:
dataframe of pollutants section in inp file
Examples: The walnut example model contains two entries in the POLLUTANTS section, one of which is TSS. Below we show how to retrieve this information, by accessing the TSS index of the pollutants dataframe:
>>> from swmmio.examples import walnut >>> walnut.inp.pollutants.loc['TSS'] MassUnits MG/L RainConcen 0.0 GWConcen 0.0 I&IConcen 0 DecayCoeff 0.0 SnowOnly NO CoPollutName * CoPollutFraction 0.0 DWFConcen 0 InitConcen 0 Name: TSS, dtype: object
-
property
polygons
¶ get/set polygons section of model :return: dataframe of model coordinates
-
property
pumps
¶ Get/set pumps section of the INP file.
-
property
raingages
¶ get/set raingages section of model
- Returns:
dataframe of raingages in the model
Examples:
>>> from swmmio.examples import philly >>> philly.inp.raingages RainType TimeIntrvl SnowCatch DataSource DataSourceName Name RG1 INTENSITY 1:00 1.0 TIMESERIES design-storm
-
property
rdii
¶ Get/set RDII section of the INP file.
Examples:
>>> from swmmio.examples import walnut >>> walnut.inp.rdii UnitHydrograph SewerArea Node 13 Hydrograph1 58.944186 14 Hydrograph1 58.944186
-
property
report
¶ Get/set report section of the INP file.
- Returns:
report section of the INP file
- Return type:
pandas.DataFrame
>>> from swmmio.examples import jersey >>> jersey.inp.report Status Param INPUT YES CONTROLS YES SUBCATCHMENTS NONE NODES ALL LINKS NONE
-
save
(target_path=None)[source]¶ Save the inp file to disk. File will be overwritten unless a target_path is provided
- Parameters:
target_path – optional path to new inp file
- Returns:
None
>>> from swmmio.examples import philly >>> philly.inp.save('copy-of-philly.inp')
-
property
storage
¶ Get/set storage section of the INP file.
- Returns:
storage section of the INP file
- Return type:
pandas.DataFrame
Examples:
-
property
streets
¶ Get/set streets section of the INP file.
pandas.DataFrame
Access the streets section of the inp file
>>> from swmmio.examples import streets >>> streets.inp.streets[['Tcrown', 'Hcurb']] Tcrown Hcurb Name HalfStreet 20 0.5 FullStreet 20 0.5
-
property
subareas
¶ Get/set subareas section of the INP file.
-
property
subcatchments
¶ Get/set subcatchments section of the INP file.
- Returns:
subcatchments section of the INP file
- Return type:
pandas.DataFrame
Examples:
Get/set tags section of the INP file.
-
property
timeseries
¶ get/set timeseries section of model :return: multi-index dataframe of model curves
-
property
vertices
¶ get/set vertices section of model :return: dataframe of model coordinates
-
property
washoff
¶ Get/set washoff section of the INP file.
Examples:
>>> from swmmio.examples import walnut >>> walnut.inp.washoff[['Pollutant', 'Function']] Pollutant Function LandUse Residential Lead EMC Residential TSS EXP Undeveloped Lead EMC Undeveloped TSS EXP
-
property
weirs
¶ Get/set weirs section of the INP file.
-
property
xsections
¶ Get/set pumps section of the INP file.
-
property
-
class
swmmio.core.
rpt
(filePath)[source]¶ Bases:
swmmio.core.SWMMIOFile
An accessible SWMM .rpt object
>>> from swmmio.tests.data import RPT_FULL_FEATURES >>> report = rpt(RPT_FULL_FEATURES) >>> report.link_flow_summary.loc['C1:C2'] Type CONDUIT MaxQ 2.45 MaxDay 0 MaxHr 10:19 MaxV 6.23 MaxQPerc 1.32 MaxDPerc 0.5 Name: C1:C2, dtype: object
-
property
cross_section_summary
¶ Return values for the Cross Section Summary description
-
property
headers
¶ Return all section headers and associated column names found in the RPT file.
-
property
link_flow_summary
¶ Return values for the Link Flow Summary description
-
property
link_results
¶ Return values for the Link Results description
-
property
link_summary
¶ Return values for the Link Summary description
-
property
node_depth_summary
¶ Return values for the Node Depth Summary description
-
property
node_flooding_summary
¶ Return values for the Node Flooding Summary description
-
property
node_inflow_summary
¶ Return values for the Node Inflow Summary description
-
property
node_results
¶ Return values for the Node Results description
-
property
node_summary
¶ Return values for the Node Summary description
-
property
node_surcharge_summary
¶ Return values for the Node Surcharge Summary description
-
property
storage_volume_summary
¶ Return values for the Storage Volume Summary description
-
property
subcatchment_results
¶ Return values for the Subcatchment Results description
-
property
subcatchment_runoff_summary
¶ Return values for the Subcatchment Runoff Summary description
-
property
subcatchment_summary
¶ Return values for the Subcatchment Summary description
-
property