swmmx Documentation

swmmx Documentation

A Python Toolkit for Building, Editing, Running, Importing, Visualizing, and Exporting EPA SWMM Models

swmmx provides one discoverable Python interface for the full EPA SWMM model lifecycle: open or create models, inspect and edit parameters, add and remove objects, run simulations, plot results, validate inputs, and exchange data with CSV, GIS, and Excel workflows.

Main Features

Open existing SWMM models
Create new SI or US models
Get and set model parameters
Count model objects
Add and remove elements
Import CSV and GIS data
Export CSV, GIS, and Excel files
Run SWMM simulations
Step through simulations with m.runs()
Plot layout maps
Plot result time series
Plot longitudinal profiles
Validate models
Preserve INP comments and unknown sections where possible
Use bundled Windows, Linux, and macOS engines
Provide custom engine paths

Quick Example

from swmmx import swmm

m = swmm("examples/example.inp")
m.plot_layout()
print(m.time.count())
lengths = m.get.conduit.length()
m.set.conduit.roughness(0.013)
m.run()
print(m.log())
m.plot_timeseries.link.flow()

Public API at a Glance

option_general

flow_units, infiltration_model, flow_routing, link_offsets, force_main_equation, allow_ponding, minimum_slope, skip_steady_state, system_flow_tolerance, lateral_flow_tolerance

option_process

ignore_rainfall, ignore_snowmelt, ignore_groundwater, ignore_rdii, ignore_routing, ignore_quality

option_date_time

start_date, start_time, end_date, end_time, report_start_date, report_start_time, report_step, wet_step, dry_step, routing_step, rule_step, sweep_start +2 more

option_dynamic_wave

inertial_damping, normal_flow_limited, surcharge_method, variable_step, minimum_step, lengthening_step, minimum_surface_area, head_tolerance, maximum_trials, threads

rain_gage

id, count, format, interval, snow_catch_factor, source_type, time_series, filename, station, units, rainfall

subcatchment

id, count, rain_gage, outlet, area, width, slope, impervious_percent, curb_length, snow_pack, tag, polygon +17 more

infiltration_horton

maximum_rate, minimum_rate, decay, dry_time, maximum_volume

infiltration_green_ampt

suction_head, hydraulic_conductivity, initial_moisture_deficit

infiltration_curve_number

curve_number, conductivity, dry_time

node

id, count, type, invert_elevation, max_depth, initial_depth, surcharge_depth, ponded_area, tag, coordinate, external_inflow, dry_weather_flow +9 more

junction

id, count, invert_elevation, max_depth, initial_depth, surcharge_depth, ponded_area

outfall

id, count, invert_elevation, type, fixed_stage, tidal_curve, time_series, tide_gate, route_to

flow_divider

id, count, invert_elevation, max_depth, initial_depth, surcharge_depth, ponded_area, type, diverted_link, cutoff_flow, diversion_curve, weir_height +1 more

storage_unit

id, count, invert_elevation, max_depth, initial_depth, storage_curve_type, storage_curve, area, area_coefficient, area_exponent, area_constant, evaporation_factor +1 more

link

id, count, type, from_node, to_node, inlet_offset, outlet_offset, initial_flow, maximum_flow, flap_gate, tag, vertices +7 more

conduit

id, count, from_node, to_node, length, roughness, inlet_offset, outlet_offset, initial_flow, maximum_flow, shape, geometry +18 more

pump

id, count, from_node, to_node, curve, initial_status, startup_depth, shutoff_depth, flow, status, setting, energy

orifice

id, count, from_node, to_node, type, shape, height, width, offset, discharge_coefficient, flap_gate, open_close_time +2 more

weir

id, count, from_node, to_node, type, crest_height, length, side_slope, discharge_coefficient, flap_gate, end_contractions, end_coefficient +5 more

outlet

id, count, from_node, to_node, offset, flap_gate, rating_type, curve, coefficient, exponent, flow, setting

cross_section

link, shape, geometry_1, geometry_2, geometry_3, geometry_4, barrels, culvert_code, height, width, side_slope, shape_curve

transect

id, count, roughness_left, roughness_right, roughness_channel, left_bank, right_bank, stations, elevations, modifiers

curve

id, count, type, x, y, points

coordinate

node_coordinates, subcatchment_coordinates, link_vertices, polygons, labels, map_dimensions, map_units

street

id, count, crown_width, curb_height, cross_slope, roughness, depression_storage, gutter_width, gutter_slope, spread

inlet

id, count, type, grate_length, grate_width, grate_type, curb_length, curb_height, slotted_length, slotted_width, captured_flow

inlet_usage

node, inlet, conduit, number, clogging_factor, flow_restriction

lid_control

id, count, type

lid_surface

storage_depth, vegetation_fraction, roughness, slope, side_slope

lid_pavement

thickness, void_ratio, impervious_surface_fraction, permeability, clogging_factor

lid_soil

thickness, porosity, field_capacity, wilting_point, conductivity, conductivity_slope, suction_head

lid_storage

height, void_ratio, seepage_rate, clogging_factor

lid_drain

coefficient, exponent, offset_height, delay, open_level, closed_level, control_curve

lid_usage

subcatchment, lid_control, number, area, width, initial_saturation, from_impervious_percent, from_pervious_percent, outlet, drain_to, inflow, evaporation +4 more

aquifer

id, count, porosity, wilting_point, field_capacity, conductivity, conductivity_slope, tension_slope, upper_evaporation_fraction, lower_evaporation_depth, lower_groundwater_loss_rate, bottom_elevation +3 more

groundwater

subcatchment, aquifer, node, surface_elevation, a1, b1, a2, b2, a3, fixed_depth, threshold_elevation, lateral_flow_equation +1 more

snow_pack

id, count, plowable_fraction, impervious_fraction, pervious_fraction, minimum_melt_coefficient, maximum_melt_coefficient, base_temperature, free_water_capacity_fraction, initial_snow_depth, initial_free_water, depth_at_100_percent_cover +7 more

climate

temperature_time_series, evaporation_type, evaporation_constant, evaporation_monthly, evaporation_time_series, evaporation_recovery_pattern, evaporation_dry_only, wind_speed_type, wind_speed_monthly, snowmelt_parameters, areal_depletion_impervious, areal_depletion_pervious

climate_adjustment

temperature, evaporation, rainfall, conductivity

pollutant

id, count, units, rain_concentration, groundwater_concentration, rdii_concentration, decay_coefficient, snow_only, co_pollutant, co_pollutant_fraction, dry_weather_flow_concentration, initial_concentration

land_use

id, count, sweeping_interval, sweeping_availability, last_swept

coverage

subcatchment, land_use, percent

loading

subcatchment, pollutant, initial_buildup

buildup

land_use, pollutant, function, maximum_buildup, rate_constant, power, normalizer

washoff

land_use, pollutant, function, coefficient, exponent, cleaning_efficiency, bmp_efficiency

treatment

node, pollutant, expression

time_series

id, count, datetime, values, filename, description

time_pattern

id, count, type, multipliers

external_inflow

node, constituent, time_series, type, units_factor, scale_factor, baseline, pattern

dry_weather_flow

node, constituent, average_value, monthly_pattern, daily_pattern, hourly_pattern, weekend_pattern

rdii

node, unit_hydrograph, sewer_area

unit_hydrograph

id, count, rain_gage, month, short_term_r, short_term_t, short_term_k, medium_term_r, medium_term_t, medium_term_k, long_term_r, long_term_t +1 more

control_rule

id, count, text, conditions, actions, priority, enabled, action_log

interface_file

rainfall, runoff, hotstart, rdii, inflow, outflow, use_file, save_file

system_result

air_temperature, rainfall, snow_depth, evaporation, infiltration, runoff, dry_weather_inflow, groundwater_inflow, rdii_inflow, direct_inflow, total_lateral_inflow, flooding +3 more

summary

model, counts, options, subcatchment_runoff, subcatchment_washoff, node_depth, node_inflow, node_flooding, node_surcharge, storage_volume, outfall_loading, link_flow +8 more