hydrological_modules package

Initialize

miscInitial module

Initializing some variables

class hydrological_modules.miscInitial.miscInitial(misc_variable)[source]

Bases: object

Miscellaneous repeatedly used expressions Definition if cell area comes from regular grid e.g. 5x5km or from irregular lat/lon Conversion factors between m3 and mm etc.

Note

Only used in the initial phase.

initial()[source]

Initialization of some basic parameters e.g. cellArea

  • grid area, length definition

  • conversion factors

  • conversion factors for precipitation and pot evaporation

initcondition module

Load initial storage parameter maps

class hydrological_modules.initcondition.initcondition(initcondition_variable)[source]

Bases: object

READ/WRITE INITIAL CONDITIONS all initial condition can be stored at the end of a run to be used as a warm start for a following up run

dynamic()[source]

Dynamic part of the initcondition module write initital conditions into a single netcdf file

Note

Several dates can be stored in different netcdf files

initial()[source]
initial part of the initcondition module

Puts all the variables which has to be stored in 2 lists:

  • initCondVar: the name of the variable in the init netcdf file

  • initCondVarValue: the variable as it can be read with the ‘eval’ command

Reads the parameter save_initial and save_initial to know if to save or load initial values

load_initial(name, default=0.0, number=None)[source]

First it is checked if the initial value is given in the settings file

  • if it is <> None it is used directly

  • if None it is loaded from the init netcdf file

Parameters
  • name – Name of the init value

  • default – default value -> default is 0.0

  • number – in case of snow or runoff concentration several layers are included: number = no of the layer

Returns

spatial map or value of initial condition

landcoverType module

Generate landcover types

class hydrological_modules.landcoverType.landcoverType(landcoverType_variable)[source]

Bases: object

LAND COVER TYPE

runs the 6 land cover types through soil procedures

This routine calls the soil routine for each land cover type

dynamic()[source]

Dynamic part of the land cover type module

Calculating soil for each of the 6 land cover class

  • calls evaporation_module.dynamic

  • calls interception_module.dynamic

  • calls soil_module.dynamic

  • calls sealed_water_module.dynamic

And sums every thing up depending on the land cover type fraction

dynamic_fracIrrigation(init=False, dynamic=True)[source]

Dynamic part of the land cover type module

Calculating fraction of land cover

  • loads the fraction of landcover for each year from netcdf maps

  • calculate the fraction of 6 land cover types based on the maps

Parameters
  • init – (optional) True: set for the first time of a run

  • dynamic – used in the dynmic run not in the initial phase

Returns

initial()[source]

Initial part of the land cover type module Initialise the six land cover types

  • Forest

  • Grasland/non irrigated land

  • Irrigation

  • Paddy iirigation

  • Sealed area

  • Water covered area

And initialize the soil variables

Hydrology I - from rain to soil

readmeteo module

Read meteorological input data

class hydrological_modules.readmeteo.readmeteo(readmeteo_variable)[source]

Bases: object

READ METEOROLOGICAL DATA

reads all meteorological data from netcdf4 files

downscaling1(input, downscale=0)[source]

Downscaling based on elevation correction for temperature and pressure

Parameters
  • input

  • downscale – 0 for no change, 1: for temperature change 6 deg per 1km , 2 for psurf

Returns

input - downscaled input data

downscaling2(input, downscaleName='', wc2=0, wc4=0, downscale=0)[source]

Downscaling based on Delta method:

Parameters
  • input – low input map

  • downscaleName – High resolution monthly map from WorldClim

  • wc2 – High resolution WorldClim map

  • wc4 – upscaled to low resolution

  • downscale – 0 for no change, 1: for temperature , 2 for pprecipitation, 3 for psurf

Returns

input - downscaled input data

Returns

wc2

Returns

wc4

dynamic()[source]

Dynamic part of the readmeteo module

Read meteo input maps from netcdf files

Note

If option calc_evaporation is False only precipitation, avg. temp., and 2 evaporation vlaues are read Otherwise all the variable needed for Penman-Monteith

Note

If option TemperatureInKelvin = True temperature is assumed to be Kelvin instead of Celsius!

initial()[source]

Initial part of meteo

read multiple file of input

inflow module

Read river discharge time series as inflow data

class hydrological_modules.inflow.inflow(inflow_variable)[source]

Bases: object

READ INFLOW HYDROGRAPHS (OPTIONAL) If option “inflow” is set to 1 the inflow hydrograph code is used otherwise dummy code is used

dynamic()[source]

Dynamic part of the inflow module Use the inflow points to add inflow from time series file(s)

initial()[source]

Initial part of the inflow module Get the inflow points

calls function hydrological_modules.getlocOutpoints() calls function hydrological_modules.join_struct_arrays2()

snow_frost module

Calculate snow and frost

class hydrological_modules.snow_frost.snow(snow_variable)[source]

Bases: object

RAIN AND SNOW

Domain: snow calculations evaluated for center points of up to 7 sub-pixel snow zones 1 -7 which each occupy a part of the pixel surface

Variables snow and rain at end of this module are the pixel-average snowfall and rain

dynamic()[source]

Dynamic part of the snow module

Distinguish between rain/snow and calculates snow melt and glacier melt The equation is a modification of:

References

Speers, D.D., Versteeg, J.D. (1979) Runoff forecasting for reservoir operations - the pastand the future. In: Proceedings 52nd Western Snow Conference, 149-156

Frost index in soil [degree days] based on:

References

Molnau and Bissel (1983, A Continuous Frozen Ground Index for Flood Forecasting. In: Maidment, Handbook of Hydrology, p. 7.28, 7.55)

Todo

calculate sinus shape function for the southern hemisspere

initial()[source]

Initial part of the snow and frost module

  • loads all the parameters for the day-degree approach for rain, snow and snowmelt

  • loads the parameter for frost

evaporationPot module

Calculate potential Evaporation

class hydrological_modules.evaporationPot.evaporationPot(evaporationPot_variable)[source]

Bases: object

POTENTIAL REFERENCE EVAPO(TRANSPI)RATION Calculate potential evapotranspiration from climate data mainly based on FAO 56 and LISVAP Based on Penman Monteith

References

http://www.fao.org/docrep/X0490E/x0490e08.htm#penman%20monteith%20equation http://www.fao.org/docrep/X0490E/x0490e06.htm http://www.fao.org/docrep/X0490E/x0490e06.htm https://ec.europa.eu/jrc/en/publication/eur-scientific-and-technical-research-reports/lisvap-evaporation-pre-processor-lisflood-water-balance-and-flood-simulation-model

dynamic()[source]

Dynamic part of the potential evaporation module :returns: ETRef - potential reference evapotranspiration rate [m/day]

EWRef - potential evaporation rate from water surface [m/day]

dynamic_1()[source]

Dynamic part of the potential evaporation module Based on Penman Monteith - FAO 56

dynamic_2()[source]

Dynamic part of the potential evaporation module Based on xxxxxxxxxxxxxxxxxxx

initial()[source]

Initial part of evaporation type module Load inictial parameters

Note

Only run if calc_evaporation is True

initial_1()[source]

Initial part of evaporation type module Load initial parameters 1: Penman Monteith

initial_2()[source]

Initial part of evaporation type module Load initial parameters 2: xxxx method

evaporation module

Calculate actual evapotranspiration

class hydrological_modules.evaporation.evaporation(evaporation_variable)[source]

Bases: object

Evaporation module Calculate potential evaporation and pot. transpiration

dynamic(coverType, No)[source]

Dynamic part of the soil module

calculating potential Evaporation for each land cover class with kc factor get crop coefficient, use potential ET, calculate potential bare soil evaporation and transpiration

Parameters
  • coverType – Land cover type: forest, grassland …

  • No – number of land cover type: forest = 0, grassland = 1 …

Returns

potential evaporation from bare soil, potential transpiration

interception module

Calculate interception

class hydrological_modules.interception.interception(interception_variable)[source]

Bases: object

INTERCEPTION

dynamic(coverType, No)[source]

Dynamic part of the interception module calculating interception for each land cover class

Parameters
  • coverType – Land cover type: forest, grassland …

  • No – number of land cover type: forest = 0, grassland = 1 …

Returns

interception evaporation, interception storage, reduced pot. transpiration

sealed_water module

Calculate water runoff from impermeable surface

class hydrological_modules.sealed_water.sealed_water(sealed_water_variable)[source]

Bases: object

Sealed and open water runoff

calculated runoff from impermeable surface (sealed) and into water bodies

dynamic(coverType, No)[source]

Dynamic part of the sealed_water module

runoff calculation for open water and sealed areas

Parameters
  • coverType – Land cover type: forest, grassland …

  • No – number of land cover type: forest = 0, grassland = 1 …

Hydrology II - from soil to river

soil module

** Calculate fluxes in 3 layer soil**

class hydrological_modules.soil.soil(soil_variable)[source]

Bases: object

SOIL

Caclulation vertical transfer of water based on Arno scheme

dynamic(coverType, No)[source]

Dynamic part of the soil module

For each of the land cover classes the vertical water transport is simulated Distribution of water holding capiacity in 3 soil layers based on saturation excess overland flow, preferential flow Dependend on soil depth, soil hydraulic parameters

initial()[source]

Initial part of the soil module

  • Initialize all the hydraulic properties of soil

  • Set soil depth

capillarRise module

Calculate capillar rise from groundwater

class hydrological_modules.capillarRise.capillarRise(capillarRise_variable)[source]

Bases: object

CAPPILAR RISE calculate cell fraction influenced by capillary rise

dynamic()[source]

Dynamic part of the capillar Rise module calculate cell fraction influenced by capillary rise depending on appr. height of groundwater and relative elevation of grid cell

Returns

capRiseFrac = cell fraction influenced by capillary rise

groundwater module

Calculate groundwater

class hydrological_modules.groundwater.groundwater(groundwater_variable)[source]

Bases: object

GROUNDWATER

dynamic()[source]

Dynamic part of the groundwater module Calculate groundweater storage and baseflow

initial()[source]

Initial part of the groundwater module

  • load parameters from settings file

  • initial groundwater storage

runoff_concentration module

Calculate runoff concentration - from grid cell to grid cell corner

class hydrological_modules.runoff_concentration.runoff_concentration(runoff_concentration_variable)[source]

Bases: object

Runoff concentration

this is the part between runoff generation and routing for each gridcell and for each land cover class the generated runoff is concentrated at a corner of a gridcell this concentration needs some lag-time (and peak time) and leads to diffusion lag-time/ peak time is calculated using slope, length and land cover class diffusion is calculated using a triangular-weighting-function

Q(t) = \sum_{i=0}^{max} c(i) * Q_{\mathrm{GW}} (t - i + 1)

where c(i) = \int_{i-1}^{i} {2 \over{max}} - | u - {max \over {2}} | * {4 \over{max^2}} du

see also:

http://stackoverflow.com/questions/24040984/transformation-using-triangular-weighting-function-in-python

dynamic()[source]

Dynamic part of the runoff concentration module

For surface runoff for each land cover class and for interflow and for baseflow the runoff concentration time is calculated

Note

the time demanding part is calculated in a c++ library

initial()[source]

Initial part of the runoff concentration module

Setting the peak time for:

  • surface runoff = 3

  • interflow = 4

  • baseflow = 5

based on the slope the concentration time for each land cover type is calculated

Note

only if option includeRunoffConcentration is TRUE

Hydrology III - Socio-economic - Water demand

waterdemand module

Calculate water demand from different sectors

Naming convention:
class hydrological_modules.waterdemand.waterdemand(waterdemand_variable)[source]

Bases: object

WATERDEMAND

calculating water demand - Industrial, domenstic based on precalculated maps Agricultural water demand based on water need by plants

dynamic()[source]

Dynamic part of the water demand module

  • calculate the fraction of water from surface water vs. groundwater

  • get non-Irrigation water demand and its return flow fraction

initial()[source]

Initial part of the water demand module

Set the water allocation

Hydrology IV - Lakes, reservoirs and river

lakes_reservoirs module

Calculate water retention in lakes

class hydrological_modules.lakes_reservoirs.lakes_reservoirs(lakes_reservoirs_variable)[source]

Bases: object

LAKES AND RESERVOIRS

Note

Calculate water retention in lakes and reservoirs

Using the Modified Puls approach to calculate retention of a lake See also: LISFLOOD manual Annex 3 (Burek et al. 2013)

for Modified Puls Method the Q(inflow)1 has to be used. It is assumed that this is the same as Q(inflow)2 for the first timestep has to be checked if this works in forecasting mode!

Lake Routine using Modified Puls Method (see Maniak, p.331ff)

{Qin1 + Qin2 \over{2}} - {Qout1 + Qout2 \over{2}} = {S2 - S1 \over{\delta time}}

changed into:

{S2 \over{time + Qout2/2}} = {S1 \over{dtime + Qout1/2}} - Qout1 + {Qin1 + Qin2 \over{2}}

Outgoing discharge (Qout) are linked to storage (S) by elevation.

Now some assumption to make life easier:

1.) storage volume is increase proportional to elevation: S = A * H where: H: elevation, A: area of lake

2.) Q_{\mathrm{out}} = c * b * H^{2.0} (c: weir constant, b: width)

2.0 because it fits to a parabolic cross section see (Aigner 2008) (and it is much easier to calculate (that’s the main reason)

c: for a perfect weir with mu=0.577 and Poleni: {2 \over{3}} \mu * \sqrt{2*g} = 1.7

c: for a parabolic weir: around 1.8

because it is a imperfect weir: C = c * 0.85 = 1.5

results in formular: Q = 1.5 * b * H^2 = a*H^2 -> H = \sqrt{Q/a}

Solving the equation:

{S2 \over{dtime + Qout2/2}} = {S1 \over{dtime + Qout1/2}} - Qout1 + {Qin1 + Qin2 \over{2}}

SI = {S2 \over{dtime}} + {Qout2 \over{2}} = {A*H \over{DtRouting}} + {Q \over{2}} = {A \over{DtRouting*\sqrt{a}* \sqrt{Q}}} + {Q \over{2}}

-> replacement: {A \over{DtSec * \sqrt{a}}} = Lakefactor, Y = \sqrt{Q}

Y^2 + 2 * Lakefactor *Y - 2 * SI=0

solution of this quadratic equation:

Q = (-LakeFactor + \sqrt{LakeFactor^2+2*SI})^2

dynamic()[source]

Dynamic part set lakes and reservoirs for each year

dynamic_inloop(NoRoutingExecuted)[source]

Dynamic part to calculate outflow from lakes and reservoirs

  • lakes with modified Puls approach

  • reservoirs with special filling levels

Parameters

NoRoutingExecuted – actual number of routing substep

Returns

outLdd: outflow in m3 to the network

Note

outflow to adjected lakes and reservoirs is calculated separately

initWaterbodies()[source]

Initialize water bodies Read parameters from maps e.g area, location, initial average discharge, type 9reservoir or lake) etc.

Compress numpy array from mask map to the size of lakes+reservoirs (marked as capital C at the end of the variable name)

initial_lakes()[source]

Initial part of the lakes module Using the Modified Puls approach to calculate retention of a lake

initial_reservoirs()[source]

Initial part of the reservoir module Using the appraoch of LISFLOOD

See also

LISFLOOD manual Annex 1: (Burek et al. 2013)

lakes_res_small module

Calculate water retention in small lakes

class hydrological_modules.lakes_res_small.lakes_res_small(lakes_res_small_variable)[source]

Bases: object

Small LAKES AND RESERVOIRS

Note

Calculate water retention in lakes and reservoirs

Using the Modified Puls approach to calculate retention of a lake See also: LISFLOOD manual Annex 3 (Burek et al. 2013)

dynamic()[source]

Dynamic part to calculate outflow from small lakes and reservoirs

  • lakes with modified Puls approach

  • reservoirs with special filling levels

Flow out of lake:

Returns

outflow in m3 to the network

initial()[source]

Initialize small lakes and reservoirs Read parameters from maps e.g area, location, initial average discharge, type: reservoir or lake) etc.

routing_reservoirs.routing_kinematic module

River routing - kinematic wave

class hydrological_modules.routing_reservoirs.routing_kinematic.routing_kinematic(routing_kinematic_variable)[source]

Bases: object

ROUTING

routing using the kinematic wave

dynamic()[source]

Dynamic part of the routing module

  • calculate evaporation from channels

  • calculate riverbed exchange between riverbed and groundwater

  • if option waterbodies is true, calculate retention from water bodies

  • calculate sideflow -> inflow to river

  • calculate kinematic wave -> using C++ library for computational speed

initial()[source]

Initial part of the routing module

  • load and create a river network

  • calculate river network parameter e.g. river length, width, depth, gradient etc.

  • calculate initial filling

  • calculate manning’s roughness coefficient

routing_reservoirs.routing_sub module

Sub routines for river routing

hydrological_modules.routing_reservoirs.routing_sub.Compress(map, mask)[source]

compressing map from 2D to 1D without missing values

Parameters
  • map – input map

  • mask – mask map

Returns

compressed map

hydrological_modules.routing_reservoirs.routing_sub.catchment1(dirUp, points)[source]

calculates all cells which belongs to a catchment from point onward

Parameters
  • dirUp

  • points

Returns

subcatchment

hydrological_modules.routing_reservoirs.routing_sub.decompress(map)[source]

Decompressing map from 1D to 2D with missing values

Parameters

map – compressed map

Returns

decompressed 2D map

hydrological_modules.routing_reservoirs.routing_sub.defLdd2(ldd)[source]

defines river network

Parameters

ldd – river network

Returns

ldd variables

hydrological_modules.routing_reservoirs.routing_sub.dirDownstream(dirUp, lddcomp, dirDown)[source]

runs the river network tree downstream - from source to outlet

Parameters
  • dirUp

  • lddcomp

  • dirDown

Returns

direction downstream

hydrological_modules.routing_reservoirs.routing_sub.dirUpstream(dirshort)[source]

runs the network tree upstream from outlet to source

Parameters

dirshort

Returns

direction upstream

hydrological_modules.routing_reservoirs.routing_sub.downstream1(dirUp, weight)[source]

calculated 1 cell downstream

Parameters
  • dirUp

  • weight

Returns

dowmnstream 1 cell

hydrological_modules.routing_reservoirs.routing_sub.lddrepair(lddnp, lddOrder)[source]

repairs a river network

  • eliminate unsound parts

  • add pits at points with no connections

Parameters
  • lddnp – rivernetwork as 1D array

  • lddOrder

Returns

repaired ldd

hydrological_modules.routing_reservoirs.routing_sub.postorder(dirUp, catchment, node, catch, dirDown)[source]

Routine to run a postoder tree traversal

Parameters
  • dirUp

  • catchment

  • node

  • catch

  • dirDown

Returns

dirDown and catchment

hydrological_modules.routing_reservoirs.routing_sub.subcatchment1(dirUp, points, ups)[source]

calculates subcatchments of points

Parameters
  • dirUp

  • points

  • ups

Returns

subcatchment

hydrological_modules.routing_reservoirs.routing_sub.upstream1(downstruct, weight)[source]

Calculates 1 cell upstream

Parameters
  • downstruct

  • weight

Returns

upstream 1cell

hydrological_modules.routing_reservoirs.routing_sub.upstreamArea(dirDown, dirshort, area)[source]

calculates upstream area

Parameters
  • dirDown – array which point from each cell to the next downstream cell

  • dirshort

  • area – area in m2 for a single gridcell

Returns

upstream area

Hydrology V - Water balance

waterbalance module

class hydrological_modules.waterbalance.waterbalance(waterbalance_variable)[source]

Bases: object

WATER BALANCE

  • check if water balnace per time step is ok ( = 0)

  • produce an annual overview - income, outcome storage

checkWaterSoilGround()[source]

Check water balance of snow, vegetation, soil, groundwater

dynamic()[source]

Dynamic part of the water balance module If option sumWaterBalance sum water balance for certain variables

initial()[source]

Initial part of the water balance module

waterBalanceCheck(fluxesIn, fluxesOut, preStorages, endStorages, processName, printTrue=False)[source]

Dynamic part of the water balance module

Returns the water balance for a list of input, output, and storage map files

Parameters
  • fluxesIn – income

  • fluxesOut – this goes out

  • preStorages – this was in before

  • endStorages – this was in afterwards

  • processName – name of the process

  • printTrue – calculate it?

Returns

waterBalanceCheckSum(fluxesIn, fluxesOut, preStorages, endStorages, processName, printTrue=False)[source]

Returns the water balance for a list of input, output, and storage map files and sums it up for a catchment

Parameters
  • fluxesIn – income

  • fluxesOut – this goes out

  • preStorages – this was in before

  • endStorages – this was in afterwards

  • processName – name of the process

  • printTrue – calculate it?

Returns

Water balance as output on the screen