Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.3.1.504
4.3.1.505
2 changes: 2 additions & 0 deletions src/lisflood/global_modules/default_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -1294,6 +1294,8 @@
'timeseries': {
'ChanqTS': TimeSeries(name='ChanqTS', output_var='ChanQ', where='Gauges',
repoption=['repDischargeTs'], restrictoption=[], operation=['']),
'ChanqavgdtTS': TimeSeries(name='ChanqavgdtTS', output_var='ChanQAvgDt', where='Gauges',
repoption=['repDischargeTs'], restrictoption=[], operation=['']),
'DSLRAvUpsTS': TimeSeries(name='DSLRAvUpsTS', output_var='DSLR[0]', where='Gauges',
repoption=['repStateUpsGauges'], restrictoption=['nonInit'],
operation=['total']),
Expand Down
5 changes: 2 additions & 3 deletions src/lisflood/hydrological_modules/inflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def initial(self):
if option['inflow']:
self.var.InflowPoints = loadmap('InflowPoints') #1D array size is pixels belonging to basin mask

self.var.QInM3Old = np.where(self.var.InflowPoints > 0, self.var.ChanQ * self.var.DtSec, 0)
self.var.QInM3Old = np.where(self.var.InflowPoints > 0, self.var.ChanQAvgDt * self.var.DtSec, 0)
# inflow volume for model step

# read inflow map
Expand Down Expand Up @@ -125,7 +125,6 @@ def dynamic(self):
# Get inflow hydrograph at each inflow point [m3/s]
QIn = compressArray(QIn)
QIn[np.isnan(QIn)] = 0
#cmcheck - inflow
self.var.QInM3 = QIn * self.var.DtSec
# Convert to [m3] per time step
self.var.TotalQInM3 += self.var.QInM3
Expand All @@ -145,7 +144,7 @@ def dynamic_inloop(self, NoRoutingExecuted):
settings = LisSettings.instance()
option = settings.options

if option['inflow']: #cmcheck - inflow
if option['inflow']:

self.var.QInDt = (self.var.QInM3Old + (NoRoutingExecuted + 1) * self.var.QDelta) * self.var.InvNoRoutSteps
# flow from inlets per sub step
Expand Down
27 changes: 27 additions & 0 deletions src/lisflood/hydrological_modules/routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,10 @@ def initial(self):
"""
settings = LisSettings.instance()
option = settings.options
flags = settings.flags
maskinfo = MaskInfo.instance()


# ************************************************************
# ***** NUMBER OF ROUTING STEPS *********************
# ************************************************************
Expand Down Expand Up @@ -542,6 +544,7 @@ def initialMCT(self):
"""
settings = LisSettings.instance()
option = settings.options
flags = settings.flags

if not (option['SplitRouting']):
self.var.ChannelAlpha2 = None
Expand Down Expand Up @@ -631,6 +634,7 @@ def dynamic(self, NoRoutingExecuted):
"""
settings = LisSettings.instance()
option = settings.options
flags = settings.flags

if not(option['InitLisflood']): # only with no InitLisflood
self.lakes_module.dynamic_inloop(NoRoutingExecuted)
Expand Down Expand Up @@ -804,6 +808,29 @@ def dynamic(self, NoRoutingExecuted):
self.var.ChanM3 # Channel storage volume. In input: at time t V00; in output: at time t+dt V11
)

##################################################################3
if flags['debug']:
# checking Courant number for potential instability in MCT
if not np.all(self.var.PrevCm0 <= 1):
warnings.warn(LisfloodWarning("WARNING! Courant > 1. Consider using smaller DtRouting steps or using kinematic routing"))

##################################################################3
# checking chanqvagdt and chanq for instability in MCT that can can create issues when using inflows
# Only consider elements where ChanQAvgDt >100 or ChanQ >100
dismask = (self.var.ChanQ > 100.) | (self.var.ChanQAvgDt > 100.)
# Check for ChanQ values that are 10x larger or smaller than ChanQAvgDt
too_large = self.var.ChanQ[dismask] > 10 * self.var.ChanQAvgDt[dismask]
too_small = self.var.ChanQ[dismask] < 0.1 * self.var.ChanQAvgDt[dismask]

bad = too_large | too_small

if np.any(bad):
warnings.warn(LisfloodWarning("WARNING! At least one ChanQ is >> or << ChanQAvgDt. Consider increasing DtRouting step or using kinematic routing"))
# # list 'bad' cells
# bad_indices = np.where(dismask)[0][bad]
# print("Bad indices:", bad_indices)
##################################################################3

else:
# Store results of kinematic/split routing in the general variables
self.var.ChanQ = ChanQ
Expand Down
15 changes: 9 additions & 6 deletions src/lisfloodSettings_reference.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1711,17 +1711,14 @@ Multiplier [] applied to ChanSdXdY

<textvar name="InflowPoints" value="$(PathInflow)/inflowPoints">
<comment>
OPTIONAL: nominal map with locations of (measured)
inflow hydrographs [cu m / s]
OPTIONAL: nominal map with locations of (measured) inflow hydrographs [cu m / s]
</comment>
</textvar>

<textvar name="QInTS" value="$(PathInflow)/inflowHyd.tss">
<comment>
OPTIONAL: observed or simulated input hydrographs as
time series [cu m / s]
Note that identifiers in time series correspond to
InflowPoints map (also optional)
OPTIONAL: observed or simulated input hydrographs as time series [cu m / s]
Note that identifiers in time series correspond to InflowPoints map (also optional). ChanqavgdtTS should be used during calibration
</comment>
</textvar>
</group>
Expand Down Expand Up @@ -4208,6 +4205,12 @@ Multiplier [] applied to ChanSdXdY
</comment>
</textvar>

<textvar name="ChanqavgdtTS" value="$(PathOut)/chanqavgdt.tss">
<comment>
Reported average discharge on the last routing sub-step [cu m/s]
</comment>
</textvar>

<textvar name="WaterLevelTS" value="$(PathOut)/waterLevel.tss">
<comment>
Reported water level [m]
Expand Down
6 changes: 6 additions & 0 deletions tests/data/LF_ETRS89_UseCase/settings/base.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3861,6 +3861,12 @@ LFBINDING: MORE LOW-LEVEL CONTROL OVER MODEL IN- AND OUTPUT
</comment>
</textvar>

<textvar name="ChanqavgdtTS" value="$(PathOut)/chanqavgdt.tss">
<comment>
Reported average discharge on the last routing sub-step [cu m/s]
</comment>
</textvar>

<textvar name="WaterLevelTS" value="$(PathOut)/waterLevel.tss">
<comment>
Reported water level [m]
Expand Down
6 changes: 6 additions & 0 deletions tests/data/LF_ETRS89_UseCase/settings/cold.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3905,6 +3905,12 @@ LFBINDING: MORE LOW-LEVEL CONTROL OVER MODEL IN- AND OUTPUT
</comment>
</textvar>

<textvar name="ChanqavgdtTS" value="$(PathOut)/chanqavgdt.tss">
<comment>
Reported average discharge on the last routing sub-step [cu m/s]
</comment>
</textvar>

<textvar name="WaterLevelTS" value="$(PathOut)/waterLevel.tss">
<comment>
Reported water level [m]
Expand Down
5 changes: 5 additions & 0 deletions tests/data/LF_ETRS89_UseCase/settings/full.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6032,6 +6032,11 @@ LFBINDING: MORE LOW-LEVEL CONTROL OVER MODEL IN- AND OUTPUT
</comment>
</textvar>

<textvar name="ChanqavgdtTS" value="$(PathOut)/chanqavgdt.tss">
<comment>
Reported average discharge on the last routing sub-step [cu m/s]
</comment>
</textvar>

<textvar name="WaterLevelTS" value="$(PathOut)/waterLevel.tss">

Expand Down
8 changes: 7 additions & 1 deletion tests/data/LF_ETRS89_UseCase/settings/inflow.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3834,7 +3834,13 @@ LFBINDING: MORE LOW-LEVEL CONTROL OVER MODEL IN- AND OUTPUT
</textvar>
<textvar name="ChanqTS" value="$(PathOut)/chanqWin.tss">
<comment>
Reported discharge over last routing sub-step [cu m/s]
Reported instantaneous discharge at the end of routing sub-step [cu m/s]
</comment>
</textvar>

<textvar name="ChanqavgdtTS" value="$(PathOut)/chanqavgdt.tss">
<comment>
Reported average discharge on the last routing sub-step [cu m/s]
</comment>
</textvar>

Expand Down
5 changes: 5 additions & 0 deletions tests/data/LF_ETRS89_UseCase/settings/mct_cold.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4071,6 +4071,11 @@ LFBINDING: MORE LOW-LEVEL CONTROL OVER MODEL IN- AND OUTPUT
</comment>
</textvar>

<textvar name="ChanqavgdtTS" value="$(PathOut)/chanqavgdt.tss">
<comment>
Reported average discharge on the last routing sub-step [cu m/s]
</comment>
</textvar>
<textvar name="WaterLevelTS" value="$(PathOut)/waterLevel.tss">
<comment>
Reported water level [m]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4028,6 +4028,12 @@ LFBINDING: MORE LOW-LEVEL CONTROL OVER MODEL IN- AND OUTPUT
</comment>
</textvar>

<textvar name="ChanqavgdtTS" value="$(PathOut)/chanqavgdt.tss">
<comment>
Reported average discharge on the last routing sub-step [cu m/s]
</comment>
</textvar>

<textvar name="WaterLevelTS" value="$(PathOut)/waterLevel.tss">
<comment>
Reported water level [m]
Expand Down
6 changes: 6 additions & 0 deletions tests/data/LF_ETRS89_UseCase/settings/mct_inflow.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4082,6 +4082,12 @@ LFBINDING: MORE LOW-LEVEL CONTROL OVER MODEL IN- AND OUTPUT
</comment>
</textvar>

<textvar name="ChanqavgdtTS" value="$(PathOut)/chanqavgdt.tss">
<comment>
Reported average discharge on the last routing sub-step [cu m/s]
</comment>
</textvar>

<textvar name="WaterLevelTS" value="$(PathOut)/waterLevel.tss">
<comment>
Reported water level [m]
Expand Down
6 changes: 6 additions & 0 deletions tests/data/LF_ETRS89_UseCase/settings/mct_inflow_test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4082,6 +4082,12 @@ LFBINDING: MORE LOW-LEVEL CONTROL OVER MODEL IN- AND OUTPUT
</comment>
</textvar>

<textvar name="ChanqavgdtTS" value="$(PathOut)/chanqavgdt.tss">
<comment>
Reported average discharge on the last routing sub-step [cu m/s]
</comment>
</textvar>

<textvar name="WaterLevelTS" value="$(PathOut)/waterLevel.tss">
<comment>
Reported water level [m]
Expand Down
6 changes: 6 additions & 0 deletions tests/data/LF_ETRS89_UseCase/settings/mct_warm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4028,6 +4028,12 @@ LFBINDING: MORE LOW-LEVEL CONTROL OVER MODEL IN- AND OUTPUT
</comment>
</textvar>

<textvar name="ChanqavgdtTS" value="$(PathOut)/chanqavgdt.tss">
<comment>
Reported average discharge on the last routing sub-step [cu m/s]
</comment>
</textvar>

<textvar name="WaterLevelTS" value="$(PathOut)/waterLevel.tss">
<comment>
Reported water level [m]
Expand Down
6 changes: 6 additions & 0 deletions tests/data/LF_ETRS89_UseCase/settings/prerun.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3836,6 +3836,12 @@ LFBINDING: MORE LOW-LEVEL CONTROL OVER MODEL IN- AND OUTPUT
Reported discharge over last routing sub-step [cu m/s]
</comment>
</textvar>

<textvar name="ChanqavgdtTS" value="$(PathOut)/chanqavgdt.tss">
<comment>
Reported average discharge on the last routing sub-step [cu m/s]
</comment>
</textvar>

<textvar name="WaterLevelTS" value="$(PathOut)/waterLevel.tss">
<comment>
Expand Down
8 changes: 7 additions & 1 deletion tests/data/LF_ETRS89_UseCase/settings/warm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3881,6 +3881,12 @@ LFBINDING: MORE LOW-LEVEL CONTROL OVER MODEL IN- AND OUTPUT
Reported discharge over last routing sub-step [cu m/s]
</comment>
</textvar>

<textvar name="ChanqavgdtTS" value="$(PathOut)/chanqavgdt.tss">
<comment>
Reported average discharge on the last routing sub-step [cu m/s]
</comment>
</textvar>

<textvar name="WaterLevelTS" value="$(PathOut)/waterLevel.tss">
<comment>
Expand Down Expand Up @@ -5411,7 +5417,7 @@ LFBINDING: MORE LOW-LEVEL CONTROL OVER MODEL IN- AND OUTPUT
</comment>
</textvar>

<textvar name="PF2ForestTS" value="$(PathOut)/ <textvar name="PF2ForestTS" value="$(PathOut)/pFForestSub.tss">
<textvar name="PF2ForestTS" value="$(PathOut)/pFForestSub.tss">
<comment>
Reported pF lower soil layer [-]
</comment>
Expand Down
17 changes: 10 additions & 7 deletions tests/data/LF_MCT_UseCase/settings/mct_cold.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ You can use builtin path variables in this template and reference to other paths

<setoption choice="0" name="SplitRouting"/>
<setoption choice="1" name="MCTRouting"/>
<setoption choice="1" name="ColdStart"/>


# use inflow data
<setoption choice="0" name="inflow"/>
Expand All @@ -62,13 +60,15 @@ You can use builtin path variables in this template and reference to other paths
# option to initialize Lisflood
<setoption choice="0" name="InitLisflood"/>
<setoption choice="0" name="InitLisfloodwithoutsplit"/>
<setoption choice="1" name="ColdStart"/>

# option to read/write NetCDF
<setoption choice="1" name="readNetcdfStack"/>
<setoption choice="1" name="writeNetcdfStack"/>
<setoption choice="1" name="writeNetcdf"/>


# option to Report PaddyRiceDebug information in CSV file for debugging Paddy Rice Water Abstraction issue on dry Channels
<setoption choice="0" name="repPaddyRiceDebug"/>

#-----------------------------------------------------------
# report time series
Expand Down Expand Up @@ -164,17 +164,14 @@ You can use builtin path variables in this template and reference to other paths
<setoption choice="0" name="repWIndex"/>

</lfoptions>


<lfuser>

<group>
<comment>
**************************************************************
netCDF parameters
**************************************************************
</comment>

</comment>
<textvar name="NetCDFTimeChunks" value="-1"/>
<comment>
!-- Optimization of netCDF I/O through chunking and caching.
Expand Down Expand Up @@ -4187,6 +4184,12 @@ LFBINDING: MORE LOW-LEVEL CONTROL OVER MODEL IN- AND OUTPUT
</comment>
</textvar>

<textvar name="ChanqavgdtTS" value="$(PathOut)/chanqavgdt.tss">
<comment>
Reported average discharge on the last routing sub-step [cu m/s]
</comment>
</textvar>

<textvar name="WaterLevelTS" value="$(PathOut)/waterLevel.tss">
<comment>
Reported water level [m]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4188,6 +4188,12 @@ LFBINDING: MORE LOW-LEVEL CONTROL OVER MODEL IN- AND OUTPUT
</comment>
</textvar>

<textvar name="ChanqavgdtTS" value="$(PathOut)/chanqavgdt.tss">
<comment>
Reported average discharge on the last routing sub-step [cu m/s]
</comment>
</textvar>

<textvar name="WaterLevelTS" value="$(PathOut)/waterLevel.tss">
<comment>
Reported water level [m]
Expand Down
6 changes: 6 additions & 0 deletions tests/data/LF_MCT_UseCase/settings/mct_inflow.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4194,6 +4194,12 @@ LFBINDING: MORE LOW-LEVEL CONTROL OVER MODEL IN- AND OUTPUT
</comment>
</textvar>

<textvar name="ChanqavgdtTS" value="$(PathOut)/chanqavgdt.tss">
<comment>
Reported average discharge on the last routing sub-step [cu m/s]
</comment>
</textvar>

<textvar name="WaterLevelTS" value="$(PathOut)/waterLevel.tss">
<comment>
Reported water level [m]
Expand Down
6 changes: 6 additions & 0 deletions tests/data/LF_MCT_UseCase/settings/mct_inflow_test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4087,6 +4087,12 @@ LFBINDING: MORE LOW-LEVEL CONTROL OVER MODEL IN- AND OUTPUT
</comment>
</textvar>

<textvar name="ChanqavgdtTS" value="$(PathOut)/chanqavgdt.tss">
<comment>
Reported average discharge on the last routing sub-step [cu m/s]
</comment>
</textvar>

<textvar name="WaterLevelTS" value="$(PathOut)/waterLevel.tss">
<comment>
Reported water level [m]
Expand Down
6 changes: 6 additions & 0 deletions tests/data/LF_MCT_UseCase/settings/mct_prerun_test_only.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4187,6 +4187,12 @@ LFBINDING: MORE LOW-LEVEL CONTROL OVER MODEL IN- AND OUTPUT
</comment>
</textvar>

<textvar name="ChanqavgdtTS" value="$(PathOut)/chanqavgdt.tss">
<comment>
Reported average discharge on the last routing sub-step [cu m/s]
</comment>
</textvar>

<textvar name="WaterLevelTS" value="$(PathOut)/waterLevel.tss">
<comment>
Reported water level [m]
Expand Down
Loading
Loading