Skip to content

Commit

Permalink
Merge pull request #145 from GeoscienceUiO/143_total_water_storage
Browse files Browse the repository at this point in the history
Total water storage reporting
  • Loading branch information
doc78 authored Jan 10, 2024
2 parents f2fe1df + ee683ac commit 9529297
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 27 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ For details, please follow instruction on [official docs](http://pcraster.geo.uu
Now your environment should be set up to run lisflood. Try with a prepared settings file for one of the two test catchments:

```bash
mkdir tests/data/LF_ETRS89_UseCase/out
python src/lisf1.py tests/data/LF_ETRS89_UseCase/settings/cold.xml
```

Expand Down
45 changes: 34 additions & 11 deletions src/lisflood/global_modules/default_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
'repLZOutflowMaps': False,
'repLeafDrainageMaps': False,
'repMBTs': False,
'repTotalWaterStorageMaps': False,
'repMeteoUpsGauges': False,
'repPFMaps': False,
'repPFSites': False,
Expand Down Expand Up @@ -222,6 +223,12 @@
end=['repEndMaps'], steps=[], all=[],
restrictoption=[], monthly=False,
yearly=False),
'CumIntSealedMaps': ReportedMap(name='CumIntSealedMaps',
output_var='CumInterSealed',
unit='mm', end=[], steps=[],
all=['repCumInterCeptionMaps'],
restrictoption=['nonInit'],
monthly=False, yearly=False),
'CumIntSealedState': ReportedMap(name='CumIntSealedState',
output_var='CumInterSealed', unit='mm',
end=[], steps=['repStateMaps'], all=[],
Expand All @@ -232,6 +239,17 @@
end=['repEndMaps'], steps=[], all=[],
restrictoption=[], monthly=False,
yearly=False),
'CumInterceptionMaps': ReportedMap(name='CumInterceptionMaps',
output_var='CumInterception[0]', unit='mm',
end=[], steps=[],
all=['repCumInterCeptionMaps'],
restrictoption=['nonInit'], monthly=False,
yearly=False),
'CumInterceptionState': ReportedMap(name='CumInterceptionState',
output_var='CumInterception[0]', unit='mm',
end=[], steps=['repStateMaps'], all=[],
restrictoption=['nonInit'], monthly=False,
yearly=False),
'CumInterceptionForestEnd': ReportedMap(name='CumInterceptionForestEnd',
output_var='CumInterception[1]',
unit='mm', end=['repEndMaps'],
Expand All @@ -256,21 +274,16 @@
steps=[], all=[],
restrictoption=[],
monthly=False, yearly=False),
'CumInterceptionIrrigationMaps': ReportedMap(name='CumInterceptionIrrigationMaps',
output_var='CumInterception[2]',
unit='mm', end=[], steps=[],
all=['repCumInterCeptionMaps'],
restrictoption=['nonInit'],
monthly=False, yearly=False),
'CumInterceptionIrrigationState': ReportedMap(
name='CumInterceptionIrrigationState', output_var='CumInterception[2]',
unit='mm', end=[], steps=['repStateMaps'], all=[],
restrictoption=['nonInit'], monthly=False, yearly=False),
'CumInterceptionMaps': ReportedMap(name='CumInterceptionMaps',
output_var='CumInterception[0]', unit='mm',
end=[], steps=[],
all=['repCumInterCeptionMaps'],
restrictoption=['nonInit'], monthly=False,
yearly=False),
'CumInterceptionState': ReportedMap(name='CumInterceptionState',
output_var='CumInterception[0]', unit='mm',
end=[], steps=['repStateMaps'], all=[],
restrictoption=['nonInit'], monthly=False,
yearly=False),
'DSLREnd': ReportedMap(name='DSLREnd', output_var='DSLR[0]', unit='-',
end=['repEndMaps'], steps=[], all=[],
restrictoption=[], monthly=False, yearly=False),
Expand Down Expand Up @@ -1099,6 +1112,10 @@
unit='mm', end=['repEndMaps'], steps=[],
all=[], restrictoption=[],
monthly=False, yearly=False),
'UZIrrigationMaps': ReportedMap(name='UZIrrigationMaps', output_var='UZ[2]',
unit='mm', end=[], steps=[],
all=['repUZMaps'], restrictoption=['nonInit'],
monthly=False, yearly=False),
'UZIrrigationState': ReportedMap(name='UZIrrigationState', output_var='UZ[2]',
unit='mm', end=[], steps=['repStateMaps'],
all=[], restrictoption=['nonInit'],
Expand Down Expand Up @@ -1167,6 +1184,12 @@
unit='m', end=[], steps=[],
all=[], restrictoption=['nonInit'],
monthly=False, yearly=False),
'TotalWaterStorageMaps': ReportedMap(name='TotalWaterStorageMaps',
output_var='TotalWaterStorageMM',
unit='mm', end=[], steps=[],
all=['repTotalWaterStorageMaps'],
restrictoption=['nonInit'],
monthly=False, yearly=False),
'WaterSecurityIndex': ReportedMap(name='WaterSecurityIndex',
output_var='WaterSecurityIndex', unit='-',
end=[], steps=['repWIndex'], all=[],
Expand Down
42 changes: 27 additions & 15 deletions src/lisflood/hydrological_modules/waterbalance.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,24 @@ def initial(self):

self.var.DischargeM3StructuresIni = np.take(np.bincount(self.var.Catchments, weights=DisStructure), self.var.Catchments)

# --------------------------------------------------------------------------
# -------------------------------------------------------------------------

def storage_channel(self, option):
ChannelStoredM3 = self.var.ChanM3.copy()
if option['simulateLakes']:
ChannelStoredM3 += self.var.LakeStorageM3Balance
if option['simulateReservoirs']:
ChannelStoredM3 += self.var.ReservoirStorageM3
if option['simulatePolders']:
ChannelStoredM3 += self.var.PolderStorageM3
return ChannelStoredM3

def storage_hillslope(self):
ax_veg = self.var.SoilFraction.dims.index("vegetation")
Hill1 = self.var.LZ + np.sum(self.var.SoilFraction * (self.var.CumInterception + self.var.W1 + self.var.W2 + self.var.UZ), ax_veg)
HillslopeStoredMM = self.var.WaterDepth + self.var.SnowCover + Hill1 + self.var.DirectRunoffFraction * self.var.CumInterSealed
return HillslopeStoredMM * self.var.MMtoM3

# --------------------------------------------------------------------------
# -------------------------------------------------------------------------
Expand All @@ -118,6 +136,11 @@ def dynamic(self):
settings = LisSettings.instance()
option = settings.options
maskinfo = MaskInfo.instance()

if (not(option['InitLisflood'])) and option['repTotalWaterStorageMaps']:
ChannelStoredM3 = self.storage_channel(option)
HillslopeStoredM3 = self.storage_hillslope()
self.var.TotalWaterStorageMM = (ChannelStoredM3 + HillslopeStoredM3) * self.var.M3toMM

if (not(option['InitLisflood'])) and option['repMBTs']:

Expand All @@ -143,22 +166,12 @@ def dynamic(self):
# spatially variable

# This is stored:
ChannelStoredM3 = self.var.ChanM3.copy()
if option['simulateLakes']:
ChannelStoredM3 += self.var.LakeStorageM3Balance
if option['simulateReservoirs']:
ChannelStoredM3 += self.var.ReservoirStorageM3
if option['simulatePolders']:
ChannelStoredM3 += self.var.PolderStorageM3

ChannelStoredM3 = self.storage_channel(option)
# ChannelStoredM3=ChanM3 + ReservoirStorageM3 + LakeStorageM3 + PolderStorageM3;
# Water stored in channel network [m3] (including reservoirs,
# lakes, polders)

ax_veg=self.var.SoilFraction.dims.index("vegetation")
Hill1 = self.var.LZ + np.sum(self.var.SoilFraction * (self.var.CumInterception + self.var.W1 + self.var.W2 + self.var.UZ),ax_veg)
HillslopeStoredM3 = (self.var.WaterDepth + self.var.SnowCover + Hill1 + self.var.DirectRunoffFraction * self.var.CumInterSealed) * self.var.MMtoM * self.var.PixelArea

HillslopeStoredM3 = self.storage_hillslope()
# Water stored at hillslope elements [m3]
# Note that W1, W2 and TotalGroundWater are defined for the pixel's permeable fraction
# only, which is why we need to multiply with PermeableFraction to get the volumes right (no soil moisture
Expand All @@ -184,8 +197,7 @@ def dynamic(self):
if not option["cropsEPIC"]: # If EPIC is active, the rice fraction initialisation is handled by EPIC (setSoilFractions in EPIC_main.py)
self.var.SoilFraction.values[self.var.vegetation.index('Rainfed_prescribed')] += self.var.RiceFraction

Hill1 = self.var.LZ + (self.var.SoilFraction * (self.var.CumInterception + self.var.W1 + self.var.W2 + self.var.UZ)).sum("vegetation").values
HillslopeStoredM3 = (self.var.WaterDepth + self.var.SnowCover + Hill1 + self.var.DirectRunoffFraction * self.var.CumInterSealed) * self.var.MMtoM * self.var.PixelArea
HillslopeStoredM3 = self.storage_hillslope()
WaterStored_nextstep =np.take(np.bincount(self.var.Catchments,weights=ChannelStoredM3),self.var.Catchments)
WaterStored_nextstep += np.take(np.bincount(self.var.Catchments,weights=HillslopeStoredM3),self.var.Catchments)

Expand Down Expand Up @@ -273,4 +285,4 @@ def dynamic(self):
ones = maskinfo.in_zero() + 1.0
numpixels = np.take(np.bincount(self.var.Catchments, weights=ones),self.var.Catchments)
self.var.MBErrorStorage = self.var.MBError/(self.var.WaterInit)
self.var.AverageFractions = SumFractions/numpixels
self.var.AverageFractions = SumFractions/numpixels
26 changes: 25 additions & 1 deletion src/lisfloodSettings_reference.xml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ You can use builtin path variables in this template and reference to other paths
<setoption choice="1" name="repPercolationMaps"/>
<setoption choice="1" name="repRWS"/>
<setoption choice="1" name="repPFMaps"/>
<setoption choice="1" name="repTotalWaterStorageMaps"/>
<setoption choice="1" name="repPFForestMaps"/>

<setoption choice="1" name="repTotalAbs"/>
Expand Down Expand Up @@ -3429,6 +3430,12 @@ Reported storage in lower response box [mm]
</comment>
</textvar>

<textvar name="TotalWaterStorageMaps" value="$(PathOut)/tws">
<comment>
Reported total water storage [mm]
</comment>
</textvar>

<textvar name="DSLRMaps" value="$(PathOut)/dslr">
<comment>
Reported days since last rain
Expand Down Expand Up @@ -3483,7 +3490,6 @@ Reported interception storage, other fraction [mm]
</comment>
</textvar>


<textvar name="DSLRForestMaps" value="$(PathOut)/dslrf">
<comment>
Reported days since last rain
Expand All @@ -3496,6 +3502,12 @@ Reported interception storage, forest fraction [mm]
</comment>
</textvar>

<textvar name="CumInterceptionIrrigationMaps" value="$(PathOut)/cumi">
<comment>
Reported interception storage, irrigation fraction [mm]
</comment>
</textvar>

<textvar name="Theta1ForestMaps" value="$(PathOut)/thfa">
<comment>
Reported volumetric soil moisture content for
Expand All @@ -3522,6 +3534,12 @@ soil layer 2 (lower layer) [V/V] [mm3/mm3]
Reported storage in upper response box [mm]
</comment>
</textvar>

<textvar name="CumIntSealedMaps" value="$(PathOut)/cums">
<comment>
Reported interception (depression) storage, direct runoff (impervious) fraction [mm]
</comment>
</textvar>
</group>

<group>
Expand Down Expand Up @@ -3829,6 +3847,12 @@ soil layer 2 [V/V] [mm3/mm3]
</comment>
</textvar>

<textvar name="UZIrrigationMaps" value="$(PathOut)/uzi">
<comment>
Reported storage in upper response box [mm]
</comment>
</textvar>

</group>


Expand Down

0 comments on commit 9529297

Please sign in to comment.