Sensitivity of the subbasin size on discharge

This example shows how to change the subbasin size repeatedly using the builtin GRASS interface and investigate the changes in discharge of each configuration.

[2]:
import os
import pandas as pd
from matplotlib import pyplot as plt

import swimpy

p = swimpy.Project()

# work on a clone to avoid messing things up
c = p.clone('subbasin_size_sensitivity')

# adapt some config parameters for simplification
c.config_parameters(brunoffdat=False)
c.config_parameters(bwam_module=False)
c.config_parameters(brsvmodule=False)
c.output_files.clear()
c.output_files(subbasin_label_daily_selected_stations_discharge=['discharge'])
# turn off runtime warnings (e.g. routing problems due to small subbasins)
c.config_parameters(log_stdout_level='error', log_stderr_level='error')

# r.watershed threshold values
upthresh = [30, 50, 200]
# get clim file averages
mclim = c.climate.inputdata.groupby(axis=1, level=0).mean()

q = pd.DataFrame()
for ut in upthresh:
    # run m.swim.subbasins and necessary postprocesses
    c.subbasin.update(upthresh=ut, verbose=-1)
    # subbasin.csv column 'output_label' required for output
    catch_lab = c.stations[['NAME', 'subbasinID']]
    catch_lab.reset_index(inplace=True)
    catch_lab.rename(columns={'NAME': 'output_label',
                              'subbasinID': 'subbasin_id'}, inplace=True)
    catch_lab.set_index('subbasin_id', inplace=True)
    sdf = c.subbasin.join(catch_lab)
    sdf['output_label'] = sdf['output_label'].fillna('')
    c.subbasin(data = sdf)
    # get mean subbasin size and count
    sb_size = c.subbasin.attributes['size']
    nsb = len(sb_size)
    # put mean values and right number of subbasins into clim files
    nclim = pd.DataFrame({(v, i+1): mclim[v] for v in mclim.columns for i in range(nsb)})
    nclim.columns.names = ['variable', 'subbasin_id']
    c.climate.inputdata(nclim)
    # run SWIM
    c.run(save=False, quiet=True)
    # keep Q at Blankenstein
    label = '%1.1f (n=%i)' % (sb_size.mean(), nsb)
    q[label] = c.subbasin_label_daily_selected_stations_discharge['discharge']['BLANKENSTEIN']
    print('Upthresh %s -> mean subbasin size %s' % (ut, label))

GIS Environment:
GISDBASE: /home/tobias/apps/swimpy_redesign/tests/grassdb
LOCATION_NAME: utm32n
MAPSET: swim
Parameters:
elevation: elevation@PERMANENT
stations: stations@PERMANENT
streamthresh: 200
upthresh: 30
lothresh: 1.6
upthreshcolumn:
depression:
accumulation: accumulation
drainage: drainage
streams: streams
subbasins: subbasins
catchments: catchments
catchmentprefix: catchment_
stations_snapped: stations_snapped
slopesteepness: slopesteepness
slopelength: slopelength
streamcarve:
predefined: reservoirs@PERMANENT
rwatershedflags: s
rwatershedmemory:
d: False
g: False
l: False
s: False
k: False
v: False
Processing DEM to derive accumulation, drainage and streams...
ABSCHNITT 1a (von 6): Initiiere den Speicher.
ABSCHNITT 1b (of 6): Ermittle den Fluß aus der Karte heraus.
   0   4   8  12  16  20  24  28  32  36  40  44  48  52  56  60  64  68  72  76  80  84  88  92  96 100
SECTION 2: A* Search.
   0   2   4   6   8  10  12  14  16  18  20  22  24  26  28  30  32  34  36  38  40  42  44  46  48  50  52  54  56  58  60  62  64  66  68  70  72  74  76  78  80  82  84  86  88  90  92  94  96  98 100
ABSCHNITT 3: Akkumuliere Oberflächenabfluß mit SFD.
   1   3   5   7   9  11  13  15  17  19  21  23  25  27  29  31  33  35  37  39  41  43  45  47  49  51  53  55  57  59  61  63  65  67  69  71  73  75  77  79  81  83  85  87  89  91  93  95  97  99 100
ABSCHNITT 4: Bestimme RUSLE LS und/oder den S Faktor.
   0   4   8  12  16  20  24  28  32  36  40  44  48  52  56  60  64  68  72  76  80  84  88  92  96 100
ABSCHNITT 5: Bestimme Wassereinzugsgebiet.
   0   2   4   6   8  10  12  14  16  18  20  22  24  26  28  30  32  34  36  38  40  42  44  46  48  50  52  54  56  58  60  62  64  66  68  70  72  74  76  78  80  82  84  86  88  90  92  94  96  98 100
ABSCHNITT 6: Schließe Karten.
 100
Making vector river network...
WARNUNG: Vektorkarte <streams> existiert bereits und wird überschrieben.
Snapping stations to streams...
Creating catchments...
   0   6  12  18  24  30  36  42  48  54  60  66  72  78  84  90  96 100
WARNUNG: Vektorkarte <catchment_1> existiert bereits und wird
         überschrieben.
  50   0   6  12  18  24  30  36  42  48  54  60  66  72  78  84  90  96 100
WARNUNG: Vektorkarte <catchment_2> existiert bereits und wird
         überschrieben.
 100
Check station topology...
Patching catchments...
Creating subbasins...
  50 100
  50 100
Including predefined subbasins reservoirs@PERMANENT...
Cleaning subbasin map...
WARNUNG: Number of centroids exceeds number of areas: 26 > 17
Assigning continuous categories to subbasins map...
WARNUNG: Vektorkarte <subbasins> existiert bereits und wird überschrieben.
WARNUNG: Values in column <subbasinID> will be overwritten
Creating catchments vector map...
WARNUNG: Vektorkarte <catchments> existiert bereits und wird
         überschrieben.
WARNUNG: Values in column <catchmentID> will be overwritten
Adding subbasin info to subbasin attribute table...
WARNUNG: Vektorkarte <stations_snapped> existiert bereits und wird
         überschrieben.
-----------------------------------------------------------------
Execution took 0:00:19.914588 hh:mm:ss
Catchment sizes :
ID  excl. upstream   incl. upstream  outlet subbasin  upstream stations
  1         523.63           523.63                8
  2         488.44          1012.07                1  1
-----------------------------------------------------------------
Subbasin statistics (km2):
stationID count    min      mean     max
    total       17     1.89    59.53   244.10
        1       11     1.89    47.60   153.18
        2        6     5.33    81.41   244.10
-----------------------------------------------------------------
GIS Environment:
GISDBASE: /home/tobias/apps/swimpy_redesign/tests/grassdb
LOCATION_NAME: utm32n
MAPSET: swim
Parameters:
subbasins: subbasins
accumulation: accumulation
drainage: drainage
routingnet: routingnetwork
mainstreams: mainstreams
outlets: subbasinoutlets
inlets: subbasininlets
output:
/home/tobias/apps/swimpy_redesign/tests/project/swimpy/clones/subbasin_size_sensitivity/input/subbasin_routing.csv
fromto:
minmainstreams: 50
rivercourse:
r: False
k: False
v: False
Will calculate routing for subbasins
All subsequent raster operations will be limited to the MASK area. Removing
or renaming raster map named 'MASK' will restore raster operations to
normal.
Searching outlets...
Growing outlets...
Searching inlets...
WARNUNG: Vektorkarte <subbasinoutlets> existiert bereits und wird
         überschrieben.
Getting inletIDs...
WARNUNG: Vektorkarte <subbasininlets> existiert bereits und wird
         überschrieben.
WARNUNG: Rastertyp ist Fließkomma und der Spaltentyp ist Integer. Etwas
         Informationsgehalt der Daten geht verloren!!
Routing successfully completed. nextID and inletID added to subbasins
table.
Find outlets (if other than ID 1, check if the accumulation
map has negative, ie. off-map flow)...
Outlet subbasin order: 8
Subbasin(s) [1] is(are) outlet(s)
Building routing vector...
Connected 17 outlets
WARNUNG: Vektorkarte <routingnetwork> existiert bereits und wird
         überschrieben.
Creating mainstream network in mainstreams...
 100
WARNUNG: Values in column <cat> will be overwritten
WARNUNG: Values in column <cat> will be overwritten
WARNUNG: Values in column <cat> will be overwritten
WARNUNG: No areas selected from vector map <mainstreams__split>
WARNUNG: Not all vector categories converted to raster. Converted 25 of 37.
WARNUNG: Vektorkarte <mainstreams> existiert bereits und wird
         überschrieben.
WARNUNG: Values in column <cat> will be overwritten
Will write routing file to
/home/tobias/apps/swimpy_redesign/tests/project/swimpy/clones/subbasin_size_sensitivity/input/subbasin_routing.csv!
Wrote
/home/tobias/apps/swimpy_redesign/tests/project/swimpy/clones/subbasin_size_sensitivity/input/subbasin_routing.csv
Execution took 0:00:22.471837 hh:mm:ss
GIS Environment:
GISDBASE: /home/tobias/apps/swimpy_redesign/tests/grassdb
LOCATION_NAME: utm32n
MAPSET: swim
Parameters:
output:
/home/tobias/apps/swimpy_redesign/tests/project/swimpy/clones/subbasin_size_sensitivity/input/subbasin.csv
subbasins: subbasins
catchment_id: catchments
elev0: 0
sdtsav: 0
sl: slopelength
stp: slopesteepness
salb: 0.15
sno: 0
ovn: 0.15
rt: 0
css: 0.5
ecp: 0.5
suborder: catchment_id,sl,stp,lat,elev0
mainstreams: mainstreams
elevation: elevation@PERMANENT
drainage: drainage
accumulation: accumulation
chl:
chs:
chw:
chd:
chk: 0.37
chn: 0.075
chxk: 0.28
chc: 1
rteorder: chw,chd,chs,chl
gwht: 1
gwq: 0.5
abf: 0.048
syld: 0.003
delay: 200
revapc: 0.2
rchrgc: 0.05
revapmn: 0
gworder: delay
k: False
v: False
   0   3   6   9  12  15  18  21  24  27  30  33  36  39  42  45  48  51  54  57  60  63  66  69  72  75  78  81  84  87  90  93  96  99 100
   0   3   6   9  12  15  18  21  24  27  30  33  36  39  42  45  48  51  54  57  60  63  66  69  72  75  78  81  84  87  90  93  96  99 100
   0   3   6   9  12  15  18  21  24  27  30  33  36  39  42  45  48  51  54  57  60  63  66  69  72  75  78  81  84  87  90  93  96  99 100
Subbasin fraction statistics:
min: 0.00186745976068849 mean: 0.0588235294117647 max: 0.24118885057357692
n: 17
Will use average subbasin values of catchments for catchment_id.
average of catchments over each subbasin__rast saved in
subbasin__rast__catchments__average
catchment_id statistics:
min: 1.0 mean: 1.3529411764705883 max: 2.0 number of nans: 0
Will use average subbasin values of slopelength for sl.
average of slopelength over each subbasin__rast saved in
subbasin__rast__slopelength__average
sl statistics:
min: 0.3411988 mean: 0.4860489 max: 0.7283888 number of nans: 0
Will use average subbasin values of slopesteepness for stp.
average of slopesteepness over each subbasin__rast saved in
subbasin__rast__slopesteepness__average
stp statistics:
min: 0.1914799 mean: 0.24131248823529408 max: 0.3225641 number of nans: 0
WARNUNG: Number of centroids exceeds number of areas: 17 > 0
WARNUNG: Anzahl der Zentroide außerhalb von Flächen: 17
WARNUNG: Number of centroids exceeds number of areas: 17 > 0
WARNUNG: Anzahl der Zentroide außerhalb von Flächen: 17
lat statistics:
min: 50.1820181175061 mean: 50.292622959136715 max: 50.4015369727707 number
of nans: 0
Using default value for elev0 = 0.0
elev0 statistics:
min: 0.0 mean: 0.0 max: 0.0 number of nans: 0
Using default value for delay = 200.0
delay statistics:
min: 200.0 mean: 200.0 max: 200.0 number of nans: 0
Calculating main channel width...
chw statistics:
min: 1.85986066239926 mean: 33.43215031032526 max: 81.9820210198713 number
of nans: 0
Calculating main channel depth...
chd statistics:
min: 0.165909205907679 mean: 1.0833058095631611 max: 2.07028098056801
number of nans: 0
Calculating main channel slope...
   0   3   6   9  12  15  18  21  24  27  30  33  36  39  42  45  48  51  54  57  60  63  66  69  72  75  78  81  84  87  90  93  96  99 100
Neigungs-Rasterkarte <elevation__slope> komplett.
average of mainstream__slope__tan over each subbasin__rast saved in
subbasin__rast__mainstream__slope__tan__average
chs statistics:
min: 0.0122960936278105 mean: 0.031246385701438967 max: 0.0720329806208611
number of nans: 0
Calculating main channel length...
average of cell__len__mainstreams over each subbasin__rast saved in
subbasin__rast__cell__len__mainstreams__average
chl statistics:
min: 0.1 mean: 6.299749735294117 max: 25.29066 number of nans: 0
Wrote
/home/tobias/apps/swimpy_redesign/tests/project/swimpy/clones/subbasin_size_sensitivity/input/subbasin.csv
Raster MASK removed
Execution took 0:00:07.667062 hh:mm:ss
GIS Environment:
GISDBASE: /home/tobias/apps/swimpy_redesign/tests/grassdb
LOCATION_NAME: utm32n
MAPSET: swim
Parameters:
subbasin_id: subbasins
landuse_id: landuse@PERMANENT
soil_id: soil@PERMANENT
output:
/home/tobias/apps/swimpy_redesign/tests/project/swimpy/clones/subbasin_size_sensitivity/input/hydrotope.csv
hydrotopes: hydrotopes
contours: 200
contourrast: contours
elevation: elevation@PERMANENT
crop_management_id:
wetland:
glacier_thickness:
more:
c: False
k: False
v: False
Contour breaks:,[400, 600, 800]
Created contourmap: contours
Check if all input are integer raster...
All subsequent raster operations will be limited to the MASK area. Removing
or renaming raster map named 'MASK' will restore raster operations to
normal.
Checking for NULLs in input maps...
   0   3   6   9  12  15  18  21  24  27  30  33  36  39  42  45  48  51  54  57  60  63  66  69  72  75  78  81  84  87  90  93  96  99 100
Calculating hydrotopes with: OrderedDict([('subbasin_id', 'subbasins'),
('landuse_id', 'landuse@PERMANENT'), ('soil_id', 'soil@PERMANENT'),
('elevation', 'contours')])...
All subsequent raster operations will be limited to the MASK area. Removing
or renaming raster map named 'MASK' will restore raster operations to
normal.
r.cross: SCHRITT 1 ...
   0   6  12  18  24  30  36  42  48  54  60  66  72  78  84  90  96 100
r.cross: SCHRITT 2 ...
r.cross: Schritt 3 ...
   0   6  12  18  24  30  36  42  48  54  60  66  72  78  84  90  96 100
Erstelle Support-Dateien für <hydrotopes__rcross>...
231 categories
   0   3   6   9  12  15  18  21  24  27  30  33  36  39  42  45  48  51  54  57  60  63  66  69  72  75  78  81  84  87  90  93  96  99 100
Get mean hydrotope values for elevation@PERMANENT
Wrote hydrotope file
/home/tobias/apps/swimpy_redesign/tests/project/swimpy/clones/subbasin_size_sensitivity/input/hydrotope.csv
231 hydrotopes created, 13.59 per subbasin on average, max.
number of hydrotopes per subbasin 27
Execution took 0:00:02.256763 hh:mm:ss
/tmp/ipykernel_18936/2029867248.py:33: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
  catch_lab.rename(columns={'NAME': 'output_label',
Upthresh 30 -> mean subbasin size 59.5 (n=17)
GIS Environment:
GISDBASE: /home/tobias/apps/swimpy_redesign/tests/grassdb
LOCATION_NAME: utm32n
MAPSET: swim
Parameters:
elevation: elevation@PERMANENT
stations: stations@PERMANENT
streamthresh: 200
upthresh: 50
lothresh: 1.6
upthreshcolumn:
depression:
accumulation: accumulation
drainage: drainage
streams: streams
subbasins: subbasins
catchments: catchments
catchmentprefix: catchment_
stations_snapped: stations_snapped
slopesteepness: slopesteepness
slopelength: slopelength
streamcarve:
predefined: reservoirs@PERMANENT
rwatershedflags: s
rwatershedmemory:
d: False
g: False
l: False
s: False
k: False
v: False
Processing DEM to derive accumulation, drainage and streams...
ABSCHNITT 1a (von 6): Initiiere den Speicher.
ABSCHNITT 1b (of 6): Ermittle den Fluß aus der Karte heraus.
   0   4   8  12  16  20  24  28  32  36  40  44  48  52  56  60  64  68  72  76  80  84  88  92  96 100
SECTION 2: A* Search.
   0   2   4   6   8  10  12  14  16  18  20  22  24  26  28  30  32  34  36  38  40  42  44  46  48  50  52  54  56  58  60  62  64  66  68  70  72  74  76  78  80  82  84  86  88  90  92  94  96  98 100
ABSCHNITT 3: Akkumuliere Oberflächenabfluß mit SFD.
   1   3   5   7   9  11  13  15  17  19  21  23  25  27  29  31  33  35  37  39  41  43  45  47  49  51  53  55  57  59  61  63  65  67  69  71  73  75  77  79  81  83  85  87  89  91  93  95  97  99 100
ABSCHNITT 4: Bestimme RUSLE LS und/oder den S Faktor.
   0   4   8  12  16  20  24  28  32  36  40  44  48  52  56  60  64  68  72  76  80  84  88  92  96 100
ABSCHNITT 5: Bestimme Wassereinzugsgebiet.
   0   2   4   6   8  10  12  14  16  18  20  22  24  26  28  30  32  34  36  38  40  42  44  46  48  50  52  54  56  58  60  62  64  66  68  70  72  74  76  78  80  82  84  86  88  90  92  94  96  98 100
ABSCHNITT 6: Schließe Karten.
   2 100
Making vector river network...
WARNUNG: Vektorkarte <streams> existiert bereits und wird überschrieben.
Snapping stations to streams...
Creating catchments...
   0   6  12  18  24  30  36  42  48  54  60  66  72  78  84  90  96 100
WARNUNG: Vektorkarte <catchment_1> existiert bereits und wird
         überschrieben.
  50   0   6  12  18  24  30  36  42  48  54  60  66  72  78  84  90  96 100
WARNUNG: Vektorkarte <catchment_2> existiert bereits und wird
         überschrieben.
 100
Check station topology...
Patching catchments...
Creating subbasins...
  50 100
  50 100
Including predefined subbasins reservoirs@PERMANENT...
Cleaning subbasin map...
WARNUNG: Number of centroids exceeds number of areas: 19 > 11
Assigning continuous categories to subbasins map...
WARNUNG: Vektorkarte <subbasins> existiert bereits und wird überschrieben.
WARNUNG: Values in column <subbasinID> will be overwritten
Creating catchments vector map...
WARNUNG: Vektorkarte <catchments> existiert bereits und wird
         überschrieben.
WARNUNG: Values in column <catchmentID> will be overwritten
Adding subbasin info to subbasin attribute table...
WARNUNG: Vektorkarte <stations_snapped> existiert bereits und wird
         überschrieben.
-----------------------------------------------------------------
Execution took 0:00:13.370879 hh:mm:ss
Catchment sizes :
ID  excl. upstream   incl. upstream  outlet subbasin  upstream stations
  1         523.63           523.63                4
  2         488.44          1012.07                1  1
-----------------------------------------------------------------
Subbasin statistics (km2):
stationID count    min      mean     max
    total       11     1.74    92.01   244.34
        1        9     1.74    58.18   153.18
        2        2   244.10   244.22   244.34
-----------------------------------------------------------------
GIS Environment:
GISDBASE: /home/tobias/apps/swimpy_redesign/tests/grassdb
LOCATION_NAME: utm32n
MAPSET: swim
Parameters:
subbasins: subbasins
accumulation: accumulation
drainage: drainage
routingnet: routingnetwork
mainstreams: mainstreams
outlets: subbasinoutlets
inlets: subbasininlets
output:
/home/tobias/apps/swimpy_redesign/tests/project/swimpy/clones/subbasin_size_sensitivity/input/subbasin_routing.csv
fromto:
minmainstreams: 50
rivercourse:
r: False
k: False
v: False
Will calculate routing for subbasins
All subsequent raster operations will be limited to the MASK area. Removing
or renaming raster map named 'MASK' will restore raster operations to
normal.
Searching outlets...
Growing outlets...
Searching inlets...
WARNUNG: Vektorkarte <subbasinoutlets> existiert bereits und wird
         überschrieben.
Getting inletIDs...
WARNUNG: Vektorkarte <subbasininlets> existiert bereits und wird
         überschrieben.
WARNUNG: Rastertyp ist Fließkomma und der Spaltentyp ist Integer. Etwas
         Informationsgehalt der Daten geht verloren!!
Routing successfully completed. nextID and inletID added to subbasins
table.
Find outlets (if other than ID 1, check if the accumulation
map has negative, ie. off-map flow)...
Outlet subbasin order: 6
Subbasin(s) [1] is(are) outlet(s)
Building routing vector...
Connected 11 outlets
WARNUNG: Vektorkarte <routingnetwork> existiert bereits und wird
         überschrieben.
Creating mainstream network in mainstreams...
 100
WARNUNG: Values in column <cat> will be overwritten
WARNUNG: Values in column <cat> will be overwritten
WARNUNG: Values in column <cat> will be overwritten
WARNUNG: No areas selected from vector map <mainstreams__split>
WARNUNG: Not all vector categories converted to raster. Converted 17 of 23.
WARNUNG: Vektorkarte <mainstreams> existiert bereits und wird
         überschrieben.
WARNUNG: Values in column <cat> will be overwritten
Will write routing file to
/home/tobias/apps/swimpy_redesign/tests/project/swimpy/clones/subbasin_size_sensitivity/input/subbasin_routing.csv!
Wrote
/home/tobias/apps/swimpy_redesign/tests/project/swimpy/clones/subbasin_size_sensitivity/input/subbasin_routing.csv
Execution took 0:00:18.415422 hh:mm:ss
GIS Environment:
GISDBASE: /home/tobias/apps/swimpy_redesign/tests/grassdb
LOCATION_NAME: utm32n
MAPSET: swim
Parameters:
output:
/home/tobias/apps/swimpy_redesign/tests/project/swimpy/clones/subbasin_size_sensitivity/input/subbasin.csv
subbasins: subbasins
catchment_id: catchments
elev0: 0
sdtsav: 0
sl: slopelength
stp: slopesteepness
salb: 0.15
sno: 0
ovn: 0.15
rt: 0
css: 0.5
ecp: 0.5
suborder: catchment_id,sl,stp,lat,elev0
mainstreams: mainstreams
elevation: elevation@PERMANENT
drainage: drainage
accumulation: accumulation
chl:
chs:
chw:
chd:
chk: 0.37
chn: 0.075
chxk: 0.28
chc: 1
rteorder: chw,chd,chs,chl
gwht: 1
gwq: 0.5
abf: 0.048
syld: 0.003
delay: 200
revapc: 0.2
rchrgc: 0.05
revapmn: 0
gworder: delay
k: False
v: False
   0   3   6   9  12  15  18  21  24  27  30  33  36  39  42  45  48  51  54  57  60  63  66  69  72  75  78  81  84  87  90  93  96  99 100
   0   3   6   9  12  15  18  21  24  27  30  33  36  39  42  45  48  51  54  57  60  63  66  69  72  75  78  81  84  87  90  93  96  99 100
   0   3   6   9  12  15  18  21  24  27  30  33  36  39  42  45  48  51  54  57  60  63  66  69  72  75  78  81  84  87  90  93  96  99 100
Subbasin fraction statistics:
min: 0.0017192486685703558 mean: 0.0909090909090909 max:
0.24142598832096593 n: 11
Will use average subbasin values of catchments for catchment_id.
average of catchments over each subbasin__rast saved in
subbasin__rast__catchments__average
catchment_id statistics:
min: 1.0 mean: 1.1818181818181819 max: 2.0 number of nans: 0
Will use average subbasin values of slopelength for sl.
average of slopelength over each subbasin__rast saved in
subbasin__rast__slopelength__average
sl statistics:
min: 0.3572398 mean: 0.5135878454545454 max: 0.7438425 number of nans: 0
Will use average subbasin values of slopesteepness for stp.
average of slopesteepness over each subbasin__rast saved in
subbasin__rast__slopesteepness__average
stp statistics:
min: 0.1989726 mean: 0.2494915 max: 0.321502 number of nans: 0
WARNUNG: Number of centroids exceeds number of areas: 11 > 0
WARNUNG: Anzahl der Zentroide außerhalb von Flächen: 11
WARNUNG: Number of centroids exceeds number of areas: 11 > 0
WARNUNG: Anzahl der Zentroide außerhalb von Flächen: 11
lat statistics:
min: 50.1820181175061 mean: 50.27492919090755 max: 50.3845142891035 number
of nans: 0
Using default value for elev0 = 0.0
elev0 statistics:
min: 0.0 mean: 0.0 max: 0.0 number of nans: 0
Using default value for delay = 200.0
delay statistics:
min: 200.0 mean: 200.0 max: 200.0 number of nans: 0
Calculating main channel width...
chw statistics:
min: 16.2916849059766 mean: 37.86882847384101 max: 81.9820210198713 number
of nans: 0
Calculating main channel depth...
chd statistics:
min: 0.705008273118553 mean: 1.2089577714017563 max: 2.07028098056801
number of nans: 0
Calculating main channel slope...
   0   3   6   9  12  15  18  21  24  27  30  33  36  39  42  45  48  51  54  57  60  63  66  69  72  75  78  81  84  87  90  93  96  99 100
Neigungs-Rasterkarte <elevation__slope> komplett.
average of mainstream__slope__tan over each subbasin__rast saved in
subbasin__rast__mainstream__slope__tan__average
chs statistics:
min: 0.014951934106648 mean: 0.02734151795845141 max: 0.0477233305573463
number of nans: 0
Calculating main channel length...
average of cell__len__mainstreams over each subbasin__rast saved in
subbasin__rast__cell__len__mainstreams__average
chl statistics:
min: 0.9828427 mean: 9.577020609090908 max: 31.04336 number of nans: 0
Wrote
/home/tobias/apps/swimpy_redesign/tests/project/swimpy/clones/subbasin_size_sensitivity/input/subbasin.csv
Raster MASK removed
Execution took 0:00:07.038483 hh:mm:ss
GIS Environment:
GISDBASE: /home/tobias/apps/swimpy_redesign/tests/grassdb
LOCATION_NAME: utm32n
MAPSET: swim
Parameters:
subbasin_id: subbasins
landuse_id: landuse@PERMANENT
soil_id: soil@PERMANENT
output:
/home/tobias/apps/swimpy_redesign/tests/project/swimpy/clones/subbasin_size_sensitivity/input/hydrotope.csv
hydrotopes: hydrotopes
contours: 200
contourrast: contours
elevation: elevation@PERMANENT
crop_management_id:
wetland:
glacier_thickness:
more:
c: False
k: False
v: False
Contour breaks:,[400, 600, 800]
Created contourmap: contours
Check if all input are integer raster...
All subsequent raster operations will be limited to the MASK area. Removing
or renaming raster map named 'MASK' will restore raster operations to
normal.
Checking for NULLs in input maps...
   0   3   6   9  12  15  18  21  24  27  30  33  36  39  42  45  48  51  54  57  60  63  66  69  72  75  78  81  84  87  90  93  96  99 100
Calculating hydrotopes with: OrderedDict([('subbasin_id', 'subbasins'),
('landuse_id', 'landuse@PERMANENT'), ('soil_id', 'soil@PERMANENT'),
('elevation', 'contours')])...
All subsequent raster operations will be limited to the MASK area. Removing
or renaming raster map named 'MASK' will restore raster operations to
normal.
r.cross: SCHRITT 1 ...
   0   6  12  18  24  30  36  42  48  54  60  66  72  78  84  90  96 100
r.cross: SCHRITT 2 ...
r.cross: Schritt 3 ...
   0   6  12  18  24  30  36  42  48  54  60  66  72  78  84  90  96 100
Erstelle Support-Dateien für <hydrotopes__rcross>...
182 categories
   0   3   6   9  12  15  18  21  24  27  30  33  36  39  42  45  48  51  54  57  60  63  66  69  72  75  78  81  84  87  90  93  96  99 100
Get mean hydrotope values for elevation@PERMANENT
Wrote hydrotope file
/home/tobias/apps/swimpy_redesign/tests/project/swimpy/clones/subbasin_size_sensitivity/input/hydrotope.csv
182 hydrotopes created, 16.55 per subbasin on average, max.
number of hydrotopes per subbasin 32
Execution took 0:00:02.138131 hh:mm:ss
/tmp/ipykernel_18936/2029867248.py:33: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
  catch_lab.rename(columns={'NAME': 'output_label',
Upthresh 50 -> mean subbasin size 92.0 (n=11)
GIS Environment:
GISDBASE: /home/tobias/apps/swimpy_redesign/tests/grassdb
LOCATION_NAME: utm32n
MAPSET: swim
Parameters:
elevation: elevation@PERMANENT
stations: stations@PERMANENT
streamthresh: 200
upthresh: 200
lothresh: 1.6
upthreshcolumn:
depression:
accumulation: accumulation
drainage: drainage
streams: streams
subbasins: subbasins
catchments: catchments
catchmentprefix: catchment_
stations_snapped: stations_snapped
slopesteepness: slopesteepness
slopelength: slopelength
streamcarve:
predefined: reservoirs@PERMANENT
rwatershedflags: s
rwatershedmemory:
d: False
g: False
l: False
s: False
k: False
v: False
Processing DEM to derive accumulation, drainage and streams...
ABSCHNITT 1a (von 6): Initiiere den Speicher.
ABSCHNITT 1b (of 6): Ermittle den Fluß aus der Karte heraus.
   0   4   8  12  16  20  24  28  32  36  40  44  48  52  56  60  64  68  72  76  80  84  88  92  96 100
SECTION 2: A* Search.
   0   2   4   6   8  10  12  14  16  18  20  22  24  26  28  30  32  34  36  38  40  42  44  46  48  50  52  54  56  58  60  62  64  66  68  70  72  74  76  78  80  82  84  86  88  90  92  94  96  98 100
ABSCHNITT 3: Akkumuliere Oberflächenabfluß mit SFD.
   1   3   5   7   9  11  13  15  17  19  21  23  25  27  29  31  33  35  37  39  41  43  45  47  49  51  53  55  57  59  61  63  65  67  69  71  73  75  77  79  81  83  85  87  89  91  93  95  97  99 100
ABSCHNITT 4: Bestimme RUSLE LS und/oder den S Faktor.
   0   4   8  12  16  20  24  28  32  36  40  44  48  52  56  60  64  68  72  76  80  84  88  92  96 100
ABSCHNITT 5: Bestimme Wassereinzugsgebiet.
   0   2   4   6   8  10  12  14  16  18  20  22  24  26  28  30  32  34  36  38  40  42  44  46  48  50  52  54  56  58  60  62  64  66  68  70  72  74  76  78  80  82  84  86  88  90  92  94  96  98 100
ABSCHNITT 6: Schließe Karten.
  10 100
Making vector river network...
WARNUNG: Vektorkarte <streams> existiert bereits und wird überschrieben.
Snapping stations to streams...
Creating catchments...
   0   6  12  18  24  30  36  42  48  54  60  66  72  78  84  90  96 100
WARNUNG: Vektorkarte <catchment_1> existiert bereits und wird
         überschrieben.
  50   0   6  12  18  24  30  36  42  48  54  60  66  72  78  84  90  96 100
WARNUNG: Vektorkarte <catchment_2> existiert bereits und wird
         überschrieben.
 100
Check station topology...
Patching catchments...
Creating subbasins...
  50 100
  50 100
Including predefined subbasins reservoirs@PERMANENT...
Cleaning subbasin map...
WARNUNG: Number of centroids exceeds number of areas: 8 > 5
Assigning continuous categories to subbasins map...
WARNUNG: Vektorkarte <subbasins> existiert bereits und wird überschrieben.
WARNUNG: Values in column <subbasinID> will be overwritten
Creating catchments vector map...
WARNUNG: Vektorkarte <catchments> existiert bereits und wird
         überschrieben.
WARNUNG: Values in column <catchmentID> will be overwritten
Adding subbasin info to subbasin attribute table...
WARNUNG: Vektorkarte <stations_snapped> existiert bereits und wird
         überschrieben.
-----------------------------------------------------------------
Execution took 0:00:12.857942 hh:mm:ss
Catchment sizes :
ID  excl. upstream   incl. upstream  outlet subbasin  upstream stations
  1         523.63           523.63                3
  2         488.44          1012.07                1  1
-----------------------------------------------------------------
Subbasin statistics (km2):
stationID count    min      mean     max
    total        5     1.61   202.41   520.28
        1        3     1.61   174.54   520.28
        2        2   244.10   244.22   244.34
-----------------------------------------------------------------
GIS Environment:
GISDBASE: /home/tobias/apps/swimpy_redesign/tests/grassdb
LOCATION_NAME: utm32n
MAPSET: swim
Parameters:
subbasins: subbasins
accumulation: accumulation
drainage: drainage
routingnet: routingnetwork
mainstreams: mainstreams
outlets: subbasinoutlets
inlets: subbasininlets
output:
/home/tobias/apps/swimpy_redesign/tests/project/swimpy/clones/subbasin_size_sensitivity/input/subbasin_routing.csv
fromto:
minmainstreams: 50
rivercourse:
r: False
k: False
v: False
Will calculate routing for subbasins
All subsequent raster operations will be limited to the MASK area. Removing
or renaming raster map named 'MASK' will restore raster operations to
normal.
Searching outlets...
Growing outlets...
Searching inlets...
WARNUNG: Vektorkarte <subbasinoutlets> existiert bereits und wird
         überschrieben.
Getting inletIDs...
WARNUNG: Vektorkarte <subbasininlets> existiert bereits und wird
         überschrieben.
WARNUNG: Rastertyp ist Fließkomma und der Spaltentyp ist Integer. Etwas
         Informationsgehalt der Daten geht verloren!!
Routing successfully completed. nextID and inletID added to subbasins
table.
Find outlets (if other than ID 1, check if the accumulation
map has negative, ie. off-map flow)...
Outlet subbasin order: 2
Subbasin(s) [1] is(are) outlet(s)
Building routing vector...
Connected 5 outlets
WARNUNG: Vektorkarte <routingnetwork> existiert bereits und wird
         überschrieben.
Creating mainstream network in mainstreams...
 100
WARNUNG: Values in column <cat> will be overwritten
WARNUNG: Values in column <cat> will be overwritten
WARNUNG: Values in column <cat> will be overwritten
WARNUNG: No areas selected from vector map <mainstreams__split>
WARNUNG: Not all vector categories converted to raster. Converted 8 of 10.
WARNUNG: Vektorkarte <mainstreams> existiert bereits und wird
         überschrieben.
WARNUNG: Values in column <cat> will be overwritten
Will write routing file to
/home/tobias/apps/swimpy_redesign/tests/project/swimpy/clones/subbasin_size_sensitivity/input/subbasin_routing.csv!
Wrote
/home/tobias/apps/swimpy_redesign/tests/project/swimpy/clones/subbasin_size_sensitivity/input/subbasin_routing.csv
Execution took 0:00:17.817809 hh:mm:ss
GIS Environment:
GISDBASE: /home/tobias/apps/swimpy_redesign/tests/grassdb
LOCATION_NAME: utm32n
MAPSET: swim
Parameters:
output:
/home/tobias/apps/swimpy_redesign/tests/project/swimpy/clones/subbasin_size_sensitivity/input/subbasin.csv
subbasins: subbasins
catchment_id: catchments
elev0: 0
sdtsav: 0
sl: slopelength
stp: slopesteepness
salb: 0.15
sno: 0
ovn: 0.15
rt: 0
css: 0.5
ecp: 0.5
suborder: catchment_id,sl,stp,lat,elev0
mainstreams: mainstreams
elevation: elevation@PERMANENT
drainage: drainage
accumulation: accumulation
chl:
chs:
chw:
chd:
chk: 0.37
chn: 0.075
chxk: 0.28
chc: 1
rteorder: chw,chd,chs,chl
gwht: 1
gwq: 0.5
abf: 0.048
syld: 0.003
delay: 200
revapc: 0.2
rchrgc: 0.05
revapmn: 0
gworder: delay
k: False
v: False
   0   3   6   9  12  15  18  21  24  27  30  33  36  39  42  45  48  51  54  57  60  63  66  69  72  75  78  81  84  87  90  93  96  99 100
   0   3   6   9  12  15  18  21  24  27  30  33  36  39  42  45  48  51  54  57  60  63  66  69  72  75  78  81  84  87  90  93  96  99 100
   0   3   6   9  12  15  18  21  24  27  30  33  36  39  42  45  48  51  54  57  60  63  66  69  72  75  78  81  84  87  90  93  96  99 100
Subbasin fraction statistics:
min: 0.0015907990554013063 mean: 0.19999999999999998 max:
0.5140751133814855 n: 5
Will use average subbasin values of catchments for catchment_id.
average of catchments over each subbasin__rast saved in
subbasin__rast__catchments__average
catchment_id statistics:
min: 1.0 mean: 1.4 max: 2.0 number of nans: 0
Will use average subbasin values of slopelength for sl.
average of slopelength over each subbasin__rast saved in
subbasin__rast__slopelength__average
sl statistics:
min: 0.4534333 mean: 0.5918076 max: 0.7494084 number of nans: 0
Will use average subbasin values of slopesteepness for stp.
average of slopesteepness over each subbasin__rast saved in
subbasin__rast__slopesteepness__average
stp statistics:
min: 0.2275173 mean: 0.27653972 max: 0.3235281 number of nans: 0
WARNUNG: Number of centroids exceeds number of areas: 5 > 0
WARNUNG: Anzahl der Zentroide außerhalb von Flächen: 5
WARNUNG: Number of centroids exceeds number of areas: 5 > 0
WARNUNG: Anzahl der Zentroide außerhalb von Flächen: 5
lat statistics:
min: 50.2319370517919 mean: 50.30059265617807 max: 50.3845142891035 number
of nans: 0
Using default value for elev0 = 0.0
elev0 statistics:
min: 0.0 mean: 0.0 max: 0.0 number of nans: 0
Using default value for delay = 200.0
delay statistics:
min: 200.0 mean: 200.0 max: 200.0 number of nans: 0
Calculating main channel width...
chw statistics:
min: 33.8472063246843 mean: 50.27976998452276 max: 81.9820210198713 number
of nans: 0
Calculating main channel depth...
chd statistics:
min: 1.14788601455104 mean: 1.475544248402692 max: 2.07028098056801 number
of nans: 0
Calculating main channel slope...
   0   3   6   9  12  15  18  21  24  27  30  33  36  39  42  45  48  51  54  57  60  63  66  69  72  75  78  81  84  87  90  93  96  99 100
Neigungs-Rasterkarte <elevation__slope> komplett.
average of mainstream__slope__tan over each subbasin__rast saved in
subbasin__rast__mainstream__slope__tan__average
chs statistics:
min: 0.014951934106648 mean: 0.031595970876514924 max: 0.0477233305573463
number of nans: 0
Calculating main channel length...
average of cell__len__mainstreams over each subbasin__rast saved in
subbasin__rast__cell__len__mainstreams__average
chl statistics:
min: 2.048528 mean: 12.450235399999999 max: 31.04336 number of nans: 0
Wrote
/home/tobias/apps/swimpy_redesign/tests/project/swimpy/clones/subbasin_size_sensitivity/input/subbasin.csv
Raster MASK removed
Execution took 0:00:08.031791 hh:mm:ss
GIS Environment:
GISDBASE: /home/tobias/apps/swimpy_redesign/tests/grassdb
LOCATION_NAME: utm32n
MAPSET: swim
Parameters:
subbasin_id: subbasins
landuse_id: landuse@PERMANENT
soil_id: soil@PERMANENT
output:
/home/tobias/apps/swimpy_redesign/tests/project/swimpy/clones/subbasin_size_sensitivity/input/hydrotope.csv
hydrotopes: hydrotopes
contours: 200
contourrast: contours
elevation: elevation@PERMANENT
crop_management_id:
wetland:
glacier_thickness:
more:
c: False
k: False
v: False
Contour breaks:,[400, 600, 800]
Created contourmap: contours
Check if all input are integer raster...
All subsequent raster operations will be limited to the MASK area. Removing
or renaming raster map named 'MASK' will restore raster operations to
normal.
Checking for NULLs in input maps...
   0   3   6   9  12  15  18  21  24  27  30  33  36  39  42  45  48  51  54  57  60  63  66  69  72  75  78  81  84  87  90  93  96  99 100
Calculating hydrotopes with: OrderedDict([('subbasin_id', 'subbasins'),
('landuse_id', 'landuse@PERMANENT'), ('soil_id', 'soil@PERMANENT'),
('elevation', 'contours')])...
All subsequent raster operations will be limited to the MASK area. Removing
or renaming raster map named 'MASK' will restore raster operations to
normal.
r.cross: SCHRITT 1 ...
   0   6  12  18  24  30  36  42  48  54  60  66  72  78  84  90  96 100
r.cross: SCHRITT 2 ...
r.cross: Schritt 3 ...
   0   6  12  18  24  30  36  42  48  54  60  66  72  78  84  90  96 100
Erstelle Support-Dateien für <hydrotopes__rcross>...
101 categories
   0   3   6   9  12  15  18  21  24  27  30  33  36  39  42  45  48  51  54  57  60  63  66  69  72  75  78  81  84  87  90  93  96  99 100
Get mean hydrotope values for elevation@PERMANENT
Wrote hydrotope file
/home/tobias/apps/swimpy_redesign/tests/project/swimpy/clones/subbasin_size_sensitivity/input/hydrotope.csv
101 hydrotopes created, 20.20 per subbasin on average, max.
number of hydrotopes per subbasin 36
Execution took 0:00:02.300435 hh:mm:ss
/tmp/ipykernel_18936/2029867248.py:33: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
  catch_lab.rename(columns={'NAME': 'output_label',
Upthresh 200 -> mean subbasin size 202.4 (n=5)
[3]:
# visualise results
ax = q['1992-03-01':'1992-03-31'].plot()
plt.title('Sensitivity of subbasin size at Blankenstein')
yl = plt.ylabel('Discharge [m^2s^-1]')
../_images/examples_sensitivity_of_subbasin_size_4_0.png
Scroll To Top