SWMM Binary Output Reader - Python Wrapper for SWMM
This package provides a Pythonic interface to a binary output file generated by USEPA Stormwater Management Model (SWMM5). This tool has proven to be useful in post-processing applications with both large and small output files. The Python wrapper (SWMMOutputAPI.swmmbinreader) calls on a compiled object library which handles seeking though the binary output file. Taking this approach increases the rate at which data can be read from a binary output file. With a simpler collection of tools to access binary output, the user can spend more time on data analysis, visualization, and prototyping than plumbing.
pip install SWMMOutputAPI
from swmmbinreader import *
#Create and instance of SWMMBinReader
OutputObject = SWMMBinReader()
#Open Outputfile
OutputObject.OpenBinFile(r"C:\PROJECTCODE\SWMMOutputAPI\testing\outputfile.out")
#Get Link IDs
LinkIDs = OutputObject.get_IDs(SM_link)
print(LinkIDs)
>>> ['C3', 'C2', 'C1']
#Get Time Series
Times = OutputObject.get_TimeSeries()
print(Times)
>>> [datetime.datetime(2015, 11, 29, 14, 0), datetime.datetime(2015, 11, 29, 14, 1), ..., datetime.datetime(2015, 11, 29, 14, 9)]
#Get Data Series
Series = OutputObject.get_Series(SM_link, flow_rate_link, 'C2')
print(series)
>>> [3.908519983291626, 4.6215434074401855, 4.594745635986328, 4.595311641693115, ..., 4.595311641693115]
#Close Binary File
OutputObject.CloseBinFile()