Skip to content

Commit

Permalink
Add r.topmodel algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
Médéric RIBREUX committed Feb 28, 2016
1 parent 6673fe3 commit 6b9f9d4
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 0 deletions.
@@ -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
42 changes: 42 additions & 0 deletions python/plugins/processing/algs/grass7/ext/r_topmodel.py
@@ -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 6b9f9d4

Please sign in to comment.