respec / HSPsquared

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

Having trouble with readWDM #176

Open mishranurag opened 1 month ago

mishranurag commented 1 month ago

Hi

I tried to read two wdm files using HSP2tools. One file was read properly, and the other file gave the following error.

Is there an easy way to troubleshoot this issue?

Thanks Anurag

File c:\\Users\\Anurag.Mishra\\miniconda3\\envs\\alafia_py311\\Lib\\site-packages\\hsp2\\hsp2tools\\readWDM.py:51, in readWDM(wdmfile, hdffile, compress_output)
     49         dsnlist.append(index)
     50 if len(dsnlist) != ntimeseries:
---> 51     raise RuntimeError (f'Wrong number of Time Series Records found expecting:{ntimeseries} found:{len(dsnlist)}')
     53 with pd.HDFStore(hdffile) as store:
     54     summary = []

RuntimeError: Wrong number of Time Series Records found expecting:75 found:74"
}
timcera commented 1 month ago

Sounds like a bad WDM file. Best bet is if you have a good copy somewhere else. Could also use "wdmrx" (might be installed with BASINS?) or wdmtoolbox has a "cleancopywdm" function which has saved some of my bad WDM files in the past.

from wdmtoolbox import wdmtoolbox
wdmtoolbox.cleancopywdm("in.wdm", "clean.wdm")

Note that "cleancopywdm" won't repair a time-series or WDM file. It just copies all the whole time-series that it finds.