Closed rburghol closed 1 year ago
The HSP2 code is designed to populate the initial state variables with the defaults if those initial state variables are not explicitly set -- this happens down within readUCI. Are you using readUCI to populate the h5 file? If so, you may indeed have discovered a bug.
Also worth noting, the default values for the IWAT-STATE1 variables are not exactly zero, from the HSPF manual:
--------------------------------------------------------------------------------
Symbol Fortran name Format Def Min Max Units Unit syst
--------------------------------------------------------------------------------
<iwat-state1> RETS 2F10.0 .001 .001 100 inches Engl
.025 .025 2500 mm Metric
SURS .001 .001 100 inches Engl
.025 .025 2500 mm Metric
Thanks @PaulDudaRESPEC -- I am using hsp2 import_uci
to populate the h5 file, and I will look into readUCI()
.
FWIW I am using the most recent pull from the "develop" branch.
Right, import_uci calls readUCI. I'll run a test on that when I get a chance and see if I can reproduce the problem you report.
@PaulDudaRESPEC I looked into the readUCI function and found that I could eliminate the error by checking for the presence of RETS, and if absent, set it and SURS to a default value of 0.001 per the entry you showed from the HSPF manual. Code 1: git diff: Changes to HSP2tools/readUCI.py
--- a/HSP2tools/readUCI.py
+++ b/HSP2tools/readUCI.py
@@ -207,6 +207,10 @@ def readUCI(uciname, hdfname):
df['PETMIN'] = 0.35
df['PETMAX'] = 40.0
df.to_hdf(store, path, data_columns=True)
+ if 'RETS' not in df.columns: # didn't read IWAT-STATE1 table
+ df['RETS'] = 0.001
+ df['SURS'] = 0.001
+ df.to_hdf(store, path, data_columns=True)
@rburghol Indeed the fix you propose will take care of the specific problem you identified, so that's great.
There's a more general issue where the code designed to populate default values (around line 328) is not working properly in this case and probably others -- I'm going to dig into that a little further to better understand why sometimes that code doesn't work as intended.
@rburghol I just pushed a code fix to the develop branch to address this issue in readUCI, in a more generic way for any missing 'initial state variable' table. Maybe you'd like to check this out when you get a chance.
Thanks @PaulDudaRESPEC - I'll pull that asap and report back.
Paul - I am sorry to delay response, this fix resolved our issue entirely. I had been so busy using it that I forgot to check back.
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
Anyone have insight here?