Skip to content

Commit 4ea75f3

Browse files
author
Médéric RIBREUX
committed
Add r.topmodel algorithm
1 parent 7e3b975 commit 4ea75f3

File tree

4 files changed

+97
-0
lines changed

4 files changed

+97
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
r.topmodel
2+
r.topmodel.topidxstats - Builds a TOPMODEL topographic index statistics file.
3+
Raster (r.*)
4+
ParameterRaster|topidx|Name of input topographic index raster map|False
5+
ParameterNumber|ntopidxclasses|Number of topographic index classes|0|None|30|True
6+
Hardcoded|-p
7+
OutputFile|outtopidxstats|TOPMODEL topographic index statistics file
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
r.topmodel
2+
Simulates TOPMODEL which is a physically based hydrologic model.
3+
Raster (r.*)
4+
ParameterFile|parameters|Name of TOPMODEL parameters file|False|False
5+
ParameterFile|topidxstats|Name of topographic index statistics file|False|False
6+
ParameterFile|input|Name of rainfall and potential evapotranspiration data file|False|False
7+
ParameterString|timestep|Time step. Generate output for this time step|None|False|True
8+
ParameterString|topidxclass|Topographic index class. Generate output for this topographic index class|None|False|True
9+
OutputFile|output|TOPMODEL output
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# -*- coding: utf-8 -*-
2+
3+
"""
4+
***************************************************************************
5+
r_topmodel.py
6+
-------------
7+
Date : February 2016
8+
Copyright : (C) 2016 by Médéric Ribreux
9+
Email : medspx at medspx dot fr
10+
***************************************************************************
11+
* *
12+
* This program is free software; you can redistribute it and/or modify *
13+
* it under the terms of the GNU General Public License as published by *
14+
* the Free Software Foundation; either version 2 of the License, or *
15+
* (at your option) any later version. *
16+
* *
17+
***************************************************************************
18+
"""
19+
20+
__author__ = 'Médéric Ribreux'
21+
__date__ = 'February 2016'
22+
__copyright__ = '(C) 2016, Médéric Ribreux'
23+
24+
# This will get replaced with a git SHA1 when you do a git archive
25+
26+
__revision__ = '$Format:%H$'
27+
28+
29+
def processCommand(alg):
30+
# We temporary remove the output
31+
out = alg.getOutputFromName('out')
32+
topidx = alg.getParameterValue('topidx')
33+
command = "r.topmodel parameters=\"{}\" topidxstats=\"{}\" input=\"{}\" output=\"{}\" {} {}--overwrite".format(
34+
alg.getParameterValue('parameters'),
35+
alg.getParameterValue('topidxstats'),
36+
alg.getParameterValue('input'),
37+
alg.getOutputValue('output'),
38+
'timestep={}'.format(alg.getParameterValue('timestep')) if alg.getParameterValue('timestep') else '',
39+
'topidxclass={}'.format(alg.getParameterValue('topidxclass')) if alg.getParameterValue('topidxclass') else ''
40+
)
41+
alg.commands.append(command)
42+
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# -*- coding: utf-8 -*-
2+
3+
"""
4+
***************************************************************************
5+
r_topmodel_topidxstats.py
6+
-------------------------
7+
Date : February 2016
8+
Copyright : (C) 2016 by Médéric Ribreux
9+
Email : medspx at medspx dot fr
10+
***************************************************************************
11+
* *
12+
* This program is free software; you can redistribute it and/or modify *
13+
* it under the terms of the GNU General Public License as published by *
14+
* the Free Software Foundation; either version 2 of the License, or *
15+
* (at your option) any later version. *
16+
* *
17+
***************************************************************************
18+
"""
19+
20+
__author__ = 'Médéric Ribreux'
21+
__date__ = 'February 2016'
22+
__copyright__ = '(C) 2016, Médéric Ribreux'
23+
24+
# This will get replaced with a git SHA1 when you do a git archive
25+
26+
__revision__ = '$Format:%H$'
27+
28+
29+
def processCommand(alg):
30+
# We temporary remove the output
31+
out = alg.getOutputFromName('outtopidxstats')
32+
topidx = alg.getParameterValue('topidx')
33+
command = "r.topmodel -p topidx={} ntopidxclasses={} outtopidxstats={} --overwrite".format(
34+
alg.exportedLayers[topidx],
35+
alg.getParameterValue('ntopidxclasses'),
36+
out.value
37+
)
38+
alg.commands.append(command)
39+

0 commit comments

Comments
 (0)