Skip to content
Permalink
Browse files

Add r.topmodel algorithm

  • Loading branch information
Médéric RIBREUX
Médéric RIBREUX committed Feb 27, 2016
1 parent 7e3b975 commit 4ea75f348a396217fa38de7135354396d19a13f3
@@ -0,0 +1,7 @@
r.topmodel
r.topmodel.topidxstats - Builds a TOPMODEL topographic index statistics file.
Raster (r.*)
ParameterRaster|topidx|Name of input topographic index raster map|False
ParameterNumber|ntopidxclasses|Number of topographic index classes|0|None|30|True
Hardcoded|-p
OutputFile|outtopidxstats|TOPMODEL topographic index statistics file
@@ -0,0 +1,9 @@
r.topmodel
Simulates TOPMODEL which is a physically based hydrologic model.
Raster (r.*)
ParameterFile|parameters|Name of TOPMODEL parameters file|False|False
ParameterFile|topidxstats|Name of topographic index statistics file|False|False
ParameterFile|input|Name of rainfall and potential evapotranspiration data file|False|False
ParameterString|timestep|Time step. Generate output for this time step|None|False|True
ParameterString|topidxclass|Topographic index class. Generate output for this topographic index class|None|False|True
OutputFile|output|TOPMODEL output
@@ -0,0 +1,42 @@
# -*- coding: utf-8 -*-

"""
***************************************************************************
r_topmodel.py
-------------
Date : February 2016
Copyright : (C) 2016 by Médéric Ribreux
Email : medspx at medspx dot fr
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""

__author__ = 'Médéric Ribreux'
__date__ = 'February 2016'
__copyright__ = '(C) 2016, Médéric Ribreux'

# This will get replaced with a git SHA1 when you do a git archive

__revision__ = '$Format:%H$'


def processCommand(alg):
# We temporary remove the output
out = alg.getOutputFromName('out')
topidx = alg.getParameterValue('topidx')
command = "r.topmodel parameters=\"{}\" topidxstats=\"{}\" input=\"{}\" output=\"{}\" {} {}--overwrite".format(
alg.getParameterValue('parameters'),
alg.getParameterValue('topidxstats'),
alg.getParameterValue('input'),
alg.getOutputValue('output'),
'timestep={}'.format(alg.getParameterValue('timestep')) if alg.getParameterValue('timestep') else '',
'topidxclass={}'.format(alg.getParameterValue('topidxclass')) if alg.getParameterValue('topidxclass') else ''
)
alg.commands.append(command)

@@ -0,0 +1,39 @@
# -*- coding: utf-8 -*-

"""
***************************************************************************
r_topmodel_topidxstats.py
-------------------------
Date : February 2016
Copyright : (C) 2016 by Médéric Ribreux
Email : medspx at medspx dot fr
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""

__author__ = 'Médéric Ribreux'
__date__ = 'February 2016'
__copyright__ = '(C) 2016, Médéric Ribreux'

# This will get replaced with a git SHA1 when you do a git archive

__revision__ = '$Format:%H$'


def processCommand(alg):
# We temporary remove the output
out = alg.getOutputFromName('outtopidxstats')
topidx = alg.getParameterValue('topidx')
command = "r.topmodel -p topidx={} ntopidxclasses={} outtopidxstats={} --overwrite".format(
alg.exportedLayers[topidx],
alg.getParameterValue('ntopidxclasses'),
out.value
)
alg.commands.append(command)

0 comments on commit 4ea75f3

Please sign in to comment.
You can’t perform that action at this time.