Closed RayLTL closed 2 years ago
@jennwuu Can u help me?
Hello @RayLTL,
Thanks for using pyswmm. What version of swmm5.exe are you using?
Can you try the following code snippet instead?
from pyswmm import Simulation
inpfile = './data/Example1.inp'
with Simulation(inpfile) as sim:
for step in sim:
print(sim.current_time)
Alternatively, you can try following this tutorial: https://medium.com/@wuu.jennifer/pyswmm-tutorial-how-to-install-and-to-start-using-pyswmm-2fddb99ee327
@jennwuu Thanks for ur reply,The version of swmm5.exe is 5.1.012. I tried ur code and get the same result. I want to get output file and use swmmtoolbox read the result But when I read the output of pyswmm , there is no "subcatchment、node、link"
Here is my code :
from swmmtoolbox import swmmtoolbox as sw
pyswmm_binfile = './data/Example1.out'
swmm5_binfile = './data/Example1_swmm5.out'
f_pyswmm = sw.SwmmExtract(pyswmm_binfile)
f_swmm5 = sw.SwmmExtract(swmm5_binfile)
type_dic = dict(zip(range(len(f_pyswmm.itemlist)), f_pyswmm.itemlist))
print(type_dic)
print(f_pyswmm.names)
print(f_swmm5.names)
The results type_dict:
{0: 'subcatchment', 1: 'node', 2: 'link', 3: 'pollutant', 4: 'system'}
The result of pyswmm outfile:
{0: [], 1: [], 2: [], 3: ['TSS', 'Lead'], 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']}
The sesult of swmm5.exe outfile
{0: ['1', '2', '3', '4', '5', '6', '7', '8'], 1: ['9', '10', '13', '14', '15', '16', '17', '19', '20', '21', '22', '23', '24', '18'], 2: ['1', '4', '5', '6', '7', '8', '10', '11', '12', '13', '14', '15', '16'], 3: ['TSS', 'Lead'], 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']}
@RayLTL Can you share the text output when you try the code snippet above? Can you confirm your pyswmm and swm-toolkit version as well?
@jennwuu
version:
swmmtoolbox==3.3.5
pyswmm==1.0.1
Files:
Example1.zip
@RayLTL Can you share the Example1.inp as well. I would like to test locally.
@jennwuu Example1_inp.zip
@RayLTL
This seems to work for me. What results are you expecting with swmmtoolbox? I also get 3kb with both pyswmm and pcswmm (swmm 5.1.015)
from pyswmm import Simulation
from swmmtoolbox import swmmtoolbox as sw
swmm_input = 'Example1.inp'
with Simulation(swmm_input) as sim:
# run simulation
for step in sim:
pass
# exit simulation object
# open with swmmtoolbox
pyswmm_binfile = swmm_input.replace('.inp', '.out')
f_pyswmm = sw.SwmmExtract(pyswmm_binfile)
type_dic = dict(zip(range(len(f_pyswmm.itemlist)), f_pyswmm.itemlist))
print(type_dic)
print(f_pyswmm.names)
@jennwuu can u show ur result of f_pyswmm.names , I dont know why there is no "subcatchment、node、link".
I want to use swmmtoolbox to analysis,for example , use machine learning to predict the trend of the data.
Just an idea.
First , need the data of results.
@RayLTL I tried opening the .inp file you provided in PCSWMM and I can't seem to open the file. Can you confirm if you are able to open it in EPASWMM?
For example, if you try the code snippet above using a different .inp file you will get swmm object names. See the attached .inp file. model_pollutants.zip
{0: 'subcatchment', 1: 'node', 2: 'link', 3: 'pollutant', 4: 'system'}
{0: ['S1', 'S2', 'S3'], 1: ['J1', 'J2', 'J3', 'J4', 'Out1'], 2: ['C1', 'C2', 'C3', 'C4'], 3: ['test-pollutant'], 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']}
@RayLTL I tried opening the .inp file you provided in PCSWMM and I can't seem to open the file. Can you confirm if you are able to open it in EPASWMM?
Can u send me ur example inp file in ur PCSWMM? The .rpt file of pyswmm contains "subcatchment、node、link" summary, but .out file not have. There is something strange.
@RayLTL See the attached model from the previous post.
Can you try to running Example1.inp with swmm engine 5.1.015?
@jennwuu I use ur model_pollutants.inp by pyswmm and swmm.exe . I get the same results and the size of .out file is both 40.1KB.
swmm5_binfile = './data/swmm5_model_pollutants.out'
pyswmm_binfile = './data/model_pollutants.out'
f_pyswmm = sw.SwmmExtract(pyswmm_binfile)
f_swmm5 = sw.SwmmExtract(swmm5_binfile)
type_dic = dict(zip(range(len(f_pyswmm.itemlist)), f_pyswmm.itemlist))
print(type_dic)
print(f_pyswmm.names)
print(f_swmm5.names)
Example1.inp might be limited to swmm 5.1.012 due to formatting issues in the .inp file.
On Wed, Dec 22, 2021 at 12:53 AM RayLTL @.***> wrote:
@jennwuu https://github.com/jennwuu I use ur model_pollutants.inp by pyswmm and swmm.exe . I get the same results and the size of .out file is both 40.1KB.
swmm5_binfile = './data/swmm5_model_pollutants.out' pyswmm_binfile = './data/model_pollutants.out' f_pyswmm = sw.SwmmExtract(pyswmm_binfile) f_swmm5 = sw.SwmmExtract(swmm5_binfile) type_dic = dict(zip(range(len(f_pyswmm.itemlist)), f_pyswmm.itemlist)) print(type_dic) print(f_pyswmm.names) print(f_swmm5.names)
model_pollutants_output.zip https://github.com/OpenWaterAnalytics/pyswmm/files/7760296/model_pollutants_output.zip
— Reply to this email directly, view it on GitHub https://github.com/OpenWaterAnalytics/pyswmm/issues/307#issuecomment-999306283, or unsubscribe https://github.com/notifications/unsubscribe-auth/AG32G7FKQE7KZ7VIQRWU46LUSFRWNANCNFSM5KRP6V6Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you were mentioned.Message ID: @.***>
@jennwuu I use EPA SWMM 5.1.015 run Example1.inp,here is result: Example1_out_EPA SWMM 5.1.015.zip
epaswmm_binfile = './data/Example1_epaswmm.out'
f_epaswmm = sw.SwmmExtract(epaswmm_binfile)
type_dic = dict(zip(range(len(f_epaswmm.itemlist)), f_epaswmm.itemlist))
print(type_dic)
print(f_epaswmm.names)
The results is same as swmm 5.1.012 PS:size is same too. 44.2KB
{0: ['1', '2', '3', '4', '5', '6', '7', '8'], 1: ['9', '10', '13', '14', '15', '16', '17', '19', '20', '21', '22', '23', '24', '18'], 2: ['1', '4', '5', '6', '7', '8', '10', '11', '12', '13', '14', '15', '16'], 3: ['TSS', 'Lead'], 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']}
@jennwuu https://www.epa.gov/water-research/storm-water-management-model-swmm If ur free , maybe u can download the Self-Extracting Installation Program for SWMM 5.1.015 (exe) to run Example1.inp
Hi @RayLTL I tried running Example1.inp provided with SWMM 5.1.015.exe and I run into errors.
... EPA-SWMM 5.1 (Build 5.1.15)
Cannot open report file
... EPA-SWMM completed in 0.00 seconds. There are errors.
I will note that the example1.inp as distributed by the EPA does run in any version of EPA SWMM
Example 1
NOTE: The summary statistics displayed in this report are
based on results found at every computational time step,
not just on results from each reporting time step.
Analysis Options
Flow Units ............... CFS Process Models: Rainfall/Runoff ........ YES RDII ................... NO Snowmelt ............... NO Groundwater ............ NO Flow Routing ........... YES Ponding Allowed ........ NO Water Quality .......... YES Infiltration Method ...... HORTON Flow Routing Method ...... KINWAVE Starting Date ............ 01/01/1998 00:00:00 Ending Date .............. 01/02/1998 12:00:00 Antecedent Dry Days ...... 5.0 Report Time Step ......... 01:00:00 Wet Time Step ............ 00:15:00 Dry Time Step ............ 01:00:00 Routing Time Step ........ 60.00 sec
@dickinsonre Thank you for checking. I wonder why I can't get swmm.exe or pyswmm to run for example1.inp.
Edit: I was having issues because of permission issues. Verified that Example1.inp works when using swmm engine.
Hi @RayLTL
You need to include the following parameters in your [REPORT] section in your .inp file to export timeseries to .out file.
[REPORT]
SUBCATCHMENTS ALL
NODES ALL
LINKS ALL
Once you have these parameters, your .out should be the same size as swmm engine. Let me know if it still doesn't work.
Also if you're looking for timeseries from model objects, I would recommend getting the data directly from pyswmm. There is an example in https://github.com/OpenWaterAnalytics/pyswmm/issues/299.
@jennwuu I add parameters you provide, and it works! Thanks, but do you know why ? I know pyswmm can get the data, but if I dont know the names of the Subcatchaments、Nodes、Links, it will be inconvenient for me . That's why I use swmmtoolbox. I'm not major in Hydroinformatics, just a fresh man.If there are something misunderstanding, you can point out.
Hi @RayLTL glad it works. The parameters indicate that you are saving results for subcatchments, nodes, and links.
See the screenshot from regarding report section from SWMM manual above: https://www.epa.gov/sites/default/files/2019-02/documents/epaswmm5_1_manual_master_8-2-15.pdf
@jennwuu Why it provide all results after simulation by swmm5.exe or EPA SWMM 5.1.015 without these parameters?
Hmmm, I'm not sure about that. Any ideas @dickinsonre or @michaeltryby?
Closing due to inactivity.
I use Example1.inp to simulate,here is my code :
after run this code , I get the output file Example1.out (size:2.8KB)
But when I use swmm5.exe and run this inpfile I get the output file Example1.out (size:44.2KB)