[processing] i18n support for TauDEM provider

This commit is contained in:
Alexander Bruy 2015-01-16 16:13:52 +02:00
parent 321ff1b1d5
commit e1d8710d8c
12 changed files with 132 additions and 186 deletions

View File

@ -81,8 +81,7 @@ class TauDEMAlgorithm(GeoAlgorithm):
line = lines.readline().strip('\n').strip()
except Exception, e:
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
'Could not load TauDEM algorithm: '
+ self.descriptionFile + '\n' + line)
self.tr('Could not load TauDEM algorithm: %s\n%s' % (self.descriptionFile, line)))
raise e
lines.close()
@ -92,10 +91,9 @@ class TauDEMAlgorithm(GeoAlgorithm):
processNum = int(ProcessingConfig.getSetting(TauDEMUtils.MPI_PROCESSES))
if processNum <= 0:
raise GeoAlgorithmExecutionException('Wrong number of MPI \
processes used.\nPlease set correct number before running \
TauDEM algorithms.'
)
raise GeoAlgorithmExecutionException(
self.tr('Wrong number of MPI processes used. Please set '
'correct number before running TauDEM algorithms.'))
commands.append('-n')
commands.append(str(processNum))
@ -121,9 +119,4 @@ class TauDEMAlgorithm(GeoAlgorithm):
commands.append(out.name)
commands.append(out.value)
loglines = []
loglines.append('TauDEM execution command')
for line in commands:
loglines.append(line)
ProcessingLog.addToLog(ProcessingLog.LOG_INFO, loglines)
TauDEMUtils.executeTauDEM(commands, progress)

View File

@ -65,17 +65,16 @@ class TauDEMAlgorithmProvider(AlgorithmProvider):
def initializeSettings(self):
AlgorithmProvider.initializeSettings(self)
ProcessingConfig.addSetting(Setting(self.getDescription(),
TauDEMUtils.TAUDEM_FOLDER,
'TauDEM command line tools folder',
TauDEMUtils.taudemPath()))
TauDEMUtils.TAUDEM_FOLDER,
self.tr('TauDEM command line tools folder'),
TauDEMUtils.taudemPath()))
ProcessingConfig.addSetting(Setting(self.getDescription(),
TauDEMUtils.MPIEXEC_FOLDER,
'MPICH2/OpenMPI bin directory',
TauDEMUtils.mpiexecPath()))
TauDEMUtils.MPIEXEC_FOLDER,
self.tr('MPICH2/OpenMPI bin directory'),
TauDEMUtils.mpiexecPath()))
ProcessingConfig.addSetting(Setting(self.getDescription(),
TauDEMUtils.MPI_PROCESSES,
'Number of MPI parallel processes to use',
2))
TauDEMUtils.MPI_PROCESSES,
self.tr('Number of MPI parallel processes to use'), 2))
def unload(self):
AlgorithmProvider.unload(self)
@ -98,12 +97,10 @@ class TauDEMAlgorithmProvider(AlgorithmProvider):
self.preloadedAlgs.append(alg)
else:
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
'Could not open TauDEM algorithm: '
+ descriptionFile)
self.tr('Could not open TauDEM algorithm: %s' % descriptionFile))
except Exception, e:
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
'Could not open TauDEM algorithm: '
+ descriptionFile)
self.tr('Could not open TauDEM algorithm: %s' % descriptionFile))
self.preloadedAlgs.append(PeukerDouglas())
self.preloadedAlgs.append(SlopeArea())

View File

@ -80,9 +80,9 @@ class TauDEMUtils:
@staticmethod
def executeTauDEM(command, progress):
loglines = []
loglines.append('TauDEM execution console output')
loglines.append(TauDEMUtils.tr('TauDEM execution console output'))
fused_command = ''.join(['"%s" ' % c for c in command])
progress.setInfo('TauDEM command:')
progress.setInfo(TauDEMUtils.tr('TauDEM command:'))
progress.setCommand(fused_command.replace('" "', ' ').strip('"'))
proc = subprocess.Popen(
fused_command,
@ -96,3 +96,9 @@ class TauDEMUtils:
progress.setConsoleInfo(line)
loglines.append(line)
ProcessingLog.addToLog(ProcessingLog.LOG_INFO, loglines)
@staticmethod
def tr(string, context=''):
if context == '':
context = 'TauDEMUtils'
return QCoreApplication.translate(context, string)

View File

@ -77,22 +77,22 @@ class DinfDistDown(GeoAlgorithm):
self.group = 'Specialized Grid Analysis tools'
self.addParameter(ParameterRaster(self.DINF_FLOW_DIR_GRID,
'D-Infinity Flow Direction Grid', False))
self.tr('D-Infinity Flow Direction Grid'), False))
self.addParameter(ParameterRaster(self.PIT_FILLED_GRID,
'Pit Filled Elevation Grid', False))
self.tr('Pit Filled Elevation Grid'), False))
self.addParameter(ParameterRaster(self.STREAM_GRID,
'Stream Raster Grid', False))
self.tr('Stream Raster Grid'), False))
self.addParameter(ParameterRaster(self.WEIGHT_PATH_GRID,
'Weight Path Grid', True))
self.tr('Weight Path Grid'), True))
self.addParameter(ParameterSelection(self.STAT_METHOD,
'Statistical Method', self.STATISTICS, 2))
self.tr('Statistical Method'), self.STATISTICS, 2))
self.addParameter(ParameterSelection(self.DIST_METHOD,
'Distance Method', self.DISTANCE, 1))
self.tr('Distance Method'), self.DISTANCE, 1))
self.addParameter(ParameterBoolean(self.EDGE_CONTAM,
'Check for edge contamination', True))
self.tr('Check for edge contamination'), True))
self.addOutput(OutputRaster(self.DIST_DOWN_GRID,
'D-Infinity Drop to Stream Grid'))
self.tr('D-Infinity Drop to Stream Grid')))
def processAlgorithm(self, progress):
commands = []
@ -100,9 +100,9 @@ class DinfDistDown(GeoAlgorithm):
processNum = ProcessingConfig.getSetting(TauDEMUtils.MPI_PROCESSES)
if processNum <= 0:
raise GeoAlgorithmExecutionException('Wrong number of MPI \
processes used.\nPlease set correct number before running \
TauDEM algorithms.')
raise GeoAlgorithmExecutionException(
self.tr('Wrong number of MPI processes used. Please set '
'correct number before running TauDEM algorithms.'))
commands.append('-n')
commands.append(str(processNum))
@ -127,10 +127,4 @@ class DinfDistDown(GeoAlgorithm):
commands.append('-dd')
commands.append(self.getOutputValue(self.DIST_DOWN_GRID))
loglines = []
loglines.append('TauDEM execution command')
for line in commands:
loglines.append(line)
ProcessingLog.addToLog(ProcessingLog.LOG_INFO, loglines)
TauDEMUtils.executeTauDEM(commands, progress)

View File

@ -78,22 +78,22 @@ class DinfDistUp(GeoAlgorithm):
self.group = 'Specialized Grid Analysis tools'
self.addParameter(ParameterRaster(self.DINF_FLOW_DIR_GRID,
'D-Infinity Flow Direction Grid', False))
self.tr('D-Infinity Flow Direction Grid'), False))
self.addParameter(ParameterRaster(self.PIT_FILLED_GRID,
'Pit Filled Elevation Grid', False))
self.addParameter(ParameterRaster(self.SLOPE_GRID, 'Slope Grid',
False))
self.tr('Pit Filled Elevation Grid'), False))
self.addParameter(ParameterRaster(self.SLOPE_GRID,
self.tr('Slope Grid'), False))
self.addParameter(ParameterSelection(self.STAT_METHOD,
'Statistical Method', self.STATISTICS, 2))
self.tr('Statistical Method'), self.STATISTICS, 2))
self.addParameter(ParameterSelection(self.DIST_METHOD,
'Distance Method', self.DISTANCE, 1))
self.tr('Distance Method'), self.DISTANCE, 1))
self.addParameter(ParameterNumber(self.THRESHOLD,
'Proportion Threshold', 0, None, 0.5))
self.tr('Proportion Threshold'), 0, None, 0.5))
self.addParameter(ParameterBoolean(self.EDGE_CONTAM,
'Check for edge contamination', True))
self.tr('Check for edge contamination'), True))
self.addOutput(OutputRaster(self.DIST_UP_GRID, 'D-Infinity Distance Up'
))
self.addOutput(OutputRaster(self.DIST_UP_GRID,
self.tr('D-Infinity Distance Up')))
def processAlgorithm(self, progress):
commands = []
@ -101,9 +101,9 @@ class DinfDistUp(GeoAlgorithm):
processNum = ProcessingConfig.getSetting(TauDEMUtils.MPI_PROCESSES)
if processNum <= 0:
raise GeoAlgorithmExecutionException('Wrong number of MPI \
processes used.\nPlease set correct number before running \
TauDEM algorithms.')
raise GeoAlgorithmExecutionException(
self.tr('Wrong number of MPI processes used. Please set '
'correct number before running TauDEM algorithms.'))
commands.append('-n')
commands.append(str(processNum))
@ -124,10 +124,4 @@ class DinfDistUp(GeoAlgorithm):
commands.append('-du')
commands.append(self.getOutputValue(self.DIST_UP_GRID))
loglines = []
loglines.append('TauDEM execution command')
for line in commands:
loglines.append(line)
ProcessingLog.addToLog(ProcessingLog.LOG_INFO, loglines)
TauDEMUtils.executeTauDEM(commands, progress)

View File

@ -67,20 +67,21 @@ class DinfTransLimAccum(GeoAlgorithm):
self.group = 'Specialized Grid Analysis tools'
self.addParameter(ParameterRaster(self.DINF_FLOW_DIR_GRID,
'D-Infinity Flow Direction Grid', False))
self.addParameter(ParameterRaster(self.SUPPLY_GRID, 'Supply Grid',
False))
self.tr('D-Infinity Flow Direction Grid'), False))
self.addParameter(ParameterRaster(self.SUPPLY_GRID,
self.tr('Supply Grid'), False))
self.addParameter(ParameterRaster(self.CAPACITY_GRID,
'Transport Capacity Grid', False))
self.tr('Transport Capacity Grid'), False))
self.addParameter(ParameterVector(self.OUTLETS_SHAPE,
'Outlets Shapefile',
[ParameterVector.VECTOR_TYPE_POINT], True))
self.tr('Outlets Shapefile'),
[ParameterVector.VECTOR_TYPE_POINT], True))
self.addParameter(ParameterBoolean(self.EDGE_CONTAM,
'Check for edge contamination', True))
self.tr('Check for edge contamination'), True))
self.addOutput(OutputRaster(self.TRANSP_LIM_ACCUM_GRID,
'Transport Limited Accumulation Grid'))
self.addOutput(OutputRaster(self.DEPOSITION_GRID, 'Deposition Grid'))
self.tr('Transport Limited Accumulation Grid')))
self.addOutput(OutputRaster(self.DEPOSITION_GRID,
self.tr('Deposition Grid')))
def processAlgorithm(self, progress):
commands = []
@ -88,9 +89,9 @@ class DinfTransLimAccum(GeoAlgorithm):
processNum = ProcessingConfig.getSetting(TauDEMUtils.MPI_PROCESSES)
if processNum <= 0:
raise GeoAlgorithmExecutionException('Wrong number of MPI \
processes used.\nPlease set correct number before running \
TauDEM algorithms.')
raise GeoAlgorithmExecutionException(
self.tr('Wrong number of MPI processes used. Please set '
'correct number before running TauDEM algorithms.'))
commands.append('-n')
commands.append(str(processNum))
@ -113,10 +114,4 @@ class DinfTransLimAccum(GeoAlgorithm):
commands.append('-tdep')
commands.append(self.getOutputValue(self.DEPOSITION_GRID))
loglines = []
loglines.append('TauDEM execution command')
for line in commands:
loglines.append(line)
ProcessingLog.addToLog(ProcessingLog.LOG_INFO, loglines)
TauDEMUtils.executeTauDEM(commands, progress)

View File

@ -67,24 +67,25 @@ class DinfTransLimAccum2(GeoAlgorithm):
self.group = 'Specialized Grid Analysis tools'
self.addParameter(ParameterRaster(self.DINF_FLOW_DIR_GRID,
'D-Infinity Flow Direction Grid', False))
self.addParameter(ParameterRaster(self.SUPPLY_GRID, 'Supply Grid',
False))
self.tr('D-Infinity Flow Direction Grid'), False))
self.addParameter(ParameterRaster(self.SUPPLY_GRID,
self.tr('Supply Grid'), False))
self.addParameter(ParameterRaster(self.CAPACITY_GRID,
'Transport Capacity Grid', False))
self.tr('Transport Capacity Grid'), False))
self.addParameter(ParameterRaster(self.IN_CONCENTR_GRID,
'Input Concentration Grid', False))
self.tr('Input Concentration Grid'), False))
self.addParameter(ParameterVector(self.OUTLETS_SHAPE,
'Outlets Shapefile',
[ParameterVector.VECTOR_TYPE_POINT], True))
self.tr('Outlets Shapefile'),
[ParameterVector.VECTOR_TYPE_POINT], True))
self.addParameter(ParameterBoolean(self.EDGE_CONTAM,
'Check for edge contamination', True))
self.tr('Check for edge contamination'), True))
self.addOutput(OutputRaster(self.TRANSP_LIM_ACCUM_GRID,
'Transport Limited Accumulation Grid'))
self.addOutput(OutputRaster(self.DEPOSITION_GRID, 'Deposition Grid'))
self.tr('Transport Limited Accumulation Grid')))
self.addOutput(OutputRaster(self.DEPOSITION_GRID,
self.tr('Deposition Grid')))
self.addOutput(OutputRaster(self.OUT_CONCENTR_GRID,
'Output Concentration Grid'))
self.tr('Output Concentration Grid')))
def processAlgorithm(self, progress):
commands = []
@ -92,9 +93,9 @@ class DinfTransLimAccum2(GeoAlgorithm):
processNum = ProcessingConfig.getSetting(TauDEMUtils.MPI_PROCESSES)
if processNum <= 0:
raise GeoAlgorithmExecutionException('Wrong number of MPI \
processes used.\nPlease set correct number before running \
TauDEM algorithms.')
raise GeoAlgorithmExecutionException(
self.tr('Wrong number of MPI processes used. Please set '
'correct number before running TauDEM algorithms.'))
commands.append('-n')
commands.append(str(processNum))
@ -121,10 +122,4 @@ class DinfTransLimAccum2(GeoAlgorithm):
commands.append('-ctpt')
commands.append(self.getOutputValue(self.OUT_CONCENTR_GRID))
loglines = []
loglines.append('TauDEM execution command')
for line in commands:
loglines.append(line)
ProcessingLog.addToLog(ProcessingLog.LOG_INFO, loglines)
TauDEMUtils.executeTauDEM(commands, progress)

View File

@ -71,35 +71,35 @@ class DropAnalysis(GeoAlgorithm):
self.group = 'Stream Network Analysis tools'
self.addParameter(ParameterRaster(self.D8_CONTRIB_AREA_GRID,
'D8 Contributing Area Grid', False))
self.tr('D8 Contributing Area Grid'), False))
self.addParameter(ParameterRaster(self.D8_FLOW_DIR_GRID,
'D8 Flow Direction Grid', False))
self.tr('D8 Flow Direction Grid'), False))
self.addParameter(ParameterRaster(self.PIT_FILLED_GRID,
'Pit Filled Elevation Grid', False))
self.tr('Pit Filled Elevation Grid'), False))
self.addParameter(ParameterRaster(self.ACCUM_STREAM_SOURCE_GRID,
'Accumulated Stream Source Grid', False))
self.tr('Accumulated Stream Source Grid'), False))
self.addParameter(ParameterVector(self.OUTLETS_SHAPE,
'Outlets Shapefile',
[ParameterVector.VECTOR_TYPE_POINT], False))
self.tr('Outlets Shapefile'),
[ParameterVector.VECTOR_TYPE_POINT], False))
self.addParameter(ParameterNumber(self.MIN_TRESHOLD,
'Minimum Threshold', 0, None, 5))
self.tr('Minimum Threshold'), 0, None, 5))
self.addParameter(ParameterNumber(self.MAX_THRESHOLD,
'Maximum Threshold', 0, None, 500))
self.tr('Maximum Threshold'), 0, None, 500))
self.addParameter(ParameterNumber(self.TRESHOLD_NUM,
'Number of Threshold Values', 0, None, 10))
self.tr('Number of Threshold Values'), 0, None, 10))
self.addParameter(ParameterSelection(self.STEP_TYPE,
'Spacing for Threshold Values', self.STEPS, 0))
self.tr('Spacing for Threshold Values'), self.STEPS, 0))
self.addOutput(OutputFile(self.DROP_ANALYSIS_FILE,
'D-Infinity Drop to Stream Grid'))
self.tr('D-Infinity Drop to Stream Grid')))
def processAlgorithm(self, progress):
commands.append(os.path.join(TauDEMUtils.mpiexecPath(), 'mpiexec'))
processNum = ProcessingConfig.getSetting(TauDEMUtils.MPI_PROCESSES)
if processNum <= 0:
raise GeoAlgorithmExecutionException('Wrong number of MPI \
processes used.\nPlease set correct number before running \
TauDEM algorithms.')
raise GeoAlgorithmExecutionException(
self.tr('Wrong number of MPI processes used. Please set '
'correct number before running TauDEM algorithms.'))
commands.append('-n')
commands.append(str(processNum))
@ -122,10 +122,4 @@ class DropAnalysis(GeoAlgorithm):
commands.append('-drp')
commands.append(self.getOutputValue(self.DROP_ANALYSIS_FILE))
loglines = []
loglines.append('TauDEM execution command')
for line in commands:
loglines.append(line)
ProcessingLog.addToLog(ProcessingLog.LOG_INFO, loglines)
TauDEMUtils.executeTauDEM(commands, progress)

View File

@ -65,20 +65,21 @@ class GridNet(GeoAlgorithm):
self.group = 'Basic Grid Analysis tools'
self.addParameter(ParameterRaster(self.D8_FLOW_DIR_GRID,
'D8 Flow Direction Grid', False))
self.tr('D8 Flow Direction Grid'), False))
self.addParameter(ParameterVector(self.OUTLETS_SHAPE,
'Outlets Shapefile',
[ParameterVector.VECTOR_TYPE_POINT], True))
self.addParameter(ParameterRaster(self.MASK_GRID, 'Mask Grid', True))
self.tr('Outlets Shapefile'),
[ParameterVector.VECTOR_TYPE_POINT], True))
self.addParameter(ParameterRaster(self.MASK_GRID,
self.tr('Mask Grid'), True))
self.addParameter(ParameterNumber(self.THRESHOLD,
'Mask Threshold', 0, None, 100))
self.tr('Mask Threshold'), 0, None, 100))
self.addOutput(OutputRaster(self.LONGEST_LEN_GRID,
'Longest Upslope Length Grid'))
self.tr('Longest Upslope Length Grid')))
self.addOutput(OutputRaster(self.TOTAL_LEN_GRID,
'Total Upslope Length Grid'))
self.tr('Total Upslope Length Grid')))
self.addOutput(OutputRaster(self.STRAHLER_GRID,
'Strahler Network Order Grid'))
self.tr('Strahler Network Order Grid')))
def processAlgorithm(self, progress):
commands = []
@ -86,9 +87,9 @@ class GridNet(GeoAlgorithm):
processNum = ProcessingConfig.getSetting(TauDEMUtils.MPI_PROCESSES)
if processNum <= 0:
raise GeoAlgorithmExecutionException('Wrong number of MPI \
processes used.\nPlease set correct number before running \
TauDEM algorithms.')
raise GeoAlgorithmExecutionException(
self.tr('Wrong number of MPI processes used. Please set '
'correct number before running TauDEM algorithms.'))
commands.append('-n')
commands.append(str(processNum))
@ -113,10 +114,4 @@ class GridNet(GeoAlgorithm):
commands.append('-gord')
commands.append(self.getOutputValue(self.STRAHLER_GRID))
loglines = []
loglines.append('TauDEM execution command')
for line in commands:
loglines.append(line)
ProcessingLog.addToLog(ProcessingLog.LOG_INFO, loglines)
TauDEMUtils.executeTauDEM(commands, progress)

View File

@ -61,17 +61,17 @@ class LengthArea(GeoAlgorithm):
self.cmdName = 'lengtharea'
self.group = 'Stream Network Analysis tools'
self.addParameter(ParameterRaster(self.LENGTH_GRID, 'Length Grid',
False))
self.addParameter(ParameterRaster(self.LENGTH_GRID,
self.tr('Length Grid'), False))
self.addParameter(ParameterRaster(self.CONTRIB_AREA_GRID,
'Contributing Area Grid', False))
self.addParameter(ParameterNumber(self.THRESHOLD, 'Threshold', 0,
None, 0.03))
self.addParameter(ParameterNumber(self.EXPONENT, 'Exponent', 0, None,
1.3))
self.tr('Contributing Area Grid'), False))
self.addParameter(ParameterNumber(self.THRESHOLD,
self.tr('Threshold'), 0, None, 0.03))
self.addParameter(ParameterNumber(self.EXPONENT,
self.tr('Exponent'), 0, None, 1.3))
self.addOutput(OutputRaster(self.STREAM_SOURCE_GRID,
'Stream Source Grid'))
self.tr('Stream Source Grid')))
def processAlgorithm(self, progress):
commands = []
@ -79,9 +79,9 @@ class LengthArea(GeoAlgorithm):
processNum = ProcessingConfig.getSetting(TauDEMUtils.MPI_PROCESSES)
if processNum <= 0:
raise GeoAlgorithmExecutionException('Wrong number of MPI \
processes used.\nPlease set correct number before running \
TauDEM algorithms.')
raise GeoAlgorithmExecutionException(
self.tr('Wrong number of MPI processes used. Please set '
'correct number before running TauDEM algorithms.'))
commands.append('-n')
commands.append(str(processNum))
@ -96,10 +96,4 @@ class LengthArea(GeoAlgorithm):
commands.append('-ss')
commands.append(self.getOutputValue(self.STREAM_SOURCE_GRID))
loglines = []
loglines.append('TauDEM execution command')
for line in commands:
loglines.append(line)
ProcessingLog.addToLog(ProcessingLog.LOG_INFO, loglines)
TauDEMUtils.executeTauDEM(commands, progress)

View File

@ -56,17 +56,17 @@ class PeukerDouglas(GeoAlgorithm):
self.cmdName = 'peukerdouglas'
self.group = 'Stream Network Analysis tools'
self.addParameter(ParameterRaster(self.ELEVATION_GRID, 'Elevation Grid'
, False))
self.addParameter(ParameterRaster(self.ELEVATION_GRID,
self.tr('Elevation Grid'), False))
self.addParameter(ParameterNumber(self.CENTER_WEIGHT,
'Center Smoothing Weight', 0, None, 0.4))
self.tr('Center Smoothing Weight'), 0, None, 0.4))
self.addParameter(ParameterNumber(self.SIDE_WEIGHT,
'Side Smoothing Weight', 0, None, 0.1))
self.tr('Side Smoothing Weight'), 0, None, 0.1))
self.addParameter(ParameterNumber(self.DIAGONAL_WEIGHT,
'Diagonal Smoothing Weight', 0, None, 0.05))
self.tr('Diagonal Smoothing Weight'), 0, None, 0.05))
self.addOutput(OutputRaster(self.STREAM_SOURCE_GRID,
'Stream Source Grid'))
self.tr('Stream Source Grid')))
def processAlgorithm(self, progress):
commands = []
@ -74,9 +74,9 @@ class PeukerDouglas(GeoAlgorithm):
processNum = ProcessingConfig.getSetting(TauDEMUtils.MPI_PROCESSES)
if processNum <= 0:
raise GeoAlgorithmExecutionException('Wrong number of MPI \
processes used.\nPlease set correct number before running \
TauDEM algorithms.')
raise GeoAlgorithmExecutionException(
self.tr('Wrong number of MPI processes used. Please set '
'correct number before running TauDEM algorithms.'))
commands.append('-n')
commands.append(str(processNum))
@ -90,10 +90,4 @@ class PeukerDouglas(GeoAlgorithm):
commands.append('-ss')
commands.append(self.getOutputValue(self.STREAM_SOURCE_GRID))
loglines = []
loglines.append('TauDEM execution command')
for line in commands:
loglines.append(line)
ProcessingLog.addToLog(ProcessingLog.LOG_INFO, loglines)
TauDEMUtils.executeTauDEM(commands, progress)

View File

@ -61,16 +61,17 @@ class SlopeArea(GeoAlgorithm):
self.cmdName = 'slopearea'
self.group = 'Stream Network Analysis tools'
self.addParameter(ParameterRaster(self.SLOPE_GRID, 'Slope Grid',
False))
self.addParameter(ParameterRaster(self.SLOPE_GRID,
self.tr('Slope Grid'), False))
self.addParameter(ParameterRaster(self.AREA_GRID,
'Contributing Area Grid', False))
self.addParameter(ParameterNumber(self.SLOPE_EXPONENT, 'Slope Exponent'
, 0, None, 2))
self.addParameter(ParameterNumber(self.AREA_EXPONENT, 'Area Exponent',
0, None, 1))
self.tr('Contributing Area Grid'), False))
self.addParameter(ParameterNumber(self.SLOPE_EXPONENT,
self.tr('Slope Exponent'), 0, None, 2))
self.addParameter(ParameterNumber(self.AREA_EXPONENT,
self.tr('Area Exponent'), 0, None, 1))
self.addOutput(OutputRaster(self.SLOPE_AREA_GRID, 'Slope Area Grid'))
self.addOutput(OutputRaster(self.SLOPE_AREA_GRID,
self.tr('Slope Area Grid')))
def processAlgorithm(self, progress):
commands = []
@ -78,9 +79,9 @@ class SlopeArea(GeoAlgorithm):
processNum = ProcessingConfig.getSetting(TauDEMUtils.MPI_PROCESSES)
if processNum <= 0:
raise GeoAlgorithmExecutionException('Wrong number of MPI \
processes used.\nPlease set correct number before running \
TauDEM algorithms.')
raise GeoAlgorithmExecutionException(
self.tr('Wrong number of MPI processes used. Please set '
'correct number before running TauDEM algorithms.'))
commands.append('-n')
commands.append(str(processNum))
@ -95,10 +96,4 @@ class SlopeArea(GeoAlgorithm):
commands.append('-sa')
commands.append(self.getOutputValue(self.SLOPE_AREA_GRID))
loglines = []
loglines.append('TauDEM execution command')
for line in commands:
loglines.append(line)
ProcessingLog.addToLog(ProcessingLog.LOG_INFO, loglines)
TauDEMUtils.executeTauDEM(commands, progress)