4. Setup of the model

Setup

Requirements

Python version

NEW from 2019 on: Requirements are a 64 bit Python 3.7.x version

Reason for this step:

  • Python 2.7 support ends in 2019

  • We will be able to provide a better error handling

  • We are able to provide an executable of CWATM for Windows

Warning

a 32 bit version is not able to handle the data requirements!

Warning

From 2019 on we are changing to Python 3.7. We do not provide further support for Python 2.7

Warning

CWATM is tested for Python 3.7 and will for sure not work with Python versions lower than 3.6. We recommend using Python 3.7

Libraries

These external libraries are needed:

Windows

The five libraries can be installed with pip or downloaded at Unofficial Windows Binaries for Python Extension Packages

Windows executeable Python version

A CWATM executable cwatm.exe can be used instead of the Python version
  • ADVANTAGE: You can run it without installing or knowledge of Python

  • DISADVANTAGE 1: You cannot see the source code or change it

  • DISADVANTAGE 2: We do not update this version as often as the Python version

  • It is done with cx_freeze library

  • It includes all Python libraries

Note

A cwatmexe.zip (around 300 MB with all Python libraries) is stored on:

Note

We recommend using the Python 3.7.x version,
but if you not experienced in Python or have problems installing CWATM, please use the executable version.
Either start it in DOS box (command cmd), or use the batch file cwatmbat.bat to start it

Todo

We will put a whole example of 30 deg Rhine basin with all necessary data in another zip file. Just for an easier start.

PCRaster

CWATM is not using anything from PCRaster
But the general idea of PCraster to split the hydrological modules in a initial | part and a dynamic part is still used
Anyway PCRaster is a great tool
PCRASTER from Faculty of Geosciences, Utrecht University, The Netherlands
Reference:
Karssenberg, D., Schmitz, O., Salamon, P., de Jong, K., and Bierkens, M. F. P.: A software framework for construction of process-based stochastic spatio-temporal models and data assimilation, Environmental Modelling & Software 25(4), 489-502, 2010. doi: 10.1016/j.envsoft.2009.10.004

C++ libraries

For the computational time demanding parts e.g. routing, CWATM comes with a C++ library

Compiled versions

Windows and CYGWIN_NT-6.1
a compiled version is provided and CWATM is detecting automatically which system is running and which compiled version is needed
Linux
For Cygwin linux a compiled version t5cyg.so is provided in ../source/hydrological_modules/routing_reservoirs/ for version CYGWIN_NT-6.1.
If you use another cygwin version please compile it by yourself and name it t5_linux.so

For Linux Ubuntu a compiled version is provided as t5_linux.so. The file is in ../source/hydrological_modules/routing_reservoirs/

Note

If you use another Linux version or the compiled version is not working or you have a compiler which produce faster executables please compile a version on your own.

Compiling a version

C++ sourcecode is in ../source/hydrological_modules/routing_reservoirs/t5.cpp

Note

A compiled version is already provided for Windows and Linux.

Windows

A compiled version is provided, but maybe you have a faster compiler than the “Minimalist GNU for Windows” or “Microsoft Visual Studio 14.0” we used.

To compile with g++:

..\g++ -c -fPIC -Ofast t5.cpp -o t5.o
..\g++ -shared -Ofast -Wl,-soname,t5.so -o t5.so  t5.o

To compile with Microsoft Visual Studio 14.0:

call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64/vcvars64.bat"
cl /LD /O2 t5.cpp

Note

We used Visual Studio, because it seems to be computational faster
the libray used with Windows is named t5.dll, if you generate a libray t5.so the filename in ../source/management_modules/globals.py has to be changed!

Linux

To compile with g++:

..\g++ -c -fPIC -Ofast t5.cpp -o t5_linux.o
..\g++ -shared -Ofast -Wl,-soname,t5_linux.so -o t5_linux.so  t5_linux.o

    or

    ..\g++ -c -Ofast t5.cpp -o t5_linux.o
..\g++ -shared -Ofast -Wl,-soname,t5_linux.so -o t5_linux.so  t5_linux.o

Warning

Please rename your compiled version to t5_linux.so! At the moment the file t5_linux.so is compiled with Ubuntu Linux

Test the model

Windows and Linux

python <modelpath>/cwatm.py

The output should be:

Running under platform:  Windows  **(or Linux etc)**
CWatM - Community Water Model
Authors: ...
Version: ...
Date: ...

Warning

If python is not set in the environment path, the full path of python has to be used

Warning

Please use the right version of CWATM with the right version of Python (either 2.7 or 3.7)

Running the model

Start the model

Warning

The model needs a settings file as an argument. See: Settings file

Windows

python <modelpath>/cwatm.py settingsfile flags

example:

python cwatm.py settings1.ini
or with more information and an overview of computational runtime
python cwatm.py settings1.ini -l -t

Warning

If python is not set in the environment path, the full path of python has to be used

Linux

<modelpath>/cwatm.py settingsfile flags

example:

cwatm.py settings1.ini -l -t

Flags

Flags can be used to change the runtime output on the screen

example:

-q --quiet       output progression given as .
-v --veryquiet   no output progression is given
-l --loud        output progression given as time step, date and discharge
-c --check       input maps and stack maps are checked, output for each input map BUT no model run
-h --noheader    .tss file have no header and start immediately with the time series
-t --printtime   the computation time for hydrological modules are printed
    -w --warranty    copyright and warranty information

Settings file

The setup of the setings file is shown in the next chapter.

NetCDF meta data

The format for spatial data for output data is netCDF. In the meta data file information can be added e.g. a description of the parameter

Note

It is not necessary to change this file! This is an option to put additional information into output maps

Test the data

The model is only as good as the data!
To give out a list of data and to check the data the model can run a check.

example:

cwatm.py settings1.ini -c
or
cwatm.py settings1.ini -c > checkdata.txt

A list is created with:

Name:      Name of the variable
Filename:  filename or if the value if it is a fixed value
nonMV:     non missing value in 2D map
MV:        missing value in 2D map
lon-lat:   longitude x latitude of 2D map
CompressV: 2D is compressed to 1D?
MV-comp:   missing value in 1D
Zero-comp: Number of 0 in 1D
NonZero:   Number of non 0 in 1D
min:       minimum in 1D (or 2D)
mean:      mean in 1D (or 2D)
max:       maximum in 1D (or 2D)

example:

Name                          File/Value                                    nonMV         MV    lon-lat   Compress    MV-comp  Zero-comp    NonZero        min       mean        max
MaskMap                       put5min_netcdf/areamaps/rhine5min.map          5236          0      68x77      False          0       2404       2832       0.00       0.54       1.00
Ldd                           _5min/input5min_netcdf/routing/ldd.nc          5236          0      68x77      False          0          0       5236       1.00       5.34       9.00
Mask+Ldd                                                                     2832          0      68x77       True          0       2832          0       0.00       0.00       0.00
CellArea                      n_netcdf/landsurface/topo/cellarea.nc          2832          0      68x77       True          0          0       2832   5.31E+07   5.63E+07   5.94E+07
precipitation_coversion       86.4                                              -          -          -          -          -                 86.40
evaporation_coversion         1.00                                              -          -          -          -          -                  1.00
crop_correct                  1.534                                             -          -          -          -          -                  1.53
NumberSnowLayers              7                                                 -          -          -          -          -                  7.00
GlacierTransportZone          3                                                 -          -          -          -          -                  3.00
ElevationStD                  min_netcdf/landsurface/topo/elvstd.nc          2832          0      68x77       True          0          0       2832       0.04      78.67     672.68
...
...

Settings file

The settings file is controlling the CWATM run

1
2
3
4
5
6
7
8
9
######## ##          ##  ####  ######  ##    ##
##       ##          ## ##  ##   ##   ####  ####
##        ##        ##  ##  ##   ##   ## #### ##
##        ##   ##   ## ########  ##  ##   ##   ##
##         ## #### ##  ##    ##  ##  ##        ##
##         ####  #### ##      ## ## ##          ##
##########  ##    ##  ##      ## ## ##          ##

# Community Water Model Version 0.99

Components of the settings file

General flags

General flags are set in the first paragraph For example: If Temperature data are in unit ° Celsius ot Kelvin

15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
[OPTIONS]
#-------------------------------------------------------
# OPTION - to switch on/off
#-------------------------------------------------------

# Data otions
# if temperature is stored in Kelvin instead Celsius
TemperatureInKelvin = True
# if lat/lon the area has to be user defined = precalculated
gridSizeUserDefined = True

#-----------------------------------------------
# Evaporation: calculate pot. evaporation (True) or use precalculated pot.evaporation map stacks (False)
calc_evaporation = False

#-----------------------------------------------
# Irrigation and water demand

# if irrigation is included, otherwise paddy and non paddy is put into 'grassland'
includeIrrigation = True
# if water demand from irrigation, industry and domestic is included
includeWaterDemand = False
# Water allocation
# if water demand and availability is calculated for region to compare demand vs. avail
usingAllocSegments = False
# limit abstraction to available groundwater (True) include fossil groundwater (False)
limitAbstraction = False

# Environmental Flow
calc_environflow = False
use_environflow = False

#-----------------------------------------------
# Soil 
# use preferential flow, that bypasses the soil matrix and drains directly to the groundwater (not for irrPaddy)
preferentialFlow = False
# Capillar rise
CapillarRise = True

#-----------------------------------------------
# Routing

# if runoff concentration to the edge of a cell is included
includeRunoffConcentration = True
# Waterbodies like lakes and reservoirs
includeWaterBodies = True
# kinematic wave routing, if False no routing is calculated
includeRouting = True

#-----------------------------------------------
# Inflow from outside of the modelled area
inflow = False

# --- Reporting & Debugging ------------------- ----------------------------------------------
# Reporting options
writeNetcdfStack = True
reportMap = True
reportTss = True
# Checking water balance (for debugging)
calcWaterBalance = False
sumWaterBalance = False
# use additional PCRaster GIS commands
PCRaster = False






#-------------------------------------------------------
# DEFINITIONS OF PARAMETERS

NetCDF meta data

The format for spatial data for input and output data is netCDF. For output data the basic information are given in the settingsfile

102
103
104
105
[NETCDF_ATTRIBUTES]
institution = IIASA
title = Global Water Model - WATCH WDFEI
metaNetcdfFile = $(FILE_PATHS:PathRoot)/source/metaNetcdf.xml

For each output file the specific information about units, variable name, displayed variable name is given in the metaNetcdf.xml. See: Output Meta NetCDF information

Path of data, output

Note

Further on the pathes can be used as placeholders

88
89
90
91
92
93
94
95
#-------------------------------------------------------
[FILE_PATHS]
#-------------------------------------------------------
PathRoot = E:/CWATM_rhine

PathOut = $(PathRoot)/output
PathMaps = $(PathRoot)/cwatm_input
PathMeteo = $(PathRoot)/climate

Defining the modeling area

In general the input data are stored and used at global scale. The modeling area can be defined by:

  • a mask map

  • coordinates

Note

The mask map can be a .tif, PCraster or a netCDF format | The coordinates have the format: Number of Cols, Number of rows, cellsize, upper left corner X, upper left corner Y

108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# AREA AND OUTLETS
#-------------------------------------------------------
[MASK_OUTLET]

# Area mask
# A pcraster map, tif or netcdf map e.g.  $(FILE_PATHS:PathRoot)/data/areamaps/area_indus.map
# or a retancle: Number of Cols, Number of rows, cellsize, upper left corner X, upper left corner Y 
MaskMap = $(FILE_PATHS:PathRoot)/source/rhine30min.tif
#MaskMap = 14 12 0.5 5.0 52.0


#-------------------------------------------------------
# Station data
# either a map e.g. $(FILE_PATHS:PathRoot)/data/areamaps/area3.map
# or a location coordinates (X,Y) e.g. 5.75 52.25 9.25 49.75 )
# Lobith/Rhine
Gauges = 6.25 51.75

# if .tif file for gauges, this is a flag if the file is global or local
# e.g. Gauges = $(FILE_PATHS:PathRoot)/data/areamaps/gaugesRhine.tif
GaugesLocal = True

Defining the time

The start and end time have to be defined. Spin-up time is the time for warming up (results will be stored after the spin-up time)

Note

The time can be given as date: dd/mm/yyyy or as relative date: number (but then CalendarDayStart has to be defined)

Note

Spin-up time can be given as date or number

130
131
132
133
134
135
136
137
138
139
140
#-------------------------------------------------------
[TIME-RELATED_CONSTANTS]
#-------------------------------------------------------

# StepStart has to be a date e.g. 01/06/1990
# SpinUp or StepEnd either date or numbers 
# SpinUp: from this date output is generated (up to this day: warm up)

StepStart = 1/1/1990
SpinUp =  1/01/1995
StepEnd =  31/12/2010

Initial conditions

Initial conditions can be stored and be loaded in order to initialise a warm start of the model

Note

Initial conditions are store as one netCDF file with all necessary variables

145
146
147
148
149
150
151
152
153
154
155
156
157
158
#-------------------------------------------------------
[INITITIAL CONDITIONS]
#-------------------------------------------------------

# for a warm start initial variables a loaded
# e.g for a start on 01/01/2010 load variable from 31/12/2009
load_initial = False
initLoad = $(FILE_PATHS:PathRoot)/init/Rhine_19891231.nc

# saving variables from this run, to initiate a warm start next run
# StepInit = saving date, can be more than one: 10/01/1973 20/01/1973
save_initial = False
initSave = $(FILE_PATHS:PathRoot)/init/Rhine
StepInit = 31/12/1989 31/12/2010

StepInit indicate the date(s) when initial conditions are saved:

StepInit = 31/12/1989
StepInit = 31/12/1989 31/12/2010
StepInit = 31/12/1989 5y
here: second value in StepInit is indicating a repetition of year(y), month(m) or day(d),
e.g. 2y for every 2 years or 6m for every 6 month

Output

Output can be spatial/time as netCDF4 map stacks
and/or time series at specified points

Note

For additional information see Model Output

Output can be as maps and time series:

  • per day [Daily]

  • total month [MonthTot], average month [MonthAvg], end of month [MonthEnd]

  • total year [AnnualTot], average year [AnnualAvg], end of year [AnnualEnd]

  • total sum [TotalTot], total average [TotalAvg]

For each of the following sections output can be defined for different variables:

  • Meteo

  • Snow

  • Soil for different land cover (forest, grassland, irrigated land, paddy irrigated)

  • Water demand

  • Groundwater

  • River routing

  • Lakes and reservoirs

Or output can be defined in the section [output]

An output directory can be defined and for each sort of output the variable(s) can be set:

OUT_ defines that this variable(s) are output
MAP_ or TSS_ defines if it is a spatial map or a time series of point(s)
Daily or MonthAvg or .. is specifying the time
The variable is given after the equal sign e.g. * = discharge*
If more than one variable should be used for output, split with ,
E.g. OUT_MAP_Daily = discharge -> daily spatial map of discharge

As example output for precipitation, temperature and discharge is shown here:

# OUTPUT maps and timeseries
OUT_Dir = $(FILE_PATHS:PathOut)
OUT_MAP_Daily =
OUT_MAP_MonthEnd =
OUT_MAP_MonthTot = Precipitation, Tavg
OUT_MAP_MonthAvg =

OUT_TSS_MonthTot = Precipitation, Tavg
OUT_TSS_Daily = discharge
OUT_TSS_MonthEnd = discharge
OUT_TSS_AnnualEnd = discharge

Note

For each variable the meta data information can be defined in Output Meta NetCDF information

Reading information

Information will be read in from values in the settings file Here the value definitions for [SNOW] is shown:

279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
#-------------------------------------------------------
[SNOW]
#-------------------------------------------------------

# Number of vertical Snow layers
NumberSnowLayers = 7
# up to which layer the ice melt is calculated with the middle temperature
GlacierTransportZone = 3

# Temperature lapse rate with altitude [deg C / m]
TemperatureLapseRate = 0.0065 
# Multiplier applied to precipitation that falls as snow
SnowFactor = 1.0
# Range [m C-1 d-1] of the seasonal variation, SnowMeltCoef is the average value
SnowSeasonAdj = 0.001
# Average temperature at which snow melts
TempMelt =1.0
# Average temperature below which precipitation is snow
TempSnow = 1.0
# Snow melt coefficient: default: 4.0 
# SRM: 0.0045 m/C/day ( = 4.50 mm/C/day), Kwadijk: 18 mm/C/month (= 0.59 mm/C/day)  
# See also Martinec et al., 1998.

# use in CALIBRATION -> copied to CALIBRATION
#SnowMeltCoef = 0.004
IceMeltCoef  = 0.007

#--------------------------------------------------------------
# INITIAL CONDITIONS - Initial snow depth in snow zone 1-7 [mm]  - SnowCoverIni

[FROST]
# Snow water equivalent, (based on snow density of 450 kg/m3) (e.g. Tarboton and Luce, 1996)
SnowWaterEquivalent = 0.45
# Daily decay coefficient, (Handbook of Hydrology, p. 7.28)
Afrost = 0.97
# Snow depth reduction coefficient, [cm-1], (HH, p. 7.28)
Kfrost = 0.57
# Degree Days Frost Threshold (stops infiltration, percolation and capillary rise)
# Molnau and Bissel found a value 56-85 for NW USA.
FrostIndexThreshold = 56

Note

TemperatureLapseRate = 0.0065 | for the variable TemperatureLapseRate the value of 0.0065 is set

Variables can also be defined by spatial maps or map stacks

tanslope = $(PathTopo)\tanslope.map
forest_coverFractionNC   = $(PathForest)\coverFractionInputForest366days.nc

Note

suffix can be .map, but if there is no PCraster map it will look automatically for netCDF .nc

Warning

in most cases values can be replaced by map

____________________________________________________________________________________________________________

Sections of information

  • Snow

  • Frost

  • General information on land cover types

  • Soil

  • Information for each of the six land cover types
    • Forest

    • Grassland

    • Paddy irrigated area

    • Irrigated area

    • Sealed area

    • Water covered area

  • Interflow

  • Groundwater

  • Water demand

  • Runoff concentration

  • Routing

  • Lakes and reservoirs

  • Inflow

Complete settings file

Example of a settings file:

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
# ------------------------------------------------

######## ##          ##  ####  ######  ##    ##
##       ##          ## ##  ##   ##   ####  ####
##        ##        ##  ##  ##   ##   ## #### ##
##        ##   ##   ## ########  ##  ##   ##   ##
##         ## #### ##  ##    ##  ##  ##        ##
##         ####  #### ##      ## ## ##          ##
##########  ##    ##  ##      ## ## ##          ##

# Community Water Model Version 0.99
# SETTINGS FILE
# ------------------------------------------------


[OPTIONS]
#-------------------------------------------------------
# OPTION - to switch on/off
#-------------------------------------------------------

# Data otions
# if temperature is stored in Kelvin instead Celsius
TemperatureInKelvin = True
# if lat/lon the area has to be user defined = precalculated
gridSizeUserDefined = True

#-----------------------------------------------
# Evaporation: calculate pot. evaporation (True) or use precalculated pot.evaporation map stacks (False)
calc_evaporation = False

#-----------------------------------------------
# Irrigation and water demand

# if irrigation is included, otherwise paddy and non paddy is put into 'grassland'
includeIrrigation = True
# if water demand from irrigation, industry and domestic is included
includeWaterDemand = False
# Water allocation
# if water demand and availability is calculated for region to compare demand vs. avail
usingAllocSegments = False
# limit abstraction to available groundwater (True) include fossil groundwater (False)
limitAbstraction = False

# Environmental Flow
calc_environflow = False
use_environflow = False

#-----------------------------------------------
# Soil 
# use preferential flow, that bypasses the soil matrix and drains directly to the groundwater (not for irrPaddy)
preferentialFlow = False
# Capillar rise
CapillarRise = True

#-----------------------------------------------
# Routing

# if runoff concentration to the edge of a cell is included
includeRunoffConcentration = True
# Waterbodies like lakes and reservoirs
includeWaterBodies = True
# kinematic wave routing, if False no routing is calculated
includeRouting = True

#-----------------------------------------------
# Inflow from outside of the modelled area
inflow = False

# --- Reporting & Debugging ------------------- ----------------------------------------------
# Reporting options
writeNetcdfStack = True
reportMap = True
reportTss = True
# Checking water balance (for debugging)
calcWaterBalance = False
sumWaterBalance = False
# use additional PCRaster GIS commands
PCRaster = False






#-------------------------------------------------------
# DEFINITIONS OF PARAMETERS
#-------------------------------------------------------

#-------------------------------------------------------
[FILE_PATHS]
#-------------------------------------------------------
PathRoot = E:/CWATM_rhine

PathOut = $(PathRoot)/output
PathMaps = $(PathRoot)/cwatm_input
PathMeteo = $(PathRoot)/climate




#-------------------------------------------------------
[NETCDF_ATTRIBUTES]
institution = IIASA
title = Global Water Model - WATCH WDFEI
metaNetcdfFile = $(FILE_PATHS:PathRoot)/source/metaNetcdf.xml

#-------------------------------------------------------
# AREA AND OUTLETS
#-------------------------------------------------------
[MASK_OUTLET]

# Area mask
# A pcraster map, tif or netcdf map e.g.  $(FILE_PATHS:PathRoot)/data/areamaps/area_indus.map
# or a retancle: Number of Cols, Number of rows, cellsize, upper left corner X, upper left corner Y 
MaskMap = $(FILE_PATHS:PathRoot)/source/rhine30min.tif
#MaskMap = 14 12 0.5 5.0 52.0


#-------------------------------------------------------
# Station data
# either a map e.g. $(FILE_PATHS:PathRoot)/data/areamaps/area3.map
# or a location coordinates (X,Y) e.g. 5.75 52.25 9.25 49.75 )
# Lobith/Rhine
Gauges = 6.25 51.75

# if .tif file for gauges, this is a flag if the file is global or local
# e.g. Gauges = $(FILE_PATHS:PathRoot)/data/areamaps/gaugesRhine.tif
GaugesLocal = True

#-------------------------------------------------------
[TIME-RELATED_CONSTANTS]
#-------------------------------------------------------

# StepStart has to be a date e.g. 01/06/1990
# SpinUp or StepEnd either date or numbers 
# SpinUp: from this date output is generated (up to this day: warm up)

StepStart = 1/1/1990
SpinUp =  1/01/1995
StepEnd =  31/12/2010




#-------------------------------------------------------
[INITITIAL CONDITIONS]
#-------------------------------------------------------

# for a warm start initial variables a loaded
# e.g for a start on 01/01/2010 load variable from 31/12/2009
load_initial = False
initLoad = $(FILE_PATHS:PathRoot)/init/Rhine_19891231.nc

# saving variables from this run, to initiate a warm start next run
# StepInit = saving date, can be more than one: 10/01/1973 20/01/1973
save_initial = False
initSave = $(FILE_PATHS:PathRoot)/init/Rhine
StepInit = 31/12/1989 31/12/2010

#-------------------------------------------------------
# CALIBARTION PARAMETERS
#-------------------------------------------------------
[CALIBRATION]

# These are parameter which are used for calibration
# could be any parameter, but for an easier overview, tehey are collected here
# in the calibration template a placeholder (e.g. %arnoBeta) instead of value

# Snow  
SnowMeltCoef = 0.0027
# Cropf factor correction  
crop_correct =  1.11
#Soil
soildepth_factor = 1.28
#Soil preferentialFlowConstant = 4.0, arnoBeta_add = 0.1
preferentialFlowConstant = 4.5
arnoBeta_add = 0.19
# interflow part of recharge factor = 1.0
factor_interflow = 2.8
# groundwater recessionCoeff_factor = 1.0
recessionCoeff_factor = 5.278
# runoff concentration factor runoffConc_factor = 1.0
runoffConc_factor = 0.1
#Routing manningsN Factor to Manning's roughness = 1.0 [0.1-10.]
manningsN = 1.86
# reservoir  normal storage limit (fraction of total storage, [-]) [0.15 - 0.85] default 0.5
normalStorageLimit = 0.44
# lake parameter - factor to alpha: parameter of of channel width and weir coefficient  [0.33 - 3.] dafault 1.
lakeAFactor = 0.33
# lake parameter - factor for wind evaporation
lakeEvaFactor = 1.52
#-------------------------------------------------------
# TOPOGRAPHY MAPS
#-------------------------------------------------------
[TOPOP]
# local drain direction map (1-9)
Ldd = $(FILE_PATHS:PathMaps)/routing/ldd.map

# Elevation standard deviation [m], i.e. altitude difference elevation within pixel.
# Used for sub-pixel modelling of snow accumulation and melt
ElevationStD = $(FILE_PATHS:PathMaps)/landsurface/topo/elvstd.map

# Area of pixel [m2] (for lat/lon every cell has a different area)
CellArea = $(FILE_PATHS:PathMaps)/routing/cellarea.map

#-------------------------------------------------------
# INPUT METEOROLOGICAL TIMESERIES AS MAPS
#-------------------------------------------------------
[METEO]
# precipitation [kg m-2 s-1]
#PrecipitationMaps = $(FILE_PATHS:PathMeteo)/pr*
PrecipitationMaps = $(FILE_PATHS:PathMeteo)/30min/pr_rhine*
# average daily temperature [K]
#TavgMaps = $(FILE_PATHS:PathMeteo)/tavg*
TavgMaps = $(FILE_PATHS:PathMeteo)/30min/tavg_rhine*

# ----------------------------------------
# This is used if calc_evaporation = False

# daily reference evaporation (free water) 
E0Maps = $(FILE_PATHS:PathMeteo)/30min/EWRef_rhine.nc
#E0Maps = $(FILE_PATHS:PathMeteo)/EWRef_daily*
# daily reference evapotranspiration (crop) 
ETMaps = $(FILE_PATHS:PathMeteo)/30min/ETRef_rhine.nc
#ETMaps = $(FILE_PATHS:PathMeteo)/ETRef_daily*

# --------------------------------
# from kg m-2s-1 to m : 86.4
precipitation_coversion = 86.4

# from MM to m : 0.001
#precipitation_coversion = 0.001

evaporation_coversion = 1.00

# OUTPUT maps and timeseries
#OUT_Dir = $(FILE_PATHS:PathOut)
#OUT_MAP_Daily = Precipitation, prec1

#-------------------------------------------------------
# CALCULATE EVAPORATION - PENMAN - MONTEITH
#-------------------------------------------------------
[EVAPORATION]

# This is used if calc_evaporation = True
# use albedo maps
albedo = True
albedoMaps = $(FILE_PATHS:PathMaps)/landsurface/albedo/albedo.nc 

# if not albedo maps use fixed albedo
# Albedo of bare soil surface (Supit et. al.)
AlbedoSoil = 0.15
# Albedo of water surface (Supit et. al.)
AlbedoWater = 0.05
# Albedo of vegetation canopy (FAO,1998)
AlbedoCanopy = 0.23

# use specific humidity (TRUE) QAir,  or relative humidity (FALSE) - rhs
useHuss = False

# map stacks Temperature [K}]
TminMaps = $(FILE_PATHS:PathMeteo)/tmin*
TmaxMaps = $(FILE_PATHS:PathMeteo)/tmax*
# Instantaneous surface pressure[Pa]
PSurfMaps = $(FILE_PATHS:PathMeteo)/ps*
# 2 m istantaneous specific humidity[kg /kg] (QAir) or relative humidity [%] (rhs)
RhsMaps = $(FILE_PATHS:PathMeteo)/hurs*
# wind speed maps at 10m [m/s]
WindMaps = $(FILE_PATHS:PathMeteo)/wind*
# radiation surface downwelling shortwave maps  [W/m2]
RSDSMaps = $(FILE_PATHS:PathMeteo)/rsds*
# radiation surface downwelling longwave maps [W/m2] [W/m2]
RSDLMaps = $(FILE_PATHS:PathMeteo)/rlds*

# OUTPUT maps and timeseries
#OUT_Dir = $(FILE_PATHS:PathOut)
#OUT_MAP_Daily = EWRef, ETRef, temp, prec

#-------------------------------------------------------
[SNOW]
#-------------------------------------------------------

# Number of vertical Snow layers
NumberSnowLayers = 7
# up to which layer the ice melt is calculated with the middle temperature
GlacierTransportZone = 3

# Temperature lapse rate with altitude [deg C / m]
TemperatureLapseRate = 0.0065 
# Multiplier applied to precipitation that falls as snow
SnowFactor = 1.0
# Range [m C-1 d-1] of the seasonal variation, SnowMeltCoef is the average value
SnowSeasonAdj = 0.001
# Average temperature at which snow melts
TempMelt =1.0
# Average temperature below which precipitation is snow
TempSnow = 1.0
# Snow melt coefficient: default: 4.0 
# SRM: 0.0045 m/C/day ( = 4.50 mm/C/day), Kwadijk: 18 mm/C/month (= 0.59 mm/C/day)  
# See also Martinec et al., 1998.

# use in CALIBRATION -> copied to CALIBRATION
#SnowMeltCoef = 0.004
IceMeltCoef  = 0.007

#--------------------------------------------------------------
# INITIAL CONDITIONS - Initial snow depth in snow zone 1-7 [mm]  - SnowCoverIni

[FROST]
# Snow water equivalent, (based on snow density of 450 kg/m3) (e.g. Tarboton and Luce, 1996)
SnowWaterEquivalent = 0.45
# Daily decay coefficient, (Handbook of Hydrology, p. 7.28)
Afrost = 0.97
# Snow depth reduction coefficient, [cm-1], (HH, p. 7.28)
Kfrost = 0.57
# Degree Days Frost Threshold (stops infiltration, percolation and capillary rise)
# Molnau and Bissel found a value 56-85 for NW USA.
FrostIndexThreshold = 56

#--------------------------------------------------------------
# INITIAL CONDITIONS: FrostIndexIni

[VEGETATION]
cropgroupnumber = $(FILE_PATHS:PathMaps)/others/cropgrp.nc
# soil water depletion fraction, Van Diepen et al., 1988: WOFOST 6.0, p.86, Doorenbos et. al 1978

#-------------------------------------------------------
[SOIL]
#-------------------------------------------------------

PathTopo = $(FILE_PATHS:PathMaps)/landsurface/topo
PathSoil = $(FILE_PATHS:PathMaps)/landsurface/soil
PathSoil1 =  $(FILE_PATHS:PathMaps)/others

# Topography - tangent slope, slope length  
tanslope = $(PathTopo)/tanslope.map
slopeLength = $(PathTopo)/slopeLength.map

# maps of relative elevation above flood plains
relativeElevation = $(PathTopo)/dzRel_hydro1k.nc

# Soil hydraulic properties

# soil (Hypres pedotransfer function - http://esdac.jrc.ec.europa.eu/ESDB_Archive/ESDBv2/popup/hy_param.htm)
KSat1 = $(PathSoil1)/ksat1.map
KSat2 = $(PathSoil1)/ksat2.map
KSat3 = $(PathSoil1)/ksat3.map
# Alpha: an Genuchten’s shape parameter
alpha1 = $(PathSoil1)/alpha1.map
alpha2 = $(PathSoil1)/alpha2.map
alpha3 = $(PathSoil1)/alpha3.map
#Lambda: an Genuchten’s shape parameter = n-1-> n = lamda+1, m = 1 - (1/n)
lambda1 = $(PathSoil1)/lambda1.map
lambda2 = $(PathSoil1)/lambda2.map
lambda3 = $(PathSoil1)/lambda3.map
# thetas  is the volumetric water content θ saturated 
thetas1 = $(PathSoil1)/thetas1.map
thetas2 = $(PathSoil1)/thetas2.map
thetas3 = $(PathSoil1)/thetas3.map
# thetar is the volumetric water content θ residual 
thetar1 = $(PathSoil1)/thetar1.map
thetar2 = $(PathSoil1)/thetar2.map
thetar3 = $(PathSoil1)/thetar3.map

percolationImp = $(PathSoil)/percolationImp.map

maxGWCapRise    = 5.0

minCropKC        = 0.2
minTopWaterLayer = 0.0

# Soil depth
StorDepth1 = $(PathSoil)/storageDepth1.map
StorDepth2 = $(PathSoil)/storageDepth2.map

# preferential flow (between 1.0 and 8.0)
# used in CALIBRATION -> copied to CALIBRATION
#preferentialFlowConstant = 4.0

#-------------------------------------------------------
[LANDCOVER]
PathLandcover = $(FILE_PATHS:PathMaps)/landsurface

coverTypes = forest, grassland, irrPaddy, irrNonPaddy, sealed, water
coverTypesShort = f, g, i, n, s, w
fractionLandcover = $(PathLandcover)/fractionLandcover.nc

# Landcover can vary from year to year
dynamicLandcover = True
# if landcover cannot vary, which year should be taken as fixed year
fixLandcoverYear = 1961

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

[__forest]
PathForest = $(FILE_PATHS:PathMaps)/landcover/forest
PathSoil1 =  $(FILE_PATHS:PathMaps)/others

# Parameters for the Arno's scheme 
# arnoBeta is defined by orographic,+ land cover add + calibration add, the soil water capacity distribution is based on this 
# range [0.01 - 1.2]
forest_arnoBeta = 0.2

#forest_soil
forest_KSat1 = $(PathSoil1)/forest_ksat1.map
forest_KSat2 = $(PathSoil1)/forest_ksat2.map
forest_KSat3 = $(PathSoil1)/ksat3.map
forest_alpha1 = $(PathSoil1)/forest_alpha1.map
forest_alpha2 = $(PathSoil1)/forest_alpha2.map
forest_alpha3 = $(PathSoil1)/alpha3.map
forest_lambda1 = $(PathSoil1)/forest_lambda1.map
forest_lambda2 = $(PathSoil1)/forest_lambda2.map
forest_lambda3 = $(PathSoil1)/lambda3.map
forest_thetas1 = $(PathSoil1)/forest_thetas1.map
forest_thetas2 = $(PathSoil1)/forest_thetas2.map
forest_thetas3 = $(PathSoil1)/thetas3.map
forest_thetar1 = $(PathSoil1)/forest_thetar1.map
forest_thetar2 = $(PathSoil1)/forest_thetar2.map
forest_thetar3 = $(PathSoil1)/thetar3.map

# other paramater values
forest_minInterceptCap  = 0.001
forest_cropDeplFactor   = 0.0

forest_fracVegCover  = $(PathForest)/fracVegCover.map
forest_rootFraction1 = $(PathForest)/rootFraction1.map
forest_rootFraction2 = $(PathForest)/rootFraction2.map
#forest_maxRootDepth  = 2.0
forest_maxRootDepth  = $(PathForest)/maxRootDepth.map
forest_minSoilDepthFrac = $(PathForest)/minSoilDepthFrac.map


forest_cropCoefficientNC = $(PathForest)/CropCoefficientForest_10days.nc
forest_interceptCapNC    = $(PathForest)/interceptCapForest10days.nc

# initial conditions: forest_interceptStor, forest_w1, forest_w2, forest_w3, 


[__grassland]
PathGrassland = $(FILE_PATHS:PathMaps)/landcover/grassland

# Parameters for the Arno's scheme: 
grassland_arnoBeta = 0.0
# arnoBeta is defined by orographic,+ land cover add + calibration add, the soil water capacity distribution is based on this
# range [0.01 - 1.2]

# other paramater values

grassland_minInterceptCap  = 0.001
grassland_cropDeplFactor   = 0.0

grassland_fracVegCover  = $(PathGrassland)/fracVegCover.map
grassland_rootFraction1 = $(PathGrassland)/rootFraction1.map
grassland_rootFraction2 = $(PathGrassland)/rootFraction2.map
grassland_maxRootDepth  = $(PathGrassland)/maxRootDepth.map
grassland_minSoilDepthFrac = $(PathGrassland)/minSoilDepthFrac.map


grassland_cropCoefficientNC = $(PathGrassland)/CropCoefficientGrassland_10days.nc
grassland_interceptCapNC    = $(PathGrassland)/interceptCapGrassland10days.nc

# initial conditions: grassland_interceptSto, grassland_w1, grassland_w2, grassland_w3


[__irrPaddy]
PathIrrPaddy = $(FILE_PATHS:PathMaps)/landcover/irrPaddy

# Parameters for the Arno's scheme:
irrPaddy_arnoBeta = 0.2
# arnoBeta is defined by orographic,+ land cover add + calibration add, the soil water capacity distribution is based on this
# range [0.01 - 1.2]

# other paramater values

irrPaddy_minInterceptCap  = 0.001
irrPaddy_cropDeplFactor   = 0.0

irrPaddy_fracVegCover  = $(PathIrrPaddy)/fracVegCover.map
irrPaddy_rootFraction1 = $(PathIrrPaddy)/rootFraction1.map
irrPaddy_rootFraction2 = $(PathIrrPaddy)/rootFraction2.map
irrPaddy_maxRootDepth  = $(PathIrrPaddy)/maxRootDepth.map
irrPaddy_minSoilDepthFrac = $(PathIrrPaddy)/minSoilDepthFrac.map

irrPaddy_cropCoefficientNC = $(PathIrrPaddy)/CropCoefficientirrPaddy_10days.nc

# maximum flooding depth for paddy
irrPaddy_maxtopwater = 0.05



# initial conditions: irrPaddy_interceptStor, irrPaddy_w1, irrPaddy_w2, irrPaddy_w3



[__irrNonPaddy]
PathIrrNonPaddy = $(FILE_PATHS:PathMaps)/landcover/irrNonPaddy

# Parameters for the Arno's scheme:
irrNonPaddy_arnoBeta = 0.2
# arnoBeta is defined by orographic,+ land cover add + calibration add, the soil water capacity distribution is based on this
# range [0.01 - 1.2]

# other paramater values


irrNonPaddy_minInterceptCap  = 0.001
irrNonPaddy_cropDeplFactor   = 0.0

irrNonPaddy_fracVegCover  = $(PathIrrNonPaddy)/fracVegCover.map
irrNonPaddy_rootFraction1 = $(PathIrrNonPaddy)/rootFraction1.map
irrNonPaddy_rootFraction2 = $(PathIrrNonPaddy)/rootFraction2.map
irrNonPaddy_maxRootDepth  = $(PathIrrNonPaddy)/maxRootDepth.map
irrNonPaddy_minSoilDepthFrac = $(PathIrrNonPaddy)/minSoilDepthFrac.map


irrNonPaddy_cropCoefficientNC = $(PathIrrNonPaddy)/CropCoefficientirrNonPaddy_10days.nc


# initial conditions: irrNonPaddy_interceptStor, irrNonPaddy_w1, irrNonPaddy_w2, irrNonPaddy_w3


[__sealed]
PathSealed = $(FILE_PATHS:PathMaps)/landcover/sealed

sealed_minInterceptCap  = 0.001

# initial conditions: sealed_interceptStor


[__open_water]
PathWater = $(FILE_PATHS:PathMaps)/landcover/water

water_minInterceptCap  = 0.0

#-------------------------------------------------------
[GROUNDWATER]
#-------------------------------------------------------

PathGroundwater = $(FILE_PATHS:PathMaps)/groundwater

recessionCoeff = $(PathGroundwater)/recessionCoeff.map
# baseflow = recessionCoeff * storage groundwater
specificYield = $(PathGroundwater)/specificYield.map
kSatAquifer = $(PathGroundwater)/kSatAquifer.map
# both not used at the moment in groundwater modul, but already loaded

#--------------------------------------------------------------
# INITIAL CONDITIONS: storGroundwater


#-------------------------------------------------------
[WATERDEMAND]
#-------------------------------------------------------

PathWaterdemand = $(FILE_PATHS:PathMaps)/landsurface/waterDemand
# For water demand vs. availability: areas have to be aggregated
# Allocation map
allocSegments = $(PathWaterdemand)/catchx.nc

domesticWaterDemandFile = $(PathWaterdemand)/domesticWaterDemand.nc
industryWaterDemandFile = $(PathWaterdemand)/industryWaterDemand.nc

irrNonPaddy_efficiency = $(FILE_PATHS:PathMaps)/landsurface/waterDemand/efficiency.nc
irrPaddy_efficiency = $(FILE_PATHS:PathMaps)/landsurface/waterDemand/efficiency.nc

#irrNonPaddy_efficiency = 0.8
#irrPaddy_efficiency = 0.8
irrigation_returnfraction = 0.5

# -----------------------------------------------------------
# Estimate of fractions of groundwater and surface water abstractions
# Either a fixed fraction for surface water abstration
# based on fraction of average baseflow and upstream average discharge 
# if swAbstractionFrac < 0: fraction is taken from baseflow / discharge 
# if swAbstractionFrac > 0 this value is taken as a fixed value 
swAbstractionFrac = 0.9
averageDischarge = $(FILE_PATHS:PathOut)/discharge_totalavg_rhine30min.nc
# in [m3/s]
averageBaseflow  = $(FILE_PATHS:PathOut)/baseflow_totalavg_rhine30min.nc
# in [m3/s]
baseflowInM = True
# if baseflow is in [m] instead of [m3/s] it will be converted


#-------------------------------------------------------
# RUNOFF CONCENTRATION
#-------------------------------------------------------
[RUNOFF_CONCENTRATION]

# using triagular weigthning method
# the bigger the factor, more lag time 
forest_runoff_peaktime = 1.0
grassland_runoff_peaktime = 0.5
irrPaddy_runoff_peaktime = 0.5
irrNonPaddy_runoff_peaktime = 0.5
sealed_runoff_peaktime = 0.15 
water_runoff_peaktime = 0.01

interflow_runoff_peaktime =1.0
baseflow_runoff_peaktime = 2.0

# initial conditions:
# here only 1 layer is shown, but there are up to 10: runoff_concIni


#-------------------------------------------------------
# ROUTING MAPS and PARAMETERSD
#-------------------------------------------------------
[ROUTING]

PathRouting = $(FILE_PATHS:PathMaps)/routing

# Number of substep per day
# should be 10 for 0.5 deg but 24 for 0.1 deg

NoRoutingSteps = 10
#kinematic wave parameter: 0.6 is for broad sheet flow
chanBeta = 0.6

# Channel gradient (fraction, dy/dx)
chanGrad = $(PathRouting)/kinematic/changrad.nc
# Minimum channel gradient (for kin. wave: slope cannot be 0)
chanGradMin = 0.0001

#Channel Manning's n
chanMan = $(PathRouting)/kinematic/chanman.nc
#Channel length [meters]
chanLength = $(PathRouting)/kinematic/chanleng.nc
#Channel bottom width [meters]
chanWidth = $(PathRouting)/kinematic/chanbw.nc
#Bankfull channel depth [meters]
chanDepth = $(PathRouting)/kinematic/chanbnkf.nc

# initial conditions: channelStorageIni, riverbedExchangeIni, dischargeIni  

#-------------------------------------------------------
# LAKES AND RESERVOIRS
#-------------------------------------------------------
[LAKES_RESERVOIRS]

PathLakesRes = $(FILE_PATHS:PathMaps)/routing/lakesreservoirs

# Use reservoirs and lakes (otherwise use only lakes Lake ID=1 and 3 => natural conditions)
useResAndLakes = True
# Reservoirs do have a year of implementation
dynamicLakesRes = True
# if Reservoirs does not have a year of implemtation, which year should be taken as fixed year
fixLakesResYear = 1950


#----------------------------
#Big lakes and Reservoirs

# ID of every lake, reservoir from HydroLakes database
waterBodyID = $(PathLakesRes)/lakesResID.nc
# 1 for lake, 2 for reservoir, 3 for lake and reservoir
waterBodyTyp = $(PathLakesRes)/lakesResType.nc
# Avergae discharge from HydroLakes Database
waterBodyDis = $(PathLakesRes)/lakesResDis.nc

# Lakes surface area from HydroLakes Database 
waterBodyArea = $(PathLakesRes)/lakesResArea.nc
# a factor to scale the outlet of a lake
#lakeAFactor = 1.0  -> calibration

#----------------------------
# Small lakes and reservoirs

useSmallLakes = True

smallLakesRes = $(PathLakesRes)/smallLakesRes.nc
smallwaterBodyDis = $(PathLakesRes)/smalllakesresDis.nc

# averageRunoff in [m] (if not given smallwaterBodyDis is taken instead)
#averageRunoff  = $(FILE_PATHS:PathOut)/runoff_totalavg_cali.nc

# for water demand
#min storage in [m3] (if not give it is calculated)
#minStorage  = $(FILE_PATHS:PathOut)/minsmalllakeStorage_cali.nc


# initial conditions: lakeInflowIni, lakeStorageIni, outLakeIni, lakeOutflowIni, reservoirStorageIni 

#------------------
# Reservoirs
# reservoir volume from HydroLakes database
waterBodyVolRes = $(PathLakesRes)/lakesResVolRes.nc
# reservoir starting year from HydroLakes database 
waterBodyYear = $(PathLakesRes)/lakesResYear.nc

#  Conservative, normal and flood storage limit (fraction of total storage, [-])
conservativeStorageLimit = 0.1
#normalStorageLimit = 0.5   # --> put into calibration
floodStorageLimit = 0.9
# adjusting the balance between normal and flood storage
# [0 ..1]  0: NormalstorageLimit      1: (= closer to flood) results in keeping the normal qoutflow longer constant
adjust_Normal_Flood = 0.5

# Minimum, Normal and Non-damaging reservoir outflow  (fraction of average discharge, [-])
MinOutflowQ = 0.2
NormalOutflowQ = 1.0
NonDamagingOutflowQ = 4.0

# initial conditions: lakeInflowIni, lakeStorageIni, outLakeIni, lakeOutflowIni, reservoirStorageIni 


#-------------------------------------------------------
[INFLOW]
#-------------------------------------------------------

# if option inflow = true
# the inflow from outside is added at inflowpoints
In_Dir = $(FILE_PATHS:PathRoot)/in

# nominal map with locations of (measured)inflow hydrographs [cu m / s]
InflowPoints = $(In_Dir)/in.map
#InflowPoints = 8.25 49.75 7.75 50.25

# if InflowPoints is a map, this flag is to identify if it is global (False) or local (True)
# observed or simulated input hydrographs as time series [cu m / s]
# Note: that identifiers in time series have to correspond to InflowPoints
# can be several timeseries in one file or different files e.g. main.tss mosel.tss
#QInTS = main1.tss mosel1.tss
QInTS = mm.tss



#-------------------------------------------------------
[ENVIRONMENTALFLOW]
#-------------------------------------------------------

# Either calculate without run with predone discharge (set calc_ef_after = False)
calc_ef_after = True
# Or calculate after run (set calc_ef_after = False) and defining the file to be used
EFDis = $(FILE_PATHS:PathOut)/discharge_rhine.nc

# if predone discharge, do the maps need to be cut to fit to the mask?
cut_ef_map = False

EnvironmentalFlowFile = $(FILE_PATHS:PathOut)/MQ90_12month.nc

# MAF: Mean, Q90: percentile 90, MMF: monthly average, MQ90: monthly Q90 9averagwed over al Jan, Feb..
# EF_VMF: Environmental flow - variable monthly flow, EF_VMF_LIH - EF- variable monthly flow, high intermediate, low class
OUT_Dir = $(FILE_PATHS:PathOut)
#OUT_MAP_Once = MAF, Q90
#OUT_MAP_12month = MMF, MQ90, EF_VMF, EF_VMF_LIH
#OUT_MAP_12month = MQ90, EF_VMF



#+++++++++++++++++++++++++++++++++++++++++++++++++++++++
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++


[OUTPUT]

# OUTPUT maps and timeseries
OUT_Dir = $(FILE_PATHS:PathOut)

OUT_TSS_Daily = discharge
#OUT_TSS_MonthAvg = discharge
#OUT_TSS_AnnualAvg = discharge

#OUT_Map_Daily = discharge
#OUT_Map_MonthAvg = discharge, precipitation, runoff
#OUT_Map_AnnualAvg = discharge
#OUT_MAP_TotalAvg = discharge, baseflow




NetCDF meta data

Output Meta NetCDF information

The metaNetcdf.xml includes information on the output netCDF files e.g. description of the parameter, unit ..

Example of a metaNetcdf.xml file:

<CWATM>
# METADATA for NETCDF OUTPUT DATA

# varname: name of the variable in the CWAT code
# unit: unit of the varibale
# long name# standard name

# Discharge maps 
<metanetcdf varname="discharge" unit="m3/s"  standard_name="Discharge" long_name="Discharge in cubic meter per second"  title="1st Demo CWATM" author="PB" />

# others
<metanetcdf varname="soilmoisture" unit="mm"  standard_name="soil moisture" long_name="Soil moisture"  title ="1st Demo CWATM" author="PB" />

# Initial condition Files
<metanetcdf varname="initcondition"  purpose ="Initial Conditions CWATM" author="PB" />
<metanetcdf varname="SnowCover1" unit="mm"  standard_name="SnowCover1" long_name="Snow cover top layer"  />
<metanetcdf varname="SnowCover2" unit="mm"  standard_name="SnowCover2" long_name="Snow cover middle layer"  />
<metanetcdf varname="SnowCover3" unit="mm"  standard_name="SnowCover3" long_name="Snow cover lower layer"  />
<metanetcdf varname="FrostIndex" unit="degree/days"  standard_name="FrostIndex" long_name="Frost index based on Molnau, Bissel (1983)"  />
</CWATM>

Name and location of the NetCDF meta data file

In the settings file the name and location of the metadata file is given.

#-------------------------------------------------------
[NETCDF_ATTRIBUTES]
institution = IIASA
title = Global Water Model - WATCH WDFEI
metaNetcdfFile = $(FILE_PATHS:PathRoot)/CWATM/source/metaNetcdf.xml

Initialisation

CWATM needs to have estimates of the initial state of the internal storage variables, e.g. the amount of water stored in snow, soil, groundwater etc.

There are two possibilities:

  1. The initial state of the internal storage variables are unknown and a first guess has to be used e.g. all storage variables are half filled.

  2. The initial state is known from a previous run, where the variables are stored at a certain time step. This is called warm start

The the warm start is usful for:

  • using a long pre-run to find the steady-state storage of the groundwater storage and use it as initial value

  • using the stored variables to shorten the warm-up period

  • using the stored variables to restart every day with the values from the pre3vious day (forecasting mode)

Example of soil moisture

The next figure shows the impact of different initial condition on the soil moisture of the lower soil. In one of the simulations the soil is initially almost ompletely saturated. In another simulation the soil is completely dry and the third simulation starts with initial conditions in between the two extremes.

In the beginning the effect of different initial condition can be seen clearly. But after one year the three curves converge. The memory of the lower soil goes back for about one year.

For all the initial condition apart from groundwater the memory is about 12 month. That means practically a spin-up of one year is sufficient to habve enough warm-up time.

_images/init_soilmoisture.jpg

Figure: Simulation of soil moisture in the lower soil with different initial conditions

For the groundwater zone a longer warm-up period is needed, because of the slow response of groundwater. Here a rather fast reacting groundwater storage is shown with the three curves coverge after two years.

_images/init_groundwater.jpg

Figure: Simulation of groundwater storage with different initial conditions

Cold start

For a cold start the values of the storage variables are unknown and set to a “first” guess. A list of variables and their default value for a cold start is given below in: Initial conditions

Set up a cold start in the settingsfile

In the settings file the option: load_initial has to be set on False

145
146
147
148
149
150
151
152
#-------------------------------------------------------
[INITITIAL CONDITIONS]
#-------------------------------------------------------

# for a warm start initial variables a loaded
# e.g for a start on 01/01/2010 load variable from 31/12/2009
load_initial = False
initLoad = $(FILE_PATHS:PathRoot)/init/Rhine_19891231.nc

Note

It is possible to exclude the warming up period of your model run for further analysis of results by setting the SpinUp option

[TIME-RELATED_CONSTANTS]
SpinUp =  01/01/1995

Storing initial variables

In the settings file the option save_intitisal has to be set to True

The name of the initial netCDF4 file has to be put in initsave

and one or more dates have to be specified in StepInit

154
155
156
157
158
# saving variables from this run, to initiate a warm start next run
# StepInit = saving date, can be more than one: 10/01/1973 20/01/1973
save_initial = False
initSave = $(FILE_PATHS:PathRoot)/init/Rhine
StepInit = 31/12/1989 31/12/2010

Warm start

CWATM can write internal variables to a netCDF file for choosen timesteps. These netCDF files can be used as the initial conditions for a suceeding simulation.

This is useful for establishing a steady-state with a long-term run and then using this steady-state for succeding simulations or for an every day run (forecasting mode)

Warning

If the parameters are changes after a run(especially the groundwater parameters) the stored initial values do not represent the conditions of the storage variables. Stored initial conditions should not be used as initial values for a model run with another set of parameters. If you do this during calibration, you will not be able to reproduce the calibration results!

Set up a cold start in the settingsfile

In the settings file the option: load_initial has to be set on True And define the name of the netcdf4 file in initLoad

Note

Use the initial values of the previous day here. E.g. if you run the model from 01/01/2006 use the inital condition from 31/12/2005

145
146
147
148
149
150
151
152
#-------------------------------------------------------
[INITITIAL CONDITIONS]
#-------------------------------------------------------

# for a warm start initial variables a loaded
# e.g for a start on 01/01/2010 load variable from 31/12/2009
load_initial = False
initLoad = $(FILE_PATHS:PathRoot)/init/Rhine_19891231.nc

Initial conditions

No.

Variable

Description

Default value

Number of maps

1

SnowCover

Snow cover for up to 7 zones

0

7

2

FrostIndex

Degree days frost threshold

0

1

3

Forest state

Interception storage

0

1

Top water layer

0

1

Soil storage for 3 soil layers

0

3

4

Grassland state

Interception storage

0

1

Top water layer

0

1

Soil storage for 3 soil layers

0

3

5

Paddy irrigation state

Interception storage

0

1

Top water layer

0

1

Soil storage for 3 soil layers

0

3

6

Irrigation state

Interception storage

0

1

Top water layer

0

1

Soil storage for 3 soil layers

0

3

7

Sealed area state

Interception storage

0

1

8

Groundwater

Groundwater storage

0

1

9

Runoff concentration

10 layers of runoff concentration

0

10

10

Routing

Channel storage

0.2 * total cross section

1

Routing

Riverbed exchange

0

1

Routing

Discharge

depending on ini channel stor.

1

11

Lakes and Reservoirs

Lake inflow

from HydroLakes database

1

Lake outflow

same as lake inflow

1

Lake&Res outflow to other lakes&res

same as lake inflow

1

Lake storage

based on inflow and lake area

1

Reservoir storage

0.5 * max. reservoir storage

1

Small lake storage

based on inflow and lake area

1

Small lake inflow

from HydroLakes database

1

Small lake outflow

same as small lake inflow

1

Model Output

An advantage of CWATM is the full flexibility of the output variables.

  • All parameters and variables can be used for output as maps or time series.

  • Even if the model is run at daily timestep, output can be daily, monthly, annual, at the end of a run

  • all variables maps are stored as netcdf and the meta data information can be added

Time depending and non depending output maps

Output maps will be produced as spatial maps, stack of spatial maps (over time)
Format: netCDF

The netCDF maps can be read with:

Windows

Linux

Or time series at specified points

Timeseries are procuded as ASCII files, which can be read with every text editor
The specific point where timeseries are provided are defined in the settings file as Gauges:
# Station data
# either a map e.g. $(FILE_PATHS:PathRoot)/data/areamaps/area3.map
# or a location coordinates (X,Y) e.g. 5.75 52.25 9.25 49.75 )
# Lobith/Rhine
Gauges = 6.25 51.75

# if .tif file for gauges, this is a flag if the file is global or local
# e.g. Gauges = $(FILE_PATHS:PathRoot)/data/areamaps/gaugesRhine.tif
GaugesLocal = True

Output variables

Output can be every global defined variable in the model Variable are e.g. Precipitation, runoff, baseflow

but also not so common variables as:

  • reservoirStorage (amount of water in the reservoirs in [m3])

  • nonIrrReturnFlowFraction (returnflow from domenstic and industrial water use [m3])

  • actualET[1] (actual evapotranspiration from grassland [m/day])

Daily, monthly - at the end or average

  • per day

  • total month, average month, end of month

  • total year, average year, end of year

  • total average, total at the end

for example

[OUTPUT]
# OUTPUT maps and timeseries
OUT_Dir = $(FILE_PATHS:PathOut)
OUT_MAP_Daily = discharge, runoff
OUT_MAP_MonthAvg = Precipitation
OUT_MAP_TotalEnd = lakeStorage
OUT_MAP_TotalAvg = Tavg

OUT_TSS_Daily = discharge
OUT_TSS_AnnualAvg = Precipitation

Note

For each variable the meta data information can be defined in Output Meta NetCDF information

Note

For information how to adjust the output in the settings file see Output

Most important output variables - a selection

#Variable name    : Description
discharge         : river discharge
runoff            : runoff
Precipitation     : rainfall + snow
Tavg              : average temperature
ETRef: potential  : evaporation from reference soil
sum_gwRecharge    : total groundwater recharge
totalET           : total actual evapotranspiration
baseflow          : baseflow from groundwater
... (to be continued)

Output variables - starting a list

A list of variables can be produced by using:
grep -d recurse ‘self.var.’ *.py
Every self.var.variable can be used as output variable
For a description of the variable please take a look at the python module itself.
.
As output variable please use without self.var.
#Python_modul            Variable_name
capillarRise.py          self.var.capRiseFrac
evaporationPot.py        self.var.AlbedoCanopy
evaporationPot.py        self.var.AlbedoSoil
evaporationPot.py        self.var.AlbedoWater
evaporationPot.py        self.var.ETRef
evaporationPot.py        self.var.EWRef
evaporation.py           self.var.potBareSoilEvap
evaporation.py           self.var.snowEvap
evaporation.py           self.var.SnowMelt
evaporation.py           self.var.potBareSoilEvap
evaporation.py           self.var.cropKC[No]
evaporation.py           self.var.totalPotET[No]
evaporation.py           self.var.potTranspiration[No]
groundwater.py           self.var.recessionCoeff
groundwater.py           self.var.specificYield
groundwater.py           self.var.kSatAquifer
groundwater.py           self.var.storGroundwater
groundwater.py           self.var.baseflow
interception.py          self.var.interceptCap[No]
interception.py          self.var.interceptStor[No]
interception.py          self.var.availWaterInfiltration[No]
interception.py          self.var.potTranspiration[No]
interception.py          self.var.actualET[No]
lakes_reservoirs.py      self.var.waterBodyID
lakes_reservoirs.py      self.var.waterBodyOut
lakes_reservoirs.py      self.var.lakeArea
lakes_reservoirs.py      self.var.lakeDis0
lakes_reservoirs.py      self.var.lakeAC
lakes_reservoirs.py      self.var.lakeEvaFactor
lakes_reservoirs.py      self.var.reslakeoutflow
lakes_reservoirs.py      self.var.lakeVolume
lakes_reservoirs.py      self.var.lakeStorage
lakes_reservoirs.py      self.var.lakeInflow
lakes_reservoirs.py      self.var.lakeOutflow
lakes_reservoirs.py      self.var.reservoirStorage
lakes_reservoirs.py      self.var.lakeResStorage
lakes_reservoirs.py      self.var.sumlakeResInflow
lakes_reservoirs.py      self.var.sumlakeResOutflow
lakes_res_small.py       self.var.smalllakeArea
lakes_res_small.py       self.var.smalllakeDis0
lakes_res_small.py       self.var.smalllakeA
lakes_res_small.py       self.var.smalllakeFactor
lakes_res_small.py       self.var.smalllakeVolumeM3
lakes_res_small.py       self.var.smallevapWaterBodyStorage
landcoverType.py         self.var.coverTypes
landcoverType.py         self.var.totalET
landcoverType.py         self.var.actSurfaceWaterAbstract
landcoverType.py         self.var.minInterceptCap
landcoverType.py         self.var.interceptStor[No]
landcoverType.py         self.var.sum_interceptStor
landcoverType.py         self.var.minCropKC
landcoverType.py         self.var.maxGWCapRise
... (to be continued)