timcera / swmmtoolbox

Command line script and Python package to read time-series from the Storm Water Management Model (SWMM) binary output.
BSD 3-Clause "New" or "Revised" License
17 stars 7 forks source link

Accessing System Data via swmmtoolbox.extract #4

Closed gregjewi closed 2 years ago

gregjewi commented 6 years ago

What is the format to extract system data using swmmtoolbox.extract()? I tried looking at docs, but didn't find any thing. My point of confusion is what to include in the second argument for example,

'system, __ , 12'

Thanks, -G

timcera commented 6 years ago

You should be able to get all available named time series by using "listvariables":

swmmtoolbox listvariables frutal.out 

Kindest regards, Tim

mdbartos commented 6 years ago

It took me a little while to figure out the proper syntax for getting the system variables. I ultimately figured it out by looking at the SwmmExtract class:

>>> swmmextract = swmmtoolbox.SwmmExtract(filename)
>>> swmmextract.names[4]
['Air_temperature',
 'Rainfall',
 'Snow_depth',
 'Evaporation_infiltration',
 'Runoff',
 'Dry_weather_inflow',
 'Groundwater_inflow',
 'RDII_inflow',
 'User_direct_inflow',
 'Total_lateral_inflow',
 'Flow_lost_to_flooding',
 'Flow_leaving_outfalls',
 'Volume_stored_water',
 'Evaporation_rate',
 'Potential_PET']

So, if you want the system outflow:

outflow = swmmtoolbox.extract(filename, 'system,Flow_leaving_outfalls,11')

Note that this is different from all the other extract calls, where the asset name corresponds to some physical asset in the model (e.g. extract(filename, 'nodes,C64,1') corresponds to node C64); hence, the confusion.

Also, note that the following call, for instance, returns all zeros:

outflow = swmmtoolbox.extract(filename, 'system,Flow_leaving_outfalls,1')

This should probably raise an error instead.

Thanks, MDB

timcera commented 2 years ago

I set it up so that you now use:

outflow = swmmtoolbox.extract(filename, 'system,Flow_leaving_outfalls,Flow_leaving_outfalls')

Not ideal, since it is just a replication of the second entry, but require three entries everywhere else. Matches what you get from "swmmtoolbox.catalog(...)" which should always be the reference of what is in the output files.