def processAlgorithm(self, progress): commands = [] 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." ) commands.append("-n") commands.append(str(processNum)) commands.append(os.path.join(TauDEMUtils.taudemPath(), self.cmdName)) commands.append("-plen") commands.append(self.getParameterValue(self.LENGTH_GRID)) commands.append("-ad8") commands.append(self.getParameterValue(self.CONTRIB_AREA_GRID)) commands.append("-par") commands.append(str(self.getParameterValue(self.THRESHOLD))) commands.append(str(self.getParameterValue(self.EXPONENT))) 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)
def processAlgorithm(self, progress): commands = [] 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.') commands.append('-n') commands.append(str(processNum)) commands.append(os.path.join(TauDEMUtils.taudemPath(), self.cmdName)) commands.append('-fel') commands.append(self.getParameterValue(self.ELEVATION_GRID)) commands.append('-par') commands.append(str(self.getParameterValue(self.CENTER_WEIGHT))) commands.append(str(self.getParameterValue(self.SIDE_WEIGHT))) commands.append(str(self.getParameterValue(self.DIAGONAL_WEIGHT))) 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)
def processAlgorithm(self, progress): commands = [] 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.") commands.append("-n") commands.append(str(processNum)) commands.append(os.path.join(TauDEMUtils.taudemPath(), self.cmdName)) commands.append("-slp") commands.append(self.getParameterValue(self.SLOPE_GRID)) commands.append("-sca") commands.append(self.getParameterValue(self.AREA_GRID)) commands.append("-par") commands.append(str(self.getParameterValue(self.SLOPE_EXPONENT))) commands.append(str(self.getParameterValue(self.AREA_EXPONENT))) 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)
def processAlgorithm(self, progress): commands = [] 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.") commands.append("-n") commands.append(str(processNum)) commands.append(os.path.join(TauDEMUtils.taudemPath(), self.cmdName)) commands.append("-ang") commands.append(self.getParameterValue(self.DINF_FLOW_DIR_GRID)) commands.append("-fel") commands.append(self.getParameterValue(self.PIT_FILLED_GRID)) commands.append("-m") commands.append(str(self.STAT_DICT[self.getParameterValue(self.STAT_METHOD)])) commands.append(str(self.DIST_DICT[self.getParameterValue(self.DIST_METHOD)])) commands.append("-thresh") commands.append(str(self.getParameterValue(self.THRESHOLD))) if str(self.getParameterValue(self.EDGE_CONTAM)).lower() == "false": commands.append("-nc") 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)
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.") commands.append("-n") commands.append(str(processNum)) commands.append(os.path.join(TauDEMUtils.taudemPath(), self.cmdName)) commands.append("-ad8") commands.append(self.getParameterValue(self.D8_CONTRIB_AREA_GRID)) commands.append("-p") commands.append(self.getParameterValue(self.D8_FLOW_DIR_GRID)) commands.append("-fel") commands.append(self.getParameterValue(self.PIT_FILLED_GRID)) commands.append("-ssa") commands.append(self.getParameterValue(self.ACCUM_STREAM_SOURCE_GRID)) commands.append("-o") commands.append(self.getParameterValue(self.OUTLETS_SHAPE)) commands.append("-par") commands.append(str(self.getParameterValue(self.MIN_TRESHOLD))) commands.append(str(self.getParameterValue(self.MAX_THRESHOLD))) commands.append(str(self.getParameterValue(self.TRESHOLD_NUM))) commands.append(str(self.getParameterValue(self.STEPS))) 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)
def initializeSettings(self): AlgorithmProvider.initializeSettings(self) ProcessingConfig.addSetting( Setting(self.getDescription(), TauDEMUtils.TAUDEM_FOLDER, "TauDEM command line tools folder", TauDEMUtils.taudemPath())) ProcessingConfig.addSetting( Setting(self.getDescription(), TauDEMUtils.MPIEXEC_FOLDER, "MPICH2/OpenMPI bin directory", TauDEMUtils.mpiexecPath())) ProcessingConfig.addSetting( Setting(self.getDescription(), TauDEMUtils.MPI_PROCESSES, "Number of MPI parallel processes to use", 2))
def processAlgorithm(self, progress): commands = [] 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." ) commands.append("-n") commands.append(str(processNum)) commands.append(os.path.join(TauDEMUtils.taudemPath(), self.cmdName)) commands.append("-ang") commands.append(self.getParameterValue(self.DINF_FLOW_DIR_GRID)) commands.append("-tsup") commands.append(self.getParameterValue(self.SUPPLY_GRID)) commands.append("-tc") commands.append(self.getParameterValue(self.CAPACITY_GRID)) commands.append("-cs") commands.append(self.getParameterValue(self.IN_CONCENTR_GRID)) param = self.getParameterValue(self.OUTLETS_SHAPE) if param is not None: commands.append("-o") commands.append(param) if str(self.getParameterValue(self.EDGE_CONTAM)).lower() == "false": commands.append("-nc") commands.append("-tla") commands.append(self.getOutputValue(self.TRANSP_LIM_ACCUM_GRID)) commands.append("-tdep") commands.append(self.getOutputValue(self.DEPOSITION_GRID)) 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)
def processAlgorithm(self, progress): commands = [] 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.') commands.append('-n') commands.append(str(processNum)) commands.append(os.path.join(TauDEMUtils.taudemPath(), self.cmdName)) commands.append('-ang') commands.append(self.getParameterValue(self.DINF_FLOW_DIR_GRID)) commands.append('-tsup') commands.append(self.getParameterValue(self.SUPPLY_GRID)) commands.append('-tc') commands.append(self.getParameterValue(self.CAPACITY_GRID)) commands.append('-cs') commands.append(self.getParameterValue(self.IN_CONCENTR_GRID)) param = self.getParameterValue(self.OUTLETS_SHAPE) if param is not None: commands.append('-o') commands.append(param) if str(self.getParameterValue(self.EDGE_CONTAM)).lower() == 'false': commands.append('-nc') commands.append('-tla') commands.append(self.getOutputValue(self.TRANSP_LIM_ACCUM_GRID)) commands.append('-tdep') commands.append(self.getOutputValue(self.DEPOSITION_GRID)) 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)
def processAlgorithm(self, progress): commands = [] 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.' ) commands.append('-n') commands.append(str(processNum)) commands.append(os.path.join(TauDEMUtils.taudemPath(), self.cmdName)) for param in self.parameters: if param.value is None or param.value == '': continue if isinstance(param, ParameterNumber): commands.append(param.name) commands.append(str(param.value)) if isinstance(param, (ParameterRaster, ParameterVector)): commands.append(param.name) commands.append(param.value) elif isinstance(param, ParameterBoolean): if param.value and str(param.value).lower() == 'false': commands.append(param.name) elif isinstance(param, ParameterString): commands.append(param.name) commands.append(str(param.value)) for out in self.outputs: 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)
def initializeSettings(self): AlgorithmProvider.initializeSettings(self) ProcessingConfig.addSetting( Setting( self.getDescription(), TauDEMUtils.TAUDEM_FOLDER, "TauDEM command line tools folder", TauDEMUtils.taudemPath(), ) ) ProcessingConfig.addSetting( Setting( self.getDescription(), TauDEMUtils.MPIEXEC_FOLDER, "MPICH2/OpenMPI bin directory", TauDEMUtils.mpiexecPath(), ) ) ProcessingConfig.addSetting( Setting(self.getDescription(), TauDEMUtils.MPI_PROCESSES, "Number of MPI parallel processes to use", 2) )
def processAlgorithm(self, progress): commands = [] 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.') commands.append('-n') commands.append(str(processNum)) commands.append(os.path.join(TauDEMUtils.taudemPath(), self.cmdName)) commands.append('-p') commands.append(self.getParameterValue(self.D8_FLOW_DIR_GRID)) param = self.getParameterValue(self.OUTLETS_SHAPE) if param is not None: commands.append('-o') commands.append(param) param = self.getParameterValue(self.MASK_GRID) if param is not None: commands.append('-mask') commands.append(param) commands.append('-thresh') commands.append(self.getParameterValue(self.THRESHOLD)) commands.append('-plen') commands.append(self.getOutputValue(self.LONGEST_LEN_GRID)) commands.append('-tlen') commands.append(self.getOutputValue(self.TOTAL_LEN_GRID)) 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)
def processAlgorithm(self, progress): commands = [] 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.') commands.append('-n') commands.append(str(processNum)) commands.append(os.path.join(TauDEMUtils.taudemPath(), self.cmdName)) commands.append('-ang') commands.append(self.getParameterValue(self.DINF_FLOW_DIR_GRID)) commands.append('-fel') commands.append(self.getParameterValue(self.PIT_FILLED_GRID)) commands.append('-src') commands.append(self.getParameterValue(self.STREAM_GRID)) wg = self.getParameterValue(self.WEIGHT_PATH_GRID) if wg is not None: commands.append('-wg') commands.append(self.getParameterValue(self.WEIGHT_PATH_GRID)) commands.append('-m') commands.append(str(self.STAT_DICT[self.getParameterValue( self.STAT_METHOD)])) commands.append(str(self.DIST_DICT[self.getParameterValue( self.DIST_METHOD)])) if str(self.getParameterValue(self.EDGE_CONTAM)).lower() == 'false': commands.append('-nc') 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)
def processAlgorithm(self, progress): commands = [] 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.') commands.append('-n') commands.append(str(processNum)) commands.append(os.path.join(TauDEMUtils.taudemPath(), self.cmdName)) commands.append('-ang') commands.append(self.getParameterValue(self.DINF_FLOW_DIR_GRID)) commands.append('-fel') commands.append(self.getParameterValue(self.PIT_FILLED_GRID)) commands.append('-src') commands.append(self.getParameterValue(self.STREAM_GRID)) wg = self.getParameterValue(self.WEIGHT_PATH_GRID) if wg is not None: commands.append('-wg') commands.append(self.getParameterValue(self.WEIGHT_PATH_GRID)) commands.append('-m') commands.append( str(self.STAT_DICT[self.getParameterValue(self.STAT_METHOD)])) commands.append( str(self.DIST_DICT[self.getParameterValue(self.DIST_METHOD)])) if str(self.getParameterValue(self.EDGE_CONTAM)).lower() == 'false': commands.append('-nc') 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)
def processAlgorithm(self, progress): commands = [] 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." ) commands.append("-n") commands.append(str(processNum)) commands.append(os.path.join(TauDEMUtils.taudemPath(), self.cmdName)) for param in self.parameters: if param.value == None or param.value == "": continue if isinstance(param, ParameterNumber): commands.append(param.name) commands.append(str(param.value)) if isinstance(param, (ParameterRaster, ParameterVector)): commands.append(param.name) commands.append(param.value) elif isinstance(param, ParameterBoolean): if param.value and str(param.value).lower() == "false": commands.append(param.name) elif isinstance(param, ParameterString): commands.append(param.name) commands.append(str(param.value)) for out in self.outputs: 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)
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.') commands.append('-n') commands.append(str(processNum)) commands.append(os.path.join(TauDEMUtils.taudemPath(), self.cmdName)) commands.append('-ad8') commands.append(self.getParameterValue(self.D8_CONTRIB_AREA_GRID)) commands.append('-p') commands.append(self.getParameterValue(self.D8_FLOW_DIR_GRID)) commands.append('-fel') commands.append(self.getParameterValue(self.PIT_FILLED_GRID)) commands.append('-ssa') commands.append(self.getParameterValue(self.ACCUM_STREAM_SOURCE_GRID)) commands.append('-o') commands.append(self.getParameterValue(self.OUTLETS_SHAPE)) commands.append('-par') commands.append(str(self.getParameterValue(self.MIN_TRESHOLD))) commands.append(str(self.getParameterValue(self.MAX_THRESHOLD))) commands.append(str(self.getParameterValue(self.TRESHOLD_NUM))) commands.append(str(self.getParameterValue(self.STEPS))) 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)