Skip to content

_iwater_() fails when IWAT-STATE1 variables are missing #96

@rburghol

Description

@rburghol

I get the following error when running a simulation with an impervious land use that lacks the IWAT-STATE1 block. This may be a bug in the version of the model that I am using (Ches. Bay model 5.3.2, hspf 11.0), or, it mayu be something that is generally allowable in HSPF, so I thought I'd post this up. These are initial condition vars.

I amended code to get around this, by checking if the vars exist in the ui list, and if not, to initialize them to zero. But if this is NOT a bug, obviously I want to fix our UCI generation routine to be standard compliant.

git diff: Changes to HSP2/IWATER.py

     # initial conditions
-    rets = ui['RETS']
-    surs = ui['SURS']
+    rets = 0
+    if 'RETS' in ui:
+        rets = int(ui['RETS'])
+    surs = 0
+    if 'SURS' in ui:
+        surs = int(ui['SURS'])

Anyone have insight here?

Traceback (most recent call last):
  File "/home/rob/.local/bin/hsp2", line 11, in <module>
    load_entry_point('HSPsquared', 'console_scripts', 'hsp2')()
  File "/opt/model/HSPsquared/HSP2tools/HSP2_CLI.py", line 60, in main
    mando.main()
  File "/home/rob/.local/lib/python3.8/site-packages/mando/core.py", line 208, in __call__
    return self.execute(sys.argv[1:])
  File "/home/rob/.local/lib/python3.8/site-packages/mando/core.py", line 204, in execute
    return command(*a)
  File "/opt/model/HSPsquared/HSP2tools/HSP2_CLI.py", line 26, in run
    hsp2main(io_manager, saveall=saveall, jupyterlab=jupyterlab)
  File "/opt/model/HSPsquared/HSP2/main.py", line 209, in main
    errors, errmessages = function(io_manager, siminfo, ui, ts)
  File "/opt/model/HSPsquared/HSP2/IWATER.py", line 69, in iwater
    errors = _iwater_(ui, ts)                       # run IWATER simulation code
  File "/home/rob/.local/lib/python3.8/site-packages/numba/typed/dictobject.py", line 738, in impl
    raise KeyError()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions