From ea747ba266cd2d4387d4c7dbceb6bfe3e85a23a8 Mon Sep 17 00:00:00 2001 From: Carlo Russo Date: Mon, 31 Oct 2022 10:20:13 +0100 Subject: [PATCH 1/5] Updated lisflood_dynamic.py and version for v4.1.1 --- VERSION | 2 +- src/lisflood/Lisflood_dynamic.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 99eba4de..2582dddf 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.1.0 \ No newline at end of file +4.1.1 \ No newline at end of file diff --git a/src/lisflood/Lisflood_dynamic.py b/src/lisflood/Lisflood_dynamic.py index c510d335..c1f42b4a 100644 --- a/src/lisflood/Lisflood_dynamic.py +++ b/src/lisflood/Lisflood_dynamic.py @@ -199,6 +199,13 @@ def splitlanduse(array1, array2=None, array3=None): self.sumDis += self.sumDisDay self.ChanQAvg = self.sumDisDay/self.NoRoutSteps self.TotalCrossSectionArea = self.ChanM3 * self.InvChanLength + + self.TotalCrossSectionAreaSAFE = self.TotalCrossSectionArea + self.CrossSection2AreaSAFE = self.CrossSection2Area + self.TotalCrossSectionArea = np.where(np.abs(self.TotalCrossSectionAreaSAFE - self.CrossSection2AreaSAFE)<0.0000001,0.0,self.TotalCrossSectionArea) + self.CrossSection2Area = np.where(np.abs(self.TotalCrossSectionAreaSAFE - self.CrossSection2AreaSAFE)<0.0000001,0.0,self.CrossSection2Area) + self.ChanQ = np.where(np.abs(self.TotalCrossSectionAreaSAFE - self.CrossSection2AreaSAFE)<0.0000001,0.0,self.ChanQ) + self.ChanM3 = np.where(np.abs(self.TotalCrossSectionAreaSAFE - self.CrossSection2AreaSAFE)<0.0000001,0.0,self.ChanM3) # Total volume of water in channel per inv channel length # New cross section area (kinematic wave) # This is the value after the kinematic wave, so we use ChanM3Kin here From fd44acf44e3f8fdd79f8981fb4855fb9a16aa434 Mon Sep 17 00:00:00 2001 From: Carlo Russo Date: Wed, 2 Nov 2022 18:00:40 +0100 Subject: [PATCH 2/5] Fix for unit test in case of the small values correction in sumDisDay --- src/lisflood/Lisflood_dynamic.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/lisflood/Lisflood_dynamic.py b/src/lisflood/Lisflood_dynamic.py index c1f42b4a..fc1b65a0 100644 --- a/src/lisflood/Lisflood_dynamic.py +++ b/src/lisflood/Lisflood_dynamic.py @@ -196,16 +196,24 @@ def splitlanduse(array1, array2=None, array3=None): # sum of both lines # CrossSection2Area = pcraster.max(scalar(0.0), (self.Chan2M3Kin - self.Chan2M3Start) / self.ChanLength) + # temporary subtract routing ChanQ here, to be added after checks for small values + self.sumDisDay -= self.ChanQ + + self.TotalCrossSectionArea = self.ChanM3 * self.InvChanLength + + if option['SplitRouting']: + self.TotalCrossSectionAreaSAFE = self.TotalCrossSectionArea + self.CrossSection2AreaSAFE = self.CrossSection2Area + self.TotalCrossSectionArea = np.where(np.abs(self.TotalCrossSectionAreaSAFE - self.CrossSection2AreaSAFE)<0.0000001,0.0,self.TotalCrossSectionArea) + self.CrossSection2Area = np.where(np.abs(self.TotalCrossSectionAreaSAFE - self.CrossSection2AreaSAFE)<0.0000001,0.0,self.CrossSection2Area) + self.ChanQ = np.where(np.abs(self.TotalCrossSectionAreaSAFE - self.CrossSection2AreaSAFE)<0.0000001,0.0,self.ChanQ) + self.ChanM3 = np.where(np.abs(self.TotalCrossSectionAreaSAFE - self.CrossSection2AreaSAFE)<0.0000001,0.0,self.ChanM3) + + # add ChanQ again after small values check + self.sumDisDay += self.ChanQ self.sumDis += self.sumDisDay self.ChanQAvg = self.sumDisDay/self.NoRoutSteps - self.TotalCrossSectionArea = self.ChanM3 * self.InvChanLength - self.TotalCrossSectionAreaSAFE = self.TotalCrossSectionArea - self.CrossSection2AreaSAFE = self.CrossSection2Area - self.TotalCrossSectionArea = np.where(np.abs(self.TotalCrossSectionAreaSAFE - self.CrossSection2AreaSAFE)<0.0000001,0.0,self.TotalCrossSectionArea) - self.CrossSection2Area = np.where(np.abs(self.TotalCrossSectionAreaSAFE - self.CrossSection2AreaSAFE)<0.0000001,0.0,self.CrossSection2Area) - self.ChanQ = np.where(np.abs(self.TotalCrossSectionAreaSAFE - self.CrossSection2AreaSAFE)<0.0000001,0.0,self.ChanQ) - self.ChanM3 = np.where(np.abs(self.TotalCrossSectionAreaSAFE - self.CrossSection2AreaSAFE)<0.0000001,0.0,self.ChanM3) # Total volume of water in channel per inv channel length # New cross section area (kinematic wave) # This is the value after the kinematic wave, so we use ChanM3Kin here From 4a8850a3bb2315afb16ec5f9aaaa6276447a342a Mon Sep 17 00:00:00 2001 From: Carlo Russo Date: Fri, 2 Dec 2022 14:51:39 +0100 Subject: [PATCH 3/5] Application of wb_fore_output changes to v4.1.1 --- .../global_modules/default_options.py | 69 ++++++++++--------- 1 file changed, 35 insertions(+), 34 deletions(-) diff --git a/src/lisflood/global_modules/default_options.py b/src/lisflood/global_modules/default_options.py index 91a27a31..9b21e0be 100644 --- a/src/lisflood/global_modules/default_options.py +++ b/src/lisflood/global_modules/default_options.py @@ -33,6 +33,7 @@ 'repESActMaps': False, 'repESRefMaps': False, 'repETRefMaps': False, + 'repETActMaps': False, 'repEWIntMaps': False, 'repEWRefMaps': False, 'repEndMaps': True, @@ -302,11 +303,11 @@ restrictoption=['nonInit'], monthly=False, yearly=False), 'DirectRunoffMaps': ReportedMap(name='DirectRunoffMaps', output_var='DirectRunoff', unit='mm', end=[], - steps=[], all=['repSurfaceRunoffMaps'], + steps=['repSurfaceRunoffMaps'], all=[''], restrictoption=['nonInit'], monthly=False, yearly=False), 'DischargeEnd': ReportedMap(name='DischargeEnd', output_var='ChanQAvg', - unit='m3/s', end=['repEndMaps'], steps=[], + unit='m3/s', end=[], steps=[], all=[], restrictoption=[], monthly=False, yearly=False), 'DischargeMaps': ReportedMap(name='DischargeMaps', output_var='ChanQAvg', @@ -323,14 +324,14 @@ all=['repESActMaps'], restrictoption=['nonInit'], monthly=False, yearly=False), 'ESActMaps': ReportedMap(name='ESActMaps', output_var='ESActPixel', unit='mm', - end=[], steps=[], all=['repE2O1'], + end=[], steps=[], all=['repESActMaps','repE2O1'], restrictoption=['nonInit'], monthly=False, yearly=False), 'ESRefMapsOut': ReportedMap(name='ESRefMapsOut', output_var='ESRef', unit='mm', end=[], steps=[], all=['repESRefMaps'], restrictoption=[], monthly=False, yearly=False), 'ETActMaps': ReportedMap(name='ETActMaps', output_var='ESActPixel+self.var.TaPixel+self.var.TaInterceptionAll+self.var.EvaAddM3*self.var.M3toMM', - unit='mm', end=[], steps=[], all=['repE2O1'], + unit='mm', end=[], steps=[], all=['repETActMaps','repE2O1'], restrictoption=['nonInit'], monthly=False, yearly=False), 'ETRefMapsOut': ReportedMap(name='ETRefMapsOut', output_var='ETRef', unit='mm', end=[], steps=[], all=['repETRefMaps'], @@ -341,7 +342,7 @@ restrictoption=['nonInit'], monthly=False, yearly=False), 'EWIntMaps': ReportedMap(name='EWIntMaps', output_var='TaInterceptionAll', - unit='mm', end=[], steps=[], all=['repE2O1'], + unit='mm', end=[], steps=[], all=['repEWIntMaps','repE2O1'], restrictoption=['nonInit'], monthly=False, yearly=False), 'EWRefMapsOut': ReportedMap(name='EWRefMapsOut', output_var='EWRef', unit='mm', end=[], steps=[], all=['repEWRefMaps'], @@ -373,7 +374,7 @@ yearly=False), 'FastRunoffMaps': ReportedMap(name='FastRunoffMaps', output_var='SurfaceRunoff+self.var.UZOutflowPixel', - unit='mm', end=[], steps=[], all=['repE2O1'], + unit='mm', end=[], steps=[], all=['repFastRunoffMaps','repE2O1'], restrictoption=['nonInit'], monthly=False, yearly=False), 'FossilGroundwaterUsedM3': ReportedMap(name='FossilGroundwaterUsedM3', @@ -401,18 +402,18 @@ all=[], restrictoption=['nonInit'], monthly=False, yearly=False), 'GwLossMaps': ReportedMap(name='GwLossMaps', output_var='GwLossPixel', - unit='mm', end=[], steps=[], all=['repE2O2'], + unit='mm', end=[], steps=[], all=['repGwLossMaps','repE2O2'], restrictoption=['nonInit'], monthly=False, yearly=False), 'GwPercUZLZForestMaps': ReportedMap(name='GwPercUZLZForestMaps', output_var='GwPercUZLZ[1]', unit='mm', - end=[], steps=[], + end=[], steps=['repGwPercUZLZMaps'], all=['repGwPercUZLZMaps'], restrictoption=['nonInit'], monthly=False, yearly=False), 'GwPercUZLZIrrigationMaps': ReportedMap(name='GwPercUZLZForestMaps', output_var='GwPercUZLZ[2]', unit='mm', - end=[], steps=[], + end=[], steps=['repGwPercUZLZMaps'], all=['repGwPercUZLZMaps'], restrictoption=['nonInit'], monthly=False, yearly=False), @@ -425,7 +426,7 @@ 'GwPercUZLZMaps': ReportedMap(name='GwPercUZLZMaps', output_var='GwPercUZLZPixel', unit='mm', end=[], - steps=[], all=['repE2O2'], + steps=[], all=['repGwPercUZLZMaps','repE2O2'], restrictoption=['nonInit'], monthly=False, yearly=False), 'InfiltrationForestMaps': ReportedMap(name='InfiltrationForestMaps', @@ -477,7 +478,7 @@ monthly=False, yearly=False), 'LZOutflowMaps': ReportedMap(name='LZOutflowMaps', output_var='LZOutflowToChannelPixel', unit='mm', - end=[], steps=[], all=['repE2O1'], + end=[], steps=[], all=['repLZOutflowMaps','repE2O1'], restrictoption=['nonInit'], monthly=False, yearly=False), 'LZState': ReportedMap(name='LZState', output_var='LZ', unit='mm', end=[], @@ -558,7 +559,7 @@ yearly=False), 'OFDirectMaps': ReportedMap(name='OFDirectMaps', output_var='OFM3Direct', unit='m3', end=[], steps=[], - all=['repWaterDepthMaps'], + all=[], restrictoption=['nonInit'], monthly=False, yearly=False), 'OFDirectState': ReportedMap(name='OFDirectState', output_var='OFM3Direct', @@ -571,7 +572,7 @@ yearly=False), 'OFForestMaps': ReportedMap(name='OFForestMaps', output_var='OFM3Forest', unit='m3', end=[], steps=[], - all=['repWaterDepthMaps'], + all=[], restrictoption=['nonInit'], monthly=False, yearly=False), 'OFForestState': ReportedMap(name='OFForestState', output_var='OFM3Forest', @@ -584,7 +585,7 @@ yearly=False), 'OFOtherMaps': ReportedMap(name='OFOtherMaps', output_var='OFM3Other', unit='m3', end=[], steps=[], - all=['repWaterDepthMaps'], restrictoption=['nonInit'], + all=[], restrictoption=['nonInit'], monthly=False, yearly=False), 'OFOtherState': ReportedMap(name='OFOtherState', output_var='OFM3Other', unit='m3', end=[], steps=['repStateMaps'], @@ -706,7 +707,7 @@ restrictoption=['nonInit'], monthly=False, yearly=False), 'RainMaps': ReportedMap(name='RainMaps', output_var='Rain', unit='mm', - end=[], steps=[], all=['repE2O1'], + end=[], steps=[], all=['repRainMaps','repE2O1'], restrictoption=['nonInit'], monthly=False, yearly=False), 'RegionMonthExternalInflowM3': ReportedMap(name='RegionMonthExternalInflowM3', output_var='RegionMonthExternalInflowM3', @@ -862,14 +863,14 @@ restrictoption=['nonInit'], monthly=False, yearly=False), 'SnowCoverMaps': ReportedMap(name='SnowCoverMaps', output_var='SnowCover', - unit='mm', end=[], steps=[], all=['repE2O1'], + unit='mm', end=[], steps=[], all=['repSnowCoverMaps','repE2O1'], restrictoption=['nonInit'], monthly=False, yearly=False), 'SnowMaps': ReportedMap(name='SnowMaps', output_var='Snow', unit='mm', end=[], steps=[], all=['repSnowMaps'], restrictoption=['nonInit'], monthly=False, yearly=False), 'SnowMeltMaps': ReportedMap(name='SnowMeltMaps', output_var='SnowMelt', - unit='mm', end=[], steps=[], all=['repStateMaps'], + unit='mm', end=[], steps=[], all=['repSnowMeltMaps'], restrictoption=['nonInit'], monthly=False, yearly=False), 'SurfaceRunoffMaps': ReportedMap(name='SurfaceRunoffMaps', @@ -905,12 +906,12 @@ monthly=False, yearly=False), 'Theta1ForestMaps': ReportedMap(name='Theta1ForestMaps', output_var='Theta1a[1]', unit='mm', end=[], steps=[], - all=['repThetaForestMaps'], + all=['repThetaForestMaps','repThetaMaps'], restrictoption=['nonInit'], monthly=False, yearly=False), 'Theta1ForestState': ReportedMap(name='Theta1ForestState', output_var='Theta1a[1]', unit='mm', end=[], - steps=['repStateMaps'], all=['repThetaForestMaps'], + steps=['repStateMaps'], all=[], restrictoption=['nonInit'], monthly=False, yearly=False), 'Theta1IrrigationEnd': ReportedMap(name='Theta1IrrigationEnd', @@ -921,21 +922,21 @@ 'Theta1IrrigationMaps': ReportedMap(name='Theta1IrrigationMaps', output_var='Theta1a[2]', unit='mm', end=[], steps=[], - all=['repThetaIrrigationMaps'], + all=['repThetaIrrigationMaps','repThetaMaps'], restrictoption=['nonInit'], monthly=False, yearly=False), 'Theta1IrrigationState': ReportedMap(name='Theta1IrrigationState', output_var='Theta1a[2]', unit='mm', - end=[], steps=['repStateMaps'], all=['repThetaIrrigationMaps'], + end=[], steps=['repStateMaps'], all=[], restrictoption=['nonInit'], monthly=False, yearly=False), 'Theta1Maps': ReportedMap(name='Theta1Maps', output_var='Theta1a[0]', unit='mm', - end=[], steps=[], all=['repE2O2'], + end=[], steps=[], all=['repThetaMaps','repE2O2'], restrictoption=['nonInit'], monthly=False, yearly=False), 'Theta1State': ReportedMap(name='Theta1State', output_var='Theta1a[0]', unit='mm', end=[], steps=['repStateMaps'], - all=['repThetaMaps'], restrictoption=['nonInit'], monthly=False, + all=[], restrictoption=['nonInit'], monthly=False, yearly=False), 'Theta2End': ReportedMap(name='Theta2End', output_var='Theta1b[0]', unit='mm', end=['repEndMaps'], steps=[], all=[], @@ -946,7 +947,7 @@ monthly=False, yearly=False), 'Theta2ForestMaps': ReportedMap(name='Theta2ForestMaps', output_var='Theta1b[1]', unit='mm', end=[], steps=[], - all=['repThetaForestMaps'], + all=['repThetaForestMaps','repThetaMaps'], restrictoption=['nonInit'], monthly=False, yearly=False), 'Theta2ForestState': ReportedMap(name='Theta2ForestState', @@ -962,7 +963,7 @@ 'Theta2IrrigationMaps': ReportedMap(name='Theta2IrrigationMaps', output_var='Theta1b[2]', unit='mm', end=[], steps=[], - all=['repThetaIrrigationMaps'], + all=['repThetaIrrigationMaps','repThetaMaps'], restrictoption=['nonInit'], monthly=False, yearly=False), 'Theta2IrrigationState': ReportedMap(name='Theta2IrrigationState', @@ -971,7 +972,7 @@ restrictoption=['nonInit'], monthly=False, yearly=False), 'Theta2Maps': ReportedMap(name='Theta2Maps', output_var='Theta1b[0]', unit='mm', - end=[], steps=[], all=['repE2O2'], + end=[], steps=[], all=['repThetaMaps','repE2O2'], restrictoption=['nonInit'], monthly=False, yearly=False), 'Theta2State': ReportedMap(name='Theta2State', output_var='Theta1b[0]', @@ -987,12 +988,12 @@ monthly=False, yearly=False), 'Theta3ForestMaps': ReportedMap(name='Theta3ForestMaps', output_var='Theta2[1]', unit='mm', end=[], steps=[], - all=['repThetaForestMaps'], + all=['repThetaForestMaps','repThetaMaps'], restrictoption=['nonInit'], monthly=False, yearly=False), 'Theta3ForestState': ReportedMap(name='Theta3ForestState', output_var='Theta2[1]', unit='mm', end=[], - steps=['repStateMaps'], all=['repThetaForestMaps'], + steps=['repStateMaps'], all=[], restrictoption=['nonInit'], monthly=False, yearly=False), 'Theta3IrrigationEnd': ReportedMap(name='Theta3IrrigationEnd', @@ -1002,21 +1003,21 @@ yearly=False), 'Theta3IrrigationMaps': ReportedMap(name='Theta3IrrigationMaps', output_var='Theta2[2]', unit='mm', end=[], - steps=[], all=['repThetaIrrigationMaps'], + steps=[], all=['repThetaIrrigationMaps','repThetaMaps'], restrictoption=['nonInit'], monthly=False, yearly=False), 'Theta3IrrigationState': ReportedMap(name='Theta3IrrigationState', output_var='Theta2[2]', unit='mm', - end=[], steps=['repStateMaps'], all=['repThetaForestMaps'], + end=[], steps=['repStateMaps'], all=[], restrictoption=['nonInit'], monthly=False, yearly=False), 'Theta3Maps': ReportedMap(name='Theta3Maps', output_var='Theta2[0]', unit='mm', - end=[], steps=[], all=['repE2O2'], + end=[], steps=[], all=['repThetaMaps','repE2O2'], restrictoption=['nonInit'], monthly=False, yearly=False), 'Theta3State': ReportedMap(name='Theta3State', output_var='Theta2[0]', unit='mm', end=[], steps=['repStateMaps'], - all=['repThetaMaps'], restrictoption=['nonInit'], monthly=False, + all=[], restrictoption=['nonInit'], monthly=False, yearly=False), 'TotalAbsGroundwater': ReportedMap(name='TotalAbsGroundwater', output_var='abstraction_GW_actual_M3*self.var.M3toMM', @@ -1154,7 +1155,7 @@ 'indicator'], monthly=True, yearly=False), 'WaterDepthEnd': ReportedMap(name='WaterDepthEnd', output_var='WaterDepth', - unit='m', end=['repEndMaps'], steps=[], + unit='m', end=[], steps=[], all=[], restrictoption=['nonInit'], monthly=False, yearly=False), 'WaterDepthMaps': ReportedMap(name='WaterDepthMaps', output_var='WaterDepth', @@ -1163,7 +1164,7 @@ restrictoption=['nonInit'], monthly=False, yearly=False), 'WaterDepthState': ReportedMap(name='WaterDepthState', output_var='WaterDepth', - unit='m', end=[], steps=['repStateMaps'], + unit='m', end=[], steps=[], all=[], restrictoption=['nonInit'], monthly=False, yearly=False), 'WaterSecurityIndex': ReportedMap(name='WaterSecurityIndex', From 579cdc0fab1f6b38e46db50f91c8bcfdb77d5714 Mon Sep 17 00:00:00 2001 From: Carlo Russo Date: Fri, 2 Dec 2022 17:42:14 +0100 Subject: [PATCH 4/5] Fix xml files and test_results.py for wb_fore_output changes --- .../global_modules/default_options.py | 2 +- .../data/LF_ETRS89_UseCase/settings/base.xml | 18 ++++----- .../data/LF_ETRS89_UseCase/settings/full.xml | 18 ++++----- .../LF_ETRS89_UseCase/settings/inflow.xml | 18 ++++----- .../LF_ETRS89_UseCase/settings/prerun.xml | 18 ++++----- .../LF_lat_lon_UseCase/prerun_lat_lon.xml | 38 ++++++------------- tests/data/LF_lat_lon_UseCase/run_lat_lon.xml | 38 ++++++------------- tests/test_results.py | 17 ++++++--- 8 files changed, 72 insertions(+), 95 deletions(-) diff --git a/src/lisflood/global_modules/default_options.py b/src/lisflood/global_modules/default_options.py index 9b21e0be..37c03a4c 100644 --- a/src/lisflood/global_modules/default_options.py +++ b/src/lisflood/global_modules/default_options.py @@ -32,8 +32,8 @@ 'repE2O2': False, 'repESActMaps': False, 'repESRefMaps': False, - 'repETRefMaps': False, 'repETActMaps': False, + 'repETRefMaps': False, 'repEWIntMaps': False, 'repEWRefMaps': False, 'repEndMaps': True, diff --git a/tests/data/LF_ETRS89_UseCase/settings/base.xml b/tests/data/LF_ETRS89_UseCase/settings/base.xml index f2375610..380c2a10 100644 --- a/tests/data/LF_ETRS89_UseCase/settings/base.xml +++ b/tests/data/LF_ETRS89_UseCase/settings/base.xml @@ -3131,21 +3131,21 @@ LFBINDING: MORE LOW-LEVEL CONTROL OVER MODEL IN- AND OUTPUT SWITCHED ON (DEFAULT: ALL SWITCHED OFF) - + Reported volumetric soil moisture content for soil layer 1 [V/V] - + Reported volumetric soil moisture content for soil layer 2 [V/V] - + Reported volumetric soil moisture content for soil layer 3 [V/V] @@ -3263,21 +3263,21 @@ LFBINDING: MORE LOW-LEVEL CONTROL OVER MODEL IN- AND OUTPUT - + Reported volumetric soil moisture content for soil layer 1 [V/V] - + Reported volumetric soil moisture content for both soil layer 2 [V/V] - + Reported volumetric soil moisture content for both soil layer 3 [V/V] @@ -3527,21 +3527,21 @@ LFBINDING: MORE LOW-LEVEL CONTROL OVER MODEL IN- AND OUTPUT - + Reported volumetric soil moisture content for soil layer 1 [V/V] - + Reported volumetric soil moisture content for both soil layer 2 [V/V] - + Reported volumetric soil moisture content for both soil layer 3 [V/V] diff --git a/tests/data/LF_ETRS89_UseCase/settings/full.xml b/tests/data/LF_ETRS89_UseCase/settings/full.xml index 7fb96a81..298a65b5 100644 --- a/tests/data/LF_ETRS89_UseCase/settings/full.xml +++ b/tests/data/LF_ETRS89_UseCase/settings/full.xml @@ -5169,7 +5169,7 @@ LFBINDING: MORE LOW-LEVEL CONTROL OVER MODEL IN- AND OUTPUT - + @@ -5182,7 +5182,7 @@ LFBINDING: MORE LOW-LEVEL CONTROL OVER MODEL IN- AND OUTPUT - + @@ -5195,7 +5195,7 @@ LFBINDING: MORE LOW-LEVEL CONTROL OVER MODEL IN- AND OUTPUT - + @@ -5375,7 +5375,7 @@ LFBINDING: MORE LOW-LEVEL CONTROL OVER MODEL IN- AND OUTPUT - + @@ -5388,7 +5388,7 @@ LFBINDING: MORE LOW-LEVEL CONTROL OVER MODEL IN- AND OUTPUT - + @@ -5401,7 +5401,7 @@ LFBINDING: MORE LOW-LEVEL CONTROL OVER MODEL IN- AND OUTPUT - + @@ -5858,7 +5858,7 @@ LFBINDING: MORE LOW-LEVEL CONTROL OVER MODEL IN- AND OUTPUT - + @@ -5871,7 +5871,7 @@ LFBINDING: MORE LOW-LEVEL CONTROL OVER MODEL IN- AND OUTPUT - + @@ -5884,7 +5884,7 @@ LFBINDING: MORE LOW-LEVEL CONTROL OVER MODEL IN- AND OUTPUT - + diff --git a/tests/data/LF_ETRS89_UseCase/settings/inflow.xml b/tests/data/LF_ETRS89_UseCase/settings/inflow.xml index e1a36962..003b3b85 100644 --- a/tests/data/LF_ETRS89_UseCase/settings/inflow.xml +++ b/tests/data/LF_ETRS89_UseCase/settings/inflow.xml @@ -3129,21 +3129,21 @@ LFBINDING: MORE LOW-LEVEL CONTROL OVER MODEL IN- AND OUTPUT SWITCHED ON (DEFAULT: ALL SWITCHED OFF) - + Reported volumetric soil moisture content for soil layer 1 [V/V] - + Reported volumetric soil moisture content for soil layer 2 [V/V] - + Reported volumetric soil moisture content for soil layer 3 [V/V] @@ -3261,21 +3261,21 @@ LFBINDING: MORE LOW-LEVEL CONTROL OVER MODEL IN- AND OUTPUT - + Reported volumetric soil moisture content for soil layer 1 [V/V] - + Reported volumetric soil moisture content for both soil layer 2 [V/V] - + Reported volumetric soil moisture content for both soil layer 3 [V/V] @@ -3525,21 +3525,21 @@ LFBINDING: MORE LOW-LEVEL CONTROL OVER MODEL IN- AND OUTPUT - + Reported volumetric soil moisture content for soil layer 1 [V/V] - + Reported volumetric soil moisture content for both soil layer 2 [V/V] - + Reported volumetric soil moisture content for both soil layer 3 [V/V] diff --git a/tests/data/LF_ETRS89_UseCase/settings/prerun.xml b/tests/data/LF_ETRS89_UseCase/settings/prerun.xml index 1f58152f..9abfd1cc 100644 --- a/tests/data/LF_ETRS89_UseCase/settings/prerun.xml +++ b/tests/data/LF_ETRS89_UseCase/settings/prerun.xml @@ -3127,21 +3127,21 @@ LFBINDING: MORE LOW-LEVEL CONTROL OVER MODEL IN- AND OUTPUT SWITCHED ON (DEFAULT: ALL SWITCHED OFF) - + Reported volumetric soil moisture content for soil layer 1 [V/V] - + Reported volumetric soil moisture content for soil layer 2 [V/V] - + Reported volumetric soil moisture content for soil layer 3 [V/V] @@ -3259,21 +3259,21 @@ LFBINDING: MORE LOW-LEVEL CONTROL OVER MODEL IN- AND OUTPUT - + Reported volumetric soil moisture content for soil layer 1 [V/V] - + Reported volumetric soil moisture content for both soil layer 2 [V/V] - + Reported volumetric soil moisture content for both soil layer 3 [V/V] @@ -3523,21 +3523,21 @@ LFBINDING: MORE LOW-LEVEL CONTROL OVER MODEL IN- AND OUTPUT - + Reported volumetric soil moisture content for soil layer 1 [V/V] - + Reported volumetric soil moisture content for both soil layer 2 [V/V] - + Reported volumetric soil moisture content for both soil layer 3 [V/V] diff --git a/tests/data/LF_lat_lon_UseCase/prerun_lat_lon.xml b/tests/data/LF_lat_lon_UseCase/prerun_lat_lon.xml index 82f9259d..e784cbf1 100644 --- a/tests/data/LF_lat_lon_UseCase/prerun_lat_lon.xml +++ b/tests/data/LF_lat_lon_UseCase/prerun_lat_lon.xml @@ -3037,48 +3037,27 @@ LFBINDING: MORE LOW-LEVEL CONTROL OVER MODEL IN- AND OUTPUT SWITCHED ON (DEFAULT: ALL SWITCHED OFF) - + Reported volumetric soil moisture content for soil layer 1 [V/V] - + Reported volumetric soil moisture content for soil layer 2 [V/V] - + Reported volumetric soil moisture content for soil layer 3 [V/V] - - - Reported volumetric soil moisture content for - forest soil layer 1 [V/V] - - - - - - Reported volumetric soil moisture content for - forest soil layer 2 [V/V] - - - - - - Reported volumetric soil moisture content for - forest soil layer 3 [V/V] - - - Reported volumetric soil moisture content for combined @@ -3172,20 +3151,27 @@ LFBINDING: MORE LOW-LEVEL CONTROL OVER MODEL IN- AND OUTPUT - + Reported volumetric soil moisture content for soil layer 1 [V/V] - + Reported volumetric soil moisture content for both soil layer 2 [V/V] + + + Reported volumetric soil moisture content for + forest soil layer 3 [V/V] + + + Reported storage in upper response box [mm] diff --git a/tests/data/LF_lat_lon_UseCase/run_lat_lon.xml b/tests/data/LF_lat_lon_UseCase/run_lat_lon.xml index bd58ebda..8ac848c1 100644 --- a/tests/data/LF_lat_lon_UseCase/run_lat_lon.xml +++ b/tests/data/LF_lat_lon_UseCase/run_lat_lon.xml @@ -3002,48 +3002,27 @@ LFBINDING: MORE LOW-LEVEL CONTROL OVER MODEL IN- AND OUTPUT SWITCHED ON (DEFAULT: ALL SWITCHED OFF) - + Reported volumetric soil moisture content for soil layer 1 [V/V] - + Reported volumetric soil moisture content for soil layer 2 [V/V] - + Reported volumetric soil moisture content for soil layer 3 [V/V] - - - Reported volumetric soil moisture content for - forest soil layer 1 [V/V] - - - - - - Reported volumetric soil moisture content for - forest soil layer 2 [V/V] - - - - - - Reported volumetric soil moisture content for - forest soil layer 3 [V/V] - - - Reported volumetric soil moisture content for combined @@ -3137,20 +3116,27 @@ LFBINDING: MORE LOW-LEVEL CONTROL OVER MODEL IN- AND OUTPUT - + Reported volumetric soil moisture content for soil layer 1 [V/V] - + Reported volumetric soil moisture content for both soil layer 2 [V/V] + + + Reported volumetric soil moisture content for + forest soil layer 3 [V/V] + + + Reported storage in upper response box [mm] diff --git a/tests/test_results.py b/tests/test_results.py index 83b71dc1..b4dd7f76 100644 --- a/tests/test_results.py +++ b/tests/test_results.py @@ -113,12 +113,17 @@ def test_initvars(self): 'StepEnd': '05/02/2016 06:00', 'PathOut': output_dir}) lisfloodexe(settings) - initcond_files = ('ch2cr.end.nc', 'chcro.end.nc', 'chside.end.nc', 'cseal.end.nc', 'cum.end.nc', 'cumf.end.nc', - 'cumi.end.nc', 'dis.end.nc', 'dslf.end.nc', 'dsli.end.nc', 'dslr.end.nc', 'frost.end.nc', - 'lz.end.nc', - 'rsfil.end.nc', 'scova.end.nc', 'scovb.end.nc', 'scovc.end.nc', 'tha.end.nc', 'thb.end.nc', - 'thc.end.nc', 'thfa.end.nc', 'thfb.end.nc', 'thfc.end.nc', 'thia.end.nc', 'thib.end.nc', - 'thic.end.nc', 'uz.end.nc', 'uzf.end.nc', 'uzi.end.nc', 'wdept.end.nc') + initcond_files = ('ch2cr.end.nc', 'chanq.end.nc', 'chcro.end.nc', + 'chside.end.nc', 'cseal.end.nc', 'cum.end.nc', + 'cumf.end.nc', 'cumi.end.nc', 'dslf.end.nc', + 'dsli.end.nc', 'dslr.end.nc', 'frost.end.nc', + 'lakeh.end.nc', 'lz.end.nc', 'ofdir.end.nc', + 'offor.end.nc', 'ofoth.end.nc', 'rsfil.end.nc', + 'scova.end.nc', 'scovb.end.nc', 'scovc.end.nc', + 'tha.end.nc', 'thb.end.nc', 'thc.end.nc', + 'thfa.end.nc', 'thfb.end.nc', 'thfc.end.nc', + 'thia.end.nc', 'thib.end.nc', 'thic.end.nc', + 'uz.end.nc', 'uzf.end.nc', 'uzi.end.nc') for f in initcond_files: assert os.path.exists(os.path.join(output_dir, f)) From 6043971861fa543d500f21a480cde20fec88c893 Mon Sep 17 00:00:00 2001 From: StefaniaGrimaldi Date: Wed, 7 Dec 2022 10:48:34 +0100 Subject: [PATCH 5/5] bug fix numerical imprecisions warm start --- src/lisflood/Lisflood_dynamic.py | 15 +-------------- src/lisflood/global_modules/default_options.py | 18 +++++++++--------- src/lisflood/hydrological_modules/routing.py | 2 +- 3 files changed, 11 insertions(+), 24 deletions(-) diff --git a/src/lisflood/Lisflood_dynamic.py b/src/lisflood/Lisflood_dynamic.py index fc1b65a0..364f0a40 100644 --- a/src/lisflood/Lisflood_dynamic.py +++ b/src/lisflood/Lisflood_dynamic.py @@ -196,21 +196,8 @@ def splitlanduse(array1, array2=None, array3=None): # sum of both lines # CrossSection2Area = pcraster.max(scalar(0.0), (self.Chan2M3Kin - self.Chan2M3Start) / self.ChanLength) - # temporary subtract routing ChanQ here, to be added after checks for small values - self.sumDisDay -= self.ChanQ - self.TotalCrossSectionArea = self.ChanM3 * self.InvChanLength - if option['SplitRouting']: - self.TotalCrossSectionAreaSAFE = self.TotalCrossSectionArea - self.CrossSection2AreaSAFE = self.CrossSection2Area - self.TotalCrossSectionArea = np.where(np.abs(self.TotalCrossSectionAreaSAFE - self.CrossSection2AreaSAFE)<0.0000001,0.0,self.TotalCrossSectionArea) - self.CrossSection2Area = np.where(np.abs(self.TotalCrossSectionAreaSAFE - self.CrossSection2AreaSAFE)<0.0000001,0.0,self.CrossSection2Area) - self.ChanQ = np.where(np.abs(self.TotalCrossSectionAreaSAFE - self.CrossSection2AreaSAFE)<0.0000001,0.0,self.ChanQ) - self.ChanM3 = np.where(np.abs(self.TotalCrossSectionAreaSAFE - self.CrossSection2AreaSAFE)<0.0000001,0.0,self.ChanM3) - - # add ChanQ again after small values check - self.sumDisDay += self.ChanQ self.sumDis += self.sumDisDay self.ChanQAvg = self.sumDisDay/self.NoRoutSteps @@ -271,4 +258,4 @@ def splitlanduse(array1, array2=None, array3=None): self.stateVar_module.dynamic() if option['wateruse'] and option['indicator'] and self.monthend: self.indicatorcalc_module.dynamic_setzero() - # setting monthly and yearly dindicator to zero at the end of the month (year) \ No newline at end of file + # setting monthly and yearly dindicator to zero at the end of the month (year) diff --git a/src/lisflood/global_modules/default_options.py b/src/lisflood/global_modules/default_options.py index 37c03a4c..7126c023 100644 --- a/src/lisflood/global_modules/default_options.py +++ b/src/lisflood/global_modules/default_options.py @@ -127,12 +127,12 @@ 'wateruseRegion', 'indicator'], monthly=True, yearly=False), - 'ChSideEnd': ReportedMap(name='ChSideEnd', output_var='Sideflow1Chan', unit='m', + 'ChSideEnd': ReportedMap(name='ChSideEnd', output_var='Sideflow1Chan', unit='m3/s', end=['repEndMaps'], steps=[], all=[], restrictoption=['SplitRouting'], monthly=False, yearly=False), 'ChSideState': ReportedMap(name='ChSideState', output_var='Sideflow1Chan', - unit='m', end=[], steps=['repStateMaps'], + unit='m3/s', end=[], steps=['repStateMaps'], all=[], restrictoption=['nonInit', 'SplitRouting'], monthly=False, yearly=False), 'ChanCrossSectionEnd': ReportedMap(name='ChanCrossSectionEnd', @@ -208,12 +208,12 @@ 'indicator'], monthly=True, yearly=False), 'CrossSection2End': ReportedMap(name='CrossSection2End', - output_var='CrossSection2Area', unit='m', + output_var='CrossSection2Area', unit='m2', end=['repEndMaps'], steps=[], all=[], restrictoption=['SplitRouting'], monthly=False, yearly=False), 'CrossSection2State': ReportedMap(name='CrossSection2State', - output_var='CrossSection2Area', unit='m', + output_var='CrossSection2Area', unit='m2', end=[], steps=['repStateMaps'], all=[], restrictoption=['nonInit', 'SplitRouting'], monthly=False, yearly=False), @@ -240,7 +240,7 @@ yearly=False), 'CumInterceptionForestMaps': ReportedMap(name='CumInterceptionForestMaps', output_var='CumInterception[1]', - unit='m', end=[], steps=[], + unit='mm', end=[], steps=[], all=['repCumInterCeptionMaps'], restrictoption=['nonInit'], monthly=False, yearly=False), @@ -261,7 +261,7 @@ unit='mm', end=[], steps=['repStateMaps'], all=[], restrictoption=['nonInit'], monthly=False, yearly=False), 'CumInterceptionMaps': ReportedMap(name='CumInterceptionMaps', - output_var='CumInterception[0]', unit='m', + output_var='CumInterception[0]', unit='mm', end=[], steps=[], all=['repCumInterCeptionMaps'], restrictoption=['nonInit'], monthly=False, @@ -791,7 +791,7 @@ restrictoption=[], monthly=False, yearly=False), 'ReservoirFillState': ReportedMap(name='ReservoirFillState', - output_var='ReservoirFill', unit='m', + output_var='ReservoirFill', unit='-', end=[], steps=['repStateMaps'], all=[], restrictoption=['simulateReservoirs'], monthly=False, yearly=False), @@ -1087,7 +1087,7 @@ end=['repEndMaps'], steps=[], all=[], restrictoption=[], monthly=False, yearly=False), - 'UZForestMaps': ReportedMap(name='UZForestMaps', output_var='UZ[1]', unit='m', + 'UZForestMaps': ReportedMap(name='UZForestMaps', output_var='UZ[1]', unit='mm', end=[], steps=[], all=['repUZMaps'], restrictoption=['nonInit'], monthly=False, yearly=False), @@ -1103,7 +1103,7 @@ unit='mm', end=[], steps=['repStateMaps'], all=[], restrictoption=['nonInit'], monthly=False, yearly=False), - 'UZMaps': ReportedMap(name='UZMaps', output_var='UZ[0]', unit='m', end=[], + 'UZMaps': ReportedMap(name='UZMaps', output_var='UZ[0]', unit='mm', end=[], steps=[], all=['repUZMaps'], restrictoption=['nonInit'], monthly=False, yearly=False), 'UZOutflowForestMaps': ReportedMap(name='UZOutflowForestMaps', diff --git a/src/lisflood/hydrological_modules/routing.py b/src/lisflood/hydrological_modules/routing.py index bea92d6c..4683437e 100644 --- a/src/lisflood/hydrological_modules/routing.py +++ b/src/lisflood/hydrological_modules/routing.py @@ -390,7 +390,7 @@ def initialSecond(self): self.var.Chan2M3Kin = self.var.CrossSection2Area * self.var.ChanLength + self.var.Chan2M3Start self.var.ChanM3Kin = self.var.ChanM3 - self.var.Chan2M3Kin + self.var.Chan2M3Start - self.var.ChanM3Kin = np.where((self.var.ChanM3Kin < 0.0) & (self.var.ChanM3Kin > -0.0000001),0.0,self.var.ChanM3Kin) + self.var.ChanM3Kin = np.where((self.var.ChanM3Kin < 0.0) & (self.var.ChanM3Kin > -0.0000001),0.0,self.var.ChanM3Kin) # this line prevents the warmstart from failing in case of small numerical imprecisions when writing and reading the maps self.var.Chan2QKin = (self.var.Chan2M3Kin * self.var.InvChanLength * self.var.InvChannelAlpha2) ** (self.var.InvBeta) self.var.ChanQKin = (self.var.ChanM3Kin * self.var.InvChanLength * self.var.InvChannelAlpha) ** (self.var.InvBeta)