def processAlgorithm(self, progress): commands = [] commands.append(os.path.join(TauDEMUtils.mpiexecPath(), "mpiexec")) processNum = SextanteConfig.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) SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines) TauDEMUtils.executeTauDEM(commands, progress)
def processAlgorithm(self, progress): commands = [] commands.append(os.path.join(TauDEMUtils.mpiexecPath(), "mpiexec")) processNum = SextanteConfig.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) SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines) TauDEMUtils.executeTauDEM(commands, progress)
def initializeSettings(self): AlgorithmProvider.initializeSettings(self) SextanteConfig.addSetting( Setting(self.getDescription(), TauDEMUtils.TAUDEM_FOLDER, "TauDEM command line tools folder", TauDEMUtils.taudemPath())) SextanteConfig.addSetting( Setting(self.getDescription(), TauDEMUtils.MPIEXEC_FOLDER, "MPICH2/OpenMPI bin directory", TauDEMUtils.mpiexecPath())) SextanteConfig.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 = SextanteConfig.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) SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines) TauDEMUtils.executeTauDEM(commands, progress)
def processAlgorithm(self, progress): commands = [] commands.append(os.path.join(TauDEMUtils.mpiexecPath(), "mpiexec")) processNum = SextanteConfig.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) SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines) TauDEMUtils.executeTauDEM(commands, progress)
def processAlgorithm(self, progress): commands = [] commands.append(os.path.join(TauDEMUtils.mpiexecPath(), "mpiexec")) processNum = SextanteConfig.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) SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines) TauDEMUtils.executeTauDEM(commands, progress)
def processAlgorithm(self, progress): commands = [] commands.append(os.path.join(TauDEMUtils.mpiexecPath(), "mpiexec")) processNum = SextanteConfig.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) SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines) TauDEMUtils.executeTauDEM(commands, progress)
def processAlgorithm(self, progress): commands = [] commands.append(os.path.join(TauDEMUtils.mpiexecPath(), "mpiexec")) processNum = SextanteConfig.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) SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines) TauDEMUtils.executeTauDEM(commands, progress)
def createAlgsList(self): self.preloadedAlgs = [] folder = TauDEMUtils.taudemDescriptionPath() for descriptionFile in os.listdir(folder): if descriptionFile.endswith("txt"): try: alg = TauDEMAlgorithm(os.path.join(folder, descriptionFile)) if alg.name.strip() != "": self.preloadedAlgs.append(alg) else: SextanteLog.addToLog(SextanteLog.LOG_ERROR, "Could not open TauDEM algorithm: " + descriptionFile) except Exception, e: SextanteLog.addToLog(SextanteLog.LOG_ERROR, "Could not open TauDEM algorithm: " + descriptionFile)
def processAlgorithm(self, progress): commands = [] commands.append(os.path.join(TauDEMUtils.mpiexecPath(), "mpiexec")) processNum = SextanteConfig.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) SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines) TauDEMUtils.executeTauDEM(commands, progress)
def processAlgorithm(self, progress): commands.append(os.path.join(TauDEMUtils.mpiexecPath(), "mpiexec")) processNum = SextanteConfig.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) SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines) TauDEMUtils.executeTauDEM(commands, progress)
def processAlgorithm(self, progress): commands = [] commands.append(os.path.join(TauDEMUtils.mpiexecPath(), "mpiexec")) processNum = SextanteConfig.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) SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines) TauDEMUtils.executeTauDEM(commands, progress)
def createAlgsList(self): self.preloadedAlgs = [] folder = TauDEMUtils.taudemDescriptionPath() for descriptionFile in os.listdir(folder): if descriptionFile.endswith("txt"): try: alg = TauDEMAlgorithm(os.path.join(folder, descriptionFile)) if alg.name.strip() != "": self.preloadedAlgs.append(alg) else: SextanteLog.addToLog( SextanteLog.LOG_ERROR, "Could not open TauDEM algorithm: " + descriptionFile) except Exception, e: SextanteLog.addToLog( SextanteLog.LOG_ERROR, "Could not open TauDEM algorithm: " + descriptionFile)
def initializeSettings(self): AlgorithmProvider.initializeSettings(self) SextanteConfig.addSetting(Setting(self.getDescription(), TauDEMUtils.TAUDEM_FOLDER, "TauDEM command line tools folder", TauDEMUtils.taudemPath())) SextanteConfig.addSetting(Setting(self.getDescription(), TauDEMUtils.MPIEXEC_FOLDER, "MPICH2/OpenMPI bin directory", TauDEMUtils.mpiexecPath())) SextanteConfig.addSetting(Setting(self.getDescription(), TauDEMUtils.MPI_PROCESSES, "Number of MPI parallel processes to use", 2))