respec / HSPsquared

Hydrologic Simulation Program Python (HSPsquared)
GNU Affero General Public License v3.0
43 stars 17 forks source link

Error in data types when running the model #93

Closed bcous closed 2 years ago

bcous commented 2 years ago

Error message is given below. @ptomasula

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Input In [13], in <cell line: 1>()
      1 with HSP2IO.hdf.HDF5(hdffile) as hdf5_instance:
      2     io_manager = HSP2IO.io.IOManager(hdf5_instance)
----> 3     HSP2.main(io_manager, saveall=True)

File ~\.conda\envs\hsp2_py38\lib\site-packages\HSP2\main.py:87, in main(io_manager, saveall, jupyterlab)
     84         flags['PO4FG'] = uci[(operation, 'NUTRX', segment)]['FLAGS']['PO4FG']
     85         flags['ADPOFG'] = uci[(operation, 'NUTRX', segment)]['FLAGS']['ADPOFG']
---> 87     get_flows(io_manager, ts, flags, uci, segment, ddlinks, ddmasslinks, siminfo['steps'], msg)
     89 for activity, function in activities[operation].items():
     90     if function == noop: #or not flags[activity]:

File ~\.conda\envs\hsp2_py38\lib\site-packages\HSP2\main.py:327, in get_flows(io_manager, ts, flags, uci, segment, ddlinks, ddmasslinks, steps, msg)
    324     sgrpn = 'PHCARB'
    326 if tmemn == 'ISED' or tmemn == 'ISQAL':
--> 327     tmemn = tmemn + tmemsb1    # need to add sand, silt, clay subscript
    328 if (sgrpn == 'HYDR' and smemn == 'OVOL') or (sgrpn == 'HTRCH' and smemn == 'OHEAT'):
    329     smemsb2 = ''

TypeError: can only concatenate str (not "float") to str
ptomasula commented 2 years ago

Interesting resolution on this. @bcous and I ultimately traced it down to error in the input file. We tried a different copy of the HDF5 file and the version correctly loaded tmemsb1 as string, so the issue above was not encountered. We then encountered another issues where SAVE tables for some of the operations had incorrect names in the headers, which resulted in these lines filtering out the parameters from that dataframe to be exported.

We ultimately resolved the issue by rereading the uci file and that corrected the SAVE tables.

I think it is fine to close this issue, but some items to think about with regards to making the save parameters logic more robust.

aufdenkampe commented 2 years ago

@ptomasula, I'm glad you were able to help @bcous on this. Thanks!