Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
c5b2a1c
Add process_groups function
ptomasula Feb 19, 2021
152d7ed
Merge branch 'develop' into develop_readWDM
aufdenkampe Feb 22, 2021
90e7ff7
Adding rpo772.wdm
ptomasula Feb 22, 2021
bad3771
Numpy Array chunk allocation approach
ptomasula Feb 22, 2021
129a228
End of block on 511th element of record
ptomasula Feb 22, 2021
762b90c
Add WDM Programmers Guide
aufdenkampe Feb 22, 2021
b6fbef4
Adding rpo772.wdm debugging files
aufdenkampe Feb 22, 2021
0f5a2d1
alternative implementation of process_group:
htaolimno Mar 1, 2021
b600ebf
remove deprecated functions
ptomasula Mar 2, 2021
2561869
renaming internal functions
ptomasula Mar 2, 2021
2e205f1
tidy up readWDM
ptomasula Mar 3, 2021
8b701e9
Searchable WDMProgrammersGuide+Search+Nav.pdf with sidebar navigation
aufdenkampe Mar 4, 2021
ef2d8df
Upload HSPF v12.2 manual with added sidebar navigation
aufdenkampe Mar 5, 2021
0cfd7c2
Merge pull request #32 from LimnoTech/develop
bcous Mar 5, 2021
e5d64a1
Numba support
ptomasula Mar 5, 2021
677adaa
Merge branch 'develop_readWDM' of https://github.com/LimnoTech/HSPsqu…
ptomasula Mar 5, 2021
1a62f38
Explicit Int64 assignment for datetime
ptomasula Mar 9, 2021
1b52a17
numba compatible datetime converter
ptomasula Mar 9, 2021
9b19a92
Remove old datetime conversion
ptomasula Mar 12, 2021
2a8373e
Test10 no longer runs since readWDM time series updates
aufdenkampe Mar 30, 2021
2014cd0
Datetime shift fix
ptomasula Mar 30, 2021
b0edc39
Remove sparse timeseries fill
ptomasula Mar 31, 2021
a094cfe
Merge branch 'develop' into develop_readWDM
aufdenkampe Mar 31, 2021
0f1f7bc
Merge branch 'develop' into develop_readWDM
aufdenkampe Mar 31, 2021
c52eaad
TimeSeries dtypes change in readWDM
aufdenkampe Apr 8, 2021
2d09713
Update HDF5_compare notebook
aufdenkampe Apr 8, 2021
ca50dd0
Merge branch 'develop' into develop_readWDM
aufdenkampe Apr 9, 2021
543ea20
Stop datetime fix
ptomasula Apr 12, 2021
ae374f1
Adding missing lines to stop datetime fix
ptomasula Apr 12, 2021
0d910ed
Merge branch 'develop' into develop_readWDM
aufdenkampe Apr 14, 2021
6e6beab
Testing outputs. Fix worked!
aufdenkampe Apr 14, 2021
479e6d6
Sparse time series fill added back
aufdenkampe Apr 23, 2021
b9e635f
timeseries freq assignment
ptomasula Apr 23, 2021
1c450ae
Update conda env & notebooks
aufdenkampe Apr 23, 2021
ee429de
block control word indexing fix
ptomasula Apr 26, 2021
146036c
Error handling for irregular timeseries
ptomasula Apr 28, 2021
c62adb6
renaming private function
ptomasula Apr 28, 2021
c545150
Merge branch 'develop' into develop_readWDM
ptomasula Apr 28, 2021
16325d1
Revert "Merge branch 'develop' into develop_readWDM"
aufdenkampe Apr 28, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Editors & IDEs
.vscode/
.idea

# Jupyter Notebook
.ipynb_checkpoints
Expand Down Expand Up @@ -37,17 +36,12 @@ htmlcov
.tox/*
.coverage
.coverage/*
*.ech
*.log
*.hbnhead
*.units.dbf

# Translations
*.mo


# Stashes, etc.
stats.dat
.ropeproject
.hg
*.tmp*
tests/_LargeFileStash
7 changes: 4 additions & 3 deletions HSP2/ADCALC.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
'''

from numpy import zeros
from numba import njit
from HSP2.utilities import make_numba_dict

# The clean way to get calculated data from adcalc() into advert() is to use a closure.
Expand Down Expand Up @@ -128,7 +127,7 @@ def adcalc_(simlen, delts, nexits, crrat, ks, vol, ADFG, O, VOL, SROVOL, EROVOL,
return


#@njit(cache=True)
#@jit(nopython=True)
def advect(imat, conc, nexits, vols, vol, srovol, erovol, sovol, eovol):
''' Simulate advection of constituent totally entrained in water.
Originally designed to be called as: advect(loop, imat, conc, omat, *ui['adcalcData'])
Expand All @@ -141,7 +140,9 @@ def advect(imat, conc, nexits, vols, vol, srovol, erovol, sovol, eovol):
# sovol = SOVOL[loop,:]
# eovol = EOVOL[loop,:]

omat = zeros((nexits))
omat = 0.0
if nexits > 1:
omat = zeros((nexits))
if vol > 0.0: # reach/res contains water
concs = conc
conc = (imat + concs * (vols - srovol)) / (vol + erovol) # material entering during interval, weighted volume of outflow based on conditions at start of ivl (srovol), and weighted volume of outflow based on conditions at end of ivl (erovol)
Expand Down
2 changes: 1 addition & 1 deletion HSP2/GQUAL.py
Original file line number Diff line number Diff line change
Expand Up @@ -1245,7 +1245,7 @@ def advqal(isqal,rsed,bsed,depscr,rosed,osed,nexits,rsqals,rbqals,errors):
if bsed <= 0.0: # no bed sediments at end of interval
bqal = -1.0e30
if abs(dsqal) > 0.0 or abs(rbqals > 0.0):
errors[5] += 1 # ERRMSG4: error-under these conditions these values should be zero
errors[4] += 1 # ERRMSG4: error-under these conditions these values should be zero
else: # there is bed sediment at the end of the interval
rbqal= dsqal + rbqals
bqal = rbqal / bsed
Expand Down
8 changes: 4 additions & 4 deletions HSP2/HTRCH.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@
0.0026, 0.0026, 0.0027, 0.0027, 0.0028, 0.0028, 0.0027, 0.0026, 0.0024, 0.0023, 0.0022,
0.0021, 0.0021, 0.0020]

ERRMSGS =('HTRCH: Water temperature is above 66 C (150 F) -- In most cases, this indicates an instability in advection','') #ERRMSG0
ERRMSG = []

def htrch(store, siminfo, uci, ts):
'''Simulate heat exchange and water temperature'''

errorsV = zeros(len(ERRMSGS), dtype=int)
errorsV = zeros(len(ERRMSG), dtype=int)

advectData = uci['advectData']
(nexits, vol, VOL, SROVOL, EROVOL, SOVOL, EOVOL) = advectData
Expand Down Expand Up @@ -172,7 +172,7 @@ def htrch(store, siminfo, uci, ts):

if tw > 66.0:
if adfg < 2:
errorsV[0] += 1 # Water temperature is above 66 C (150 F). In most cases, this indicates an instability in advection.
# errormsg: 'advect:tw problem ',dtw, airtmp
rtw = tw
else:
tw = tws
Expand Down Expand Up @@ -369,7 +369,7 @@ def htrch(store, siminfo, uci, ts):
for i in range(nexits):
ts['OHEAT' + str(i+1)] = OHEAT[:, i]

return errorsV, ERRMSGS
return errorsV, ERRMSG

def vapor(tmp):
''' # define vapor function based on temperature (deg c); vapor pressure is expressed in millibars'''
Expand Down
9 changes: 3 additions & 6 deletions HSP2/IQUAL.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
UNDEFINED: sliqsp
'''

ERRMSGS =('IQUAL: A constituent must be associated with overland flow in order to receive atmospheric deposition inputs','') #ERRMSG0
ERRMSG = []

def iqual(store, siminfo, uci, ts):
''' Simulate washoff of quality constituents (other than solids, Heat, dox, and co2)
Expand All @@ -35,7 +35,7 @@ def iqual(store, siminfo, uci, ts):
flags = uci['IQUAL' + iqual + '_FLAGS']
constituents.append(flags['QUALID'])

errorsV = zeros(len(ERRMSGS), dtype=int)
errorsV = zeros(len(ERRMSG), dtype=int)
delt60 = siminfo['delt'] / 60 # delt60 - simulation time interval in hours
simlen = siminfo['steps']
tindex = siminfo['tindex']
Expand Down Expand Up @@ -118,9 +118,6 @@ def iqual(store, siminfo, uci, ts):
elif iqadfgc == -1:
ts['IQADCN'] = ts['IQADCN' + str(index) + ' 1']

if QSOFG == 0 and (iqadfgf != 0 or iqadfgc != 0):
errorsV[0] += 1 # error - non-qualof cannot have atmospheric deposition

if 'IQADFX' not in ts:
ts['IQADFX'] = zeros(simlen)
if 'IQADCN' not in ts:
Expand Down Expand Up @@ -232,5 +229,5 @@ def iqual(store, siminfo, uci, ts):
IQADDR[loop] = adfxfx
IQADEP[loop] = adtot

return errorsV, ERRMSGS
return errorsV, ERRMSG

20 changes: 7 additions & 13 deletions HSP2/IWTGAS.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,23 +125,17 @@ def iwtgas(store, siminfo, uci, ts):
if slico2 >= 0.0: # there is co2 conc of surface lateral inflow
soco2 = slico2 * slifac + soco2 * (1.0 - slifac)

SOHT[loop] = sotmp * suro * EFACTA # compute outflow of heat energy in water - units are deg. c-in./ivl
SODOXM[loop] = sodox * suro * MFACTA # calculate outflow mass of dox - units are mg-in./l-ivl
SOCO2M[loop] = soco2 * suro * MFACTA # calculate outflow mass of co2 - units are mg-in./l-ivl
SOTMP[loop] = (sotmp * 9.0 / 5.0) + 32.0
SODOX[loop] = sodox
SOCO2[loop] = soco2

else:
sotmp = -1.0e30
sodox = -1.0e30
soco2 = -1.0e30

SOHT[loop] = 0.0
SODOXM[loop] = 0.0
SOCO2M[loop] = 0.0
SOTMP[loop] = sotmp
SODOX[loop] = sodox
SOCO2[loop] = soco2
SOHT[loop] = sotmp * suro * EFACTA # compute outflow of heat energy in water - units are deg. c-in./ivl
SODOXM[loop] = sodox * suro * MFACTA # calculate outflow mass of dox - units are mg-in./l-ivl
SOCO2M[loop] = soco2 * suro * MFACTA # calculate outflow mass of co2 - units are mg-in./l-ivl

SOTMP[loop] = (sotmp * 9.0 / 5.0) + 32.0
SODOX[loop] = sodox
SOCO2[loop] = soco2

return errorsV, ERRMSG
9 changes: 3 additions & 6 deletions HSP2/PQUAL.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
NEED to check all units conversions
'''

ERRMSGS =('PQUAL: A constituent must be associated with overland flow in order to receive atmospheric deposition inputs','') #ERRMSG0
ERRMSG = []

# english system
FACTA = 1.0
Expand All @@ -38,7 +38,7 @@ def pqual(store, siminfo, uci, ts):
flags = uci['PQUAL' + pqual + '_FLAGS']
constituents.append(flags['QUALID'])

errorsV = zeros(len(ERRMSGS), dtype=int)
errorsV = zeros(len(ERRMSG), dtype=int)
delt60 = siminfo['delt'] / 60 # delt60 - simulation time interval in hours
simlen = siminfo['steps']
tindex = siminfo['tindex']
Expand Down Expand Up @@ -138,9 +138,6 @@ def pqual(store, siminfo, uci, ts):
elif pqadfgc == -1:
ts['PQADCN'] = ts['PQADCN' + str(index) + ' 1']

if QSOFG == 0 and (pqadfgf != 0 or pqadfgc != 0):
errorsV[0] += 1 # error - non-qualof cannot have atmospheric deposition

if 'PQADFX' not in ts:
ts['PQADFX'] = zeros(simlen)
if 'PQADCN' not in ts:
Expand Down Expand Up @@ -332,5 +329,5 @@ def pqual(store, siminfo, uci, ts):
PQADDR[loop] = adfxfx
PQADEP[loop] = adtot

return errorsV, ERRMSGS
return errorsV, ERRMSG

6 changes: 3 additions & 3 deletions HSP2/PSTEMP.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
from HSP2.utilities import hoursval, initm, make_numba_dict


ERRMSG = ['SLTMP temperature less than -100C', # MSG0
'ULTMP temperature less than -100C', # MSG1
'LGTMP temperature less than -100C', # MSG2
ERRMSG = ['SLTMP temperature less than 100C', # MSG0
'ULTMP temperature less than 100C', # MSG1
'LGTMP temperature less than 100C', # MSG2
'SLTMP temperature greater than 100C', # MSG3
'ULTMP temperature greater than 100C', # MSG4
'LGTMP temperature greater than 100C'] # MSG5
Expand Down
2 changes: 1 addition & 1 deletion HSP2/PWATER.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
'PWATER: Proute runoff did not converge', #ERRMSG6
'PWATER: UZI highly negative', #ERRMSG7
'PWATER: Reset AGWS to zero', #ERRMSG8
'PWATER: High Water Table code not implemented', #ERRMSG9
'PWATER: High Water Table code not implimented', #ERRMSG9
)

def pwater(store, siminfo, uci, ts):
Expand Down
33 changes: 10 additions & 23 deletions HSP2/SEDTRN.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,12 @@
from HSP2.ADCALC import advect
from HSP2.utilities import make_numba_dict

ERRMSGS =('SEDTRN: Warning -- bed storage of sediment size fraction sand is empty', #ERRMSG0
'SEDTRN: Warning -- bed storage of sediment size fraction silt is empty', #ERRMSG1
'SEDTRN: Warning -- bed storage of sediment size fraction clay is empty', #ERRMSG2
'SEDTRN: Warning -- bed depth appears excessive', #ERRMSG3
'SEDTRN: Fatal error ocurred in colby method- variable outside valid range- switching to toffaleti method', #ERRMSG4
'SEDTRN: Simulation of sediment requires all 3 "auxiliary flags" (AUX1FG, etc) in section HYDR must be turned on', #ERRMSG5
'SEDTRN: When specifying the initial composition of the bed, the fraction of sand, silt, and clay must sum to a value close to 1.0.') #ERRMSG6
ERRMSG = []

def sedtrn(store, siminfo, uci, ts):
''' Simulate behavior of inorganic sediment'''

errorsV = zeros(len(ERRMSGS), dtype=int)
errorsV = zeros(len(ERRMSG), dtype=int)

simlen = siminfo['steps']
delt = siminfo['delt']
Expand All @@ -37,9 +31,6 @@ def sedtrn(store, siminfo, uci, ts):
# table SANDFG
sandfg = ui['SANDFG'] # 1: Toffaleti method, 2:Colby method, 3:old HSPF power function

if ui['AUX3FG'] == 0:
errorsV[5] += 1 # error - sediment transport requires aux3fg to be on

# table SED-GENPARM
bedwid = ui['BEDWID']
bedwrn = ui['BEDWRN']
Expand Down Expand Up @@ -108,7 +99,7 @@ def sedtrn(store, siminfo, uci, ts):
clay_bedfr = ui['CLAYFR']
total_bedfr = sand_bedfr + silt_bedfr + clay_bedfr
if abs(total_bedfr - 1.0) > 0.01:
errorsV[6] += 1 # error message: sum of bed sediment fractions is not close enough to 1.0
pass # error message: sum of bed sediment fractions is not close enough to 1.0

# suspended sediment concentrations; table ssed-init
sand_ssed1 = ui['SSED1']
Expand Down Expand Up @@ -399,20 +390,17 @@ def sedtrn(store, siminfo, uci, ts):
osed4 += osed1
sand_rssed1 = sand_t_rsed7 = sand_rsed1 + sand_wt_rsed4 # total storage in mg.vol/l
if sand_wt_rsed4 == 0.0: # warn that bed is empty
# errmsg
errorsV[0] += 1 # The bed storage of sediment size fraction sand is empty.
pass # errmsg

osed4 += osed2
silt_rssed2 = silt_t_rsed8 = silt_rsed2 + silt_wt_rsed5 # total storage in mg.vol/l
if silt_wt_rsed5 == 0.0: # warn that bed is empty
# errmsg
errorsV[1] += 1 # The bed storage of sediment size fraction silt is empty.
pass # errmsg

osed4 += osed3
clay_rssed3 = clay_t_rsed9 = clay_rsed3 + clay_wt_rsed6 # total storage in mg.vol/l
if clay_wt_rsed6 == 0.0: # warn that bed is empty
# errmsg
errorsV[2] += 1 # The bed storage of sediment size fraction clay is empty.
pass # errmsg

# find the volume occupied by each fraction of bed sediment- ft3 or m3
volsed = (sand_wt_rsed4 / (sand_rho * 1.0e06)
Expand All @@ -430,8 +418,7 @@ def sedtrn(store, siminfo, uci, ts):
volsed = volsed / (1.0 - por) # allow for porosit
beddep = volsed / (len_ * bedwid) # calculate thickness of bed- ft or m
if beddep > bedwrn:
# Errormsg: warn that bed depth appears excessive
errorsV[3] += 1
pass # Errormsg: warn that bed depth appears excessive

svol = vol # svol is volume at start of time step, update for next time thru

Expand Down Expand Up @@ -500,7 +487,7 @@ def sedtrn(store, siminfo, uci, ts):
ts['OSED3' + str(i + 1)] = OSED3[:, i]
ts['OSED4' + str(i + 1)] = OSED4[:, i]

return errorsV, ERRMSGS
return errorsV, ERRMSG


def bdexch (avdepm, w, tau, taucd, taucs, m, vol, frcsed, susp, bed):
Expand Down Expand Up @@ -657,8 +644,8 @@ def colby(v, db50, fhrad, fsl, tempr):
if vx > v:
break
iv2 = iv1 + 1
yy1 = log10(VG[iv1-1])
yy2 = log10(VG[iv2-1])
yy1 = log10(VG[iv1])
yy2 = log10(VG[iv2])
yyratio = (log10(v) - yy1) / (yy2 - yy1)

tmpr = min(100.0, max(32.0, tempr * 1.8 + 32.0))
Expand Down
5 changes: 2 additions & 3 deletions HSP2/SNOW.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def _snow_(ui, ts):
icefg = int(ui['ICEFG'])

melev = ui['MELEV']
packf = ui['PACKF'] + ui['PACKI']
packf = ui['PACKF'] # inital df.PKSNOW += df.PKICE fixed in uciReader
packi = ui['PACKI']
packw = ui['PACKW']
paktmp = ui['PAKTMP']
Expand Down Expand Up @@ -535,7 +535,7 @@ def _snow_(ui, ts):
PACKF[step] = packf
PACKI[step] = packi
PACKW[step] = packw
PACK[step] = packf + packw # + packi
PACK[step] = packf + packi + packw
PAKTMP[step] = paktmp
PDEPTH[step] = pdepth
PRAIN[step] = prain
Expand Down Expand Up @@ -565,7 +565,6 @@ def vapor(SVP, temp):
def hour6flag(siminfo, dofirst=False):
'''timeseries with 1 at 6am and earlier each day, and zero otherwise'''
hours24 = zeros(24)
hours24[0] = 1.0
hours24[1] = 1.0
hours24[2] = 1.0
hours24[3] = 1.0
Expand Down
2 changes: 0 additions & 2 deletions HSP2/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,10 @@ def main(hdfname, saveall=False, jupyterlab=True):
ui['advectData'] = uci[(operation, 'ADCALC', segment)]['adcalcData']
# ui['STATES']['VOL'] = uci[(operation, 'HYDR', segment)]['STATES']['VOL']
ui['PARAMETERS']['HTFG'] = flags['HTRCH']
ui['PARAMETERS']['AUX3FG'] = 0
if flags['HYDR']:
ui['PARAMETERS']['LEN'] = uci[(operation, 'HYDR', segment)]['PARAMETERS']['LEN']
ui['PARAMETERS']['DELTH'] = uci[(operation, 'HYDR', segment)]['PARAMETERS']['DELTH']
ui['PARAMETERS']['DB50'] = uci[(operation, 'HYDR', segment)]['PARAMETERS']['DB50']
ui['PARAMETERS']['AUX3FG'] = uci[(operation, 'HYDR', segment)]['PARAMETERS']['AUX3FG']
if activity == 'GQUAL':
ui['advectData'] = uci[(operation, 'ADCALC', segment)]['adcalcData']
ui['PARAMETERS']['HTFG'] = flags['HTRCH']
Expand Down
2 changes: 1 addition & 1 deletion HSP2/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def transform(ts, name, how, siminfo):
if freq == tsfreq:
pass
elif tsfreq == None: # Sparse time base, frequency not defined
ts = ts.reindex(siminfo['tbase']).ffill().bfill()
ts = ts.reindex(siminfo['tbase']).ffill().bfill()
elif how == 'SAME':
ts = ts.resample(freq).ffill() # tsfreq >= freq assumed, or bad user choice
elif not how:
Expand Down
7 changes: 7 additions & 0 deletions HSP2tools/.vs/VSWorkspaceState.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"ExpandedNodes": [
""
],
"SelectedNode": "\\readWDM.py",
"PreviewInSolutionExplorer": false
}
Loading