Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
hru-delin-dev
hru-delin
Commits
bdd9d960
Commit
bdd9d960
authored
Oct 09, 2020
by
Rabotin Michael
Browse files
Add tests directory and author name
parent
f30c7137
Changes
75
Show whitespace changes
Inline
Side-by-side
bin/hru-delin_all-steps.sh
View file @
bdd9d960
#!/bin/bash
#!/bin/bash
############################################################################
#
# MODULE: hru-delin_all-steps.sh
# AUTHOR(S): Julien Veyssier
#
#
# COPYRIGHT: (C) 2020 UR RIVERLY - INRAE
#
# This program is free software under the GNU General Public
# License (>=v2). Read the file LICENSE that comes with
# HRU-DELIN for details.
#
#############################################################################
# very simple, we just call all steps scripts with same arguments we got here
# very simple, we just call all steps scripts with same arguments we got here
hru-delin_step1.sh
"
$@
"
hru-delin_step1.sh
"
$@
"
...
...
bin/hru-delin_step1.sh
View file @
bdd9d960
#!/bin/bash
#!/bin/bash
############################################################################
#
# MODULE: hru-delin_step1.sh
# AUTHOR(S): Julien Veyssier
#
#
# COPYRIGHT: (C) 2020 UR RIVERLY - INRAE
#
# This program is free software under the GNU General Public
# License (>=v2). Read the file LICENSE that comes with
# HRU-DELIN for details.
#
#############################################################################
# HRU-DELIN
# HRU-DELIN
# first step : hru-delin_init
# first step : hru-delin_init
...
@@ -105,11 +120,20 @@ fi
...
@@ -105,11 +120,20 @@ fi
# clean work environment
# clean work environment
# ----------------------
# ----------------------
# test id dir output exist
clean_files
=
`
grep
"files
\s
*:"
$CONFIGFILE
|
cut
-d
':'
-f2
|
sed
-e
's/\s*$//'
|
sed
-e
's/^\s*//'
`
clean_files
=
`
grep
"files
\s
*:"
$CONFIGFILE
|
cut
-d
':'
-f2
|
sed
-e
's/\s*$//'
|
sed
-e
's/^\s*//'
`
if
[
-z
"
$clean_files
"
]
;
then
if
[
-z
"
$clean_files
"
]
;
then
clean_files
=
`
grep
"files
\s
*="
$CONFIGFILE
|
cut
-d
'='
-f2
|
sed
-e
's/\s*$//'
|
sed
-e
's/^\s*//'
`
clean_files
=
`
grep
"files
\s
*="
$CONFIGFILE
|
cut
-d
'='
-f2
|
sed
-e
's/\s*$//'
|
sed
-e
's/^\s*//'
`
fi
fi
if
[
-z
"
$clean_files
"
]
;
then
echo
"------------> ERROR : Output FILE Directory not provided !"
exit
1
fi
echo
"clean files
$clean_files
"
echo
"clean files
$clean_files
"
# is the path absolute?
# is the path absolute?
if
[[
"
$clean_files
"
=
/
*
]]
;
then
if
[[
"
$clean_files
"
=
/
*
]]
;
then
rm
-rf
$clean_files
rm
-rf
$clean_files
...
@@ -120,10 +144,23 @@ else
...
@@ -120,10 +144,23 @@ else
mkdir
$CONFIGFILEPATH
/
$clean_files
mkdir
$CONFIGFILEPATH
/
$clean_files
fi
fi
# test if mkdir works
if
[
$?
-ne
0
]
;
then
echo
"------------> ERROR : Impossible to create Output directory !"
exit
1
fi
clean_results
=
`
grep
"results
\s
*:"
$CONFIGFILE
|
cut
-d
':'
-f2
|
sed
-e
's/\s*$//'
|
sed
-e
's/^\s*//'
`
clean_results
=
`
grep
"results
\s
*:"
$CONFIGFILE
|
cut
-d
':'
-f2
|
sed
-e
's/\s*$//'
|
sed
-e
's/^\s*//'
`
if
[
-z
"
$clean_results
"
]
;
then
if
[
-z
"
$clean_results
"
]
;
then
clean_results
=
`
grep
"results
\s
*="
$CONFIGFILE
|
cut
-d
'='
-f2
|
sed
-e
's/\s*$//'
|
sed
-e
's/^\s*//'
`
clean_results
=
`
grep
"results
\s
*="
$CONFIGFILE
|
cut
-d
'='
-f2
|
sed
-e
's/\s*$//'
|
sed
-e
's/^\s*//'
`
fi
fi
if
[
-z
"
$clean_results
"
]
;
then
echo
"------------> ERROR : Output RESULTS Directory not provided !"
exit
1
fi
echo
"clean results
$clean_results
"
echo
"clean results
$clean_results
"
# is the path absolute?
# is the path absolute?
if
[[
"
$clean_results
"
=
/
*
]]
;
then
if
[[
"
$clean_results
"
=
/
*
]]
;
then
...
...
bin/hru-delin_step2.sh
View file @
bdd9d960
#!/bin/bash
#!/bin/bash
############################################################################
#
# MODULE: hru-delin_step2.sh
# AUTHOR(S): Julien Veyssier
#
#
# COPYRIGHT: (C) 2020 UR RIVERLY - INRAE
#
# This program is free software under the GNU General Public
# License (>=v2). Read the file LICENSE that comes with
# HRU-DELIN for details.
#
#############################################################################
# HRU-DELIN
# HRU-DELIN
# 2nd step : hru-delin_basins
# 2nd step : hru-delin_basins
...
@@ -107,6 +121,12 @@ clean_files=`grep "files\s*:" $CONFIGFILE | cut -d ':' -f2 | sed -e 's/\s*$//' |
...
@@ -107,6 +121,12 @@ clean_files=`grep "files\s*:" $CONFIGFILE | cut -d ':' -f2 | sed -e 's/\s*$//' |
if
[
-z
"
$clean_files
"
]
;
then
if
[
-z
"
$clean_files
"
]
;
then
clean_files
=
`
grep
"files
\s
*="
$CONFIGFILE
|
cut
-d
'='
-f2
|
sed
-e
's/\s*$//'
|
sed
-e
's/^\s*//'
`
clean_files
=
`
grep
"files
\s
*="
$CONFIGFILE
|
cut
-d
'='
-f2
|
sed
-e
's/\s*$//'
|
sed
-e
's/^\s*//'
`
fi
fi
if
[
-z
"
$clean_files
"
]
;
then
echo
"------------> ERROR : Output FILE Directory not provided !"
exit
1
fi
# is the path absolute?
# is the path absolute?
if
[[
"
$clean_files
"
=
/
*
]]
;
then
if
[[
"
$clean_files
"
=
/
*
]]
;
then
rm
-f
$clean_files
/step2
*
$clean_files
/step3
*
rm
-f
$clean_files
/step2
*
$clean_files
/step3
*
...
@@ -118,6 +138,12 @@ clean_results=`grep "results\s*:" $CONFIGFILE | cut -d ':' -f2 | sed -e 's/\s*$/
...
@@ -118,6 +138,12 @@ clean_results=`grep "results\s*:" $CONFIGFILE | cut -d ':' -f2 | sed -e 's/\s*$/
if
[
-z
"
$clean_results
"
]
;
then
if
[
-z
"
$clean_results
"
]
;
then
clean_results
=
`
grep
"results
\s
*="
$CONFIGFILE
|
cut
-d
'='
-f2
|
sed
-e
's/\s*$//'
|
sed
-e
's/^\s*//'
`
clean_results
=
`
grep
"results
\s
*="
$CONFIGFILE
|
cut
-d
'='
-f2
|
sed
-e
's/\s*$//'
|
sed
-e
's/^\s*//'
`
fi
fi
if
[
-z
"
$clean_results
"
]
;
then
echo
"------------> ERROR : Output RESULTS Directory not provided !"
exit
1
fi
# is the path absolute?
# is the path absolute?
if
[[
"
$clean_results
"
=
/
*
]]
;
then
if
[[
"
$clean_results
"
=
/
*
]]
;
then
rm
-rf
$clean_results
rm
-rf
$clean_results
...
@@ -127,6 +153,12 @@ else
...
@@ -127,6 +153,12 @@ else
mkdir
$CONFIGFILEPATH
/
$clean_results
mkdir
$CONFIGFILEPATH
/
$clean_results
fi
fi
# test if mkdir works
if
[
$?
-ne
0
]
;
then
echo
"------------> ERROR : Impossible to create Output directory !"
exit
1
fi
# -----------------------------------
# -----------------------------------
# exec second step of HRU-DELIN batch
# exec second step of HRU-DELIN batch
# -----------------------------------
# -----------------------------------
...
...
bin/hru-delin_step3.sh
View file @
bdd9d960
#!/bin/bash
#!/bin/bash
############################################################################
#
# MODULE: hru-delin_step3.sh
# AUTHOR(S): Julien Veyssier
#
#
# COPYRIGHT: (C) 2020 UR RIVERLY - INRAE
#
# This program is free software under the GNU General Public
# License (>=v2). Read the file LICENSE that comes with
# HRU-DELIN for details.
#
#############################################################################
# HRU-DELIN
# HRU-DELIN
# 3rd step : hru-delin_hrugen
# 3rd step : hru-delin_hrugen
...
@@ -108,6 +121,12 @@ clean_files=`grep "files\s*:" $CONFIGFILE | cut -d ':' -f2 | sed -e 's/\s*$//' |
...
@@ -108,6 +121,12 @@ clean_files=`grep "files\s*:" $CONFIGFILE | cut -d ':' -f2 | sed -e 's/\s*$//' |
if
[
-z
"
$clean_files
"
]
;
then
if
[
-z
"
$clean_files
"
]
;
then
clean_files
=
`
grep
"files
\s
*="
$CONFIGFILE
|
cut
-d
'='
-f2
|
sed
-e
's/\s*$//'
|
sed
-e
's/^\s*//'
`
clean_files
=
`
grep
"files
\s
*="
$CONFIGFILE
|
cut
-d
'='
-f2
|
sed
-e
's/\s*$//'
|
sed
-e
's/^\s*//'
`
fi
fi
if
[
-z
"
$clean_files
"
]
;
then
echo
"------------> ERROR : Output FILE Directory not provided !"
exit
1
fi
# is the path absolute?
# is the path absolute?
if
[[
"
$clean_files
"
=
/
*
]]
;
then
if
[[
"
$clean_files
"
=
/
*
]]
;
then
rm
-f
$clean_files
/step3
*
rm
-f
$clean_files
/step3
*
...
@@ -118,6 +137,12 @@ clean_results=`grep "results\s*:" $CONFIGFILE | cut -d ':' -f2 | sed -e 's/\s*$/
...
@@ -118,6 +137,12 @@ clean_results=`grep "results\s*:" $CONFIGFILE | cut -d ':' -f2 | sed -e 's/\s*$/
if
[
-z
"
$clean_results
"
]
;
then
if
[
-z
"
$clean_results
"
]
;
then
clean_results
=
`
grep
"results
\s
*="
$CONFIGFILE
|
cut
-d
'='
-f2
|
sed
-e
's/\s*$//'
|
sed
-e
's/^\s*//'
`
clean_results
=
`
grep
"results
\s
*="
$CONFIGFILE
|
cut
-d
'='
-f2
|
sed
-e
's/\s*$//'
|
sed
-e
's/^\s*//'
`
fi
fi
if
[
-z
"
$clean_results
"
]
;
then
echo
"------------> ERROR : Output RESULTS Directory not provided !"
exit
1
fi
# is the path absolute?
# is the path absolute?
if
[[
"
$clean_results
"
=
/
*
]]
;
then
if
[[
"
$clean_results
"
=
/
*
]]
;
then
rm
-rf
$clean_results
rm
-rf
$clean_results
...
@@ -127,6 +152,12 @@ else
...
@@ -127,6 +152,12 @@ else
mkdir
$CONFIGFILEPATH
/
$clean_results
mkdir
$CONFIGFILEPATH
/
$clean_results
fi
fi
# test if mkdir works
if
[
$?
-ne
0
]
;
then
echo
"------------> ERROR : Impossible to create Output directory !"
exit
1
fi
# -----------------------------------
# -----------------------------------
# exec third step of HRU-DELIN batch
# exec third step of HRU-DELIN batch
# -----------------------------------
# -----------------------------------
...
...
bin/hru-delin_step4.sh
View file @
bdd9d960
#!/bin/bash
#!/bin/bash
############################################################################
#
# MODULE: hru-delin_step4.sh
# AUTHOR(S): Julien Veyssier
#
#
# COPYRIGHT: (C) 2020 UR RIVERLY - INRAE
#
# This program is free software under the GNU General Public
# License (>=v2). Read the file LICENSE that comes with
# HRU-DELIN for details.
#
#############################################################################
# HRU-DELIN
# HRU-DELIN
# 4th step : hru-delin_parms_J2000
# 4th step : hru-delin_parms_J2000
...
@@ -109,6 +123,12 @@ clean_results=`grep "results\s*:" $CONFIGFILE | cut -d ':' -f2 | sed -e 's/\s*$/
...
@@ -109,6 +123,12 @@ clean_results=`grep "results\s*:" $CONFIGFILE | cut -d ':' -f2 | sed -e 's/\s*$/
if
[
-z
"
$clean_results
"
]
;
then
if
[
-z
"
$clean_results
"
]
;
then
clean_results
=
`
grep
"results
\s
*="
$CONFIGFILE
|
cut
-d
'='
-f2
|
sed
-e
's/\s*$//'
|
sed
-e
's/^\s*//'
`
clean_results
=
`
grep
"results
\s
*="
$CONFIGFILE
|
cut
-d
'='
-f2
|
sed
-e
's/\s*$//'
|
sed
-e
's/^\s*//'
`
fi
fi
if
[
-z
"
$clean_results
"
]
;
then
echo
"------------> ERROR : Output RESULTS Directory not provided !"
exit
1
fi
# is the path absolute?
# is the path absolute?
if
[[
"
$clean_results
"
=
/
*
]]
;
then
if
[[
"
$clean_results
"
=
/
*
]]
;
then
rm
-rf
$clean_results
rm
-rf
$clean_results
...
@@ -118,6 +138,13 @@ else
...
@@ -118,6 +138,13 @@ else
mkdir
$CONFIGFILEPATH
/
$clean_results
mkdir
$CONFIGFILEPATH
/
$clean_results
fi
fi
# test if mkdir works
if
[
$?
-ne
0
]
;
then
echo
"------------> ERROR : Impossible to create Output directory !"
exit
1
fi
rm
-f
topologie_
*
tmp/topologie_
*
rm
-f
topologie_
*
tmp/topologie_
*
# -----------------------------------
# -----------------------------------
...
...
bin/tools.sh
View file @
bdd9d960
#!/bin/bash
#!/bin/bash
############################################################################
#
# MODULE: tools.sh
# AUTHOR(S): Julien Veyssier
#
#
# COPYRIGHT: (C) 2020 UR RIVERLY - INRAE
#
# This program is free software under the GNU General Public
# License (>=v2). Read the file LICENSE that comes with
# HRU-DELIN for details.
#
#############################################################################
buildGrassEnv
()
{
buildGrassEnv
()
{
envPath
=
$1
envPath
=
$1
...
...
modules/awk.py
View file @
bdd9d960
############################################################################
#
# MODULE: awk.py
# AUTHOR(S): Julien Veyssier
#
#
# COPYRIGHT: (C) 2020 UR RIVERLY - INRAE
#
# This program is free software under the GNU General Public
# License (>=v2). Read the file LICENSE that comes with
# HRU-DELIN for details.
#
#############################################################################
# coding: utf-8
# coding: utf-8
# this file contains the converted old awk scripts which were not portable (to windows)
# this file contains the converted old awk scripts which were not portable (to windows)
...
...
modules/circleKill.py
View file @
bdd9d960
#!/usr/bin/env python3
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
############################################################################
#
# MODULE: circleKill.py
# AUTHOR(S): Julien Veyssier
#
#
# COPYRIGHT: (C) 2020 UR RIVERLY - INRAE
#
# This program is free software under the GNU General Public
# License (>=v2). Read the file LICENSE that comes with
# HRU-DELIN for details.
#
#############################################################################
import
sys
import
sys
try
:
try
:
import
dbf
import
dbf
...
...
modules/grassUtils.py
View file @
bdd9d960
# coding: utf-8
# coding: utf-8
############################################################################
#
# MODULE: grassUtils.py
# AUTHOR(S): Julien Veyssier
#
#
# COPYRIGHT: (C) 2020 UR RIVERLY - INRAE
#
# This program is free software under the GNU General Public
# License (>=v2). Read the file LICENSE that comes with
# HRU-DELIN for details.
#
#############################################################################
import
os
,
sys
,
shutil
import
os
,
sys
,
shutil
try
:
try
:
# Python 3
# Python 3
...
...
modules/hrudelin_1_init.py
View file @
bdd9d960
# coding: utf-8
# coding: utf-8
'''
MODULE: hru-delin_init
AUTHOR(S): adapted from GRASS-HRU (ILMS) - JENA University
############################################################################
by IRSTEA - Christine Barachet
#
# MODULE: hrudelin_1_init.py
# AUTHOR(S): adapted from GRASS-HRU (ILMS) - JENA University
# by IRSTEA - Christine Barachet,
# Julien Veyssier
# PURPOSE: Prepare files for the next steps of HRU Delineation
# shapefile : selected gauges
# rasters : bounded DEM and others (geology, soils, landuse)
# DEM, slope and aspect with values of reclassification
# calculates oriented flows and subbasins
#
# COPYRIGHT: (C) 2020 UR RIVERLY - INRAE
#
# This program is free software under the GNU General Public
# License (>=v2). Read the file LICENSE that comes with
# HRU-DELIN for details.
#
#############################################################################
PURPOSE: Prepare files for the next steps of HRU Delineation
shapefile : selected gauges
rasters : bounded DEM and others (geology, soils, landuse)
DEM, slope and aspect with values of reclassification
calculates oriented flows and subbasins
'''
# to keep python2 compatibility
# to keep python2 compatibility
from
__future__
import
print_function
from
__future__
import
print_function
...
@@ -61,13 +70,37 @@ def get_polygon_bounds(shape, xmin_slect, ymax_slect, xmax_slect, ymin_slect):
...
@@ -61,13 +70,37 @@ def get_polygon_bounds(shape, xmin_slect, ymax_slect, xmax_slect, ymin_slect):
max
(
ymin_slect
,
ymin
)
max
(
ymin_slect
,
ymin
)
)
)
def
isfloat
(
value
):
try
:
float
(
value
)
return
True
except
ValueError
:
return
False
def
isint
(
value
):
try
:
int
(
value
)
return
True
except
ValueError
:
return
False
def
get_coords
(
parms
,
xmin_slect
,
ymax_slect
,
xmax_slect
,
ymin_slect
):
def
get_coords
(
parms
,
xmin_slect
,
ymax_slect
,
xmax_slect
,
ymin_slect
):
if
not
isfloat
(
parms
.
get
(
'surface'
,
'west'
))
or
isfloat
(
parms
.
get
(
'surface'
,
'north'
))
or
isfloat
(
parms
.
get
(
'surface'
,
'east'
))
or
isfloat
(
parms
.
get
(
'surface'
,
'south'
)):
sys
.
exit
(
'------------> ERROR : coordinates for surface selection is not valid'
)
xmin_slect
=
max
(
xmin_slect
,
float
(
parms
.
get
(
'surface'
,
'west'
)))
xmin_slect
=
max
(
xmin_slect
,
float
(
parms
.
get
(
'surface'
,
'west'
)))
ymax_slect
=
min
(
ymax_slect
,
float
(
parms
.
get
(
'surface'
,
'north'
)))
ymax_slect
=
min
(
ymax_slect
,
float
(
parms
.
get
(
'surface'
,
'north'
)))
xmax_slect
=
min
(
xmax_slect
,
float
(
parms
.
get
(
'surface'
,
'east'
)))
xmax_slect
=
min
(
xmax_slect
,
float
(
parms
.
get
(
'surface'
,
'east'
)))
ymin_slect
=
max
(
ymin_slect
,
float
(
parms
.
get
(
'surface'
,
'south'
)))
ymin_slect
=
max
(
ymin_slect
,
float
(
parms
.
get
(
'surface'
,
'south'
)))
print
(
"hello"
,
xmin_slect
)
return
xmin_slect
,
ymax_slect
,
xmax_slect
,
ymin_slect
return
xmin_slect
,
ymax_slect
,
xmax_slect
,
ymin_slect
try
:
try
:
# Python 3
# Python 3
from
subprocess
import
DEVNULL
from
subprocess
import
DEVNULL
...
@@ -75,12 +108,20 @@ except ImportError:
...
@@ -75,12 +108,20 @@ except ImportError:
#DEVNULL = open('cbtrace_step1', 'wb')
#DEVNULL = open('cbtrace_step1', 'wb')
DEVNULL
=
open
(
os
.
devnull
,
'wb'
)
DEVNULL
=
open
(
os
.
devnull
,
'wb'
)
'''
'''
MAIN
MAIN
'''
'''
def
main
(
parms_file
):
def
main
(
parms_file
):
print
(
'---------- HRU-delin Step 1 started ---------------------------------------------'
)
print
(
'---------- HRU-delin Step 1 started ---------------------------------------------'
)
configFileDir
=
os
.
path
.
dirname
(
parms_file
)
configFileDir
=
os
.
path
.
dirname
(
parms_file
)
# create main env
# create main env
buildGrassEnv
(
os
.
path
.
join
(
configFileDir
,
'grass_db'
),
'hru-delin'
)
buildGrassEnv
(
os
.
path
.
join
(
configFileDir
,
'grass_db'
),
'hru-delin'
)
...
@@ -89,26 +130,81 @@ def main(parms_file):
...
@@ -89,26 +130,81 @@ def main(parms_file):
parms
=
ConfigParser
.
ConfigParser
(
allow_no_value
=
True
)
parms
=
ConfigParser
.
ConfigParser
(
allow_no_value
=
True
)
parms
.
read
(
parms_file
)
parms
.
read
(
parms_file
)
directory
=
parms
.
get
(
'dir_in'
,
'dir'
)
directory
=
parms
.
get
(
'dir_in'
,
'dir'
)
# manage absolute and relative paths
# Test parameters from configuration file
## test if directory is valid
if
not
os
.
path
.
isdir
(
directory
):
sys
.
exit
(
'------------> ERROR : In Directoy is not valid'
)
## manage absolute and relative paths
if
not
os
.
path
.
isabs
(
directory
):
if
not
os
.
path
.
isabs
(
directory
):
directory
=
os
.
path
.
join
(
configFileDir
,
directory
)
directory
=
os
.
path
.
join
(
configFileDir
,
directory
)
directory_out
=
parms
.
get
(
'dir_out'
,
'files'
)
directory_out
=
parms
.
get
(
'dir_out'
,
'files'
)
if
not
os
.
path
.
isabs
(
directory_out
):
if
not
os
.
path
.
isabs
(
directory_out
):
directory_out
=
os
.
path
.
join
(
configFileDir
,
directory_out
)
directory_out
=
os
.
path
.
join
(
configFileDir
,
directory_out
)
## Test if dem exist
dem
=
os
.
path
.
join
(
directory
,
str
(
parms
.
get
(
'files_in'
,
'dem'
)))
if
not
os
.
path
.
isfile
(
dem
):
sys
.
exit
(
'------------> ERROR : Input Dem not found'
)
## Test if gauges exist
gauges
=
os
.
path
.
join
(
directory
,
str
(
parms
.
get
(
'files_in'
,
'gauges'
)))
if
not
os
.
path
.
isfile
(
gauges
):
sys
.
exit
(
'------------> ERROR : Input Gauges not found'
)
## Test if gauges is point or multipoint
ds
=
ogr
.
Open
(
gauges
)
layer
=
ds
.
GetLayer
()
layer_defn
=
layer
.
GetLayerDefn
()
if
ogr
.
GeometryTypeToName
(
layer_defn
.
GetGeomType
())
!=
'Point'
:
sys
.
exit
(
'------------> ERROR : Input Gauges is not Point Geometry (multi Point not allowed)'
)
## if hgeon, landuse and soil provided, test if exist
for
data
in
parms
.
items
(
'data'
):
data
=
os
.
path
.
join
(
directory
,
data
[
1
])
if
not
os
.
path
.
isfile
(
data
):
print
(
data
)
sys
.
exit
(
'------------> ERROR : Input data not found'
)
## if irrig_rast provided, test if is valid
if
str
(
parms
.
get
(
'irrigation'
,
'irrig_rast'
))
!=
''
:
irr_rast_test
=
os
.
path
.
join
(
directory
,
str
(
parms
.
get
(
'irrigation'
,
'irrig_rast'
)))
if
not
os
.
path
.
isfile
(
irr_rast_test
):
sys
.
exit
(
'------------> ERROR : Irrigation raster not found'
)
## if rules_auto_dem is yes, test if step_dem valid
if
(
parms
.
get
(
'reclass_dem'
,
'rules_auto_dem'
))
==
'yes'
:
if
not
isint
(
parms
.
get
(
'reclass_dem'
,
'step_dem'
)):
sys
.
exit
(
'------------> ERROR : Step dem value not provided or is not integer'
)
## test if basin min size is valid
if
not
isint
(
parms
.
get
(
'basin_min_size'
,
'size'
)):
sys
.
exit
(
'------------> ERROR : Basin min size value not provided or is not integer'
)
# Initializing the variables for cutting up of layers
# Initializing the variables for cutting up of layers
xmin_slect
=
ymin_slect
=
0.0
xmin_slect
=
ymin_slect
=
0.0
ymax_slect
=
xmax_slect
=
9999999999.9
ymax_slect
=
xmax_slect
=
9999999999.9
dem
=
os
.
path
.
join
(
directory
,
str
(
parms
.
get
(
'files_in'
,
'dem'
)))
dem_name
=
os
.
path
.
basename
(
parms
.
get
(
'files_in'
,
'dem'
)).
split
(
'.'
)[
0
]
dem_name
=
os
.
path
.
basename
(
parms
.
get
(
'files_in'
,
'dem'
)).
split
(
'.'
)[
0
]
selection
=
(
parms
.
get
(
'surface'
,
'selection'
))
selection
=
(
parms
.
get
(
'surface'
,
'selection'
))
xmin_slect
,
ymax_slect
,
xmax_slect
,
ymin_slect
=
get_raster_bounds
(
dem
,
xmin_slect
,
ymax_slect
,
xmax_slect
,
ymin_slect
)
xmin_slect
,
ymax_slect
,
xmax_slect
,
ymin_slect
=
get_raster_bounds
(
dem
,
xmin_slect
,
ymax_slect
,
xmax_slect
,
ymin_slect
)
## test if selection is valid
if
selection
==
'total'
:
if
selection
==
'total'
:
pass