Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

model.inp.infiltration yielding IndexError: list index out of range #130

Closed
lassiterdc opened this issue Apr 22, 2022 · 6 comments · Fixed by #137
Closed

model.inp.infiltration yielding IndexError: list index out of range #130

lassiterdc opened this issue Apr 22, 2022 · 6 comments · Fixed by #137

Comments

@lassiterdc
Copy link

lassiterdc commented Apr 22, 2022

Hello, the title pretty much says it all.

Reproducible example:
download link for swmm model

import swmmio
inp_path = "model.inp"
mymodel = swmmio.Model(inp_path)
infiltration = mymodel.inp.infiltration

and here's the output:

failed to parse infiltration with cols: ['Subcatchment', 'Suction', 'HydCon', 'IMDmax']. head:
[INFILTRATION]


S10              4.33       0.43       0.368      0          0         
S11              4.33       0.43       0.368      0          0         
S116_2           4.33       0.43       0.368      0          0         
S116_3           4.33       0.43       0.368      0          0         
S12              4.33       0.43       0.368      0          0         
S13              4.33       0.43       0.368      0          0         
S14              4.33       0.43       0.368      0
Traceback (most recent call last):

  File "C:\Users\Daniel\anaconda3\envs\SYS6582Uncrtnty\lib\site-packages\spyder_kernels\py3compat.py", line 356, in compat_exec
    exec(code, globals, locals)

  File "c:\users\daniel\dropbox\_gradschool\courses\sys6582\assignments\final_project\reprex\2022-4-22_swmmio_infiltrationparams\reprex.py", line 4, in <module>
    infiltration = mymodel.inp.infiltration

  File "C:\Users\Daniel\anaconda3\envs\SYS6582Uncrtnty\lib\site-packages\swmmio\core.py", line 860, in infiltration
    self._infiltration_df = dataframe_from_inp(self.path, "infiltration")

  File "C:\Users\Daniel\anaconda3\envs\SYS6582Uncrtnty\lib\site-packages\swmmio\utils\dataframes.py", line 148, in dataframe_from_inp
    df = pd.read_csv(StringIO(s), header=None, delim_whitespace=True,

  File "C:\Users\Daniel\anaconda3\envs\SYS6582Uncrtnty\lib\site-packages\pandas\util\_decorators.py", line 311, in wrapper
    return func(*args, **kwargs)

  File "C:\Users\Daniel\anaconda3\envs\SYS6582Uncrtnty\lib\site-packages\pandas\io\parsers\readers.py", line 680, in read_csv
    return _read(filepath_or_buffer, kwds)

  File "C:\Users\Daniel\anaconda3\envs\SYS6582Uncrtnty\lib\site-packages\pandas\io\parsers\readers.py", line 581, in _read
    return parser.read(nrows)

  File "C:\Users\Daniel\anaconda3\envs\SYS6582Uncrtnty\lib\site-packages\pandas\io\parsers\readers.py", line 1254, in read
    index, columns, col_dict = self._engine.read(nrows)

  File "C:\Users\Daniel\anaconda3\envs\SYS6582Uncrtnty\lib\site-packages\pandas\io\parsers\c_parser_wrapper.py", line 271, in read
    values = data.pop(self.index_col[i])

IndexError: list index out of range
@aerispaha
Copy link
Member

@lassiterdc apologies for the delay, but thank you for documenting this issue! I was unable to download the file from Dropbox - can you please share that file again so that we can reproduce your issue?

@lassiterdc
Copy link
Author

Thanks for revisiting this, the link should be working now!

@aerispaha
Copy link
Member

Thanks @lassiterdc! I've just reproduced the error and (hopefully) identified a solution.

After looking into the inp file, I noticed that you are using GREEN_AMPT for infiltration, as configured in the [OPTIONS] section. Further down in the file, we can see what your [INFILTRATION] section looks like:

[INFILTRATION]
;;Subcatchment   Param1     Param2     Param3     Param4     Param5    
;;-------------- ---------- ---------- ---------- ---------- ----------
S10              4.33       0.43       0.368      0          0         
S11              4.33       0.43       0.368      0          0         
S116_2           4.33       0.43       0.368      0          0         
S116_3           4.33       0.43       0.368      0          0         
S12              4.33       0.43       0.368      0          0         
S13              4.33       0.43       0.368      0          0 

Since Green-Ampt requires just three parameters (Suction, HydCon, IMDmax), swmmio parsers are expecting there to be 3 values in the [INFILTRATION] section in addition to the Subcatchment name. After modifying your inp file slightly to omit the two zeros in each row, as shown below, I was able to parse the infiltration section without any problems.

[INFILTRATION]
;;Subcatchment   Param1     Param2     Param3     Param4     Param5    
;;-------------- ---------- ---------- ---------- ---------- ----------
S10              4.33       0.43       0.368
S11              4.33       0.43       0.368
S116_2           4.33       0.43       0.368
S116_3           4.33       0.43       0.368
S12              4.33       0.43       0.368
S13              4.33       0.43       0.368
S14              4.33       0.43       0.368

Can you give this a try on your end and see if this solves your problem?

I wonder why the two trailing zeros were there in the first place. Did you enter them manually? If not, did you switch the infiltration model your model is using in the EPA SWMM user interface?

@dickinsonre
Copy link

The SWMM5 GUI does not add zeroes if you change infiltration type from the two HORTONS
image

@lassiterdc
Copy link
Author

Ahhh I think that must be a PCSWMM thing. I even tried opening the .inp in EPA's GUI and changing the infiltration parameters, but even that doesn't work. Thanks for identifying the workaround though. Do you think it would be possible to modify swmmio to accommodate the 0's added by PCSWMM since it's such a common software to use for SWMM modeling?

@aerispaha
Copy link
Member

@lassiterdc FYI this issue should be resolved when we merge #137 and make the next release!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants